diff options
author | marha <marha@users.sourceforge.net> | 2012-01-25 08:24:51 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-01-25 08:24:51 +0100 |
commit | e6432710d8a586386b3c7025e845cf4f80830da3 (patch) | |
tree | a403fa86779a287c97f5605f9b4d455d662ece66 /mesalib/src/mesa | |
parent | d3f0fe49b8cb29295f3e529cc699a2abde1515a1 (diff) | |
download | vcxsrv-e6432710d8a586386b3c7025e845cf4f80830da3.tar.gz vcxsrv-e6432710d8a586386b3c7025e845cf4f80830da3.tar.bz2 vcxsrv-e6432710d8a586386b3c7025e845cf4f80830da3.zip |
mesa git update 25 jan 2012
Diffstat (limited to 'mesalib/src/mesa')
56 files changed, 1309 insertions, 5451 deletions
diff --git a/mesalib/src/mesa/drivers/common/driverfuncs.c b/mesalib/src/mesa/drivers/common/driverfuncs.c index c6b42a21d..1df838173 100644 --- a/mesalib/src/mesa/drivers/common/driverfuncs.c +++ b/mesalib/src/mesa/drivers/common/driverfuncs.c @@ -119,8 +119,6 @@ _mesa_init_driver_functions(struct dd_function_table *driver) driver->FreeTextureImageBuffer = _swrast_free_texture_image_buffer; driver->MapTextureImage = _swrast_map_teximage; driver->UnmapTextureImage = _swrast_unmap_teximage; - driver->MapTexture = NULL; - driver->UnmapTexture = NULL; driver->DrawTex = _mesa_meta_DrawTex; /* Vertex/fragment programs */ diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c index 05cc712cf..aa5fef873 100644 --- a/mesalib/src/mesa/drivers/common/meta.c +++ b/mesalib/src/mesa/drivers/common/meta.c @@ -3131,6 +3131,11 @@ copy_tex_sub_image(struct gl_context *ctx, format = GL_RGBA; } + if (_mesa_is_format_integer_color(texImage->TexFormat)) { + _mesa_problem(ctx, "unsupported integer color copyteximage"); + return; + } + type = get_temp_image_type(ctx, format); bpp = _mesa_bytes_per_pixel(format, type); if (bpp <= 0) { diff --git a/mesalib/src/mesa/drivers/dri/common/depthtmp.h b/mesalib/src/mesa/drivers/dri/common/depthtmp.h deleted file mode 100644 index d8f259f67..000000000 --- a/mesalib/src/mesa/drivers/dri/common/depthtmp.h +++ /dev/null @@ -1,218 +0,0 @@ - -/* - * Notes: - * 1. These functions plug into the gl_renderbuffer structure. - * 2. The 'values' parameter always points to GLuint values, regardless of - * the actual Z buffer depth. - */ - - -#include "spantmp_common.h" - -#ifndef DBG -#define DBG 0 -#endif - -#ifndef HAVE_HW_DEPTH_SPANS -#define HAVE_HW_DEPTH_SPANS 0 -#endif - -#ifndef HAVE_HW_DEPTH_PIXELS -#define HAVE_HW_DEPTH_PIXELS 0 -#endif - -static void TAG(WriteDepthSpan)( struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, - const void *values, - const GLubyte mask[] ) -{ - HW_WRITE_LOCK() - { - const VALUE_TYPE *depth = (const VALUE_TYPE *) values; - GLint x1; - GLint n1; - LOCAL_DEPTH_VARS; - - y = Y_FLIP( y ); - -#if HAVE_HW_DEPTH_SPANS - (void) x1; (void) n1; - - if ( DBG ) fprintf( stderr, "WriteDepthSpan 0..%d (x1 %d)\n", - (int)n, (int)x ); - - WRITE_DEPTH_SPAN(); -#else - HW_CLIPLOOP() - { - GLint i = 0; - CLIPSPAN( x, y, n, x1, n1, i ); - - if ( DBG ) fprintf( stderr, "WriteDepthSpan %d..%d (x1 %d) (mask %p)\n", - (int)i, (int)n1, (int)x1, mask ); - - if ( mask ) { - for ( ; n1>0 ; i++, x1++, n1-- ) { - if ( mask[i] ) WRITE_DEPTH( x1, y, depth[i] ); - } - } else { - for ( ; n1>0 ; i++, x1++, n1-- ) { - WRITE_DEPTH( x1, y, depth[i] ); - } - } - } - HW_ENDCLIPLOOP(); -#endif - } - HW_WRITE_UNLOCK(); - - (void) ctx; -} - - -static void TAG(WriteDepthPixels)( struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint n, - const GLint x[], - const GLint y[], - const void *values, - const GLubyte mask[] ) -{ - HW_WRITE_LOCK() - { - const VALUE_TYPE *depth = (const VALUE_TYPE *) values; - GLuint i; - LOCAL_DEPTH_VARS; - - if ( DBG ) fprintf( stderr, "WriteDepthPixels\n" ); - -#if HAVE_HW_DEPTH_PIXELS - (void) i; - - WRITE_DEPTH_PIXELS(); -#else - HW_CLIPLOOP() - { - if ( mask ) { - for ( i = 0 ; i < n ; i++ ) { - if ( mask[i] ) { - const int fy = Y_FLIP( y[i] ); - if ( CLIPPIXEL( x[i], fy ) ) - WRITE_DEPTH( x[i], fy, depth[i] ); - } - } - } - else { - for ( i = 0 ; i < n ; i++ ) { - const int fy = Y_FLIP( y[i] ); - if ( CLIPPIXEL( x[i], fy ) ) - WRITE_DEPTH( x[i], fy, depth[i] ); - } - } - } - HW_ENDCLIPLOOP(); -#endif - } - HW_WRITE_UNLOCK(); - - (void) ctx; -} - - -/* Read depth spans and pixels - */ -static void TAG(ReadDepthSpan)( struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, - void *values ) -{ - HW_READ_LOCK() - { - VALUE_TYPE *depth = (VALUE_TYPE *) values; - GLint x1, n1; - LOCAL_DEPTH_VARS; - - y = Y_FLIP( y ); - - if ( DBG ) fprintf( stderr, "ReadDepthSpan\n" ); - -#if HAVE_HW_DEPTH_SPANS - (void) x1; (void) n1; - - READ_DEPTH_SPAN(); -#else - HW_CLIPLOOP() - { - GLint i = 0; - CLIPSPAN( x, y, n, x1, n1, i ); - for ( ; n1>0 ; i++, n1-- ) { - READ_DEPTH( depth[i], x+i, y ); - } - } - HW_ENDCLIPLOOP(); -#endif - } - HW_READ_UNLOCK(); -} - -static void TAG(ReadDepthPixels)( struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint n, - const GLint x[], const GLint y[], - void *values ) -{ - HW_READ_LOCK() - { - VALUE_TYPE *depth = (VALUE_TYPE *) values; - GLuint i; - LOCAL_DEPTH_VARS; - - if ( DBG ) fprintf( stderr, "ReadDepthPixels\n" ); - -#if HAVE_HW_DEPTH_PIXELS - (void) i; - - READ_DEPTH_PIXELS(); -#else - HW_CLIPLOOP() - { - for ( i = 0 ; i < n ;i++ ) { - int fy = Y_FLIP( y[i] ); - if ( CLIPPIXEL( x[i], fy ) ) - READ_DEPTH( depth[i], x[i], fy ); - } - } - HW_ENDCLIPLOOP(); -#endif - } - HW_READ_UNLOCK(); - - (void) ctx; -} - - -/** - * Initialize the given renderbuffer's span routines to point to - * the depth/z functions we generated above. - */ -static void TAG(InitDepthPointers)(struct gl_renderbuffer *rb) -{ - rb->GetRow = TAG(ReadDepthSpan); - rb->GetValues = TAG(ReadDepthPixels); - rb->PutRow = TAG(WriteDepthSpan); - rb->PutValues = TAG(WriteDepthPixels); -} - - -#if HAVE_HW_DEPTH_SPANS -#undef WRITE_DEPTH_SPAN -#undef WRITE_DEPTH_PIXELS -#undef READ_DEPTH_SPAN -#undef READ_DEPTH_PIXELS -#else -#undef WRITE_DEPTH -#undef READ_DEPTH -#endif -#undef TAG -#undef VALUE_TYPE diff --git a/mesalib/src/mesa/drivers/dri/common/spantmp2.h b/mesalib/src/mesa/drivers/dri/common/spantmp2.h deleted file mode 100644 index 744dfcd3b..000000000 --- a/mesalib/src/mesa/drivers/dri/common/spantmp2.h +++ /dev/null @@ -1,777 +0,0 @@ -/* - * Copyright 2000-2001 VA Linux Systems, Inc. - * (C) Copyright IBM Corporation 2004 - * 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 - * VA LINUX SYSTEM, IBM 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 spantmp2.h - * - * Template file of span read / write functions. - * - * \author Keith Whitwell <keithw@tungstengraphics.com> - * \author Gareth Hughes <gareth@nvidia.com> - * \author Ian Romanick <idr@us.ibm.com> - */ - -#include "main/colormac.h" -#include "spantmp_common.h" - -#ifndef DBG -#define DBG 0 -#endif - -#ifndef HW_READ_CLIPLOOP -#define HW_READ_CLIPLOOP() HW_CLIPLOOP() -#endif - -#ifndef HW_WRITE_CLIPLOOP -#define HW_WRITE_CLIPLOOP() HW_CLIPLOOP() -#endif - -#if (SPANTMP_PIXEL_FMT == GL_RGB) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5) - -/** - ** GL_RGB, GL_UNSIGNED_SHORT_5_6_5 - **/ - -#ifndef GET_VALUE -#ifndef GET_PTR -#define GET_PTR(_x, _y) (buf + (_x) * 2 + (_y) * pitch) -#endif - -#define GET_VALUE(_x, _y) *(volatile GLushort *)(GET_PTR(_x, _y)) -#define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v) -#endif /* GET_VALUE */ - -#define WRITE_RGBA( _x, _y, r, g, b, a ) \ - PUT_VALUE(_x, _y, ((((int)r & 0xf8) << 8) | \ - (((int)g & 0xfc) << 3) | \ - (((int)b & 0xf8) >> 3))) \ - -#define WRITE_PIXEL( _x, _y, p ) PUT_VALUE(_x, _y, p) - -#define READ_RGBA( rgba, _x, _y ) \ - do { \ - GLushort p = GET_VALUE(_x, _y); \ - rgba[0] = ((p >> 8) & 0xf8) * 255 / 0xf8; \ - rgba[1] = ((p >> 3) & 0xfc) * 255 / 0xfc; \ - rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8; \ - rgba[3] = 0xff; \ - } while (0) - -#elif (SPANTMP_PIXEL_FMT == GL_RGB) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5_REV) - -/** - ** GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV - **/ - -#ifndef GET_VALUE -#ifndef GET_PTR -#define GET_PTR(_x, _y) (buf + (_x) * 2 + (_y) * pitch) -#endif - -#define GET_VALUE(_x, _y) *(volatile GLushort *)(GET_PTR(_x, _y)) -#define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v) -#endif /* GET_VALUE */ - -#define WRITE_RGBA( _x, _y, r, g, b, a ) \ - PUT_VALUE(_x, _y, PACK_COLOR_565_REV( r, g, b )) - -#define WRITE_PIXEL( _x, _y, p ) PUT_VALUE(_x, _y, p) - -#define READ_RGBA( rgba, _x, _y ) \ - do { \ - GLushort p = GET_VALUE(_x, _y); \ - p = p << 8 | p >> 8; \ - rgba[0] = ((p >> 8) & 0xf8) * 255 / 0xf8; \ - rgba[1] = ((p >> 3) & 0xfc) * 255 / 0xfc; \ - rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8; \ - rgba[3] = 0xff; \ - } while (0) - -#elif (SPANTMP_PIXEL_FMT == GL_BGRA) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_4_4_4_4) - -/** - ** GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4 - **/ - -#ifndef GET_VALUE -#ifndef GET_PTR -#define GET_PTR(_x, _y) (buf + (_x) * 2 + (_y) * pitch) -#endif - -#define GET_VALUE(_x, _y) *(volatile GLushort *)(GET_PTR(_x, _y)) -#define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v) -#endif /* GET_VALUE */ - -#define WRITE_RGBA( _x, _y, r, g, b, a ) \ - PUT_VALUE(_x, _y, PACK_COLOR_4444_REV(a, r, g, b)) \ - -#define WRITE_PIXEL( _x, _y, p ) PUT_VALUE(_x, _y, p) - -#define READ_RGBA( rgba, _x, _y ) \ - do { \ - GLushort p = GET_VALUE(_x, _y); \ - rgba[0] = ((p >> 0) & 0xf) * 0x11; \ - rgba[1] = ((p >> 12) & 0xf) * 0x11; \ - rgba[2] = ((p >> 4) & 0xf) * 0x11; \ - rgba[3] = ((p >> 8) & 0xf) * 0x11; \ - } while (0) - - -#elif (SPANTMP_PIXEL_FMT == GL_BGRA) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_4_4_4_4_REV) - -/** - ** GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV - **/ - -#ifndef GET_VALUE -#ifndef GET_PTR -#define GET_PTR(_x, _y) (buf + (_x) * 2 + (_y) * pitch) -#endif - -#define GET_VALUE(_x, _y) *(volatile GLushort *)(GET_PTR(_x, _y)) -#define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v) -#endif /* GET_VALUE */ - -#define WRITE_RGBA( _x, _y, r, g, b, a ) \ - PUT_VALUE(_x, _y, PACK_COLOR_4444(a, r, g, b)) \ - -#define WRITE_PIXEL( _x, _y, p ) PUT_VALUE(_x, _y, p) - -#define READ_RGBA( rgba, _x, _y ) \ - do { \ - GLushort p = GET_VALUE(_x, _y); \ - rgba[0] = ((p >> 8) & 0xf) * 0x11; \ - rgba[1] = ((p >> 4) & 0xf) * 0x11; \ - rgba[2] = ((p >> 0) & 0xf) * 0x11; \ - rgba[3] = ((p >> 12) & 0xf) * 0x11; \ - } while (0) - - -#elif (SPANTMP_PIXEL_FMT == GL_BGRA) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_1_5_5_5_REV) - -/** - ** GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV - **/ - -#ifndef GET_VALUE -#ifndef GET_PTR -#define GET_PTR(_x, _y) (buf + (_x) * 2 + (_y) * pitch) -#endif - -#define GET_VALUE(_x, _y) *(volatile GLushort *)(GET_PTR(_x, _y)) -#define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v) -#endif /* GET_VALUE */ - -#define WRITE_RGBA( _x, _y, r, g, b, a ) \ - PUT_VALUE(_x, _y, PACK_COLOR_1555(a, r, g, b)) \ - -#define WRITE_PIXEL( _x, _y, p ) PUT_VALUE(_x, _y, p) - -#define READ_RGBA( rgba, _x, _y ) \ - do { \ - GLushort p = GET_VALUE(_x, _y); \ - rgba[0] = ((p >> 7) & 0xf8) * 255 / 0xf8; \ - rgba[1] = ((p >> 2) & 0xf8) * 255 / 0xf8; \ - rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8; \ - rgba[3] = ((p >> 15) & 0x1) * 0xff; \ - } while (0) - -#elif (SPANTMP_PIXEL_FMT == GL_BGRA) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_1_5_5_5) - -/** - ** GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5 - **/ - -#ifndef GET_VALUE -#ifndef GET_PTR -#define GET_PTR(_x, _y) (buf + (_x) * 2 + (_y) * pitch) -#endif - -#define GET_VALUE(_x, _y) *(volatile GLushort *)(GET_PTR(_x, _y)) -#define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v) -#endif /* GET_VALUE */ - -#define WRITE_RGBA( _x, _y, r, g, b, a ) \ - PUT_VALUE(_x, _y, PACK_COLOR_1555_REV(a, r, g, b)) \ - -#define WRITE_PIXEL( _x, _y, p ) PUT_VALUE(_x, _y, p) - -#define READ_RGBA( rgba, _x, _y ) \ - do { \ - GLushort p = GET_VALUE(_x, _y); \ - p = p << 8 | p >> 8; \ - rgba[0] = ((p >> 7) & 0xf8) * 255 / 0xf8; \ - rgba[1] = ((p >> 2) & 0xf8) * 255 / 0xf8; \ - rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8; \ - rgba[3] = ((p >> 15) & 0x1) * 0xff; \ - } while (0) - -#elif (SPANTMP_PIXEL_FMT == GL_BGRA) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV) - -/** - ** GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV - **/ - -#ifndef GET_VALUE -#ifndef GET_PTR -#define GET_PTR(_x, _y) ( buf + (_x) * 4 + (_y) * pitch) -#endif - -#define GET_VALUE(_x, _y) *(volatile GLuint *)(GET_PTR(_x, _y)) -#define PUT_VALUE(_x, _y, _v) *(volatile GLuint *)(GET_PTR(_x, _y)) = (_v) -#endif /* GET_VALUE */ - -# define WRITE_RGBA(_x, _y, r, g, b, a) \ - PUT_VALUE(_x, _y, ((r << 16) | \ - (g << 8) | \ - (b << 0) | \ - (a << 24))) - -#define WRITE_PIXEL(_x, _y, p) PUT_VALUE(_x, _y, p) - -# if defined( USE_X86_ASM ) -# define READ_RGBA(rgba, _x, _y) \ - do { \ - GLuint p = GET_VALUE(_x, _y); \ - __asm__ __volatile__( "bswap %0; rorl $8, %0" \ - : "=r" (p) : "0" (p) ); \ - ((GLuint *)rgba)[0] = p; \ - } while (0) -# elif defined( MESA_BIG_ENDIAN ) - /* On PowerPC with GCC 3.4.2 the shift madness below becomes a single - * rotlwi instruction. It also produces good code on SPARC. - */ -# define READ_RGBA( rgba, _x, _y ) \ - do { \ - GLuint p = GET_VALUE(_x, _y); \ - GLuint t = p; \ - *((uint32_t *) rgba) = (t >> 24) | (p << 8); \ - } while (0) -# else -# define READ_RGBA( rgba, _x, _y ) \ - do { \ - GLuint p = GET_VALUE(_x, _y); \ - rgba[0] = (p >> 16) & 0xff; \ - rgba[1] = (p >> 8) & 0xff; \ - rgba[2] = (p >> 0) & 0xff; \ - rgba[3] = (p >> 24) & 0xff; \ - } while (0) -# endif - -#elif (SPANTMP_PIXEL_FMT == GL_BGRA) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8) - -/** - ** GL_BGRA, GL_UNSIGNED_INT_8_8_8_8 - **/ - -#ifndef GET_VALUE -#ifndef GET_PTR -#define GET_PTR(_x, _y) ( buf + (_x) * 4 + (_y) * pitch) -#endif - -#define GET_VALUE(_x, _y) *(volatile GLuint *)(GET_PTR(_x, _y)) -#define PUT_VALUE(_x, _y, _v) *(volatile GLuint *)(GET_PTR(_x, _y)) = (_v) -#endif /* GET_VALUE */ - -# define WRITE_RGBA(_x, _y, r, g, b, a) \ - PUT_VALUE(_x, _y, ((r << 8) | \ - (g << 16) | \ - (b << 24) | \ - (a << 0))) - -#define WRITE_PIXEL(_x, _y, p) PUT_VALUE(_x, _y, p) - -# if defined( USE_X86_ASM ) -# define READ_RGBA(rgba, _x, _y) \ - do { \ - GLuint p = GET_VALUE(_x, _y); \ - __asm__ __volatile__( "rorl $8, %0" \ - : "=r" (p) : "0" (p) ); \ - ((GLuint *)rgba)[0] = p; \ - } while (0) -# elif defined( MESA_BIG_ENDIAN ) - /* On PowerPC with GCC 3.4.2 the shift madness below becomes a single - * rotlwi instruction. It also produces good code on SPARC. - */ -# define READ_RGBA( rgba, _x, _y ) \ - do { \ - GLuint p = CPU_TO_LE32(GET_VALUE(_x, _y)); \ - GLuint t = p; \ - *((uint32_t *) rgba) = (t >> 24) | (p << 8); \ - } while (0) -# else -# define READ_RGBA( rgba, _x, _y ) \ - do { \ - GLuint p = GET_VALUE(_x, _y); \ - rgba[0] = (p >> 8) & 0xff; \ - rgba[1] = (p >> 16) & 0xff; \ - rgba[2] = (p >> 24) & 0xff; \ - rgba[3] = (p >> 0) & 0xff; \ - } while (0) -# endif - -#elif (SPANTMP_PIXEL_FMT == GL_BGR) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV) - -/** - ** GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV - ** - ** This is really for MESA_FORMAT_XRGB8888. The spantmp code needs to be - ** kicked to the curb, and we need to just code-gen this. - **/ - -#ifndef GET_VALUE -#ifndef GET_PTR -#define GET_PTR(_x, _y) ( buf + (_x) * 4 + (_y) * pitch) -#endif - -#define GET_VALUE(_x, _y) *(volatile GLuint *)(GET_PTR(_x, _y)) -#define PUT_VALUE(_x, _y, _v) *(volatile GLuint *)(GET_PTR(_x, _y)) = (_v) -#endif /* GET_VALUE */ - -# define WRITE_RGBA(_x, _y, r, g, b, a) \ - PUT_VALUE(_x, _y, ((r << 16) | \ - (g << 8) | \ - (b << 0) | \ - (0xff << 24))) - -#define WRITE_PIXEL(_x, _y, p) PUT_VALUE(_x, _y, p) - -# if defined( USE_X86_ASM ) -# define READ_RGBA(rgba, _x, _y) \ - do { \ - GLuint p = GET_VALUE(_x, _y); \ - __asm__ __volatile__( "bswap %0; rorl $8, %0" \ - : "=r" (p) : "0" (p) ); \ - ((GLuint *)rgba)[0] = p | 0xff000000; \ - } while (0) -# elif defined( MESA_BIG_ENDIAN ) - /* On PowerPC with GCC 3.4.2 the shift madness below becomes a single - * rotlwi instruction. It also produces good code on SPARC. - */ -# define READ_RGBA( rgba, _x, _y ) \ - do { \ - GLuint p = GET_VALUE(_x, _y); \ - *((uint32_t *) rgba) = (p << 8) | 0xff; \ - } while (0) -# else -# define READ_RGBA( rgba, _x, _y ) \ - do { \ - GLuint p = GET_VALUE(_x, _y); \ - rgba[0] = (p >> 16) & 0xff; \ - rgba[1] = (p >> 8) & 0xff; \ - rgba[2] = (p >> 0) & 0xff; \ - rgba[3] = 0xff; \ - } while (0) -# endif - -#elif (SPANTMP_PIXEL_FMT == GL_ALPHA) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_BYTE) - -/** - ** GL_ALPHA, GL_UNSIGNED_BYTE - **/ - -#ifndef GET_VALUE -#ifndef GET_PTR -#define GET_PTR(_x, _y) ( buf + (_x) + (_y) * pitch) -#endif - -#define GET_VALUE(_x, _y) *(volatile GLubyte *)(GET_PTR(_x, _y)) -#define PUT_VALUE(_x, _y, _v) *(volatile GLubyte *)(GET_PTR(_x, _y)) = (_v) -#endif /* GET_VALUE */ - -# define WRITE_RGBA(_x, _y, r, g, b, a) \ - PUT_VALUE(_x, _y, a | (r & 0 /* quiet warnings */)) - -#define WRITE_PIXEL(_x, _y, p) PUT_VALUE(_x, _y, p) - -#define READ_RGBA( rgba, _x, _y ) \ - do { \ - GLubyte p = GET_VALUE(_x, _y); \ - rgba[0] = 0; \ - rgba[1] = 0; \ - rgba[2] = 0; \ - rgba[3] = p; \ - } while (0) - -#else -#error SPANTMP_PIXEL_FMT must be set to a valid value! -#endif - - - -/** - ** Assembly routines. - **/ - -#if defined( USE_MMX_ASM ) || defined( USE_SSE_ASM ) -#include "x86/read_rgba_span_x86.h" -#include "x86/common_x86_asm.h" -#endif - -static void TAG(WriteRGBASpan)( struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, - const void *values, const GLubyte mask[] ) -{ - (void) ctx; - - HW_WRITE_LOCK() - { - const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values; - GLint x1; - GLint n1; - LOCAL_VARS; - - y = Y_FLIP(y); - - HW_WRITE_CLIPLOOP() - { - GLint i = 0; - CLIPSPAN(x,y,n,x1,n1,i); - - if (DBG) fprintf(stderr, "WriteRGBASpan %d..%d (x1 %d)\n", - (int)i, (int)n1, (int)x1); - - if (mask) - { - for (;n1>0;i++,x1++,n1--) - if (mask[i]) - WRITE_RGBA( x1, y, - rgba[i][0], rgba[i][1], - rgba[i][2], rgba[i][3] ); - } - else - { - for (;n1>0;i++,x1++,n1--) - WRITE_RGBA( x1, y, - rgba[i][0], rgba[i][1], - rgba[i][2], rgba[i][3] ); - } - } - HW_ENDCLIPLOOP(); - } - HW_WRITE_UNLOCK(); -} - - -static void TAG(WriteRGBAPixels)( struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint n, const GLint x[], const GLint y[], - const void *values, const GLubyte mask[] ) -{ - (void) ctx; - - HW_WRITE_LOCK() - { - const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values; - GLint i; - LOCAL_VARS; - - if (DBG) fprintf(stderr, "WriteRGBAPixels\n"); - - HW_WRITE_CLIPLOOP() - { - if (mask) - { - for (i=0;i<n;i++) - { - if (mask[i]) { - const int fy = Y_FLIP(y[i]); - if (CLIPPIXEL(x[i],fy)) - WRITE_RGBA( x[i], fy, - rgba[i][0], rgba[i][1], - rgba[i][2], rgba[i][3] ); - } - } - } - else - { - for (i=0;i<n;i++) - { - const int fy = Y_FLIP(y[i]); - if (CLIPPIXEL(x[i],fy)) - WRITE_RGBA( x[i], fy, - rgba[i][0], rgba[i][1], - rgba[i][2], rgba[i][3] ); - } - } - } - HW_ENDCLIPLOOP(); - } - HW_WRITE_UNLOCK(); -} - - -static void TAG(ReadRGBASpan)( struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, void *values) -{ - (void) ctx; - - HW_READ_LOCK() - { - GLubyte (*rgba)[4] = (GLubyte (*)[4]) values; - GLint x1,n1; - LOCAL_VARS; - - y = Y_FLIP(y); - - if (DBG) fprintf(stderr, "ReadRGBASpan\n"); - - HW_READ_CLIPLOOP() - { - GLint i = 0; - CLIPSPAN(x,y,n,x1,n1,i); - for (;n1>0;i++,x1++,n1--) - READ_RGBA( rgba[i], x1, y ); - } - HW_ENDCLIPLOOP(); - } - HW_READ_UNLOCK(); -} - - -#if defined(GET_PTR) && \ - defined(USE_MMX_ASM) && \ - (((SPANTMP_PIXEL_FMT == GL_BGRA) && \ - (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)) || \ - ((SPANTMP_PIXEL_FMT == GL_RGB) && \ - (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5))) -static void TAG2(ReadRGBASpan,_MMX)( struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, void *values) -{ -#ifndef USE_INNER_EMMS - /* The EMMS instruction is directly in-lined here because using GCC's - * built-in _mm_empty function was found to utterly destroy performance. - */ - __asm__ __volatile__( "emms" ); -#endif - - (void) ctx; - - HW_READ_LOCK() - { - GLubyte (*rgba)[4] = (GLubyte (*)[4]) values; - GLint x1,n1; - LOCAL_VARS; - - y = Y_FLIP(y); - - if (DBG) fprintf(stderr, "ReadRGBASpan\n"); - - HW_READ_CLIPLOOP() - { - GLint i = 0; - CLIPSPAN(x,y,n,x1,n1,i); - - { - const void * src = GET_PTR( x1, y ); -#if (SPANTMP_PIXEL_FMT == GL_RGB) && \ - (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5) - _generic_read_RGBA_span_RGB565_MMX( src, rgba[i], n1 ); -#else - _generic_read_RGBA_span_BGRA8888_REV_MMX( src, rgba[i], n1 ); -#endif - } - } - HW_ENDCLIPLOOP(); - } - HW_READ_UNLOCK(); -#ifndef USE_INNER_EMMS - __asm__ __volatile__( "emms" ); -#endif -} -#endif - - -#if defined(GET_PTR) && \ - defined(USE_SSE_ASM) && \ - (SPANTMP_PIXEL_FMT == GL_BGRA) && \ - (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV) -static void TAG2(ReadRGBASpan,_SSE2)( struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, - void *values) -{ - (void) ctx; - - HW_READ_LOCK() - { - GLubyte (*rgba)[4] = (GLubyte (*)[4]) values; - GLint x1,n1; - LOCAL_VARS; - - y = Y_FLIP(y); - - if (DBG) fprintf(stderr, "ReadRGBASpan\n"); - - HW_READ_CLIPLOOP() - { - GLint i = 0; - CLIPSPAN(x,y,n,x1,n1,i); - - { - const void * src = GET_PTR( x1, y ); - _generic_read_RGBA_span_BGRA8888_REV_SSE2( src, rgba[i], n1 ); - } - } - HW_ENDCLIPLOOP(); - } - HW_READ_UNLOCK(); -} -#endif - -#if defined(GET_PTR) && \ - defined(USE_SSE_ASM) && \ - (SPANTMP_PIXEL_FMT == GL_BGRA) && \ - (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV) -static void TAG2(ReadRGBASpan,_SSE)( struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, - void *values) -{ -#ifndef USE_INNER_EMMS - /* The EMMS instruction is directly in-lined here because using GCC's - * built-in _mm_empty function was found to utterly destroy performance. - */ - __asm__ __volatile__( "emms" ); -#endif - - (void) ctx; - - HW_READ_LOCK() - { - GLubyte (*rgba)[4] = (GLubyte (*)[4]) values; - GLint x1,n1; - LOCAL_VARS; - - y = Y_FLIP(y); - - if (DBG) fprintf(stderr, "ReadRGBASpan\n"); - - HW_READ_CLIPLOOP() - { - GLint i = 0; - CLIPSPAN(x,y,n,x1,n1,i); - - { - const void * src = GET_PTR( x1, y ); - _generic_read_RGBA_span_BGRA8888_REV_SSE( src, rgba[i], n1 ); - } - } - HW_ENDCLIPLOOP(); - } - HW_READ_UNLOCK(); -#ifndef USE_INNER_EMMS - __asm__ __volatile__( "emms" ); -#endif -} -#endif - - -static void TAG(ReadRGBAPixels)( struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint n, const GLint x[], const GLint y[], - void *values ) -{ - (void) ctx; - - HW_READ_LOCK() - { - GLubyte (*rgba)[4] = (GLubyte (*)[4]) values; - GLint i; - LOCAL_VARS; - - if (DBG) fprintf(stderr, "ReadRGBAPixels\n"); - - HW_READ_CLIPLOOP() - { - for (i=0;i<n;i++) { - int fy = Y_FLIP( y[i] ); - if (CLIPPIXEL( x[i], fy )) - READ_RGBA( rgba[i], x[i], fy ); - } - } - HW_ENDCLIPLOOP(); - } - HW_READ_UNLOCK(); -} - -static void TAG(InitPointers)(struct gl_renderbuffer *rb) -{ - rb->PutRow = TAG(WriteRGBASpan); - rb->PutValues = TAG(WriteRGBAPixels); - rb->GetValues = TAG(ReadRGBAPixels); - -#if defined(GET_PTR) -#if defined(USE_SSE_ASM) && \ - (SPANTMP_PIXEL_FMT == GL_BGRA) && \ - (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV) - if ( cpu_has_xmm2 ) { - if (DBG) fprintf( stderr, "Using %s version of GetRow\n", "SSE2" ); - rb->GetRow = TAG2(ReadRGBASpan, _SSE2); - } - else -#endif -#if defined(USE_SSE_ASM) && \ - (SPANTMP_PIXEL_FMT == GL_BGRA) && \ - (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV) - if ( cpu_has_xmm ) { - if (DBG) fprintf( stderr, "Using %s version of GetRow\n", "SSE" ); - rb->GetRow = TAG2(ReadRGBASpan, _SSE); - } - else -#endif -#if defined(USE_MMX_ASM) && \ - (((SPANTMP_PIXEL_FMT == GL_BGRA) && \ - (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)) || \ - ((SPANTMP_PIXEL_FMT == GL_RGB) && \ - (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5))) - if ( cpu_has_mmx ) { - if (DBG) fprintf( stderr, "Using %s version of GetRow\n", "MMX" ); - rb->GetRow = TAG2(ReadRGBASpan, _MMX); - } - else -#endif -#endif /* GET_PTR */ - { - if (DBG) fprintf( stderr, "Using %s version of GetRow\n", "C" ); - rb->GetRow = TAG(ReadRGBASpan); - } - -} - - -#undef WRITE_PIXEL -#undef WRITE_RGBA -#undef READ_RGBA -#undef TAG -#undef TAG2 -#undef GET_VALUE -#undef PUT_VALUE -#undef GET_PTR -#undef SPANTMP_PIXEL_FMT -#undef SPANTMP_PIXEL_TYPE diff --git a/mesalib/src/mesa/drivers/dri/common/spantmp_common.h b/mesalib/src/mesa/drivers/dri/common/spantmp_common.h deleted file mode 100644 index 8916e7b0c..000000000 --- a/mesalib/src/mesa/drivers/dri/common/spantmp_common.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2000-2001 VA Linux Systems, Inc. - * (C) Copyright IBM Corporation 2004 - * 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 - * VA LINUX SYSTEM, IBM 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 spantmp_common.h - * - * common macros for span read / write functions to be used in the depth, - * stencil and pixel span templates. - */ - -#ifndef HW_WRITE_LOCK -#define HW_WRITE_LOCK() HW_LOCK() -#endif - -#ifndef HW_WRITE_UNLOCK -#define HW_WRITE_UNLOCK() HW_UNLOCK() -#endif - -#ifndef HW_READ_LOCK -#define HW_READ_LOCK() HW_LOCK() -#endif - -#ifndef HW_READ_UNLOCK -#define HW_READ_UNLOCK() HW_UNLOCK() -#endif - -#ifndef HW_CLIPLOOP -#define HW_CLIPLOOP() \ - do { \ - int minx = 0; \ - int miny = 0; \ - int maxx = dPriv->w; \ - int maxy = dPriv->h; -#endif - -#ifndef HW_ENDCLIPLOOP -#define HW_ENDCLIPLOOP() \ - } while (0) -#endif - -#ifndef CLIPPIXEL -#define CLIPPIXEL( _x, _y ) \ - ((_x >= minx) && (_x < maxx) && (_y >= miny) && (_y < maxy)) -#endif - -#ifndef CLIPSPAN -#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i ) \ - if ( _y < miny || _y >= maxy /*|| _x + n < minx || _x >=maxx*/ ) { \ - _n1 = 0, _x1 = x; \ - } else { \ - _n1 = _n; \ - _x1 = _x; \ - if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \ - if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx); \ - } -#endif diff --git a/mesalib/src/mesa/drivers/dri/common/stenciltmp.h b/mesalib/src/mesa/drivers/dri/common/stenciltmp.h deleted file mode 100644 index 950d3c4df..000000000 --- a/mesalib/src/mesa/drivers/dri/common/stenciltmp.h +++ /dev/null @@ -1,186 +0,0 @@ - -#include "spantmp_common.h" - -#ifndef DBG -#define DBG 0 -#endif - -#ifndef HAVE_HW_STENCIL_SPANS -#define HAVE_HW_STENCIL_SPANS 0 -#endif - -#ifndef HAVE_HW_STENCIL_PIXELS -#define HAVE_HW_STENCIL_PIXELS 0 -#endif - -static void TAG(WriteStencilSpan)( struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, - const void *values, const GLubyte mask[] ) -{ - HW_WRITE_LOCK() - { - const GLubyte *stencil = (const GLubyte *) values; - GLint x1; - GLint n1; - LOCAL_STENCIL_VARS; - - y = Y_FLIP(y); - -#if HAVE_HW_STENCIL_SPANS - (void) x1; (void) n1; - - if (DBG) fprintf(stderr, "WriteStencilSpan 0..%d (x1 %d)\n", - (int)n1, (int)x1); - - WRITE_STENCIL_SPAN(); -#else /* HAVE_HW_STENCIL_SPANS */ - HW_CLIPLOOP() - { - GLint i = 0; - CLIPSPAN(x,y,n,x1,n1,i); - - if (DBG) fprintf(stderr, "WriteStencilSpan %d..%d (x1 %d)\n", - (int)i, (int)n1, (int)x1); - - if (mask) - { - for (;n1>0;i++,x1++,n1--) - if (mask[i]) - WRITE_STENCIL( x1, y, stencil[i] ); - } - else - { - for (;n1>0;i++,x1++,n1--) - WRITE_STENCIL( x1, y, stencil[i] ); - } - } - HW_ENDCLIPLOOP(); -#endif /* !HAVE_HW_STENCIL_SPANS */ - } - HW_WRITE_UNLOCK(); -} - - -static void TAG(WriteStencilPixels)( struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint n, - const GLint x[], const GLint y[], - const void *values, const GLubyte mask[] ) -{ - HW_WRITE_LOCK() - { - const GLubyte *stencil = (const GLubyte *) values; - GLuint i; - LOCAL_STENCIL_VARS; - - if (DBG) fprintf(stderr, "WriteStencilPixels\n"); - -#if HAVE_HW_STENCIL_PIXELS - (void) i; - - WRITE_STENCIL_PIXELS(); -#else /* HAVE_HW_STENCIL_PIXELS */ - HW_CLIPLOOP() - { - for (i=0;i<n;i++) - { - if (mask[i]) { - const int fy = Y_FLIP(y[i]); - if (CLIPPIXEL(x[i],fy)) - WRITE_STENCIL( x[i], fy, stencil[i] ); - } - } - } - HW_ENDCLIPLOOP(); -#endif /* !HAVE_HW_STENCIL_PIXELS */ - } - HW_WRITE_UNLOCK(); -} - - -/* Read stencil spans and pixels - */ -static void TAG(ReadStencilSpan)( struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, - void *values) -{ - HW_READ_LOCK() - { - GLubyte *stencil = (GLubyte *) values; - GLint x1,n1; - LOCAL_STENCIL_VARS; - - y = Y_FLIP(y); - - if (DBG) fprintf(stderr, "ReadStencilSpan\n"); - -#if HAVE_HW_STENCIL_SPANS - (void) x1; (void) n1; - - READ_STENCIL_SPAN(); -#else /* HAVE_HW_STENCIL_SPANS */ - HW_CLIPLOOP() - { - GLint i = 0; - CLIPSPAN(x,y,n,x1,n1,i); - for (;n1>0;i++,n1--) - READ_STENCIL( stencil[i], (x+i), y ); - } - HW_ENDCLIPLOOP(); -#endif /* !HAVE_HW_STENCIL_SPANS */ - } - HW_READ_UNLOCK(); -} - -static void TAG(ReadStencilPixels)( struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint n, const GLint x[], const GLint y[], - void *values ) -{ - HW_READ_LOCK() - { - GLubyte *stencil = (GLubyte *) values; - GLuint i; - LOCAL_STENCIL_VARS; - - if (DBG) fprintf(stderr, "ReadStencilPixels\n"); - -#if HAVE_HW_STENCIL_PIXELS - (void) i; - - READ_STENCIL_PIXELS(); -#else /* HAVE_HW_STENCIL_PIXELS */ - HW_CLIPLOOP() - { - for (i=0;i<n;i++) { - int fy = Y_FLIP( y[i] ); - if (CLIPPIXEL( x[i], fy )) - READ_STENCIL( stencil[i], x[i], fy ); - } - } - HW_ENDCLIPLOOP(); -#endif /* !HAVE_HW_STENCIL_PIXELS */ - } - HW_READ_UNLOCK(); -} - - - -/** - * Initialize the given renderbuffer's span routines to point to - * the stencil functions we generated above. - */ -static void TAG(InitStencilPointers)(struct gl_renderbuffer *rb) -{ - rb->GetRow = TAG(ReadStencilSpan); - rb->GetValues = TAG(ReadStencilPixels); - rb->PutRow = TAG(WriteStencilSpan); - rb->PutValues = TAG(WriteStencilPixels); -} - - -#undef WRITE_STENCIL -#undef READ_STENCIL -#undef TAG diff --git a/mesalib/src/mesa/drivers/dri/swrast/Makefile.sources b/mesalib/src/mesa/drivers/dri/swrast/Makefile.sources index 9de5cb823..7630dba4b 100644 --- a/mesalib/src/mesa/drivers/dri/swrast/Makefile.sources +++ b/mesalib/src/mesa/drivers/dri/swrast/Makefile.sources @@ -1,6 +1,5 @@ SWRAST_DRIVER_FILES = \ - swrast.c \ - swrast_span.c + swrast.c SWRAST_COMMON_FILES = \ ../common/utils.c \ diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c index 4f6d0160f..d18dd0927 100644 --- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c +++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c @@ -94,7 +94,7 @@ static void swrastSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, _mesa_init_teximage_fields(&dri_ctx->Base, texImage, w, h, 1, 0, internalFormat, texFormat); - sPriv->swrast_loader->getImage(dPriv, x, y, w, h, (char *)swImage->Data, + sPriv->swrast_loader->getImage(dPriv, x, y, w, h, (char *)swImage->Buffer, dPriv->loaderPrivate); _mesa_unlock_texture(&dri_ctx->Base, texObj); @@ -263,10 +263,12 @@ choose_pixel_format(const struct gl_config *v) static void swrast_delete_renderbuffer(struct gl_renderbuffer *rb) { + struct dri_swrast_renderbuffer *xrb = dri_swrast_renderbuffer(rb); + TRACE; - free(rb->Data); - free(rb); + free(xrb->Base.Buffer); + free(xrb); } /* see bytes_per_line in libGL */ @@ -282,17 +284,16 @@ static GLboolean swrast_alloc_front_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, GLenum internalFormat, GLuint width, GLuint height) { - struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb); + struct dri_swrast_renderbuffer *xrb = dri_swrast_renderbuffer(rb); TRACE; (void) ctx; (void) internalFormat; - rb->Data = NULL; + xrb->Base.Buffer = NULL; rb->Width = width; rb->Height = height; - rb->RowStride = width; xrb->pitch = bytes_per_line(width * xrb->bpp, 32); return GL_TRUE; @@ -302,24 +303,25 @@ static GLboolean swrast_alloc_back_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, GLenum internalFormat, GLuint width, GLuint height) { - struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb); + struct dri_swrast_renderbuffer *xrb = dri_swrast_renderbuffer(rb); TRACE; - free(rb->Data); + free(xrb->Base.Buffer); swrast_alloc_front_storage(ctx, rb, internalFormat, width, height); - rb->Data = malloc(height * xrb->pitch); + xrb->Base.Buffer = malloc(height * xrb->pitch); return GL_TRUE; } -static struct swrast_renderbuffer * +static struct dri_swrast_renderbuffer * swrast_new_renderbuffer(const struct gl_config *visual, __DRIdrawable *dPriv, GLboolean front) { - struct swrast_renderbuffer *xrb = calloc(1, sizeof *xrb); + struct dri_swrast_renderbuffer *xrb = calloc(1, sizeof *xrb); + struct gl_renderbuffer *rb; GLuint pixel_format; TRACE; @@ -327,48 +329,44 @@ swrast_new_renderbuffer(const struct gl_config *visual, __DRIdrawable *dPriv, if (!xrb) return NULL; - _mesa_init_renderbuffer(&xrb->Base, 0); + rb = &xrb->Base.Base; + + _mesa_init_renderbuffer(rb, 0); pixel_format = choose_pixel_format(visual); xrb->dPriv = dPriv; - xrb->Base.Delete = swrast_delete_renderbuffer; + xrb->Base.Base.Delete = swrast_delete_renderbuffer; if (front) { - xrb->Base.AllocStorage = swrast_alloc_front_storage; - swrast_set_span_funcs_front(xrb, pixel_format); + rb->AllocStorage = swrast_alloc_front_storage; } else { - xrb->Base.AllocStorage = swrast_alloc_back_storage; - swrast_set_span_funcs_back(xrb, pixel_format); + rb->AllocStorage = swrast_alloc_back_storage; } switch (pixel_format) { case PF_A8R8G8B8: - xrb->Base.Format = MESA_FORMAT_ARGB8888; - xrb->Base.InternalFormat = GL_RGBA; - xrb->Base._BaseFormat = GL_RGBA; - xrb->Base.DataType = GL_UNSIGNED_BYTE; + rb->Format = MESA_FORMAT_ARGB8888; + rb->InternalFormat = GL_RGBA; + rb->_BaseFormat = GL_RGBA; xrb->bpp = 32; break; case PF_X8R8G8B8: - xrb->Base.Format = MESA_FORMAT_ARGB8888; /* XXX */ - xrb->Base.InternalFormat = GL_RGB; - xrb->Base._BaseFormat = GL_RGB; - xrb->Base.DataType = GL_UNSIGNED_BYTE; + rb->Format = MESA_FORMAT_ARGB8888; /* XXX */ + rb->InternalFormat = GL_RGB; + rb->_BaseFormat = GL_RGB; xrb->bpp = 32; break; case PF_R5G6B5: - xrb->Base.Format = MESA_FORMAT_RGB565; - xrb->Base.InternalFormat = GL_RGB; - xrb->Base._BaseFormat = GL_RGB; - xrb->Base.DataType = GL_UNSIGNED_BYTE; + rb->Format = MESA_FORMAT_RGB565; + rb->InternalFormat = GL_RGB; + rb->_BaseFormat = GL_RGB; xrb->bpp = 16; break; case PF_R3G3B2: - xrb->Base.Format = MESA_FORMAT_RGB332; - xrb->Base.InternalFormat = GL_RGB; - xrb->Base._BaseFormat = GL_RGB; - xrb->Base.DataType = GL_UNSIGNED_BYTE; + rb->Format = MESA_FORMAT_RGB332; + rb->InternalFormat = GL_RGB; + rb->_BaseFormat = GL_RGB; xrb->bpp = 8; break; default: @@ -386,10 +384,10 @@ swrast_map_renderbuffer(struct gl_context *ctx, GLubyte **out_map, GLint *out_stride) { - struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb); - GLubyte *map = rb->Data; + struct dri_swrast_renderbuffer *xrb = dri_swrast_renderbuffer(rb); + GLubyte *map = xrb->Base.Buffer; int cpp = _mesa_get_format_bytes(rb->Format); - int stride = rb->RowStride * cpp; + int stride = rb->Width * cpp; if (rb->AllocStorage == swrast_alloc_front_storage) { __DRIdrawable *dPriv = xrb->dPriv; @@ -402,18 +400,18 @@ swrast_map_renderbuffer(struct gl_context *ctx, xrb->map_h = h; stride = w * cpp; - rb->Data = malloc(h * stride); + xrb->Base.Buffer = malloc(h * stride); sPriv->swrast_loader->getImage(dPriv, x, y, w, h, - (char *)rb->Data, + (char *) xrb->Base.Buffer, dPriv->loaderPrivate); - *out_map = rb->Data; + *out_map = xrb->Base.Buffer; *out_stride = stride; return; } - ASSERT(rb->Data); + ASSERT(xrb->Base.Buffer); if (rb->AllocStorage == swrast_alloc_back_storage) { map += (rb->Height - 1) * stride; @@ -431,7 +429,7 @@ static void swrast_unmap_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb) { - struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb); + struct dri_swrast_renderbuffer *xrb = dri_swrast_renderbuffer(rb); if (rb->AllocStorage == swrast_alloc_front_storage) { __DRIdrawable *dPriv = xrb->dPriv; @@ -441,12 +439,12 @@ swrast_unmap_renderbuffer(struct gl_context *ctx, sPriv->swrast_loader->putImage(dPriv, __DRI_SWRAST_IMAGE_OP_DRAW, xrb->map_x, xrb->map_y, xrb->map_w, xrb->map_h, - rb->Data, + (char *) xrb->Base.Buffer, dPriv->loaderPrivate); } - free(rb->Data); - rb->Data = NULL; + free(xrb->Base.Buffer); + xrb->Base.Buffer = NULL; } } @@ -457,7 +455,7 @@ dri_create_buffer(__DRIscreen * sPriv, { struct dri_drawable *drawable = NULL; struct gl_framebuffer *fb; - struct swrast_renderbuffer *frontrb, *backrb; + struct dri_swrast_renderbuffer *frontrb, *backrb; TRACE; @@ -482,12 +480,12 @@ dri_create_buffer(__DRIscreen * sPriv, /* add front renderbuffer */ frontrb = swrast_new_renderbuffer(visual, dPriv, GL_TRUE); - _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontrb->Base); + _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontrb->Base.Base); /* add back renderbuffer */ if (visual->doubleBufferMode) { backrb = swrast_new_renderbuffer(visual, dPriv, GL_FALSE); - _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backrb->Base); + _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backrb->Base.Base); } /* add software renderbuffers */ @@ -538,16 +536,16 @@ dri_swap_buffers(__DRIdrawable * dPriv) struct dri_drawable *drawable = dri_drawable(dPriv); struct gl_framebuffer *fb; - struct swrast_renderbuffer *frontrb, *backrb; + struct dri_swrast_renderbuffer *frontrb, *backrb; TRACE; fb = &drawable->Base; frontrb = - swrast_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer); + dri_swrast_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer); backrb = - swrast_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer); + dri_swrast_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer); /* check for signle-buffered */ if (backrb == NULL) @@ -561,9 +559,9 @@ dri_swap_buffers(__DRIdrawable * dPriv) sPriv->swrast_loader->putImage(dPriv, __DRI_SWRAST_IMAGE_OP_SWAP, 0, 0, - frontrb->Base.Width, - frontrb->Base.Height, - backrb->Base.Data, + frontrb->Base.Base.Width, + frontrb->Base.Base.Height, + (char *) backrb->Base.Buffer, dPriv->loaderPrivate); } diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h b/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h index b57012aef..b25de931a 100644 --- a/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h +++ b/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h @@ -31,6 +31,7 @@ #include <GL/internal/dri_interface.h> #include "main/mtypes.h" #include "dri_util.h" +#include "swrast/s_context.h" /** @@ -100,8 +101,8 @@ swrast_drawable(struct gl_framebuffer *fb) return (struct dri_drawable *) fb; } -struct swrast_renderbuffer { - struct gl_renderbuffer Base; +struct dri_swrast_renderbuffer { + struct swrast_renderbuffer Base; __DRIdrawable *dPriv; /* GL_MAP_*_BIT, used for mapping of front buffer. */ @@ -114,10 +115,10 @@ struct swrast_renderbuffer { GLuint bpp; }; -static INLINE struct swrast_renderbuffer * -swrast_renderbuffer(struct gl_renderbuffer *rb) +static INLINE struct dri_swrast_renderbuffer * +dri_swrast_renderbuffer(struct gl_renderbuffer *rb) { - return (struct swrast_renderbuffer *) rb; + return (struct dri_swrast_renderbuffer *) rb; } @@ -130,14 +131,4 @@ swrast_renderbuffer(struct gl_renderbuffer *rb) #define PF_X8R8G8B8 4 /**< 32bpp TrueColor: 8-R, 8-G, 8-B bits */ -/* swrast_span.c */ - -extern void -swrast_set_span_funcs_back(struct swrast_renderbuffer *xrb, - GLuint pixel_format); - -extern void -swrast_set_span_funcs_front(struct swrast_renderbuffer *xrb, - GLuint pixel_format); - #endif /* _SWRAST_PRIV_H_ */ diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast_span.c b/mesalib/src/mesa/drivers/dri/swrast/swrast_span.c deleted file mode 100644 index ba6174f9d..000000000 --- a/mesalib/src/mesa/drivers/dri/swrast/swrast_span.c +++ /dev/null @@ -1,347 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright 2008, 2010 George Sapountzis <gsapountzis@gmail.com> - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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 "swrast_priv.h" - -#define YFLIP(_xrb, Y) ((_xrb)->Base.Height - (Y) - 1) - -/* - * Dithering support takes the "computation" extreme in the "computation vs. - * storage" trade-off. This approach is very simple to implement and any - * computational overhead should be acceptable. XMesa uses table lookups for - * around 8KB of storage overhead per visual. - */ -#define DITHER 1 - -static const GLubyte kernel[16] = { - 0*16, 8*16, 2*16, 10*16, - 12*16, 4*16, 14*16, 6*16, - 3*16, 11*16, 1*16, 9*16, - 15*16, 7*16, 13*16, 5*16, -}; - -#if DITHER -#define DITHER_COMP(X, Y) kernel[((X) & 0x3) | (((Y) & 0x3) << 2)] - -#define DITHER_CLAMP(X) (((X) < 255) ? (X) : 255) -#else -#define DITHER_COMP(X, Y) 0 - -#define DITHER_CLAMP(X) (X) -#endif - - -/* - * Pixel macros shared across front/back buffer span functions. - */ - -/* 32-bit BGRA */ -#define STORE_PIXEL_A8R8G8B8(DST, X, Y, VALUE) \ - *DST = VALUE[ACOMP] << 24 | VALUE[RCOMP] << 16 | VALUE[GCOMP] << 8 | VALUE[BCOMP] -#define STORE_PIXEL_RGB_A8R8G8B8(DST, X, Y, VALUE) \ - *DST = 0xff << 24 | VALUE[RCOMP] << 16 | VALUE[GCOMP] << 8 | VALUE[BCOMP] -#define FETCH_PIXEL_A8R8G8B8(DST, SRC) \ - DST[ACOMP] = *SRC >> 24; \ - DST[RCOMP] = (*SRC >> 16) & 0xff; \ - DST[GCOMP] = (*SRC >> 8) & 0xff; \ - DST[BCOMP] = *SRC & 0xff - - -/* 32-bit BGRX */ -#define STORE_PIXEL_X8R8G8B8(DST, X, Y, VALUE) \ - *DST = 0xff << 24 | VALUE[RCOMP] << 16 | VALUE[GCOMP] << 8 | VALUE[BCOMP] -#define STORE_PIXEL_RGB_X8R8G8B8(DST, X, Y, VALUE) \ - *DST = 0xff << 24 | VALUE[RCOMP] << 16 | VALUE[GCOMP] << 8 | VALUE[BCOMP] -#define FETCH_PIXEL_X8R8G8B8(DST, SRC) \ - DST[ACOMP] = 0xff; \ - DST[RCOMP] = (*SRC >> 16) & 0xff; \ - DST[GCOMP] = (*SRC >> 8) & 0xff; \ - DST[BCOMP] = *SRC & 0xff - - -/* 16-bit BGR */ -#define STORE_PIXEL_R5G6B5(DST, X, Y, VALUE) \ - do { \ - int d = DITHER_COMP(X, Y) >> 6; \ - *DST = ( ((DITHER_CLAMP((VALUE[RCOMP]) + d) & 0xf8) << 8) | \ - ((DITHER_CLAMP((VALUE[GCOMP]) + d) & 0xfc) << 3) | \ - ((DITHER_CLAMP((VALUE[BCOMP]) + d) & 0xf8) >> 3) ); \ - } while(0) -#define FETCH_PIXEL_R5G6B5(DST, SRC) \ - do { \ - DST[ACOMP] = 0xff; \ - DST[RCOMP] = ((*SRC >> 8) & 0xf8) * 255 / 0xf8; \ - DST[GCOMP] = ((*SRC >> 3) & 0xfc) * 255 / 0xfc; \ - DST[BCOMP] = ((*SRC << 3) & 0xf8) * 255 / 0xf8; \ - } while(0) - - -/* 8-bit BGR */ -#define STORE_PIXEL_R3G3B2(DST, X, Y, VALUE) \ - do { \ - int d = DITHER_COMP(X, Y) >> 3; \ - GLubyte *p = (GLubyte *)DST; \ - *p = ( ((DITHER_CLAMP((VALUE[RCOMP]) + d) & 0xe0) >> 5) | \ - ((DITHER_CLAMP((VALUE[GCOMP]) + d) & 0xe0) >> 2) | \ - ((DITHER_CLAMP((VALUE[BCOMP]) + d) & 0xc0) >> 0) ); \ - } while(0) -#define FETCH_PIXEL_R3G3B2(DST, SRC) \ - do { \ - GLubyte p = *(GLubyte *)SRC; \ - DST[ACOMP] = 0xff; \ - DST[RCOMP] = ((p << 5) & 0xe0) * 255 / 0xe0; \ - DST[GCOMP] = ((p << 2) & 0xe0) * 255 / 0xe0; \ - DST[BCOMP] = ((p << 0) & 0xc0) * 255 / 0xc0; \ - } while(0) - - -/* - * Generate code for back-buffer span functions. - */ - -/* 32-bit BGRA */ -#define NAME(FUNC) FUNC##_A8R8G8B8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb); -#define INIT_PIXEL_PTR(P, X, Y) \ - GLuint *P = (GLuint *)xrb->Base.Data + YFLIP(xrb, Y) * xrb->pitch / 4 + (X) -#define INC_PIXEL_PTR(P) P++ -#define STORE_PIXEL(DST, X, Y, VALUE) \ - STORE_PIXEL_A8R8G8B8(DST, X, Y, VALUE) -#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \ - STORE_PIXEL_RGB_A8R8G8B8(DST, X, Y, VALUE) -#define FETCH_PIXEL(DST, SRC) \ - FETCH_PIXEL_A8R8G8B8(DST, SRC) - -#include "swrast/s_spantemp.h" - - -/* 32-bit BGRX */ -#define NAME(FUNC) FUNC##_X8R8G8B8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb); -#define INIT_PIXEL_PTR(P, X, Y) \ - GLuint *P = (GLuint *)xrb->Base.Data + YFLIP(xrb, Y) * xrb->pitch / 4 + (X); -#define INC_PIXEL_PTR(P) P++ -#define STORE_PIXEL(DST, X, Y, VALUE) \ - STORE_PIXEL_X8R8G8B8(DST, X, Y, VALUE) -#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \ - STORE_PIXEL_RGB_X8R8G8B8(DST, X, Y, VALUE) -#define FETCH_PIXEL(DST, SRC) \ - FETCH_PIXEL_X8R8G8B8(DST, SRC) - -#include "swrast/s_spantemp.h" - - -/* 16-bit BGR */ -#define NAME(FUNC) FUNC##_R5G6B5 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb); -#define INIT_PIXEL_PTR(P, X, Y) \ - GLushort *P = (GLushort *)xrb->Base.Data + YFLIP(xrb, Y) * xrb->pitch / 2 + (X); -#define INC_PIXEL_PTR(P) P++ -#define STORE_PIXEL(DST, X, Y, VALUE) \ - STORE_PIXEL_R5G6B5(DST, X, Y, VALUE) -#define FETCH_PIXEL(DST, SRC) \ - FETCH_PIXEL_R5G6B5(DST, SRC) - -#include "swrast/s_spantemp.h" - - -/* 8-bit BGR */ -#define NAME(FUNC) FUNC##_R3G3B2 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb); -#define INIT_PIXEL_PTR(P, X, Y) \ - GLubyte *P = (GLubyte *)xrb->Base.Data + YFLIP(xrb, Y) * xrb->pitch + (X) * 1; -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL(DST, X, Y, VALUE) \ - STORE_PIXEL_R3G3B2(DST, X, Y, VALUE) -#define FETCH_PIXEL(DST, SRC) \ - FETCH_PIXEL_R3G3B2(DST, SRC) - -#include "swrast/s_spantemp.h" - - -/* - * Generate code for front-buffer span functions. - */ - -/* 32-bit BGRA */ -#define NAME(FUNC) FUNC##_A8R8G8B8_front -#define RB_TYPE GLubyte -#define SPAN_VARS \ - struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb); -#define INIT_PIXEL_PTR(P, X, Y) \ - GLuint *P = (GLuint *)row; -#define INC_PIXEL_PTR(P) P++ -#define STORE_PIXEL(DST, X, Y, VALUE) \ - STORE_PIXEL_A8R8G8B8(DST, X, Y, VALUE) -#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \ - STORE_PIXEL_RGB_A8R8G8B8(DST, X, Y, VALUE) -#define FETCH_PIXEL(DST, SRC) \ - FETCH_PIXEL_A8R8G8B8(DST, SRC) - -#include "swrast_spantemp.h" - - -/* 32-bit BGRX */ -#define NAME(FUNC) FUNC##_X8R8G8B8_front -#define RB_TYPE GLubyte -#define SPAN_VARS \ - struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb); -#define INIT_PIXEL_PTR(P, X, Y) \ - GLuint *P = (GLuint *)row; -#define INC_PIXEL_PTR(P) P++ -#define STORE_PIXEL(DST, X, Y, VALUE) \ - STORE_PIXEL_X8R8G8B8(DST, X, Y, VALUE) -#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \ - STORE_PIXEL_RGB_X8R8G8B8(DST, X, Y, VALUE) -#define FETCH_PIXEL(DST, SRC) \ - FETCH_PIXEL_X8R8G8B8(DST, SRC) - -#include "swrast_spantemp.h" - - -/* 16-bit BGR */ -#define NAME(FUNC) FUNC##_R5G6B5_front -#define RB_TYPE GLubyte -#define SPAN_VARS \ - struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb); -#define INIT_PIXEL_PTR(P, X, Y) \ - GLushort *P = (GLushort *)row; -#define INC_PIXEL_PTR(P) P++ -#define STORE_PIXEL(DST, X, Y, VALUE) \ - STORE_PIXEL_R5G6B5(DST, X, Y, VALUE) -#define FETCH_PIXEL(DST, SRC) \ - FETCH_PIXEL_R5G6B5(DST, SRC) - -#include "swrast_spantemp.h" - - -/* 8-bit BGR */ -#define NAME(FUNC) FUNC##_R3G3B2_front -#define RB_TYPE GLubyte -#define SPAN_VARS \ - struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb); -#define INIT_PIXEL_PTR(P, X, Y) \ - GLubyte *P = (GLubyte *)row; -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL(DST, X, Y, VALUE) \ - STORE_PIXEL_R3G3B2(DST, X, Y, VALUE) -#define FETCH_PIXEL(DST, SRC) \ - FETCH_PIXEL_R3G3B2(DST, SRC) - -#include "swrast_spantemp.h" - - -/* - * Back-buffers are malloced memory and always private. - * - * BACK_PIXMAP (not supported) - * BACK_XIMAGE - */ -void -swrast_set_span_funcs_back(struct swrast_renderbuffer *xrb, - GLuint pixel_format) -{ - switch (pixel_format) { - case PF_A8R8G8B8: - xrb->Base.GetRow = get_row_A8R8G8B8; - xrb->Base.GetValues = get_values_A8R8G8B8; - xrb->Base.PutRow = put_row_A8R8G8B8; - xrb->Base.PutValues = put_values_A8R8G8B8; - break; - case PF_X8R8G8B8: - xrb->Base.GetRow = get_row_X8R8G8B8; - xrb->Base.GetValues = get_values_X8R8G8B8; - xrb->Base.PutRow = put_row_X8R8G8B8; - xrb->Base.PutValues = put_values_X8R8G8B8; - break; - case PF_R5G6B5: - xrb->Base.GetRow = get_row_R5G6B5; - xrb->Base.GetValues = get_values_R5G6B5; - xrb->Base.PutRow = put_row_R5G6B5; - xrb->Base.PutValues = put_values_R5G6B5; - break; - case PF_R3G3B2: - xrb->Base.GetRow = get_row_R3G3B2; - xrb->Base.GetValues = get_values_R3G3B2; - xrb->Base.PutRow = put_row_R3G3B2; - xrb->Base.PutValues = put_values_R3G3B2; - break; - default: - assert(0); - return; - } -} - - -/* - * Front-buffers are provided by the loader, the xorg loader uses pixmaps. - * - * WINDOW, An X window - * GLXWINDOW, GLX window - * PIXMAP, GLX pixmap - * PBUFFER GLX Pbuffer - */ -void -swrast_set_span_funcs_front(struct swrast_renderbuffer *xrb, - GLuint pixel_format) -{ - switch (pixel_format) { - case PF_A8R8G8B8: - xrb->Base.GetRow = get_row_A8R8G8B8_front; - xrb->Base.GetValues = get_values_A8R8G8B8_front; - xrb->Base.PutRow = put_row_A8R8G8B8_front; - xrb->Base.PutValues = put_values_A8R8G8B8_front; - break; - case PF_X8R8G8B8: - xrb->Base.GetRow = get_row_X8R8G8B8_front; - xrb->Base.GetValues = get_values_X8R8G8B8_front; - xrb->Base.PutRow = put_row_X8R8G8B8_front; - xrb->Base.PutValues = put_values_X8R8G8B8_front; - break; - case PF_R5G6B5: - xrb->Base.GetRow = get_row_R5G6B5_front; - xrb->Base.GetValues = get_values_R5G6B5_front; - xrb->Base.PutRow = put_row_R5G6B5_front; - xrb->Base.PutValues = put_values_R5G6B5_front; - break; - case PF_R3G3B2: - xrb->Base.GetRow = get_row_R3G3B2_front; - xrb->Base.GetValues = get_values_R3G3B2_front; - xrb->Base.PutRow = put_row_R3G3B2_front; - xrb->Base.PutValues = put_values_R3G3B2_front; - break; - default: - assert(0); - return; - } -} diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast_spantemp.h b/mesalib/src/mesa/drivers/dri/swrast/swrast_spantemp.h deleted file mode 100644 index 50671193e..000000000 --- a/mesalib/src/mesa/drivers/dri/swrast/swrast_spantemp.h +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul 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, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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. - */ - - -/* - * Modified version of swrast/s_spantemp.h for front-buffer rendering. The - * no-mask paths use a scratch row to avoid repeated calls to the loader. - * - * For the mask paths we always use an array of 4 elements of RB_TYPE. This is - * to satisfy the xorg loader requirement of an image pitch of 32 bits and - * should be ok for other loaders also. - */ - - -#ifndef _SWRAST_SPANTEMP_ONCE -#define _SWRAST_SPANTEMP_ONCE - -static INLINE void -PUT_PIXEL( struct gl_context *glCtx, GLint x, GLint y, GLvoid *p ) -{ - __DRIcontext *ctx = swrast_context(glCtx)->cPriv; - __DRIdrawable *draw = swrast_drawable(glCtx->DrawBuffer)->dPriv; - - __DRIscreen *screen = ctx->driScreenPriv; - - screen->swrast_loader->putImage(draw, __DRI_SWRAST_IMAGE_OP_DRAW, - x, y, 1, 1, (char *)p, - draw->loaderPrivate); -} - - -static INLINE void -GET_PIXEL( struct gl_context *glCtx, GLint x, GLint y, GLubyte *p ) -{ - __DRIcontext *ctx = swrast_context(glCtx)->cPriv; - __DRIdrawable *read = swrast_drawable(glCtx->ReadBuffer)->dPriv; - - __DRIscreen *screen = ctx->driScreenPriv; - - screen->swrast_loader->getImage(read, x, y, 1, 1, (char *)p, - read->loaderPrivate); -} - -static INLINE void -PUT_ROW( struct gl_context *glCtx, GLint x, GLint y, GLuint n, char *row ) -{ - __DRIcontext *ctx = swrast_context(glCtx)->cPriv; - __DRIdrawable *draw = swrast_drawable(glCtx->DrawBuffer)->dPriv; - - __DRIscreen *screen = ctx->driScreenPriv; - - screen->swrast_loader->putImage(draw, __DRI_SWRAST_IMAGE_OP_DRAW, - x, y, n, 1, row, - draw->loaderPrivate); -} - -static INLINE void -GET_ROW( struct gl_context *glCtx, GLint x, GLint y, GLuint n, char *row ) -{ - __DRIcontext *ctx = swrast_context(glCtx)->cPriv; - __DRIdrawable *read = swrast_drawable(glCtx->ReadBuffer)->dPriv; - - __DRIscreen *screen = ctx->driScreenPriv; - - screen->swrast_loader->getImage(read, x, y, n, 1, row, - read->loaderPrivate); -} - -#endif /* _SWRAST_SPANTEMP_ONCE */ - - -/* - * Templates for the span/pixel-array write/read functions called via - * the gl_renderbuffer's GetRow, GetValues, PutRow and PutValues. - * - * Define the following macros before including this file: - * NAME(BASE) to generate the function name (i.e. add prefix or suffix) - * RB_TYPE the renderbuffer DataType - * SPAN_VARS to declare any local variables - * INIT_PIXEL_PTR(P, X, Y) to initialize a pointer to a pixel - * INC_PIXEL_PTR(P) to increment a pixel pointer by one pixel - * STORE_PIXEL(DST, X, Y, VALUE) to store pixel values in buffer - * FETCH_PIXEL(DST, SRC) to fetch pixel values from buffer - * - * Note that in the STORE_PIXEL macros, we also pass in the (X,Y) coordinates - * for the pixels to be stored. This is useful when dithering and probably - * ignored otherwise. - */ - -#include "main/macros.h" - - -#if !defined(RB_COMPONENTS) -#define RB_COMPONENTS 4 -#endif - - -static void -NAME(get_row)( struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, void *values ) -{ -#ifdef SPAN_VARS - SPAN_VARS -#endif - RB_TYPE (*dest)[RB_COMPONENTS] = (RB_TYPE (*)[RB_COMPONENTS]) values; - GLuint i; - char *row = swrast_drawable(ctx->ReadBuffer)->row; - INIT_PIXEL_PTR(pixel, x, y); - GET_ROW( ctx, x, YFLIP(xrb, y), count, row ); - for (i = 0; i < count; i++) { - FETCH_PIXEL(dest[i], pixel); - INC_PIXEL_PTR(pixel); - } - (void) rb; -} - - -static void -NAME(get_values)( struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], void *values ) -{ -#ifdef SPAN_VARS - SPAN_VARS -#endif - RB_TYPE (*dest)[RB_COMPONENTS] = (RB_TYPE (*)[RB_COMPONENTS]) values; - GLuint i; - for (i = 0; i < count; i++) { - RB_TYPE pixel[4]; - GET_PIXEL(ctx, x[i], YFLIP(xrb, y[i]), pixel); - FETCH_PIXEL(dest[i], pixel); - } - (void) rb; -} - - -static void -NAME(put_row)( struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, - const void *values, const GLubyte mask[] ) -{ -#ifdef SPAN_VARS - SPAN_VARS -#endif - const RB_TYPE (*src)[RB_COMPONENTS] = (const RB_TYPE (*)[RB_COMPONENTS]) values; - GLuint i; - if (mask) { - for (i = 0; i < count; i++) { - if (mask[i]) { - RB_TYPE row[4]; - INIT_PIXEL_PTR(pixel, x, y); - STORE_PIXEL(pixel, x + i, y, src[i]); - PUT_PIXEL(ctx, x + i, YFLIP(xrb, y), pixel); - } - } - } - else { - char *row = swrast_drawable(ctx->DrawBuffer)->row; - INIT_PIXEL_PTR(pixel, x, y); - for (i = 0; i < count; i++) { - STORE_PIXEL(pixel, x + i, y, src[i]); - INC_PIXEL_PTR(pixel); - } - PUT_ROW( ctx, x, YFLIP(xrb, y), count, row ); - } - (void) rb; -} - - -static void -NAME(put_values)( struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *values, const GLubyte mask[] ) -{ -#ifdef SPAN_VARS - SPAN_VARS -#endif - const RB_TYPE (*src)[RB_COMPONENTS] = (const RB_TYPE (*)[RB_COMPONENTS]) values; - GLuint i; - ASSERT(mask); - for (i = 0; i < count; i++) { - if (mask[i]) { - RB_TYPE row[4]; - INIT_PIXEL_PTR(pixel, x, y); - STORE_PIXEL(pixel, x[i], y[i], src[i]); - PUT_PIXEL(ctx, x[i], YFLIP(xrb, y[i]), pixel); - } - } - (void) rb; -} - - - - -#undef NAME -#undef RB_TYPE -#undef RB_COMPONENTS -#undef SPAN_VARS -#undef INIT_PIXEL_PTR -#undef INC_PIXEL_PTR -#undef STORE_PIXEL -#undef STORE_PIXEL_RGB -#undef FETCH_PIXEL diff --git a/mesalib/src/mesa/drivers/windows/gdi/wmesa.c b/mesalib/src/mesa/drivers/windows/gdi/wmesa.c index 255d811ca..ba11998eb 100644 --- a/mesalib/src/mesa/drivers/windows/gdi/wmesa.c +++ b/mesalib/src/mesa/drivers/windows/gdi/wmesa.c @@ -940,54 +940,6 @@ wmesa_renderbuffer_storage(struct gl_context *ctx, /** - * Plug in the Get/PutRow/Values functions for a renderbuffer depending - * on if we're drawing to the front or back color buffer. - */ -static void -wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat, - int cColorBits, int double_buffer) -{ - if (double_buffer) { - /* back buffer */ - /* Picking the correct span functions is important because - * the DIB was allocated with the indicated depth. */ - switch(pixelformat) { - case PF_5R6G5B: - rb->PutRow = write_rgba_span_16; - rb->PutValues = write_rgba_pixels_16; - rb->GetRow = read_rgba_span_16; - rb->GetValues = read_rgba_pixels_16; - break; - case PF_8R8G8B: - if (cColorBits == 24) - { - rb->PutRow = write_rgba_span_24; - rb->PutValues = write_rgba_pixels_24; - rb->GetRow = read_rgba_span_24; - rb->GetValues = read_rgba_pixels_24; - } - else - { - rb->PutRow = write_rgba_span_32; - rb->PutValues = write_rgba_pixels_32; - rb->GetRow = read_rgba_span_32; - rb->GetValues = read_rgba_pixels_32; - } - break; - default: - break; - } - } - else { - /* front buffer (actual Windows window) */ - rb->PutRow = write_rgba_span_front; - rb->PutValues = write_rgba_pixels_front; - rb->GetRow = read_rgba_span_front; - rb->GetValues = read_rgba_pixels_front; - } -} - -/** * Called by ctx->Driver.ResizeBuffers() * Resize the front/back colorbuffers to match the latest window size. */ @@ -1233,7 +1185,6 @@ wmesa_new_renderbuffer(void) rb->_BaseFormat = GL_RGBA; rb->InternalFormat = GL_RGBA; - rb->DataType = CHAN_TYPE; rb->Delete = wmesa_delete_renderbuffer; rb->AllocStorage = wmesa_renderbuffer_storage; return rb; @@ -1276,11 +1227,9 @@ void WMesaMakeCurrent(WMesaContext c, HDC hdc) if (visual->doubleBufferMode == 1) { rb = wmesa_new_renderbuffer(); _mesa_add_renderbuffer(&pwfb->Base, BUFFER_BACK_LEFT, rb); - wmesa_set_renderbuffer_funcs(rb, pwfb->pixelformat, pwfb->cColorBits, 1); } rb = wmesa_new_renderbuffer(); _mesa_add_renderbuffer(&pwfb->Base, BUFFER_FRONT_LEFT, rb); - wmesa_set_renderbuffer_funcs(rb, pwfb->pixelformat, pwfb->cColorBits, 0); /* Let Mesa own the Depth, Stencil, and Accum buffers */ _swrast_add_soft_renderbuffers(&pwfb->Base, diff --git a/mesalib/src/mesa/main/arrayobj.c b/mesalib/src/mesa/main/arrayobj.c index 328774543..d9ae187bb 100644 --- a/mesalib/src/mesa/main/arrayobj.c +++ b/mesalib/src/mesa/main/arrayobj.c @@ -372,6 +372,14 @@ bind_vertex_array(struct gl_context *ctx, GLuint id, GLboolean genRequired) _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindVertexArrayAPPLE"); return; } + + /* The "Interactions with APPLE_vertex_array_object" section of the + * GL_ARB_vertex_array_object spec says: + * + * "The first bind call, either BindVertexArray or + * BindVertexArrayAPPLE, determines the semantic of the object." + */ + newObj->ARBsemantics = genRequired; save_array_object(ctx, newObj); } } @@ -468,8 +476,7 @@ _mesa_DeleteVertexArraysAPPLE(GLsizei n, const GLuint *ids) * \param vboOnly Will arrays have to reside in VBOs? */ static void -gen_vertex_arrays(struct gl_context *ctx, GLsizei n, GLuint *arrays, - GLboolean vboOnly) +gen_vertex_arrays(struct gl_context *ctx, GLsizei n, GLuint *arrays) { GLuint first; GLint i; @@ -496,7 +503,6 @@ gen_vertex_arrays(struct gl_context *ctx, GLsizei n, GLuint *arrays, _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenVertexArraysAPPLE"); return; } - obj->VBOonly = vboOnly; save_array_object(ctx, obj); arrays[i] = first + i; } @@ -511,7 +517,7 @@ void GLAPIENTRY _mesa_GenVertexArrays(GLsizei n, GLuint *arrays) { GET_CURRENT_CONTEXT(ctx); - gen_vertex_arrays(ctx, n, arrays, GL_TRUE); + gen_vertex_arrays(ctx, n, arrays); } @@ -523,7 +529,7 @@ void GLAPIENTRY _mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *arrays) { GET_CURRENT_CONTEXT(ctx); - gen_vertex_arrays(ctx, n, arrays, GL_FALSE); + gen_vertex_arrays(ctx, n, arrays); } diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c index 1c1ee5dde..01e79455c 100644 --- a/mesalib/src/mesa/main/attrib.c +++ b/mesalib/src/mesa/main/attrib.c @@ -58,6 +58,8 @@ #include "viewport.h" #include "mtypes.h" #include "main/dispatch.h" +#include "hash.h" +#include <stdbool.h> /** @@ -1320,7 +1322,7 @@ copy_array_object(struct gl_context *ctx, /* skip RefCount */ /* In theory must be the same anyway, but on recreate make sure it matches */ - dest->VBOonly = src->VBOonly; + dest->ARBsemantics = src->ARBsemantics; for (i = 0; i < Elements(src->VertexAttrib); i++) _mesa_copy_client_array(ctx, &dest->VertexAttrib[i], &src->VertexAttrib[i]); @@ -1337,7 +1339,8 @@ copy_array_object(struct gl_context *ctx, static void copy_array_attrib(struct gl_context *ctx, struct gl_array_attrib *dest, - struct gl_array_attrib *src) + struct gl_array_attrib *src, + bool vbo_deleted) { /* skip ArrayObj */ /* skip DefaultArrayObj, Objects */ @@ -1349,7 +1352,8 @@ copy_array_attrib(struct gl_context *ctx, /* skip NewState */ /* skip RebindArrays */ - copy_array_object(ctx, dest->ArrayObj, src->ArrayObj); + if (!vbo_deleted) + copy_array_object(ctx, dest->ArrayObj, src->ArrayObj); /* skip ArrayBufferObj */ /* skip ElementArrayBufferObj */ @@ -1367,7 +1371,7 @@ save_array_attrib(struct gl_context *ctx, * Needs to match value in the object hash. */ dest->ArrayObj->Name = src->ArrayObj->Name; /* And copy all of the rest. */ - copy_array_attrib(ctx, dest, src); + copy_array_attrib(ctx, dest, src, false); /* Just reference them here */ _mesa_reference_buffer_object(ctx, &dest->ArrayBufferObj, @@ -1384,17 +1388,44 @@ restore_array_attrib(struct gl_context *ctx, struct gl_array_attrib *dest, struct gl_array_attrib *src) { - /* Restore or recreate the array object by its name ... */ - _mesa_BindVertexArrayAPPLE(src->ArrayObj->Name); + /* The ARB_vertex_array_object spec says: + * + * "BindVertexArray fails and an INVALID_OPERATION error is generated + * if array is not a name returned from a previous call to + * GenVertexArrays, or if such a name has since been deleted with + * DeleteVertexArrays." + * + * Therefore popping a deleted VAO cannot magically recreate it. + * + * The semantics of objects created using APPLE_vertex_array_objects behave + * differently. These objects expect to be recreated by pop. Alas. + */ + const bool arb_vao = (src->ArrayObj->Name != 0 + && src->ArrayObj->ARBsemantics); + + if (arb_vao && !_mesa_IsVertexArrayAPPLE(src->ArrayObj->Name)) + return; - /* ... and restore its content */ - copy_array_attrib(ctx, dest, src); + _mesa_BindVertexArrayAPPLE(src->ArrayObj->Name); /* Restore or recreate the buffer objects by the names ... */ - _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, - src->ArrayBufferObj->Name); - _mesa_BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, - src->ArrayObj->ElementArrayBufferObj->Name); + if (!arb_vao + || src->ArrayBufferObj->Name == 0 + || _mesa_IsBufferARB(src->ArrayBufferObj->Name)) { + /* ... and restore its content */ + copy_array_attrib(ctx, dest, src, false); + + _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, + src->ArrayBufferObj->Name); + } else { + copy_array_attrib(ctx, dest, src, true); + } + + if (!arb_vao + || src->ArrayObj->ElementArrayBufferObj->Name == 0 + || _mesa_IsBufferARB(src->ArrayObj->ElementArrayBufferObj->Name)) + _mesa_BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, + src->ArrayObj->ElementArrayBufferObj->Name); /* Better safe than sorry?! */ dest->RebindArrays = GL_TRUE; diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h index 8393f328f..96311131a 100644 --- a/mesalib/src/mesa/main/dd.h +++ b/mesalib/src/mesa/main/dd.h @@ -398,18 +398,16 @@ struct dd_function_table { GLenum format, GLsizei imageSize, const GLvoid *data); - /** * Called by glGetCompressedTexImage. */ void (*GetCompressedTexImage)(struct gl_context *ctx, struct gl_texture_image *texImage, GLvoid *data); - /*@}*/ /** - * \name Texture object functions + * \name Texture object / image functions */ /*@{*/ @@ -420,24 +418,20 @@ struct dd_function_table { struct gl_texture_object *tObj ); /** - * Called to allocate a new texture object. - * A new gl_texture_object should be returned. The driver should - * attach to it any device-specific info it needs. + * Called to allocate a new texture object. Drivers will usually + * allocate/return a subclass of gl_texture_object. */ - struct gl_texture_object * (*NewTextureObject)( struct gl_context *ctx, GLuint name, - GLenum target ); + struct gl_texture_object * (*NewTextureObject)(struct gl_context *ctx, + GLuint name, GLenum target); /** - * Called when a texture object is about to be deallocated. - * - * Driver should delete the gl_texture_object object and anything - * hanging off of it. + * Called to delete/free a texture object. Drivers should free the + * object and any image data it contains. */ - void (*DeleteTexture)( struct gl_context *ctx, struct gl_texture_object *tObj ); + void (*DeleteTexture)(struct gl_context *ctx, + struct gl_texture_object *texObj); - /** - * Called to allocate a new texture image object. - */ - struct gl_texture_image * (*NewTextureImage)( struct gl_context *ctx ); + /** Called to allocate a new texture image object. */ + struct gl_texture_image * (*NewTextureImage)(struct gl_context *ctx); /** Called to free a texture image object returned by NewTextureImage() */ void (*DeleteTextureImage)(struct gl_context *ctx, @@ -449,10 +443,9 @@ struct dd_function_table { gl_format format, GLsizei width, GLsizei height, GLsizei depth); - /** - * Called to free tImage->Data. - */ - void (*FreeTextureImageBuffer)( struct gl_context *ctx, struct gl_texture_image *tImage ); + /** Free the memory for a single texture image */ + void (*FreeTextureImageBuffer)(struct gl_context *ctx, + struct gl_texture_image *texImage); /** Map a slice of a texture image into user space. * Note: for GL_TEXTURE_1D_ARRAY, height must be 1, y must be 0 and slice @@ -476,11 +469,6 @@ struct dd_function_table { struct gl_texture_image *texImage, GLuint slice); - /** Map texture image data into user space */ - void (*MapTexture)( struct gl_context *ctx, struct gl_texture_object *tObj ); - /** Unmap texture images from user space */ - void (*UnmapTexture)( struct gl_context *ctx, struct gl_texture_object *tObj ); - /** For GL_ARB_texture_storage. Allocate memory for whole mipmap stack. * All the gl_texture_images in the texture object will have their * dimensions, format, etc. initialized already. diff --git a/mesalib/src/mesa/main/image.c b/mesalib/src/mesa/main/image.c index b37cd7e7d..8b65cf0f0 100644 --- a/mesalib/src/mesa/main/image.c +++ b/mesalib/src/mesa/main/image.c @@ -759,36 +759,48 @@ _mesa_is_color_format(GLenum format) /* sized integer formats */ case GL_RGBA32UI_EXT: case GL_RGB32UI_EXT: + case GL_RG32UI: + case GL_R32UI: case GL_ALPHA32UI_EXT: case GL_INTENSITY32UI_EXT: case GL_LUMINANCE32UI_EXT: case GL_LUMINANCE_ALPHA32UI_EXT: case GL_RGBA16UI_EXT: case GL_RGB16UI_EXT: + case GL_RG16UI: + case GL_R16UI: case GL_ALPHA16UI_EXT: case GL_INTENSITY16UI_EXT: case GL_LUMINANCE16UI_EXT: case GL_LUMINANCE_ALPHA16UI_EXT: case GL_RGBA8UI_EXT: case GL_RGB8UI_EXT: + case GL_RG8UI: + case GL_R8UI: case GL_ALPHA8UI_EXT: case GL_INTENSITY8UI_EXT: case GL_LUMINANCE8UI_EXT: case GL_LUMINANCE_ALPHA8UI_EXT: case GL_RGBA32I_EXT: case GL_RGB32I_EXT: + case GL_RG32I: + case GL_R32I: case GL_ALPHA32I_EXT: case GL_INTENSITY32I_EXT: case GL_LUMINANCE32I_EXT: case GL_LUMINANCE_ALPHA32I_EXT: case GL_RGBA16I_EXT: case GL_RGB16I_EXT: + case GL_RG16I: + case GL_R16I: case GL_ALPHA16I_EXT: case GL_INTENSITY16I_EXT: case GL_LUMINANCE16I_EXT: case GL_LUMINANCE_ALPHA16I_EXT: case GL_RGBA8I_EXT: case GL_RGB8I_EXT: + case GL_RG8I: + case GL_R8I: case GL_ALPHA8I_EXT: case GL_INTENSITY8I_EXT: case GL_LUMINANCE8I_EXT: diff --git a/mesalib/src/mesa/main/imports.c b/mesalib/src/mesa/main/imports.c index bbc6ac6e2..82713a13b 100644 --- a/mesalib/src/mesa/main/imports.c +++ b/mesalib/src/mesa/main/imports.c @@ -764,7 +764,7 @@ float _mesa_strtof( const char *s, char **end ) { #if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \ - !defined(ANDROID) + !defined(ANDROID) && !defined(__HAIKU__) static locale_t loc = NULL; if (!loc) { loc = newlocale(LC_CTYPE_MASK, "C", NULL); diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index 2ff608596..760113172 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -1614,7 +1614,22 @@ struct gl_array_object GLint RefCount; _glthread_Mutex Mutex; - GLboolean VBOonly; /**< require all arrays to live in VBOs? */ + + /** + * Does the VAO use ARB semantics or Apple semantics? + * + * There are several ways in which ARB_vertex_array_object and + * APPLE_vertex_array_object VAOs have differing semantics. At the very + * least, + * + * - ARB VAOs require that all array data be sourced from vertex buffer + * objects, but Apple VAOs do not. + * + * - ARB VAOs require that names come from GenVertexArrays. + * + * This flag notes which behavior governs this VAO. + */ + GLboolean ARBsemantics; /** Vertex attribute arrays */ struct gl_client_array VertexAttrib[VERT_ATTRIB_MAX]; @@ -2515,85 +2530,34 @@ struct gl_shared_state - /** - * A renderbuffer stores colors or depth values or stencil values. - * A framebuffer object will have a collection of these. - * Data are read/written to the buffer with a handful of Get/Put functions. - * - * Instances of this object are allocated with the Driver's NewRenderbuffer - * hook. Drivers will likely wrap this class inside a driver-specific - * class to simulate inheritance. + * Renderbuffers represent drawing surfaces such as color, depth and/or + * stencil. A framebuffer object has a set of renderbuffers. + * Drivers will typically derive subclasses of this type. */ struct gl_renderbuffer { - _glthread_Mutex Mutex; /**< for thread safety */ + _glthread_Mutex Mutex; /**< for thread safety */ GLuint ClassID; /**< Useful for drivers */ GLuint Name; GLint RefCount; GLuint Width, Height; - GLint RowStride; /**< Padded width in units of pixels */ - GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ - + GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ GLboolean AttachedAnytime; /**< TRUE if it was attached to a framebuffer */ - GLubyte NumSamples; - GLenum InternalFormat; /**< The user-specified format */ GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or GL_STENCIL_INDEX. */ gl_format Format; /**< The actual renderbuffer memory format */ - GLenum DataType; /**< Type of values passed to the Get/Put functions */ - GLvoid *Data; /**< This may not be used by some kinds of RBs */ - - /* Used to wrap one renderbuffer around another: */ - struct gl_renderbuffer *Wrapped; - - /* Delete this renderbuffer */ + /** Delete this renderbuffer */ void (*Delete)(struct gl_renderbuffer *rb); - /* Allocate new storage for this renderbuffer */ - GLboolean (*AllocStorage)(struct gl_context *ctx, struct gl_renderbuffer *rb, + /** Allocate new storage for this renderbuffer */ + GLboolean (*AllocStorage)(struct gl_context *ctx, + struct gl_renderbuffer *rb, GLenum internalFormat, GLuint width, GLuint height); - - /* Lock/Unlock are called before/after calling the Get/Put functions. - * Not sure this is the right place for these yet. - void (*Lock)(struct gl_context *ctx, struct gl_renderbuffer *rb); - void (*Unlock)(struct gl_context *ctx, struct gl_renderbuffer *rb); - */ - - /* Return a pointer to the element/pixel at (x,y). - * Should return NULL if the buffer memory can't be directly addressed. - */ - void *(*GetPointer)(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLint x, GLint y); - - /* Get/Read a row of values. - * The values will be of format _BaseFormat and type DataType. - */ - void (*GetRow)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values); - - /* Get/Read values at arbitrary locations. - * The values will be of format _BaseFormat and type DataType. - */ - void (*GetValues)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values); - - /* Put/Write a row of values. - * The values will be of format _BaseFormat and type DataType. - */ - void (*PutRow)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask); - - /* Put/Write values at arbitrary locations. - * The values will be of format _BaseFormat and type DataType. - */ - void (*PutValues)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask); }; diff --git a/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c index 8f2c8fd97..f874ab21a 100644 --- a/mesalib/src/mesa/main/pack.c +++ b/mesalib/src/mesa/main/pack.c @@ -448,65 +448,75 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max) } } -/* - * integer packing , no transfer operations only packs - * to dst of GL_UNSIGNED_INT or GL_INT +/* Customization of integer packing. We always treat src as uint, and can pack dst + * as any integer type/format combo. */ +#define SRC_TYPE GLuint + +#define DST_TYPE GLuint +#define SRC_CONVERT(x) (x) +#define FN_NAME pack_uint_from_uint_rgba +#include "pack_tmp.h" +#undef DST_TYPE +#undef SRC_CONVERT +#undef FN_NAME + +#define DST_TYPE GLushort +#define SRC_CONVERT(x) (x) +#define FN_NAME pack_ushort_from_uint_rgba +#include "pack_tmp.h" +#undef DST_TYPE +#undef SRC_CONVERT +#undef FN_NAME + +#define DST_TYPE GLshort +#define SRC_CONVERT(x) (x) +#define FN_NAME pack_short_from_uint_rgba +#include "pack_tmp.h" +#undef DST_TYPE +#undef SRC_CONVERT +#undef FN_NAME + +#define DST_TYPE GLubyte +#define SRC_CONVERT(x) (x) +#define FN_NAME pack_ubyte_from_uint_rgba +#include "pack_tmp.h" +#undef DST_TYPE +#undef SRC_CONVERT +#undef FN_NAME + +#define DST_TYPE GLbyte +#define SRC_CONVERT(x) (x) +#define FN_NAME pack_byte_from_uint_rgba +#include "pack_tmp.h" +#undef DST_TYPE +#undef SRC_CONVERT +#undef FN_NAME + void _mesa_pack_rgba_span_int(struct gl_context *ctx, GLuint n, GLuint rgba[][4], GLenum dstFormat, GLenum dstType, GLvoid *dstAddr) { - int i; - switch(dstType) { - case GL_UNSIGNED_INT: { - GLuint *dst = (GLuint *) dstAddr; - switch (dstFormat) { - case GL_RED_INTEGER_EXT: - case GL_GREEN_INTEGER_EXT: - case GL_BLUE_INTEGER_EXT: - case GL_ALPHA_INTEGER_EXT: - case GL_RG_INTEGER: - case GL_RGB_INTEGER_EXT: - case GL_RGBA_INTEGER_EXT: - case GL_BGR_INTEGER_EXT: - case GL_BGRA_INTEGER_EXT: - case GL_LUMINANCE_INTEGER_EXT: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - for (i=0;i<n;i++) { - dst[i*4+0] = (GLuint) rgba[i][RCOMP]; - dst[i*4+1] = (GLuint) rgba[i][GCOMP]; - dst[i*4+2] = (GLuint) rgba[i][BCOMP]; - dst[i*4+3] = (GLuint) rgba[i][ACOMP]; - } - break; - } - } + case GL_UNSIGNED_INT: + pack_uint_from_uint_rgba(dstAddr, dstFormat, rgba, n); break; - case GL_INT: { - GLint *dst = (GLint *) dstAddr; - switch (dstFormat) { - case GL_RED_INTEGER_EXT: - case GL_GREEN_INTEGER_EXT: - case GL_BLUE_INTEGER_EXT: - case GL_ALPHA_INTEGER_EXT: - case GL_RG_INTEGER: - case GL_RGB_INTEGER_EXT: - case GL_RGBA_INTEGER_EXT: - case GL_BGR_INTEGER_EXT: - case GL_BGRA_INTEGER_EXT: - case GL_LUMINANCE_INTEGER_EXT: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - for (i=0;i<n;i++) { - dst[i*4+0] = (GLint) rgba[i][RCOMP]; - dst[i*4+1] = (GLint) rgba[i][GCOMP]; - dst[i*4+2] = (GLint) rgba[i][BCOMP]; - dst[i*4+3] = (GLint) rgba[i][ACOMP]; - } - break; - } - } + case GL_INT: + /* No conversion necessary. */ + pack_uint_from_uint_rgba(dstAddr, dstFormat, rgba, n); + break; + case GL_UNSIGNED_SHORT: + pack_ushort_from_uint_rgba(dstAddr, dstFormat, rgba, n); + break; + case GL_SHORT: + pack_short_from_uint_rgba(dstAddr, dstFormat, rgba, n); + break; + case GL_UNSIGNED_BYTE: + pack_ubyte_from_uint_rgba(dstAddr, dstFormat, rgba, n); + break; + case GL_BYTE: + pack_byte_from_uint_rgba(dstAddr, dstFormat, rgba, n); break; default: assert(0); diff --git a/mesalib/src/mesa/main/pack_tmp.h b/mesalib/src/mesa/main/pack_tmp.h new file mode 100644 index 000000000..83b655729 --- /dev/null +++ b/mesalib/src/mesa/main/pack_tmp.h @@ -0,0 +1,115 @@ +/* + * Copyright © 2012 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +static void +FN_NAME(DST_TYPE *dst, + GLenum dstFormat, + SRC_TYPE rgba[][4], + int n) +{ + int i; + + switch (dstFormat) { + case GL_RED_INTEGER_EXT: + for (i=0;i<n;i++) { + dst[i] = SRC_CONVERT(rgba[i][RCOMP]); + } + break; + + case GL_GREEN_INTEGER_EXT: + for (i=0;i<n;i++) { + dst[i] = SRC_CONVERT(rgba[i][GCOMP]); + } + break; + + case GL_BLUE_INTEGER_EXT: + for (i=0;i<n;i++) { + dst[i] = SRC_CONVERT(rgba[i][BCOMP]); + }; + break; + + case GL_ALPHA_INTEGER_EXT: + for (i=0;i<n;i++) { + dst[i] = SRC_CONVERT(rgba[i][ACOMP]); + } + break; + + case GL_RG_INTEGER: + for (i=0;i<n;i++) { + dst[i*2+0] = SRC_CONVERT(rgba[i][RCOMP]); + dst[i*2+1] = SRC_CONVERT(rgba[i][GCOMP]); + } + break; + + case GL_RGB_INTEGER_EXT: + for (i=0;i<n;i++) { + dst[i*3+0] = SRC_CONVERT(rgba[i][RCOMP]); + dst[i*3+1] = SRC_CONVERT(rgba[i][GCOMP]); + dst[i*3+2] = SRC_CONVERT(rgba[i][BCOMP]); + } + break; + + case GL_RGBA_INTEGER_EXT: + for (i=0;i<n;i++) { + dst[i*4+0] = SRC_CONVERT(rgba[i][RCOMP]); + dst[i*4+1] = SRC_CONVERT(rgba[i][GCOMP]); + dst[i*4+2] = SRC_CONVERT(rgba[i][BCOMP]); + dst[i*4+3] = SRC_CONVERT(rgba[i][ACOMP]); + } + break; + + case GL_BGR_INTEGER_EXT: + for (i=0;i<n;i++) { + dst[i*3+0] = SRC_CONVERT(rgba[i][BCOMP]); + dst[i*3+1] = SRC_CONVERT(rgba[i][GCOMP]); + dst[i*3+2] = SRC_CONVERT(rgba[i][RCOMP]); + } + break; + + case GL_BGRA_INTEGER_EXT: + for (i=0;i<n;i++) { + dst[i*4+0] = SRC_CONVERT(rgba[i][BCOMP]); + dst[i*4+1] = SRC_CONVERT(rgba[i][GCOMP]); + dst[i*4+2] = SRC_CONVERT(rgba[i][RCOMP]); + dst[i*4+3] = SRC_CONVERT(rgba[i][ACOMP]); + } + break; + + case GL_LUMINANCE_INTEGER_EXT: + for (i=0;i<n;i++) { + dst[i] = SRC_CONVERT(rgba[i][RCOMP] + + rgba[i][GCOMP] + + rgba[i][BCOMP]); + } + break; + + case GL_LUMINANCE_ALPHA_INTEGER_EXT: + for (i=0;i<n;i++) { + dst[i*2+0] = SRC_CONVERT(rgba[i][RCOMP] + + rgba[i][GCOMP] + + rgba[i][BCOMP]); + dst[i*2+1] = SRC_CONVERT(rgba[i][ACOMP]); + } + break; + } +} diff --git a/mesalib/src/mesa/main/renderbuffer.c b/mesalib/src/mesa/main/renderbuffer.c index 08e694673..1bb09bfe6 100644 --- a/mesalib/src/mesa/main/renderbuffer.c +++ b/mesalib/src/mesa/main/renderbuffer.c @@ -33,17 +33,6 @@ /** - * Default GetPointer routine. Always return NULL to indicate that - * direct buffer access is not supported. - */ -static void * -nop_get_pointer(struct gl_context *ctx, struct gl_renderbuffer *rb, GLint x, GLint y) -{ - return NULL; -} - - -/** * Initialize the fields of a gl_renderbuffer to default values. */ void @@ -65,20 +54,6 @@ _mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name) rb->Height = 0; rb->InternalFormat = GL_RGBA; rb->Format = MESA_FORMAT_NONE; - - rb->DataType = GL_NONE; - rb->Data = NULL; - - /* Point back to ourself so that we don't have to check for Wrapped==NULL - * all over the drivers. - */ - rb->Wrapped = rb; - - rb->GetPointer = nop_get_pointer; - rb->GetRow = NULL; - rb->GetValues = NULL; - rb->PutRow = NULL; - rb->PutValues = NULL; } @@ -104,10 +79,7 @@ _mesa_new_renderbuffer(struct gl_context *ctx, GLuint name) void _mesa_delete_renderbuffer(struct gl_renderbuffer *rb) { - if (rb->Data) { - free(rb->Data); - } - free(rb); + /* no-op */ } diff --git a/mesalib/src/mesa/main/state.c b/mesalib/src/mesa/main/state.c index 39d7294f7..20fd17d06 100644 --- a/mesalib/src/mesa/main/state.c +++ b/mesalib/src/mesa/main/state.c @@ -136,6 +136,8 @@ update_program(struct gl_context *ctx) _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, (struct gl_fragment_program *) fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program); + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, + NULL); } else if (ctx->FragmentProgram._Enabled) { /* Use user-defined fragment program */ @@ -144,6 +146,8 @@ update_program(struct gl_context *ctx) NULL); _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, ctx->FragmentProgram.Current); + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, + NULL); } else if (ctx->FragmentProgram._MaintainTexEnvProgram) { /* Use fragment program generated from fixed-function state */ @@ -155,10 +159,15 @@ update_program(struct gl_context *ctx) _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, (struct gl_fragment_program *) f->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program); + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, + (struct gl_fragment_program *) + f->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program); } else { /* No fragment program */ _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL); + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, + NULL); } if (gsProg && gsProg->LinkStatus diff --git a/mesalib/src/mesa/main/texcompress.c b/mesalib/src/mesa/main/texcompress.c index 5045aef06..44590ea96 100644 --- a/mesalib/src/mesa/main/texcompress.c +++ b/mesalib/src/mesa/main/texcompress.c @@ -478,7 +478,7 @@ _mesa_decompress_image(gl_format format, GLuint width, GLuint height, /* setup dummy texture image info */ memset(&texImage, 0, sizeof(texImage)); - texImage.Data = (void *) src; + texImage.Map = (void *) src; texImage.RowStride = srcRowStride; switch (format) { diff --git a/mesalib/src/mesa/main/texcompress_etc.c b/mesalib/src/mesa/main/texcompress_etc.c index 4d3b857cf..5b331a92a 100644 --- a/mesalib/src/mesa/main/texcompress_etc.c +++ b/mesalib/src/mesa/main/texcompress_etc.c @@ -58,7 +58,7 @@ _mesa_fetch_texel_2d_f_etc1_rgb8(const struct swrast_texture_image *texImage, GLubyte dst[3]; const GLubyte *src; - src = (const GLubyte *) texImage->Data + + src = (const GLubyte *) texImage->Map + (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 8; etc1_parse_block(&block, src); diff --git a/mesalib/src/mesa/main/texcompress_fxt1.c b/mesalib/src/mesa/main/texcompress_fxt1.c index 2480ffb38..eafa18794 100644 --- a/mesalib/src/mesa/main/texcompress_fxt1.c +++ b/mesalib/src/mesa/main/texcompress_fxt1.c @@ -163,7 +163,7 @@ _mesa_fetch_texel_2d_f_rgba_fxt1( const struct swrast_texture_image *texImage, /* just sample as GLubyte and convert to float here */ GLubyte rgba[4]; (void) k; - fxt1_decode_1(texImage->Data, texImage->RowStride, i, j, rgba); + fxt1_decode_1(texImage->Map, texImage->RowStride, i, j, rgba); texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]); texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]); texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]); @@ -178,7 +178,7 @@ _mesa_fetch_texel_2d_f_rgb_fxt1( const struct swrast_texture_image *texImage, /* just sample as GLubyte and convert to float here */ GLubyte rgba[4]; (void) k; - fxt1_decode_1(texImage->Data, texImage->RowStride, i, j, rgba); + fxt1_decode_1(texImage->Map, texImage->RowStride, i, j, rgba); texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]); texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]); texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]); diff --git a/mesalib/src/mesa/main/texcompress_rgtc.c b/mesalib/src/mesa/main/texcompress_rgtc.c index b8e334b45..f707a0994 100644 --- a/mesalib/src/mesa/main/texcompress_rgtc.c +++ b/mesalib/src/mesa/main/texcompress_rgtc.c @@ -296,7 +296,7 @@ _mesa_fetch_texel_2d_f_red_rgtc1(const struct swrast_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel) { GLubyte red; - unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Data, + unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Map, i, j, &red, 1); texel[RCOMP] = UBYTE_TO_FLOAT(red); texel[GCOMP] = 0.0; @@ -309,7 +309,7 @@ _mesa_fetch_texel_2d_f_signed_red_rgtc1(const struct swrast_texture_image *texIm GLint i, GLint j, GLint k, GLfloat *texel) { GLbyte red; - signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Data), + signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Map), i, j, &red, 1); texel[RCOMP] = BYTE_TO_FLOAT_TEX(red); texel[GCOMP] = 0.0; @@ -322,9 +322,9 @@ _mesa_fetch_texel_2d_f_rg_rgtc2(const struct swrast_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel) { GLubyte red, green; - unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Data, + unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Map, i, j, &red, 2); - unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Data + 8, + unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Map + 8, i, j, &green, 2); texel[RCOMP] = UBYTE_TO_FLOAT(red); texel[GCOMP] = UBYTE_TO_FLOAT(green); @@ -337,9 +337,9 @@ _mesa_fetch_texel_2d_f_signed_rg_rgtc2(const struct swrast_texture_image *texIma GLint i, GLint j, GLint k, GLfloat *texel) { GLbyte red, green; - signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Data), + signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Map), i, j, &red, 2); - signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Data) + 8, + signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Map) + 8, i, j, &green, 2); texel[RCOMP] = BYTE_TO_FLOAT_TEX(red); texel[GCOMP] = BYTE_TO_FLOAT_TEX(green); @@ -352,7 +352,7 @@ _mesa_fetch_texel_2d_f_l_latc1(const struct swrast_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel) { GLubyte red; - unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Data, + unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Map, i, j, &red, 1); texel[RCOMP] = texel[GCOMP] = @@ -365,7 +365,7 @@ _mesa_fetch_texel_2d_f_signed_l_latc1(const struct swrast_texture_image *texImag GLint i, GLint j, GLint k, GLfloat *texel) { GLbyte red; - signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Data), + signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Map), i, j, &red, 1); texel[RCOMP] = texel[GCOMP] = @@ -378,9 +378,9 @@ _mesa_fetch_texel_2d_f_la_latc2(const struct swrast_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel) { GLubyte red, green; - unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Data, + unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Map, i, j, &red, 2); - unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Data + 8, + unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Map + 8, i, j, &green, 2); texel[RCOMP] = texel[GCOMP] = @@ -393,9 +393,9 @@ _mesa_fetch_texel_2d_f_signed_la_latc2(const struct swrast_texture_image *texIma GLint i, GLint j, GLint k, GLfloat *texel) { GLbyte red, green; - signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Data), + signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Map), i, j, &red, 2); - signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Data) + 8, + signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Map) + 8, i, j, &green, 2); texel[RCOMP] = texel[GCOMP] = diff --git a/mesalib/src/mesa/main/texcompress_s3tc.c b/mesalib/src/mesa/main/texcompress_s3tc.c index 995e079fd..e30890c8b 100644 --- a/mesalib/src/mesa/main/texcompress_s3tc.c +++ b/mesalib/src/mesa/main/texcompress_s3tc.c @@ -374,7 +374,7 @@ fetch_texel_2d_rgb_dxt1( const struct swrast_texture_image *texImage, (void) k; if (fetch_ext_rgb_dxt1) { fetch_ext_rgb_dxt1(texImage->RowStride, - texImage->Data, i, j, texel); + texImage->Map, i, j, texel); } else _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgb_dxt1"); @@ -402,7 +402,7 @@ fetch_texel_2d_rgba_dxt1( const struct swrast_texture_image *texImage, (void) k; if (fetch_ext_rgba_dxt1) { fetch_ext_rgba_dxt1(texImage->RowStride, - texImage->Data, i, j, texel); + texImage->Map, i, j, texel); } else _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt1\n"); @@ -430,7 +430,7 @@ fetch_texel_2d_rgba_dxt3( const struct swrast_texture_image *texImage, (void) k; if (fetch_ext_rgba_dxt3) { fetch_ext_rgba_dxt3(texImage->RowStride, - texImage->Data, i, j, texel); + texImage->Map, i, j, texel); } else _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt3\n"); @@ -458,7 +458,7 @@ fetch_texel_2d_rgba_dxt5( const struct swrast_texture_image *texImage, (void) k; if (fetch_ext_rgba_dxt5) { fetch_ext_rgba_dxt5(texImage->RowStride, - texImage->Data, i, j, texel); + texImage->Map, i, j, texel); } else _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt5\n"); diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c index 8c85c1e54..818deb8e4 100644 --- a/mesalib/src/mesa/main/texgetimage.c +++ b/mesalib/src/mesa/main/texgetimage.c @@ -312,18 +312,26 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions, const gl_format texFormat = _mesa_get_srgb_format_linear(texImage->TexFormat); const GLuint width = texImage->Width; - const GLuint height = texImage->Height; - const GLuint depth = texImage->Depth; + GLuint height = texImage->Height; + GLuint depth = texImage->Depth; GLuint img, row; GLfloat (*rgba)[4]; + GLuint (*rgba_uint)[4]; + GLboolean is_integer = _mesa_is_format_integer_color(texImage->TexFormat); /* Allocate buffer for one row of texels */ rgba = (GLfloat (*)[4]) malloc(4 * width * sizeof(GLfloat)); + rgba_uint = (GLuint (*)[4]) rgba; if (!rgba) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage()"); return; } + if (texImage->TexObject->Target == GL_TEXTURE_1D_ARRAY) { + depth = height; + height = 1; + } + for (img = 0; img < depth; img++) { GLubyte *srcMap; GLint rowstride; @@ -339,44 +347,83 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions, width, height, format, type, img, row, 0); - _mesa_unpack_rgba_row(texFormat, width, src, rgba); - - if (texImage->_BaseFormat == GL_ALPHA) { - GLint col; - for (col = 0; col < width; col++) { - rgba[col][RCOMP] = 0.0F; - rgba[col][GCOMP] = 0.0F; - rgba[col][BCOMP] = 0.0F; - } - } - else if (texImage->_BaseFormat == GL_LUMINANCE) { - GLint col; - for (col = 0; col < width; col++) { - rgba[col][GCOMP] = 0.0F; - rgba[col][BCOMP] = 0.0F; - rgba[col][ACOMP] = 1.0F; - } - } - else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) { - GLint col; - for (col = 0; col < width; col++) { - rgba[col][GCOMP] = 0.0F; - rgba[col][BCOMP] = 0.0F; - } - } - else if (texImage->_BaseFormat == GL_INTENSITY) { - GLint col; - for (col = 0; col < width; col++) { - rgba[col][GCOMP] = 0.0F; - rgba[col][BCOMP] = 0.0F; - rgba[col][ACOMP] = 1.0F; - } - } - - _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, - format, type, dest, - &ctx->Pack, transferOps); - } + if (is_integer) { + _mesa_unpack_uint_rgba_row(texFormat, width, src, rgba_uint); + + if (texImage->_BaseFormat == GL_ALPHA) { + GLuint col; + for (col = 0; col < width; col++) { + rgba_uint[col][RCOMP] = 0; + rgba_uint[col][GCOMP] = 0; + rgba_uint[col][BCOMP] = 0; + } + } + else if (texImage->_BaseFormat == GL_LUMINANCE) { + GLuint col; + for (col = 0; col < width; col++) { + rgba_uint[col][GCOMP] = 0; + rgba_uint[col][BCOMP] = 0; + rgba_uint[col][ACOMP] = 1; + } + } + else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) { + GLuint col; + for (col = 0; col < width; col++) { + rgba_uint[col][GCOMP] = 0; + rgba_uint[col][BCOMP] = 0; + } + } + else if (texImage->_BaseFormat == GL_INTENSITY) { + GLuint col; + for (col = 0; col < width; col++) { + rgba_uint[col][GCOMP] = 0; + rgba_uint[col][BCOMP] = 0; + rgba_uint[col][ACOMP] = 1; + } + } + + _mesa_pack_rgba_span_int(ctx, width, rgba_uint, + format, type, dest); + } else { + _mesa_unpack_rgba_row(texFormat, width, src, rgba); + + if (texImage->_BaseFormat == GL_ALPHA) { + GLuint col; + for (col = 0; col < width; col++) { + rgba[col][RCOMP] = 0.0F; + rgba[col][GCOMP] = 0.0F; + rgba[col][BCOMP] = 0.0F; + } + } + else if (texImage->_BaseFormat == GL_LUMINANCE) { + GLuint col; + for (col = 0; col < width; col++) { + rgba[col][GCOMP] = 0.0F; + rgba[col][BCOMP] = 0.0F; + rgba[col][ACOMP] = 1.0F; + } + } + else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) { + GLuint col; + for (col = 0; col < width; col++) { + rgba[col][GCOMP] = 0.0F; + rgba[col][BCOMP] = 0.0F; + } + } + else if (texImage->_BaseFormat == GL_INTENSITY) { + GLuint col; + for (col = 0; col < width; col++) { + rgba[col][GCOMP] = 0.0F; + rgba[col][BCOMP] = 0.0F; + rgba[col][ACOMP] = 1.0F; + } + } + + _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, + format, type, dest, + &ctx->Pack, transferOps); + } + } /* Unmap the src texture buffer */ ctx->Driver.UnmapTextureImage(ctx, texImage, img); diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c index 39732522c..c64b10b04 100644 --- a/mesalib/src/mesa/main/teximage.c +++ b/mesalib/src/mesa/main/teximage.c @@ -1938,6 +1938,24 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions, return GL_TRUE; } + /* From the EXT_texture_integer spec: + * + * "INVALID_OPERATION is generated by CopyTexImage* and CopyTexSubImage* + * if the texture internalformat is an integer format and the read color + * buffer is not an integer format, or if the internalformat is not an + * integer format and the read color buffer is an integer format." + */ + if (_mesa_is_color_format(internalFormat)) { + struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; + + if (_mesa_is_integer_format(rb->InternalFormat) != + _mesa_is_integer_format(internalFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexImage%dD(integer vs non-integer)", dimensions); + return GL_TRUE; + } + } + /* Do size, level checking */ sizeOK = (proxyTarget == GL_PROXY_TEXTURE_CUBE_MAP_ARB) ? (width == height) : 1; @@ -2153,16 +2171,21 @@ copytexsubimage_error_check2( struct gl_context *ctx, GLuint dimensions, return GL_TRUE; } - /* If copying into an integer texture, the source buffer must also be - * integer-valued. + /* From the EXT_texture_integer spec: + * + * "INVALID_OPERATION is generated by CopyTexImage* and CopyTexSubImage* + * if the texture internalformat is an integer format and the read color + * buffer is not an integer format, or if the internalformat is not an + * integer format and the read color buffer is an integer format." */ - if (_mesa_is_format_integer_color(teximage->TexFormat)) { + if (_mesa_is_color_format(teximage->InternalFormat)) { struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; - if (!_mesa_is_format_integer_color(rb->Format)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexSubImage%dD(source buffer is not integer format)", - dimensions); - return GL_TRUE; + + if (_mesa_is_format_integer_color(rb->Format) != + _mesa_is_format_integer_color(teximage->TexFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexImage%dD(integer vs non-integer)", dimensions); + return GL_TRUE; } } diff --git a/mesalib/src/mesa/main/varray.c b/mesalib/src/mesa/main/varray.c index 9078d1161..77c1d7d9b 100644 --- a/mesalib/src/mesa/main/varray.c +++ b/mesalib/src/mesa/main/varray.c @@ -194,7 +194,7 @@ update_array(struct gl_context *ctx, return; } - if (ctx->Array.ArrayObj->VBOonly && + if (ctx->Array.ArrayObj->ARBsemantics && !_mesa_is_bufferobj(ctx->Array.ArrayBufferObj)) { /* GL_ARB_vertex_array_object requires that all arrays reside in VBOs. * Generate GL_INVALID_OPERATION if that's not true. diff --git a/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c b/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c index 76386fe01..a8907c157 100644 --- a/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c @@ -139,7 +139,6 @@ update_framebuffer_state( struct st_context *st ) */ strb = st_renderbuffer(fb->Attachment[BUFFER_DEPTH].Renderbuffer); if (strb) { - strb = st_renderbuffer(strb->Base.Wrapped); if (strb->rtt) { /* rendering to a GL texture, may have to update surface */ update_renderbuffer_surface(st, strb); @@ -149,7 +148,6 @@ update_framebuffer_state( struct st_context *st ) else { strb = st_renderbuffer(fb->Attachment[BUFFER_STENCIL].Renderbuffer); if (strb) { - strb = st_renderbuffer(strb->Base.Wrapped); assert(strb->surface); pipe_surface_reference(&framebuffer->zsbuf, strb->surface); } diff --git a/mesalib/src/mesa/state_tracker/st_cb_eglimage.c b/mesalib/src/mesa/state_tracker/st_cb_eglimage.c index 5209fc795..e91e9142d 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_eglimage.c +++ b/mesalib/src/mesa/state_tracker/st_cb_eglimage.c @@ -86,7 +86,6 @@ st_egl_image_target_renderbuffer_storage(struct gl_context *ctx, strb->Base.Width = ps->width; strb->Base.Height = ps->height; strb->Base.Format = st_pipe_format_to_mesa_format(ps->format); - strb->Base.DataType = st_format_datatype(ps->format); strb->Base._BaseFormat = st_pipe_format_to_base_format(ps->format); strb->Base.InternalFormat = strb->Base._BaseFormat; diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.c b/mesalib/src/mesa/state_tracker/st_cb_fbo.c index 911e321a5..fefd93a4b 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_fbo.c +++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.c @@ -97,7 +97,6 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx, strb->Base.Height = height; strb->Base.Format = st_pipe_format_to_mesa_format(format); strb->Base._BaseFormat = _mesa_base_fbo_format(ctx, internalFormat); - strb->Base.DataType = st_format_datatype(format); strb->format = format; strb->defined = GL_FALSE; /* undefined contents now */ @@ -186,23 +185,6 @@ st_renderbuffer_delete(struct gl_renderbuffer *rb) /** - * gl_renderbuffer::GetPointer() - */ -static void * -null_get_pointer(struct gl_context * ctx, struct gl_renderbuffer *rb, - GLint x, GLint y) -{ - /* By returning NULL we force all software rendering to go through - * the span routines. - */ -#if 0 - assert(0); /* Should never get called with softpipe */ -#endif - return NULL; -} - - -/** * Called via ctx->Driver.NewFramebuffer() */ static struct gl_framebuffer * @@ -224,7 +206,6 @@ st_new_renderbuffer(struct gl_context *ctx, GLuint name) _mesa_init_renderbuffer(&strb->Base, name); strb->Base.Delete = st_renderbuffer_delete; strb->Base.AllocStorage = st_renderbuffer_alloc_storage; - strb->Base.GetPointer = null_get_pointer; strb->format = PIPE_FORMAT_NONE; return &strb->Base; } @@ -252,7 +233,6 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw) strb->Base.NumSamples = samples; strb->Base.Format = st_pipe_format_to_mesa_format(format); strb->Base._BaseFormat = _mesa_get_format_base_format(strb->Base.Format); - strb->Base.DataType = st_format_datatype(format); strb->format = format; strb->software = sw; @@ -309,7 +289,6 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw) /* st-specific methods */ strb->Base.Delete = st_renderbuffer_delete; strb->Base.AllocStorage = st_renderbuffer_alloc_storage; - strb->Base.GetPointer = null_get_pointer; /* surface is allocated in st_renderbuffer_alloc_storage() */ strb->surface = NULL; @@ -425,7 +404,6 @@ st_render_texture(struct gl_context *ctx, strb->format = pt->format; strb->Base.Format = st_pipe_format_to_mesa_format(pt->format); - strb->Base.DataType = st_format_datatype(pt->format); /* printf("RENDER TO TEXTURE obj=%p pt=%p surf=%p %d x %d\n", diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c index 620910ddb..2fdbcd773 100644 --- a/mesalib/src/mesa/state_tracker/st_format.c +++ b/mesalib/src/mesa/state_tracker/st_format.c @@ -47,106 +47,6 @@ #include "st_format.h" -static GLuint -format_max_bits(enum pipe_format format) -{ - GLuint size = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0); - - size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 1)); - size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 2)); - size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 3)); - size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0)); - size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1)); - return size; -} - - -/** - * Return basic GL datatype for the given gallium format. - */ -GLenum -st_format_datatype(enum pipe_format format) -{ - const struct util_format_description *desc; - int i; - - desc = util_format_description(format); - assert(desc); - - /* Find the first non-VOID channel. */ - for (i = 0; i < 4; i++) { - if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID) { - break; - } - } - - if (desc->layout == UTIL_FORMAT_LAYOUT_PLAIN) { - if (format == PIPE_FORMAT_B5G5R5A1_UNORM || - format == PIPE_FORMAT_B5G6R5_UNORM) { - return GL_UNSIGNED_SHORT; - } - else if (format == PIPE_FORMAT_R11G11B10_FLOAT || - format == PIPE_FORMAT_R9G9B9E5_FLOAT) { - return GL_FLOAT; - } - else if (format == PIPE_FORMAT_Z24_UNORM_S8_UINT || - format == PIPE_FORMAT_S8_UINT_Z24_UNORM || - format == PIPE_FORMAT_Z24X8_UNORM || - format == PIPE_FORMAT_X8Z24_UNORM) { - return GL_UNSIGNED_INT_24_8; - } - else if (format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT) { - return GL_FLOAT_32_UNSIGNED_INT_24_8_REV; - } - else { - const GLuint size = format_max_bits(format); - - assert(i < 4); - if (i == 4) - return GL_NONE; - - if (size == 8) { - if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED) - return GL_UNSIGNED_BYTE; - else - return GL_BYTE; - } - else if (size == 16) { - if (desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT) - return GL_HALF_FLOAT; - if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED) - return GL_UNSIGNED_SHORT; - else - return GL_SHORT; - } - else if (size <= 32) { - if (desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT) - return GL_FLOAT; - if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED) - return GL_UNSIGNED_INT; - else - return GL_INT; - } - else { - assert(size == 64); - assert(desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT); - return GL_DOUBLE; - } - } - } - else if (format == PIPE_FORMAT_UYVY) { - return GL_UNSIGNED_SHORT; - } - else if (format == PIPE_FORMAT_YUYV) { - return GL_UNSIGNED_SHORT; - } - else { - /* probably a compressed format, unsupported anyway */ - return GL_NONE; - } -} - - /** * Translate Mesa format to Gallium format. */ diff --git a/mesalib/src/mesa/state_tracker/st_format.h b/mesalib/src/mesa/state_tracker/st_format.h index 10ffeaa73..1dea0d9a5 100644 --- a/mesalib/src/mesa/state_tracker/st_format.h +++ b/mesalib/src/mesa/state_tracker/st_format.h @@ -39,9 +39,6 @@ struct gl_context; struct pipe_screen; -extern GLenum -st_format_datatype(enum pipe_format format); - extern enum pipe_format st_mesa_format_to_pipe_format(gl_format mesaFormat); diff --git a/mesalib/src/mesa/swrast/s_blend.c b/mesalib/src/mesa/swrast/s_blend.c index be5010b13..cd6e6f036 100644 --- a/mesalib/src/mesa/swrast/s_blend.c +++ b/mesalib/src/mesa/swrast/s_blend.c @@ -1000,7 +1000,6 @@ _swrast_blend_span(struct gl_context *ctx, struct gl_renderbuffer *rb, SWspan *s ASSERT(span->end <= MAX_WIDTH); ASSERT(span->arrayMask & SPAN_RGBA); - ASSERT(rb->DataType == span->array->ChanType); ASSERT(!ctx->Color.ColorLogicOpEnabled); rbPixels = _swrast_get_dest_rgba(ctx, rb, span); diff --git a/mesalib/src/mesa/swrast/s_context.c b/mesalib/src/mesa/swrast/s_context.c index 06824ea2c..14cb9b180 100644 --- a/mesalib/src/mesa/swrast/s_context.c +++ b/mesalib/src/mesa/swrast/s_context.c @@ -752,9 +752,6 @@ _swrast_CreateContext( struct gl_context *ctx ) swrast->Driver.SpanRenderStart = _swrast_span_render_start; swrast->Driver.SpanRenderFinish = _swrast_span_render_finish; - ctx->Driver.MapTexture = _swrast_map_texture; - ctx->Driver.UnmapTexture = _swrast_unmap_texture; - for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++) swrast->TextureSample[i] = NULL; @@ -872,10 +869,11 @@ void _swrast_render_finish( struct gl_context *ctx ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - if (swrast->Driver.SpanRenderFinish) - swrast->Driver.SpanRenderFinish( ctx ); _swrast_flush(ctx); + + if (swrast->Driver.SpanRenderFinish) + swrast->Driver.SpanRenderFinish( ctx ); } diff --git a/mesalib/src/mesa/swrast/s_context.h b/mesalib/src/mesa/swrast/s_context.h index 0a383aa3b..ae239a9a8 100644 --- a/mesalib/src/mesa/swrast/s_context.h +++ b/mesalib/src/mesa/swrast/s_context.h @@ -120,14 +120,10 @@ typedef void (*FetchTexelFunc)(const struct swrast_texture_image *texImage, GLfloat *texelOut); -typedef void (*StoreTexelFunc)(struct swrast_texture_image *texImage, - GLint col, GLint row, GLint img, - const void *texel); - /** * Subclass of gl_texture_image. * We need extra fields/info to keep tracking of mapped texture buffers, - * strides and Fetch/Store functions. + * strides and Fetch functions. */ struct swrast_texture_image { @@ -142,13 +138,12 @@ struct swrast_texture_image GLint RowStride; /**< Padded width in units of texels */ GLuint *ImageOffsets; /**< if 3D texture: array [Depth] of offsets to each 2D slice in 'Data', in texels */ - GLubyte *Data; /**< Image data, accessed via FetchTexel() */ + GLubyte *Map; /**< Pointer to mapped image memory */ /** Malloc'd texture memory */ GLubyte *Buffer; FetchTexelFunc FetchTexel; - StoreTexelFunc Store; }; @@ -168,6 +163,31 @@ swrast_texture_image_const(const struct gl_texture_image *img) /** + * Subclass of gl_renderbuffer with extra fields needed for software + * rendering. + */ +struct swrast_renderbuffer +{ + struct gl_renderbuffer Base; + + GLubyte *Buffer; /**< The malloc'd memory for buffer */ + + /** These fields are only valid while buffer is mapped for rendering */ + GLubyte *Map; + GLint RowStride; /**< in bytes */ +}; + + +/** cast wrapper */ +static inline struct swrast_renderbuffer * +swrast_renderbuffer(struct gl_renderbuffer *img) +{ + return (struct swrast_renderbuffer *) img; +} + + + +/** * \struct SWcontext * \brief Per-context state that's private to the software rasterizer module. */ @@ -428,9 +448,18 @@ _swrast_unmap_renderbuffers(struct gl_context *ctx); static inline GLubyte * _swrast_pixel_address(struct gl_renderbuffer *rb, GLint x, GLint y) { + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); const GLint bpp = _mesa_get_format_bytes(rb->Format); - const GLint rowStride = rb->RowStride * bpp; - return (GLubyte *) rb->Data + y * rowStride + x * bpp; + const GLint rowStride = srb->RowStride; + assert(x >= 0); + assert(y >= 0); + /* NOTE: using <= only because of s_tritemp.h which gets a pixel + * address but doesn't necessarily access it. + */ + assert(x <= (GLint) rb->Width); + assert(y <= (GLint) rb->Height); + assert(srb->Map); + return (GLubyte *) srb->Map + y * rowStride + x * bpp; } diff --git a/mesalib/src/mesa/swrast/s_copypix.c b/mesalib/src/mesa/swrast/s_copypix.c index 1e0f9fe7d..592d35a98 100644 --- a/mesalib/src/mesa/swrast/s_copypix.c +++ b/mesalib/src/mesa/swrast/s_copypix.c @@ -148,7 +148,7 @@ copy_rgba_pixels(struct gl_context *ctx, GLint srcx, GLint srcy, p = tmpImage; for (row = 0; row < height; row++) { _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer, - width, srcx, sy + row, GL_FLOAT, p ); + width, srcx, sy + row, p ); p += width * 4; } p = tmpImage; @@ -172,7 +172,7 @@ copy_rgba_pixels(struct gl_context *ctx, GLint srcx, GLint srcy, else { /* get from framebuffer */ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer, - width, srcx, sy, GL_FLOAT, rgba ); + width, srcx, sy, rgba ); } if (transferOps) { @@ -558,6 +558,49 @@ swrast_fast_copy_pixels(struct gl_context *ctx, /** + * Find/map the renderbuffer that we'll be reading from. + * The swrast_render_start() function only maps the drawing buffers, + * not the read buffer. + */ +static struct gl_renderbuffer * +map_readbuffer(struct gl_context *ctx, GLenum type) +{ + struct gl_framebuffer *fb = ctx->ReadBuffer; + struct gl_renderbuffer *rb; + struct swrast_renderbuffer *srb; + + switch (type) { + case GL_COLOR: + rb = fb->Attachment[fb->_ColorReadBufferIndex].Renderbuffer; + break; + case GL_DEPTH: + case GL_DEPTH_STENCIL: + rb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; + break; + case GL_STENCIL: + rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; + break; + default: + return NULL; + } + + srb = swrast_renderbuffer(rb); + + if (!srb || srb->Map) { + /* no buffer, or buffer is mapped already, we're done */ + return NULL; + } + + ctx->Driver.MapRenderbuffer(ctx, rb, + 0, 0, rb->Width, rb->Height, + GL_MAP_READ_BIT, + &srb->Map, &srb->RowStride); + + return rb; +} + + +/** * Do software-based glCopyPixels. * By time we get here, all parameters will have been error-checked. */ @@ -567,6 +610,7 @@ _swrast_CopyPixels( struct gl_context *ctx, GLint destx, GLint desty, GLenum type ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); + struct gl_renderbuffer *rb; if (!_mesa_check_conditional_render(ctx)) return; /* don't copy */ @@ -585,6 +629,7 @@ _swrast_CopyPixels( struct gl_context *ctx, } swrast_render_start(ctx); + rb = map_readbuffer(ctx, type); switch (type) { case GL_COLOR: @@ -606,4 +651,10 @@ _swrast_CopyPixels( struct gl_context *ctx, } swrast_render_finish(ctx); + + if (rb) { + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); + ctx->Driver.UnmapRenderbuffer(ctx, rb); + srb->Map = NULL; + } } diff --git a/mesalib/src/mesa/swrast/s_depth.c b/mesalib/src/mesa/swrast/s_depth.c index 42724c72b..c90388209 100644 --- a/mesalib/src/mesa/swrast/s_depth.c +++ b/mesalib/src/mesa/swrast/s_depth.c @@ -212,12 +212,13 @@ get_z32_values(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, const GLint x[], const GLint y[], GLuint zbuffer[]) { + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); const GLint w = rb->Width, h = rb->Height; - const GLubyte *map = (const GLubyte *) rb->Data; + const GLubyte *map = _swrast_pixel_address(rb, 0, 0); GLuint i; if (rb->Format == MESA_FORMAT_Z32) { - const GLint rowStride = rb->RowStride * 4; + const GLint rowStride = srb->RowStride; for (i = 0; i < count; i++) { if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { zbuffer[i] = *((GLuint *) (map + y[i] * rowStride + x[i] * 4)); @@ -226,7 +227,7 @@ get_z32_values(struct gl_context *ctx, struct gl_renderbuffer *rb, } else { const GLint bpp = _mesa_get_format_bytes(rb->Format); - const GLint rowStride = rb->RowStride * bpp; + const GLint rowStride = srb->RowStride; for (i = 0; i < count; i++) { if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { const GLubyte *src = map + y[i] * rowStride+ x[i] * bpp; @@ -246,12 +247,13 @@ put_z32_values(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, const GLint x[], const GLint y[], const GLuint zvalues[], const GLubyte mask[]) { + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); const GLint w = rb->Width, h = rb->Height; - GLubyte *map = (GLubyte *) rb->Data; + GLubyte *map = _swrast_pixel_address(rb, 0, 0); GLuint i; if (rb->Format == MESA_FORMAT_Z32) { - const GLuint rowStride = rb->RowStride * 4; + const GLint rowStride = srb->RowStride; for (i = 0; i < count; i++) { if (mask[i] && x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { GLuint *dst = (GLuint *) (map + y[i] * rowStride + x[i] * 4); @@ -262,7 +264,7 @@ put_z32_values(struct gl_context *ctx, struct gl_renderbuffer *rb, else { gl_pack_uint_z_func packZ = _mesa_get_pack_uint_z_func(rb->Format); const GLint bpp = _mesa_get_format_bytes(rb->Format); - const GLint rowStride = rb->RowStride * bpp; + const GLint rowStride = srb->RowStride; for (i = 0; i < count; i++) { if (mask[i] && x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { void *dst = map + y[i] * rowStride + x[i] * bpp; @@ -283,7 +285,7 @@ _swrast_depth_test_span(struct gl_context *ctx, SWspan *span) struct gl_framebuffer *fb = ctx->DrawBuffer; struct gl_renderbuffer *rb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; const GLint bpp = _mesa_get_format_bytes(rb->Format); - void *zStart = _swrast_pixel_address(rb, span->x, span->y); + void *zStart; const GLuint count = span->end; const GLuint *fragZ = span->array->z; GLubyte *mask = span->array->mask; @@ -293,6 +295,11 @@ _swrast_depth_test_span(struct gl_context *ctx, SWspan *span) GLuint zBits = _mesa_get_format_bits(rb->Format, GL_DEPTH_BITS); GLboolean ztest16 = GL_FALSE; + if (span->arrayMask & SPAN_XY) + zStart = NULL; + else + zStart = _swrast_pixel_address(rb, span->x, span->y); + if (rb->Format == MESA_FORMAT_Z16 && !(span->arrayMask & SPAN_XY)) { /* directly read/write row of 16-bit Z values */ zBufferVals = zStart; @@ -405,9 +412,7 @@ _swrast_depth_bounds_test( struct gl_context *ctx, SWspan *span ) { struct gl_framebuffer *fb = ctx->DrawBuffer; struct gl_renderbuffer *rb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; - const GLint bpp = _mesa_get_format_bytes(rb->Format); - const GLint rowStride = rb->RowStride * bpp; - GLubyte *zStart = (GLubyte*) rb->Data + span->y * rowStride + span->x * bpp; + GLubyte *zStart; GLuint zMin = (GLuint) (ctx->Depth.BoundsMin * fb->_DepthMaxF + 0.5F); GLuint zMax = (GLuint) (ctx->Depth.BoundsMax * fb->_DepthMaxF + 0.5F); GLubyte *mask = span->array->mask; @@ -417,6 +422,11 @@ _swrast_depth_bounds_test( struct gl_context *ctx, SWspan *span ) GLuint zBufferTemp[MAX_WIDTH]; const GLuint *zBufferVals; + if (span->arrayMask & SPAN_XY) + zStart = NULL; + else + zStart = _swrast_pixel_address(rb, span->x, span->y); + if (rb->Format == MESA_FORMAT_Z32 && !(span->arrayMask & SPAN_XY)) { /* directly access 32-bit values in the depth buffer */ zBufferVals = (const GLuint *) zStart; diff --git a/mesalib/src/mesa/swrast/s_drawpix.c b/mesalib/src/mesa/swrast/s_drawpix.c index 4231bb4bd..c5466ddbd 100644 --- a/mesalib/src/mesa/swrast/s_drawpix.c +++ b/mesalib/src/mesa/swrast/s_drawpix.c @@ -429,11 +429,14 @@ draw_rgba_pixels( struct gl_context *ctx, GLint x, GLint y, span.arrayMask = SPAN_RGBA; span.arrayAttribs = FRAG_BIT_COL0; /* we're fill in COL0 attrib values */ - if (ctx->DrawBuffer->_NumColorDrawBuffers > 0 && - ctx->DrawBuffer->_ColorDrawBuffers[0]->DataType != GL_FLOAT && - ctx->Color.ClampFragmentColor != GL_FALSE) { - /* need to clamp colors before applying fragment ops */ - transferOps |= IMAGE_CLAMP_BIT; + if (ctx->DrawBuffer->_NumColorDrawBuffers > 0) { + GLenum datatype = _mesa_get_format_datatype( + ctx->DrawBuffer->_ColorDrawBuffers[0]->Format); + if (datatype != GL_FLOAT && + ctx->Color.ClampFragmentColor != GL_FALSE) { + /* need to clamp colors before applying fragment ops */ + transferOps |= IMAGE_CLAMP_BIT; + } } /* @@ -510,6 +513,7 @@ fast_draw_depth_stencil(struct gl_context *ctx, GLint x, GLint y, const GLenum type = GL_UNSIGNED_INT_24_8; struct gl_renderbuffer *rb = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); GLubyte *src, *dst; GLint srcRowStride, dstRowStride; GLint i; @@ -519,7 +523,7 @@ fast_draw_depth_stencil(struct gl_context *ctx, GLint x, GLint y, srcRowStride = _mesa_image_row_stride(unpack, width, format, type); dst = _swrast_pixel_address(rb, x, y); - dstRowStride = rb->RowStride * 4; + dstRowStride = srb->RowStride; for (i = 0; i < height; i++) { _mesa_pack_uint_24_8_depth_stencil_row(rb->Format, width, diff --git a/mesalib/src/mesa/swrast/s_logic.c b/mesalib/src/mesa/swrast/s_logic.c index 80ee46c24..e908a0efe 100644 --- a/mesalib/src/mesa/swrast/s_logic.c +++ b/mesalib/src/mesa/swrast/s_logic.c @@ -195,7 +195,6 @@ _swrast_logicop_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb, ASSERT(span->end < MAX_WIDTH); ASSERT(span->arrayMask & SPAN_RGBA); - ASSERT(rb->DataType == span->array->ChanType); rbPixels = _swrast_get_dest_rgba(ctx, rb, span); diff --git a/mesalib/src/mesa/swrast/s_masking.c b/mesalib/src/mesa/swrast/s_masking.c index 6ee29d4b3..2d962ebc5 100644 --- a/mesalib/src/mesa/swrast/s_masking.c +++ b/mesalib/src/mesa/swrast/s_masking.c @@ -1,103 +1,102 @@ -/*
- * Mesa 3-D graphics library
- * Version: 6.5.2
- *
- * Copyright (C) 1999-2006 Brian Paul 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, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL 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.
- */
-
-
-/*
- * Implement the effect of glColorMask and glIndexMask in software.
- */
-
-
-#include "main/glheader.h"
-#include "main/macros.h"
-
-#include "s_context.h"
-#include "s_masking.h"
-#include "s_span.h"
-
-
-/**
- * Apply the color mask to a span of rgba values.
- */
-void
-_swrast_mask_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb,
- SWspan *span, GLuint buf)
-{
- const GLuint n = span->end;
- void *rbPixels;
-
- ASSERT(n < MAX_WIDTH);
- ASSERT(span->arrayMask & SPAN_RGBA);
- ASSERT(rb->DataType == span->array->ChanType);
-
- rbPixels = _swrast_get_dest_rgba(ctx, rb, span);
-
- /*
- * Do component masking.
- * Note that we're not using span->array->mask[] here. We could...
- */
- if (span->array->ChanType == GL_UNSIGNED_BYTE) {
- /* treat 4xGLubyte as 1xGLuint */
- const GLuint srcMask = *((GLuint *) ctx->Color.ColorMask[buf]);
- const GLuint dstMask = ~srcMask;
- const GLuint *dst = (const GLuint *) rbPixels;
- GLuint *src = (GLuint *) span->array->rgba8;
- GLuint i;
- for (i = 0; i < n; i++) {
- src[i] = (src[i] & srcMask) | (dst[i] & dstMask);
- }
- }
- else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
- /* 2-byte components */
- /* XXX try to use 64-bit arithmetic someday */
- const GLushort rMask = ctx->Color.ColorMask[buf][RCOMP] ? 0xffff : 0x0;
- const GLushort gMask = ctx->Color.ColorMask[buf][GCOMP] ? 0xffff : 0x0;
- const GLushort bMask = ctx->Color.ColorMask[buf][BCOMP] ? 0xffff : 0x0;
- const GLushort aMask = ctx->Color.ColorMask[buf][ACOMP] ? 0xffff : 0x0;
- const GLushort (*dst)[4] = (const GLushort (*)[4]) rbPixels;
- GLushort (*src)[4] = span->array->rgba16;
- GLuint i;
- for (i = 0; i < n; i++) {
- src[i][RCOMP] = (src[i][RCOMP] & rMask) | (dst[i][RCOMP] & ~rMask);
- src[i][GCOMP] = (src[i][GCOMP] & gMask) | (dst[i][GCOMP] & ~gMask);
- src[i][BCOMP] = (src[i][BCOMP] & bMask) | (dst[i][BCOMP] & ~bMask);
- src[i][ACOMP] = (src[i][ACOMP] & aMask) | (dst[i][ACOMP] & ~aMask);
- }
- }
- else {
- /* 4-byte components */
- const GLuint rMask = ctx->Color.ColorMask[buf][RCOMP] ? ~0x0 : 0x0;
- const GLuint gMask = ctx->Color.ColorMask[buf][GCOMP] ? ~0x0 : 0x0;
- const GLuint bMask = ctx->Color.ColorMask[buf][BCOMP] ? ~0x0 : 0x0;
- const GLuint aMask = ctx->Color.ColorMask[buf][ACOMP] ? ~0x0 : 0x0;
- const GLuint (*dst)[4] = (const GLuint (*)[4]) rbPixels;
- GLuint (*src)[4] = (GLuint (*)[4]) span->array->attribs[FRAG_ATTRIB_COL0];
- GLuint i;
- for (i = 0; i < n; i++) {
- src[i][RCOMP] = (src[i][RCOMP] & rMask) | (dst[i][RCOMP] & ~rMask);
- src[i][GCOMP] = (src[i][GCOMP] & gMask) | (dst[i][GCOMP] & ~gMask);
- src[i][BCOMP] = (src[i][BCOMP] & bMask) | (dst[i][BCOMP] & ~bMask);
- src[i][ACOMP] = (src[i][ACOMP] & aMask) | (dst[i][ACOMP] & ~aMask);
- }
- }
-}
+/* + * Mesa 3-D graphics library + * Version: 6.5.2 + * + * Copyright (C) 1999-2006 Brian Paul 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, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + + +/* + * Implement the effect of glColorMask and glIndexMask in software. + */ + + +#include "main/glheader.h" +#include "main/macros.h" + +#include "s_context.h" +#include "s_masking.h" +#include "s_span.h" + + +/** + * Apply the color mask to a span of rgba values. + */ +void +_swrast_mask_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb, + SWspan *span, GLuint buf) +{ + const GLuint n = span->end; + void *rbPixels; + + ASSERT(n < MAX_WIDTH); + ASSERT(span->arrayMask & SPAN_RGBA); + + rbPixels = _swrast_get_dest_rgba(ctx, rb, span); + + /* + * Do component masking. + * Note that we're not using span->array->mask[] here. We could... + */ + if (span->array->ChanType == GL_UNSIGNED_BYTE) { + /* treat 4xGLubyte as 1xGLuint */ + const GLuint srcMask = *((GLuint *) ctx->Color.ColorMask[buf]); + const GLuint dstMask = ~srcMask; + const GLuint *dst = (const GLuint *) rbPixels; + GLuint *src = (GLuint *) span->array->rgba8; + GLuint i; + for (i = 0; i < n; i++) { + src[i] = (src[i] & srcMask) | (dst[i] & dstMask); + } + } + else if (span->array->ChanType == GL_UNSIGNED_SHORT) { + /* 2-byte components */ + /* XXX try to use 64-bit arithmetic someday */ + const GLushort rMask = ctx->Color.ColorMask[buf][RCOMP] ? 0xffff : 0x0; + const GLushort gMask = ctx->Color.ColorMask[buf][GCOMP] ? 0xffff : 0x0; + const GLushort bMask = ctx->Color.ColorMask[buf][BCOMP] ? 0xffff : 0x0; + const GLushort aMask = ctx->Color.ColorMask[buf][ACOMP] ? 0xffff : 0x0; + const GLushort (*dst)[4] = (const GLushort (*)[4]) rbPixels; + GLushort (*src)[4] = span->array->rgba16; + GLuint i; + for (i = 0; i < n; i++) { + src[i][RCOMP] = (src[i][RCOMP] & rMask) | (dst[i][RCOMP] & ~rMask); + src[i][GCOMP] = (src[i][GCOMP] & gMask) | (dst[i][GCOMP] & ~gMask); + src[i][BCOMP] = (src[i][BCOMP] & bMask) | (dst[i][BCOMP] & ~bMask); + src[i][ACOMP] = (src[i][ACOMP] & aMask) | (dst[i][ACOMP] & ~aMask); + } + } + else { + /* 4-byte components */ + const GLuint rMask = ctx->Color.ColorMask[buf][RCOMP] ? ~0x0 : 0x0; + const GLuint gMask = ctx->Color.ColorMask[buf][GCOMP] ? ~0x0 : 0x0; + const GLuint bMask = ctx->Color.ColorMask[buf][BCOMP] ? ~0x0 : 0x0; + const GLuint aMask = ctx->Color.ColorMask[buf][ACOMP] ? ~0x0 : 0x0; + const GLuint (*dst)[4] = (const GLuint (*)[4]) rbPixels; + GLuint (*src)[4] = (GLuint (*)[4]) span->array->attribs[FRAG_ATTRIB_COL0]; + GLuint i; + for (i = 0; i < n; i++) { + src[i][RCOMP] = (src[i][RCOMP] & rMask) | (dst[i][RCOMP] & ~rMask); + src[i][GCOMP] = (src[i][GCOMP] & gMask) | (dst[i][GCOMP] & ~gMask); + src[i][BCOMP] = (src[i][BCOMP] & bMask) | (dst[i][BCOMP] & ~bMask); + src[i][ACOMP] = (src[i][ACOMP] & aMask) | (dst[i][ACOMP] & ~aMask); + } + } +} diff --git a/mesalib/src/mesa/swrast/s_renderbuffer.c b/mesalib/src/mesa/swrast/s_renderbuffer.c index 1a7cb36d9..637a7b6dc 100644 --- a/mesalib/src/mesa/swrast/s_renderbuffer.c +++ b/mesalib/src/mesa/swrast/s_renderbuffer.c @@ -37,1048 +37,10 @@ #include "main/formats.h" #include "main/mtypes.h" #include "main/renderbuffer.h" +#include "swrast/s_context.h" #include "swrast/s_renderbuffer.h" -/* - * Routines for get/put values in common buffer formats follow. - */ - -/* Returns a bytes per pixel of the DataType in the get/put span - * functions for at least a subset of the available combinations a - * renderbuffer can have. - * - * It would be nice to see gl_renderbuffer start talking about a - * gl_format instead of a GLenum DataType. - */ -static int -get_datatype_bytes(struct gl_renderbuffer *rb) -{ - int component_size; - - switch (rb->DataType) { - case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: - component_size = 8; - break; - case GL_FLOAT: - case GL_UNSIGNED_INT: - case GL_UNSIGNED_INT_24_8_EXT: - component_size = 4; - break; - case GL_UNSIGNED_SHORT: - component_size = 2; - break; - case GL_UNSIGNED_BYTE: - component_size = 1; - break; - default: - component_size = 1; - assert(0); - } - - switch (rb->_BaseFormat) { - case GL_DEPTH_COMPONENT: - case GL_DEPTH_STENCIL: - return component_size; - default: - return 4 * component_size; - } -} - -/* This is commonly used by most of the accessors. */ -static void * -get_pointer_generic(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLint x, GLint y) -{ - if (!rb->Data) - return NULL; - - return ((char *) rb->Data + - (y * rb->RowStride + x) * _mesa_get_format_bytes(rb->Format)); -} - -/* GetRow() implementation for formats where DataType matches the rb->Format. - */ -static void -get_row_generic(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, void *values) -{ - void *src = rb->GetPointer(ctx, rb, x, y); - memcpy(values, src, count * _mesa_get_format_bytes(rb->Format)); -} - -/* Only used for float textures currently, but might also be used for - * RGBA8888, RGBA16, etc. - */ -static void -get_values_generic(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], void *values) -{ - int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat); - GLuint i; - - for (i = 0; i < count; i++) { - const void *src = rb->GetPointer(ctx, rb, x[i], y[i]); - char *dst = (char *) values + i * format_bytes; - memcpy(dst, src, format_bytes); - } -} - -/* For the GL_RED/GL_RG/GL_RGB format/DataType combinations (and - * GL_LUMINANCE/GL_INTENSITY?), the Put functions are a matter of - * storing those initial components of the value per pixel into the - * destination. - */ -static void -put_row_generic(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, - const void *values, const GLubyte *mask) -{ - void *row = rb->GetPointer(ctx, rb, x, y); - int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat); - int datatype_bytes = get_datatype_bytes(rb); - unsigned int i; - - if (mask) { - for (i = 0; i < count; i++) { - char *dst = (char *) row + i * format_bytes; - const char *src = (const char *) values + i * datatype_bytes; - - if (mask[i]) { - memcpy(dst, src, format_bytes); - } - } - } - else { - for (i = 0; i < count; i++) { - char *dst = (char *) row + i * format_bytes; - const char *src = (const char *) values + i * datatype_bytes; - memcpy(dst, src, format_bytes); - } - } -} - - -static void -put_values_generic(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *values, const GLubyte *mask) -{ - int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat); - int datatype_bytes = get_datatype_bytes(rb); - unsigned int i; - - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - void *dst = rb->GetPointer(ctx, rb, x[i], y[i]); - const char *src = (const char *) values + i * datatype_bytes; - memcpy(dst, src, format_bytes); - } - } -} - - - -/********************************************************************** - * Functions for buffers of 1 X GLubyte values. - * Typically stencil. - */ - -static void -get_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLubyte *dst = (GLubyte *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - const GLubyte *src = (GLubyte *) rb->Data + y[i] * rb->RowStride + x[i]; - dst[i] = *src; - } -} - - -static void -put_row_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - const GLubyte *src = (const GLubyte *) values; - GLubyte *dst = (GLubyte *) rb->Data + y * rb->RowStride + x; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = src[i]; - } - } - } - else { - memcpy(dst, values, count * sizeof(GLubyte)); - } -} - - -static void -put_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], - const void *values, const GLubyte *mask) -{ - const GLubyte *src = (const GLubyte *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->RowStride + x[i]; - *dst = src[i]; - } - } -} - - -/********************************************************************** - * Functions for buffers of 1 X GLushort values. - * Typically depth/Z. - */ - -static void -get_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLushort *dst = (GLushort *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - for (i = 0; i < count; i++) { - const GLushort *src = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i]; - dst[i] = *src; - } -} - - -static void -put_row_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - const GLushort *src = (const GLushort *) values; - GLushort *dst = (GLushort *) rb->Data + y * rb->RowStride + x; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = src[i]; - } - } - } - else { - memcpy(dst, src, count * sizeof(GLushort)); - } -} - - -static void -put_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask) -{ - const GLushort *src = (const GLushort *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLushort *dst = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i]; - *dst = src[i]; - } - } -} - - -/********************************************************************** - * Functions for buffers of 1 X GLuint values. - * Typically depth/Z or color index. - */ - -static void -get_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLuint *dst = (GLuint *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_INT || - rb->DataType == GL_UNSIGNED_INT_24_8_EXT); - for (i = 0; i < count; i++) { - const GLuint *src = (GLuint *) rb->Data + y[i] * rb->RowStride + x[i]; - dst[i] = *src; - } -} - - -static void -put_row_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - const GLuint *src = (const GLuint *) values; - GLuint *dst = (GLuint *) rb->Data + y * rb->RowStride + x; - ASSERT(rb->DataType == GL_UNSIGNED_INT || - rb->DataType == GL_UNSIGNED_INT_24_8_EXT); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = src[i]; - } - } - } - else { - memcpy(dst, src, count * sizeof(GLuint)); - } -} - - -static void -put_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask) -{ - const GLuint *src = (const GLuint *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_INT || - rb->DataType == GL_UNSIGNED_INT_24_8_EXT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) rb->Data + y[i] * rb->RowStride + x[i]; - *dst = src[i]; - } - } -} - - -/********************************************************************** - * Functions for buffers of 3 X GLubyte (or GLbyte) values. - * Typically color buffers. - * NOTE: the incoming and outgoing colors are RGBA! We ignore incoming - * alpha values and return 255 for outgoing alpha values. - */ - -static void * -get_pointer_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLint x, GLint y) -{ - ASSERT(rb->Format == MESA_FORMAT_RGB888); - /* No direct access since this buffer is RGB but caller will be - * treating it as if it were RGBA. - */ - return NULL; -} - - -static void -get_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values) -{ - const GLubyte *src = ((const GLubyte *) rb->Data) + - 3 * (y * rb->RowStride + x); - GLubyte *dst = (GLubyte *) values; - GLuint i; - ASSERT(rb->Format == MESA_FORMAT_RGB888); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - dst[i * 4 + 0] = src[i * 3 + 0]; - dst[i * 4 + 1] = src[i * 3 + 1]; - dst[i * 4 + 2] = src[i * 3 + 2]; - dst[i * 4 + 3] = 255; - } -} - - -static void -get_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLubyte *dst = (GLubyte *) values; - GLuint i; - ASSERT(rb->Format == MESA_FORMAT_RGB888); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - const GLubyte *src - = (GLubyte *) rb->Data + 3 * (y[i] * rb->RowStride + x[i]); - dst[i * 4 + 0] = src[0]; - dst[i * 4 + 1] = src[1]; - dst[i * 4 + 2] = src[2]; - dst[i * 4 + 3] = 255; - } -} - - -static void -put_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - /* note: incoming values are RGB+A! */ - const GLubyte *src = (const GLubyte *) values; - GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->RowStride + x); - GLuint i; - ASSERT(rb->Format == MESA_FORMAT_RGB888); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i * 3 + 0] = src[i * 4 + 0]; - dst[i * 3 + 1] = src[i * 4 + 1]; - dst[i * 3 + 2] = src[i * 4 + 2]; - } - } -} - - -static void -put_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask) -{ - /* note: incoming values are RGB+A! */ - const GLubyte *src = (const GLubyte *) values; - GLuint i; - ASSERT(rb->Format == MESA_FORMAT_RGB888); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLubyte *dst = (GLubyte *) rb->Data + 3 * (y[i] * rb->RowStride + x[i]); - dst[0] = src[i * 4 + 0]; - dst[1] = src[i * 4 + 1]; - dst[2] = src[i * 4 + 2]; - } - } -} - - -/********************************************************************** - * Functions for buffers of 4 X GLubyte (or GLbyte) values. - * Typically color buffers. - */ - -static void -get_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - /* treat 4*GLubyte as 1*GLuint */ - GLuint *dst = (GLuint *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(rb->Format == MESA_FORMAT_RGBA8888 || - rb->Format == MESA_FORMAT_RGBA8888_REV); - for (i = 0; i < count; i++) { - const GLuint *src = (GLuint *) rb->Data + (y[i] * rb->RowStride + x[i]); - dst[i] = *src; - } -} - - -static void -put_row_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - /* treat 4*GLubyte as 1*GLuint */ - const GLuint *src = (const GLuint *) values; - GLuint *dst = (GLuint *) rb->Data + (y * rb->RowStride + x); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(rb->Format == MESA_FORMAT_RGBA8888 || - rb->Format == MESA_FORMAT_RGBA8888_REV); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = src[i]; - } - } - } - else { - memcpy(dst, src, 4 * count * sizeof(GLubyte)); - } -} - - -static void -put_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask) -{ - /* treat 4*GLubyte as 1*GLuint */ - const GLuint *src = (const GLuint *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(rb->Format == MESA_FORMAT_RGBA8888 || - rb->Format == MESA_FORMAT_RGBA8888_REV); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->RowStride + x[i]); - *dst = src[i]; - } - } -} - - -/********************************************************************** - * Functions for buffers of 4 X GLushort (or GLshort) values. - * Typically accum buffer. - */ - -static void -get_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLushort *dst = (GLushort *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); - for (i = 0; i < count; i++) { - const GLushort *src - = (GLushort *) rb->Data + 4 * (y[i] * rb->RowStride + x[i]); - dst[i] = *src; - } -} - - -static void -put_row_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - const GLushort *src = (const GLushort *) values; - GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->RowStride + x); - ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i * 4 + 0] = src[i * 4 + 0]; - dst[i * 4 + 1] = src[i * 4 + 1]; - dst[i * 4 + 2] = src[i * 4 + 2]; - dst[i * 4 + 3] = src[i * 4 + 3]; - } - } - } - else { - memcpy(dst, src, 4 * count * sizeof(GLushort)); - } -} - - -static void -put_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask) -{ - const GLushort *src = (const GLushort *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLushort *dst = - ((GLushort *) rb->Data) + 4 * (y[i] * rb->RowStride + x[i]); - dst[0] = src[i * 4 + 0]; - dst[1] = src[i * 4 + 1]; - dst[2] = src[i * 4 + 2]; - dst[3] = src[i * 4 + 3]; - } - } -} - - -/********************************************************************** - * Functions for MESA_FORMAT_R8. - */ -static void -get_row_r8(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values) -{ - const GLubyte *src = rb->GetPointer(ctx, rb, x, y); - GLuint *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - dst[i] = 0xff000000 | src[i]; - } -} - -static void -get_values_r8(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLuint *dst = (GLuint *) values; - GLuint i; - - for (i = 0; i < count; i++) { - const GLubyte *src = rb->GetPointer(ctx, rb, x[i], y[i]); - dst[i] = 0xff000000 | *src; - } -} - -/********************************************************************** - * Functions for MESA_FORMAT_GR88. - */ -static void -get_row_rg88(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values) -{ - const GLushort *src = rb->GetPointer(ctx, rb, x, y); - GLuint *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - dst[i] = 0xff000000 | src[i]; - } -} - -static void -get_values_rg88(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], void *values) -{ - GLuint *dst = (GLuint *) values; - GLuint i; - - for (i = 0; i < count; i++) { - const GLshort *src = rb->GetPointer(ctx, rb, x[i], y[i]); - dst[i] = 0xff000000 | *src; - } -} - -/********************************************************************** - * Functions for MESA_FORMAT_R16. - */ -static void -get_row_r16(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values) -{ - const GLushort *src = rb->GetPointer(ctx, rb, x, y); - GLushort *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - dst[i * 4 + RCOMP] = src[i]; - dst[i * 4 + GCOMP] = 0; - dst[i * 4 + BCOMP] = 0; - dst[i * 4 + ACOMP] = 0xffff; - } -} - -static void -get_values_r16(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLushort *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - const GLushort *src = rb->GetPointer(ctx, rb, x[i], y[i]); - dst[i * 4 + RCOMP] = *src; - dst[i * 4 + GCOMP] = 0; - dst[i * 4 + BCOMP] = 0; - dst[i * 4 + ACOMP] = 0xffff; - } -} - -/********************************************************************** - * Functions for MESA_FORMAT_RG1616. - */ -static void -get_row_rg1616(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values) -{ - const GLushort *src = rb->GetPointer(ctx, rb, x, y); - GLushort *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - dst[i * 4 + RCOMP] = src[i * 2]; - dst[i * 4 + GCOMP] = src[i * 2 + 1]; - dst[i * 4 + BCOMP] = 0; - dst[i * 4 + ACOMP] = 0xffff; - } -} - -static void -get_values_rg1616(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], void *values) -{ - GLushort *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - const GLshort *src = rb->GetPointer(ctx, rb, x[i], y[i]); - dst[i * 4 + RCOMP] = src[0]; - dst[i * 4 + GCOMP] = src[1]; - dst[i * 4 + BCOMP] = 0; - dst[i * 4 + ACOMP] = 0xffff; - } -} - -/********************************************************************** - * Functions for MESA_FORMAT_INTENSITY_FLOAT32. - */ -static void -get_row_i_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, void *values) -{ - const GLfloat *src = rb->GetPointer(ctx, rb, x, y); - GLfloat *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - dst[i * 4 + RCOMP] = - dst[i * 4 + GCOMP] = - dst[i * 4 + BCOMP] = - dst[i * 4 + ACOMP] = src[i]; - } -} - -static void -get_values_i_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - void *values) -{ - GLfloat *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]); - dst[i * 4 + RCOMP] = - dst[i * 4 + GCOMP] = - dst[i * 4 + BCOMP] = - dst[i * 4 + ACOMP] = src[0]; - } -} - -/********************************************************************** - * Functions for MESA_FORMAT_LUMINANCE_FLOAT32. - */ -static void -get_row_l_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, void *values) -{ - const GLfloat *src = rb->GetPointer(ctx, rb, x, y); - GLfloat *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - dst[i * 4 + RCOMP] = - dst[i * 4 + GCOMP] = - dst[i * 4 + BCOMP] = src[i]; - dst[i * 4 + ACOMP] = 1.0; - } -} - -static void -get_values_l_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - void *values) -{ - GLfloat *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]); - dst[i * 4 + RCOMP] = - dst[i * 4 + GCOMP] = - dst[i * 4 + BCOMP] = src[0]; - dst[i * 4 + ACOMP] = 1.0; - } -} - -/********************************************************************** - * Functions for MESA_FORMAT_ALPHA_FLOAT32. - */ -static void -get_row_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, void *values) -{ - const GLfloat *src = rb->GetPointer(ctx, rb, x, y); - GLfloat *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - dst[i * 4 + RCOMP] = 0.0; - dst[i * 4 + GCOMP] = 0.0; - dst[i * 4 + BCOMP] = 0.0; - dst[i * 4 + ACOMP] = src[i]; - } -} - -static void -get_values_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - void *values) -{ - GLfloat *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]); - dst[i * 4 + RCOMP] = 0.0; - dst[i * 4 + GCOMP] = 0.0; - dst[i * 4 + BCOMP] = 0.0; - dst[i * 4 + ACOMP] = src[0]; - } -} - -static void -put_row_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, - const void *values, const GLubyte *mask) -{ - float *dst = rb->GetPointer(ctx, rb, x, y); - const float *src = values; - unsigned int i; - - if (mask) { - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = src[i * 4 + ACOMP]; - } - } - } - else { - for (i = 0; i < count; i++) { - dst[i] = src[i * 4 + ACOMP]; - } - } -} - -static void -put_values_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *values, const GLubyte *mask) -{ - const float *src = values; - unsigned int i; - - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - float *dst = rb->GetPointer(ctx, rb, x[i], y[i]); - - *dst = src[i * 4 + ACOMP]; - } - } -} - -/********************************************************************** - * Functions for MESA_FORMAT_R_FLOAT32. - */ -static void -get_row_r_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, void *values) -{ - const GLfloat *src = rb->GetPointer(ctx, rb, x, y); - GLfloat *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - dst[i * 4 + RCOMP] = src[i]; - dst[i * 4 + GCOMP] = 0.0; - dst[i * 4 + BCOMP] = 0.0; - dst[i * 4 + ACOMP] = 1.0; - } -} - -static void -get_values_r_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - void *values) -{ - GLfloat *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]); - dst[i * 4 + RCOMP] = src[0]; - dst[i * 4 + GCOMP] = 0.0; - dst[i * 4 + BCOMP] = 0.0; - dst[i * 4 + ACOMP] = 1.0; - } -} - -/********************************************************************** - * Functions for MESA_FORMAT_RG_FLOAT32. - */ -static void -get_row_rg_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, void *values) -{ - const GLfloat *src = rb->GetPointer(ctx, rb, x, y); - GLfloat *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - dst[i * 4 + RCOMP] = src[i * 2 + 0]; - dst[i * 4 + GCOMP] = src[i * 2 + 1]; - dst[i * 4 + BCOMP] = 0.0; - dst[i * 4 + ACOMP] = 1.0; - } -} - -static void -get_values_rg_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - void *values) -{ - GLfloat *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]); - dst[i * 4 + RCOMP] = src[0]; - dst[i * 4 + GCOMP] = src[1]; - dst[i * 4 + BCOMP] = 0.0; - dst[i * 4 + ACOMP] = 1.0; - } -} - -/** - * This is the default software fallback for gl_renderbuffer's span - * access functions. - * - * The assumptions are that rb->Data will be a pointer to (0,0), that pixels - * are packed in the type of rb->Format, and that subsequent rows appear - * rb->RowStride pixels later. - */ -void -_swrast_set_renderbuffer_accessors(struct gl_renderbuffer *rb) -{ - rb->GetPointer = get_pointer_generic; - rb->GetRow = get_row_generic; - - switch (rb->Format) { - case MESA_FORMAT_RGB888: - rb->DataType = GL_UNSIGNED_BYTE; - rb->GetPointer = get_pointer_ubyte3; - rb->GetRow = get_row_ubyte3; - rb->GetValues = get_values_ubyte3; - rb->PutRow = put_row_ubyte3; - rb->PutValues = put_values_ubyte3; - break; - - case MESA_FORMAT_RGBA8888: - case MESA_FORMAT_RGBA8888_REV: - rb->DataType = GL_UNSIGNED_BYTE; - rb->GetValues = get_values_ubyte4; - rb->PutRow = put_row_ubyte4; - rb->PutValues = put_values_ubyte4; - break; - - case MESA_FORMAT_R8: - rb->DataType = GL_UNSIGNED_BYTE; - rb->GetValues = get_values_r8; - rb->GetRow = get_row_r8; - rb->PutRow = put_row_generic; - rb->PutValues = put_values_generic; - break; - - case MESA_FORMAT_GR88: - rb->DataType = GL_UNSIGNED_BYTE; - rb->GetValues = get_values_rg88; - rb->GetRow = get_row_rg88; - rb->PutRow = put_row_generic; - rb->PutValues = put_values_generic; - break; - - case MESA_FORMAT_R16: - rb->DataType = GL_UNSIGNED_SHORT; - rb->GetValues = get_values_r16; - rb->GetRow = get_row_r16; - rb->PutRow = put_row_generic; - rb->PutValues = put_values_generic; - break; - - case MESA_FORMAT_RG1616: - rb->DataType = GL_UNSIGNED_SHORT; - rb->GetValues = get_values_rg1616; - rb->GetRow = get_row_rg1616; - rb->PutRow = put_row_generic; - rb->PutValues = put_values_generic; - break; - - case MESA_FORMAT_SIGNED_RGBA_16: - rb->DataType = GL_SHORT; - rb->GetValues = get_values_ushort4; - rb->PutRow = put_row_ushort4; - rb->PutValues = put_values_ushort4; - break; - - case MESA_FORMAT_S8: - rb->DataType = GL_UNSIGNED_BYTE; - rb->GetValues = get_values_ubyte; - rb->PutRow = put_row_ubyte; - rb->PutValues = put_values_ubyte; - break; - - case MESA_FORMAT_Z16: - rb->DataType = GL_UNSIGNED_SHORT; - rb->GetValues = get_values_ushort; - rb->PutRow = put_row_ushort; - rb->PutValues = put_values_ushort; - break; - - case MESA_FORMAT_Z32: - case MESA_FORMAT_X8_Z24: - case MESA_FORMAT_Z24_X8: - rb->DataType = GL_UNSIGNED_INT; - rb->GetValues = get_values_uint; - rb->PutRow = put_row_uint; - rb->PutValues = put_values_uint; - break; - - case MESA_FORMAT_Z24_S8: - case MESA_FORMAT_S8_Z24: - rb->DataType = GL_UNSIGNED_INT_24_8_EXT; - rb->GetValues = get_values_uint; - rb->PutRow = put_row_uint; - rb->PutValues = put_values_uint; - break; - - case MESA_FORMAT_RGBA_FLOAT32: - rb->GetRow = get_row_generic; - rb->GetValues = get_values_generic; - rb->PutRow = put_row_generic; - rb->PutValues = put_values_generic; - break; - - case MESA_FORMAT_INTENSITY_FLOAT32: - rb->GetRow = get_row_i_float32; - rb->GetValues = get_values_i_float32; - rb->PutRow = put_row_generic; - rb->PutValues = put_values_generic; - break; - - case MESA_FORMAT_LUMINANCE_FLOAT32: - rb->GetRow = get_row_l_float32; - rb->GetValues = get_values_l_float32; - rb->PutRow = put_row_generic; - rb->PutValues = put_values_generic; - break; - - case MESA_FORMAT_ALPHA_FLOAT32: - rb->GetRow = get_row_a_float32; - rb->GetValues = get_values_a_float32; - rb->PutRow = put_row_a_float32; - rb->PutValues = put_values_a_float32; - break; - - case MESA_FORMAT_RG_FLOAT32: - rb->GetRow = get_row_rg_float32; - rb->GetValues = get_values_rg_float32; - rb->PutRow = put_row_generic; - rb->PutValues = put_values_generic; - break; - - case MESA_FORMAT_R_FLOAT32: - rb->GetRow = get_row_r_float32; - rb->GetValues = get_values_r_float32; - rb->PutRow = put_row_generic; - rb->PutValues = put_values_generic; - break; - - default: - break; - } -} - /** * This is a software fallback for the gl_renderbuffer->AllocStorage * function. @@ -1089,15 +51,15 @@ _swrast_set_renderbuffer_accessors(struct gl_renderbuffer *rb) * * This one multi-purpose function can allocate stencil, depth, accum, color * or color-index buffers! - * - * This function also plugs in the appropriate GetPointer, Get/PutRow and - * Get/PutValues functions. */ static GLboolean soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, GLenum internalFormat, GLuint width, GLuint height) { + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); + GLuint bpp; + switch (internalFormat) { case GL_RGB: case GL_R3_G3_B2: @@ -1154,34 +116,26 @@ soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, return GL_FALSE; } - _swrast_set_renderbuffer_accessors(rb); - - ASSERT(rb->DataType); - ASSERT(rb->GetPointer); - ASSERT(rb->GetRow); - ASSERT(rb->GetValues); - ASSERT(rb->PutRow); - ASSERT(rb->PutValues); + bpp = _mesa_get_format_bytes(rb->Format); /* free old buffer storage */ - if (rb->Data) { - free(rb->Data); - rb->Data = NULL; + if (srb->Buffer) { + free(srb->Buffer); + srb->Buffer = NULL; } - rb->RowStride = width; + srb->RowStride = width * bpp; if (width > 0 && height > 0) { /* allocate new buffer storage */ - rb->Data = malloc(width * height * _mesa_get_format_bytes(rb->Format)); + srb->Buffer = malloc(srb->RowStride * height); - if (rb->Data == NULL) { + if (srb->Buffer == NULL) { rb->Width = 0; rb->Height = 0; - rb->RowStride = 0; _mesa_error(ctx, GL_OUT_OF_MEMORY, "software renderbuffer allocation (%d x %d x %d)", - width, height, _mesa_get_format_bytes(rb->Format)); + width, height, bpp); return GL_FALSE; } } @@ -1208,6 +162,22 @@ soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, } +/** + * Called via gl_renderbuffer::Delete() + */ +static void +soft_renderbuffer_delete(struct gl_renderbuffer *rb) +{ + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); + + if (srb->Buffer) { + free(srb->Buffer); + srb->Buffer = NULL; + } + free(srb); +} + + void _swrast_map_soft_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb, @@ -1216,11 +186,15 @@ _swrast_map_soft_renderbuffer(struct gl_context *ctx, GLubyte **out_map, GLint *out_stride) { - GLubyte *map = rb->Data; + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); + GLubyte *map = srb->Buffer; int cpp = _mesa_get_format_bytes(rb->Format); - int stride = rb->RowStride * cpp; + int stride = rb->Width * cpp; - ASSERT(rb->Data); + if (!map) { + *out_map = NULL; + *out_stride = 0; + } map += y * stride; map += x * cpp; @@ -1247,15 +221,13 @@ _swrast_unmap_soft_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer * _swrast_new_soft_renderbuffer(struct gl_context *ctx, GLuint name) { - struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, name); - if (rb) { - rb->AllocStorage = soft_renderbuffer_storage; - /* Normally, one would setup the PutRow, GetRow, etc functions here. - * But we're doing that in the soft_renderbuffer_storage() function - * instead. - */ + struct swrast_renderbuffer *srb = CALLOC_STRUCT(swrast_renderbuffer); + if (srb) { + _mesa_init_renderbuffer(&srb->Base, name); + srb->Base.AllocStorage = soft_renderbuffer_storage; + srb->Base.Delete = soft_renderbuffer_delete; } - return rb; + return &srb->Base; } @@ -1297,7 +269,7 @@ add_color_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, assert(fb->Attachment[b].Renderbuffer == NULL); - rb = _mesa_new_renderbuffer(ctx, 0); + rb = ctx->Driver.NewRenderbuffer(ctx, 0); if (!rb) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating color buffer"); return GL_FALSE; @@ -1335,7 +307,7 @@ add_depth_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, assert(fb->Attachment[BUFFER_DEPTH].Renderbuffer == NULL); - rb = _mesa_new_renderbuffer(ctx, 0); + rb = _swrast_new_soft_renderbuffer(ctx, 0); if (!rb) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating depth buffer"); return GL_FALSE; @@ -1380,7 +352,7 @@ add_stencil_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, assert(fb->Attachment[BUFFER_STENCIL].Renderbuffer == NULL); - rb = _mesa_new_renderbuffer(ctx, 0); + rb = _swrast_new_soft_renderbuffer(ctx, 0); if (!rb) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating stencil buffer"); return GL_FALSE; @@ -1405,7 +377,7 @@ add_depth_stencil_renderbuffer(struct gl_context *ctx, assert(fb->Attachment[BUFFER_DEPTH].Renderbuffer == NULL); assert(fb->Attachment[BUFFER_STENCIL].Renderbuffer == NULL); - rb = _mesa_new_renderbuffer(ctx, 0); + rb = _swrast_new_soft_renderbuffer(ctx, 0); if (!rb) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating depth+stencil buffer"); return GL_FALSE; @@ -1444,7 +416,7 @@ add_accum_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, assert(fb->Attachment[BUFFER_ACCUM].Renderbuffer == NULL); - rb = _mesa_new_renderbuffer(ctx, 0); + rb = _swrast_new_soft_renderbuffer(ctx, 0); if (!rb) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating accum buffer"); return GL_FALSE; @@ -1484,7 +456,7 @@ add_aux_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, assert(numBuffers <= MAX_AUX_BUFFERS); for (i = 0; i < numBuffers; i++) { - struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, 0); + struct gl_renderbuffer *rb = _swrast_new_soft_renderbuffer(ctx, 0); assert(fb->Attachment[BUFFER_AUX0 + i].Renderbuffer == NULL); @@ -1580,3 +552,122 @@ _swrast_add_soft_renderbuffers(struct gl_framebuffer *fb, } #endif } + + + +static void +map_attachment(struct gl_context *ctx, + struct gl_framebuffer *fb, + gl_buffer_index buffer) +{ + struct gl_texture_object *texObj = fb->Attachment[buffer].Texture; + struct gl_renderbuffer *rb = fb->Attachment[buffer].Renderbuffer; + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); + + if (texObj) { + /* map texture image (render to texture) */ + const GLuint level = fb->Attachment[buffer].TextureLevel; + const GLuint face = fb->Attachment[buffer].CubeMapFace; + const GLuint slice = fb->Attachment[buffer].Zoffset; + struct gl_texture_image *texImage = texObj->Image[face][level]; + if (texImage) { + ctx->Driver.MapTextureImage(ctx, texImage, slice, + 0, 0, texImage->Width, texImage->Height, + GL_MAP_READ_BIT | GL_MAP_WRITE_BIT, + &srb->Map, &srb->RowStride); + } + } + else if (rb) { + /* Map ordinary renderbuffer */ + ctx->Driver.MapRenderbuffer(ctx, rb, + 0, 0, rb->Width, rb->Height, + GL_MAP_READ_BIT | GL_MAP_WRITE_BIT, + &srb->Map, &srb->RowStride); + } + + assert(srb->Map); +} + + +static void +unmap_attachment(struct gl_context *ctx, + struct gl_framebuffer *fb, + gl_buffer_index buffer) +{ + struct gl_texture_object *texObj = fb->Attachment[buffer].Texture; + struct gl_renderbuffer *rb = fb->Attachment[buffer].Renderbuffer; + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); + + if (texObj) { + /* unmap texture image (render to texture) */ + const GLuint level = fb->Attachment[buffer].TextureLevel; + const GLuint face = fb->Attachment[buffer].CubeMapFace; + const GLuint slice = fb->Attachment[buffer].Zoffset; + struct gl_texture_image *texImage = texObj->Image[face][level]; + if (texImage) { + ctx->Driver.UnmapTextureImage(ctx, texImage, slice); + } + } + else if (rb) { + /* unmap ordinary renderbuffer */ + ctx->Driver.UnmapRenderbuffer(ctx, rb); + } + + srb->Map = NULL; +} + + +/** + * Map the renderbuffers we'll use for tri/line/point rendering. + */ +void +_swrast_map_renderbuffers(struct gl_context *ctx) +{ + struct gl_framebuffer *fb = ctx->DrawBuffer; + struct gl_renderbuffer *depthRb, *stencilRb; + GLuint buf; + + depthRb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; + if (depthRb) { + /* map depth buffer */ + map_attachment(ctx, fb, BUFFER_DEPTH); + } + + stencilRb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; + if (stencilRb && stencilRb != depthRb) { + /* map stencil buffer */ + map_attachment(ctx, fb, BUFFER_STENCIL); + } + + for (buf = 0; buf < fb->_NumColorDrawBuffers; buf++) { + map_attachment(ctx, fb, fb->_ColorDrawBufferIndexes[buf]); + } +} + + +/** + * Unmap renderbuffers after rendering. + */ +void +_swrast_unmap_renderbuffers(struct gl_context *ctx) +{ + struct gl_framebuffer *fb = ctx->DrawBuffer; + struct gl_renderbuffer *depthRb, *stencilRb; + GLuint buf; + + depthRb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; + if (depthRb) { + /* map depth buffer */ + unmap_attachment(ctx, fb, BUFFER_DEPTH); + } + + stencilRb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; + if (stencilRb && stencilRb != depthRb) { + /* map stencil buffer */ + unmap_attachment(ctx, fb, BUFFER_STENCIL); + } + + for (buf = 0; buf < fb->_NumColorDrawBuffers; buf++) { + unmap_attachment(ctx, fb, fb->_ColorDrawBufferIndexes[buf]); + } +} diff --git a/mesalib/src/mesa/swrast/s_span.c b/mesalib/src/mesa/swrast/s_span.c index e89930353..7ab60b1e5 100644 --- a/mesalib/src/mesa/swrast/s_span.c +++ b/mesalib/src/mesa/swrast/s_span.c @@ -33,6 +33,8 @@ #include "main/glheader.h" #include "main/colormac.h" +#include "main/format_pack.h" +#include "main/format_unpack.h" #include "main/macros.h" #include "main/imports.h" #include "main/image.h" @@ -50,6 +52,7 @@ #include "s_stencil.h" #include "s_texcombine.h" +#include <stdbool.h> /** * Set default fragment attributes for the span using the @@ -968,7 +971,25 @@ convert_color_type(SWspan *span, GLenum newType, GLuint output) static inline void shade_texture_span(struct gl_context *ctx, SWspan *span) { - if (ctx->FragmentProgram._Current || + /* This is a hack to work around drivers such as i965 that: + * + * - Set _MaintainTexEnvProgram to generate GLSL IR for + * fixed-function fragment processing. + * - Don't call _mesa_ir_link_shader to generate Mesa IR from + * the GLSL IR. + * - May use swrast to handle glDrawPixels. + * + * Since _mesa_ir_link_shader is never called, there is no Mesa IR + * to execute. Instead do regular fixed-function processing. + * + * It is also worth noting that the software fixed-function path is + * much faster than the software shader path. + */ + const bool use_fragment_program = + ctx->FragmentProgram._Current + && ctx->FragmentProgram._Current != ctx->FragmentProgram._TexEnvProgram; + + if (use_fragment_program || ctx->ATIFragmentShader._Enabled) { /* programmable shading */ if (span->primitive == GL_BITMAP && span->array->ChanType != GL_FLOAT) { @@ -997,7 +1018,7 @@ shade_texture_span(struct gl_context *ctx, SWspan *span) interpolate_wpos(ctx, span); /* Run fragment program/shader now */ - if (ctx->FragmentProgram._Current) { + if (use_fragment_program) { _swrast_exec_fragment_program(ctx, span); } else { @@ -1024,6 +1045,94 @@ shade_texture_span(struct gl_context *ctx, SWspan *span) } +/** Put colors at x/y locations into a renderbuffer */ +static void +put_values(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLenum datatype, + GLuint count, const GLint x[], const GLint y[], + const void *values, const GLubyte *mask) +{ + gl_pack_ubyte_rgba_func pack_ubyte; + gl_pack_float_rgba_func pack_float; + GLuint i; + + if (datatype == GL_UNSIGNED_BYTE) + pack_ubyte = _mesa_get_pack_ubyte_rgba_function(rb->Format); + else + pack_float = _mesa_get_pack_float_rgba_function(rb->Format); + + for (i = 0; i < count; i++) { + if (mask[i]) { + GLubyte *dst = _swrast_pixel_address(rb, x[i], y[i]); + + if (datatype == GL_UNSIGNED_BYTE) { + pack_ubyte((const GLubyte *) values + 4 * i, dst); + } + else { + assert(datatype == GL_FLOAT); + pack_float((const GLfloat *) values + 4 * i, dst); + } + } + } +} + + +/** Put row of colors into renderbuffer */ +void +_swrast_put_row(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLenum datatype, + GLuint count, GLint x, GLint y, + const void *values, const GLubyte *mask) +{ + GLubyte *dst = _swrast_pixel_address(rb, x, y); + + if (!mask) { + if (datatype == GL_UNSIGNED_BYTE) { + _mesa_pack_ubyte_rgba_row(rb->Format, count, + (const GLubyte (*)[4]) values, dst); + } + else { + assert(datatype == GL_FLOAT); + _mesa_pack_float_rgba_row(rb->Format, count, + (const GLfloat (*)[4]) values, dst); + } + } + else { + const GLuint bpp = _mesa_get_format_bytes(rb->Format); + GLuint i, runLen, runStart; + /* We can't pass a 'mask' array to the _mesa_pack_rgba_row() functions + * so look for runs where mask=1... + */ + runLen = runStart = 0; + for (i = 0; i < count; i++) { + if (mask[i]) { + if (runLen == 0) + runStart = i; + runLen++; + } + + if (!mask[i] || i == count - 1) { + /* might be the end of a run of pixels */ + if (runLen > 0) { + if (datatype == GL_UNSIGNED_BYTE) { + _mesa_pack_ubyte_rgba_row(rb->Format, runLen, + (const GLubyte (*)[4]) values + runStart, + dst + runStart * bpp); + } + else { + assert(datatype == GL_FLOAT); + _mesa_pack_float_rgba_row(rb->Format, runLen, + (const GLfloat (*)[4]) values + runStart, + dst + runStart * bpp); + } + runLen = 0; + } + } + } + } +} + + /** * Apply all the per-fragment operations to a span. @@ -1227,23 +1336,13 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) if (rb) { GLchan rgbaSave[MAX_WIDTH][4]; - const GLuint fragOutput = multiFragOutputs ? buf : 0; - /* set span->array->rgba to colors for render buffer's datatype */ - if (rb->DataType != span->array->ChanType || fragOutput > 0) { - convert_color_type(span, rb->DataType, fragOutput); + if (span->array->ChanType == GL_UNSIGNED_BYTE) { + span->array->rgba = span->array->rgba8; } else { - if (rb->DataType == GL_UNSIGNED_BYTE) { - span->array->rgba = span->array->rgba8; - } - else if (rb->DataType == GL_UNSIGNED_SHORT) { - span->array->rgba = (void *) span->array->rgba16; - } - else { - span->array->rgba = (void *) - span->array->attribs[FRAG_ATTRIB_COL0]; - } + span->array->rgba = (void *) + span->array->attribs[FRAG_ATTRIB_COL0]; } if (!multiFragOutputs && numBuffers > 1) { @@ -1271,17 +1370,18 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) if (span->arrayMask & SPAN_XY) { /* array of pixel coords */ - ASSERT(rb->PutValues); - rb->PutValues(ctx, rb, span->end, - span->array->x, span->array->y, - span->array->rgba, span->array->mask); + put_values(ctx, rb, + span->array->ChanType, span->end, + span->array->x, span->array->y, + span->array->rgba, span->array->mask); } else { /* horizontal run of pixels */ - ASSERT(rb->PutRow); - rb->PutRow(ctx, rb, span->end, span->x, span->y, - span->array->rgba, - span->writeAll ? NULL: span->array->mask); + _swrast_put_row(ctx, rb, + span->array->ChanType, + span->end, span->x, span->y, + span->array->rgba, + span->writeAll ? NULL: span->array->mask); } if (!multiFragOutputs && numBuffers > 1) { @@ -1305,16 +1405,17 @@ end: /** - * Read RGBA pixels from a renderbuffer. Clipping will be done to prevent - * reading ouside the buffer's boundaries. - * \param dstType datatype for returned colors + * Read float RGBA pixels from a renderbuffer. Clipping will be done to + * prevent reading ouside the buffer's boundaries. * \param rgba the returned colors */ void _swrast_read_rgba_span( struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, GLenum dstType, + GLuint n, GLint x, GLint y, GLvoid *rgba) { + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); + GLenum dstType = GL_FLOAT; const GLint bufWidth = (GLint) rb->Width; const GLint bufHeight = (GLint) rb->Height; @@ -1325,6 +1426,8 @@ _swrast_read_rgba_span( struct gl_context *ctx, struct gl_renderbuffer *rb, } else { GLint skip, length; + GLubyte *src; + if (x < 0) { /* left edge clipping */ skip = -x; @@ -1353,7 +1456,6 @@ _swrast_read_rgba_span( struct gl_context *ctx, struct gl_renderbuffer *rb, } ASSERT(rb); - ASSERT(rb->GetRow); ASSERT(rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB || rb->_BaseFormat == GL_RG || @@ -1363,70 +1465,69 @@ _swrast_read_rgba_span( struct gl_context *ctx, struct gl_renderbuffer *rb, rb->_BaseFormat == GL_LUMINANCE_ALPHA || rb->_BaseFormat == GL_ALPHA); - if (rb->DataType == dstType) { - rb->GetRow(ctx, rb, length, x + skip, y, - (GLubyte *) rgba + skip * RGBA_PIXEL_SIZE(rb->DataType)); + assert(srb->Map); + + src = _swrast_pixel_address(rb, x + skip, y); + + if (dstType == GL_UNSIGNED_BYTE) { + _mesa_unpack_ubyte_rgba_row(rb->Format, length, src, + (GLubyte (*)[4]) rgba + skip); + } + else if (dstType == GL_FLOAT) { + _mesa_unpack_rgba_row(rb->Format, length, src, + (GLfloat (*)[4]) rgba + skip); } else { - GLuint temp[MAX_WIDTH * 4]; - rb->GetRow(ctx, rb, length, x + skip, y, temp); - _mesa_convert_colors(rb->DataType, temp, - dstType, (GLubyte *) rgba + skip * RGBA_PIXEL_SIZE(dstType), - length, NULL); + _mesa_problem(ctx, "unexpected type in _swrast_read_rgba_span()"); } } } /** - * Wrapper for gl_renderbuffer::GetValues() which does clipping to avoid - * reading values outside the buffer bounds. - * We can use this for reading any format/type of renderbuffer. - * \param valueSize is the size in bytes of each value (pixel) put into the - * values array. + * Get colors at x/y positions with clipping. + * \param type type of values to return */ -void -_swrast_get_values(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - void *values, GLuint valueSize) +static void +get_values(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + void *values, GLenum type) { - GLuint i, inCount = 0, inStart = 0; + GLuint i; for (i = 0; i < count; i++) { if (x[i] >= 0 && y[i] >= 0 && x[i] < (GLint) rb->Width && y[i] < (GLint) rb->Height) { /* inside */ - if (inCount == 0) - inStart = i; - inCount++; - } - else { - if (inCount > 0) { - /* read [inStart, inStart + inCount) */ - rb->GetValues(ctx, rb, inCount, x + inStart, y + inStart, - (GLubyte *) values + inStart * valueSize); - inCount = 0; + const GLubyte *src = _swrast_pixel_address(rb, x[i], y[i]); + + if (type == GL_UNSIGNED_BYTE) { + _mesa_unpack_ubyte_rgba_row(rb->Format, 1, src, + (GLubyte (*)[4]) values + i); + } + else if (type == GL_FLOAT) { + _mesa_unpack_rgba_row(rb->Format, 1, src, + (GLfloat (*)[4]) values + i); + } + else { + _mesa_problem(ctx, "unexpected type in get_values()"); } } } - if (inCount > 0) { - /* read last values */ - rb->GetValues(ctx, rb, inCount, x + inStart, y + inStart, - (GLubyte *) values + inStart * valueSize); - } } /** - * Wrapper for gl_renderbuffer::PutRow() which does clipping. - * \param valueSize size of each value (pixel) in bytes + * Get row of colors with clipping. + * \param type type of values to return */ -void -_swrast_put_row(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, - const GLvoid *values, GLuint valueSize) +static void +get_row(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, GLint x, GLint y, + GLvoid *values, GLenum type) { GLint skip = 0; + GLubyte *src; if (y < 0 || y >= (GLint) rb->Height) return; /* above or below */ @@ -1434,7 +1535,7 @@ _swrast_put_row(struct gl_context *ctx, struct gl_renderbuffer *rb, if (x + (GLint) count <= 0 || x >= (GLint) rb->Width) return; /* entirely left or right */ - if ((GLint) (x + count) > (GLint) rb->Width) { + if (x + count > rb->Width) { /* right clip */ GLint clip = x + count - rb->Width; count -= clip; @@ -1447,42 +1548,19 @@ _swrast_put_row(struct gl_context *ctx, struct gl_renderbuffer *rb, count -= skip; } - rb->PutRow(ctx, rb, count, x, y, - (const GLubyte *) values + skip * valueSize, NULL); -} + src = _swrast_pixel_address(rb, x, y); - -/** - * Wrapper for gl_renderbuffer::GetRow() which does clipping. - * \param valueSize size of each value (pixel) in bytes - */ -void -_swrast_get_row(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, - GLvoid *values, GLuint valueSize) -{ - GLint skip = 0; - - if (y < 0 || y >= (GLint) rb->Height) - return; /* above or below */ - - if (x + (GLint) count <= 0 || x >= (GLint) rb->Width) - return; /* entirely left or right */ - - if (x + count > rb->Width) { - /* right clip */ - GLint clip = x + count - rb->Width; - count -= clip; + if (type == GL_UNSIGNED_BYTE) { + _mesa_unpack_ubyte_rgba_row(rb->Format, count, src, + (GLubyte (*)[4]) values + skip); } - - if (x < 0) { - /* left clip */ - skip = -x; - x = 0; - count -= skip; + else if (type == GL_FLOAT) { + _mesa_unpack_rgba_row(rb->Format, count, src, + (GLfloat (*)[4]) values + skip); + } + else { + _mesa_problem(ctx, "unexpected type in get_row()"); } - - rb->GetRow(ctx, rb, count, x, y, (GLubyte *) values + skip * valueSize); } @@ -1495,7 +1573,6 @@ void * _swrast_get_dest_rgba(struct gl_context *ctx, struct gl_renderbuffer *rb, SWspan *span) { - const GLuint pixelSize = RGBA_PIXEL_SIZE(span->array->ChanType); void *rbPixels; /* Point rbPixels to a temporary space */ @@ -1503,12 +1580,12 @@ _swrast_get_dest_rgba(struct gl_context *ctx, struct gl_renderbuffer *rb, /* Get destination values from renderbuffer */ if (span->arrayMask & SPAN_XY) { - _swrast_get_values(ctx, rb, span->end, span->array->x, span->array->y, - rbPixels, pixelSize); + get_values(ctx, rb, span->end, span->array->x, span->array->y, + rbPixels, span->array->ChanType); } else { - _swrast_get_row(ctx, rb, span->end, span->x, span->y, - rbPixels, pixelSize); + get_row(ctx, rb, span->end, span->x, span->y, + rbPixels, span->array->ChanType); } return rbPixels; diff --git a/mesalib/src/mesa/swrast/s_span.h b/mesalib/src/mesa/swrast/s_span.h index f4d32dd87..ff0fe6cd9 100644 --- a/mesalib/src/mesa/swrast/s_span.h +++ b/mesalib/src/mesa/swrast/s_span.h @@ -201,23 +201,13 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span); extern void _swrast_read_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, GLenum type, GLvoid *rgba); - -extern void -_swrast_get_values(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - void *values, GLuint valueSize); + GLuint n, GLint x, GLint y, GLvoid *rgba); extern void _swrast_put_row(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLenum datatype, GLuint count, GLint x, GLint y, - const GLvoid *values, GLuint valueSize); - -extern void -_swrast_get_row(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, - GLvoid *values, GLuint valueSize); - + const void *values, const GLubyte *mask); extern void * _swrast_get_dest_rgba(struct gl_context *ctx, struct gl_renderbuffer *rb, diff --git a/mesalib/src/mesa/swrast/s_spantemp.h b/mesalib/src/mesa/swrast/s_spantemp.h deleted file mode 100644 index 2d2561b6f..000000000 --- a/mesalib/src/mesa/swrast/s_spantemp.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul 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, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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. - */ - - -/* - * Templates for the span/pixel-array write/read functions called via - * the gl_renderbuffer's GetRow, GetValues, PutRow, and PutValues. - * - * Define the following macros before including this file: - * NAME(BASE) to generate the function name (i.e. add prefix or suffix) - * RB_TYPE the renderbuffer DataType - * SPAN_VARS to declare any local variables - * INIT_PIXEL_PTR(P, X, Y) to initialize a pointer to a pixel - * INC_PIXEL_PTR(P) to increment a pixel pointer by one pixel - * STORE_PIXEL(DST, X, Y, VALUE) to store pixel values in buffer - * FETCH_PIXEL(DST, SRC) to fetch pixel values from buffer - * - * Note that in the STORE_PIXEL macros, we also pass in the (X,Y) coordinates - * for the pixels to be stored. This is useful when dithering and probably - * ignored otherwise. - */ - -#include "main/macros.h" - - -#if !defined(RB_COMPONENTS) -#define RB_COMPONENTS 4 -#endif - - -static void -NAME(get_row)( struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, void *values ) -{ -#ifdef SPAN_VARS - SPAN_VARS -#endif - RB_TYPE (*dest)[RB_COMPONENTS] = (RB_TYPE (*)[RB_COMPONENTS]) values; - GLuint i; - INIT_PIXEL_PTR(pixel, x, y); - for (i = 0; i < count; i++) { - FETCH_PIXEL(dest[i], pixel); - INC_PIXEL_PTR(pixel); - } - (void) rb; - (void) ctx; -} - - -static void -NAME(get_values)( struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], void *values ) -{ -#ifdef SPAN_VARS - SPAN_VARS -#endif - RB_TYPE (*dest)[RB_COMPONENTS] = (RB_TYPE (*)[RB_COMPONENTS]) values; - GLuint i; - for (i = 0; i < count; i++) { - INIT_PIXEL_PTR(pixel, x[i], y[i]); - FETCH_PIXEL(dest[i], pixel); - } - (void) rb; - (void) ctx; -} - - -static void -NAME(put_row)( struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, - const void *values, const GLubyte mask[] ) -{ -#ifdef SPAN_VARS - SPAN_VARS -#endif - const RB_TYPE (*src)[RB_COMPONENTS] = (const RB_TYPE (*)[RB_COMPONENTS]) values; - GLuint i; - INIT_PIXEL_PTR(pixel, x, y); - if (mask) { - for (i = 0; i < count; i++) { - if (mask[i]) { - STORE_PIXEL(pixel, x + i, y, src[i]); - } - INC_PIXEL_PTR(pixel); - } - } - else { - for (i = 0; i < count; i++) { - STORE_PIXEL(pixel, x + i, y, src[i]); - INC_PIXEL_PTR(pixel); - } - } - (void) rb; - (void) ctx; -} - - -static void -NAME(put_values)( struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *values, const GLubyte mask[] ) -{ -#ifdef SPAN_VARS - SPAN_VARS -#endif - const RB_TYPE (*src)[RB_COMPONENTS] = (const RB_TYPE (*)[RB_COMPONENTS]) values; - GLuint i; - ASSERT(mask); - for (i = 0; i < count; i++) { - if (mask[i]) { - INIT_PIXEL_PTR(pixel, x[i], y[i]); - STORE_PIXEL(pixel, x[i], y[i], src[i]); - } - } - (void) rb; - (void) ctx; -} - - -#undef NAME -#undef RB_TYPE -#undef RB_COMPONENTS -#undef SPAN_VARS -#undef INIT_PIXEL_PTR -#undef INC_PIXEL_PTR -#undef STORE_PIXEL -#undef STORE_PIXEL_RGB -#undef FETCH_PIXEL diff --git a/mesalib/src/mesa/swrast/s_stencil.c b/mesalib/src/mesa/swrast/s_stencil.c index fb95ef14d..bbfbf44cc 100644 --- a/mesalib/src/mesa/swrast/s_stencil.c +++ b/mesalib/src/mesa/swrast/s_stencil.c @@ -292,12 +292,13 @@ get_s8_values(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, const GLint x[], const GLint y[], GLubyte stencil[]) { + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); const GLint w = rb->Width, h = rb->Height; - const GLubyte *map = (const GLubyte *) rb->Data; + const GLubyte *map = _swrast_pixel_address(rb, 0, 0); GLuint i; if (rb->Format == MESA_FORMAT_S8) { - const GLint rowStride = rb->RowStride; + const GLint rowStride = srb->RowStride; for (i = 0; i < count; i++) { if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { stencil[i] = *(map + y[i] * rowStride + x[i]); @@ -306,7 +307,7 @@ get_s8_values(struct gl_context *ctx, struct gl_renderbuffer *rb, } else { const GLint bpp = _mesa_get_format_bytes(rb->Format); - const GLint rowStride = rb->RowStride * bpp; + const GLint rowStride = srb->RowStride; for (i = 0; i < count; i++) { if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { const GLubyte *src = map + y[i] * rowStride + x[i] * bpp; @@ -326,12 +327,14 @@ put_s8_values(struct gl_context *ctx, struct gl_renderbuffer *rb, const GLubyte stencil[]) { const GLint w = rb->Width, h = rb->Height; + gl_pack_ubyte_stencil_func pack_stencil = + _mesa_get_pack_ubyte_stencil_func(rb->Format); GLuint i; for (i = 0; i < count; i++) { if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { GLubyte *dst = _swrast_pixel_address(rb, x[i], y[i]); - _mesa_pack_ubyte_stencil_row(rb->Format, 1, &stencil[i], dst); + pack_stencil(&stencil[i], dst); } } } diff --git a/mesalib/src/mesa/swrast/s_texfetch.c b/mesalib/src/mesa/swrast/s_texfetch.c index 7cb6e68b1..8529ff08d 100644 --- a/mesalib/src/mesa/swrast/s_texfetch.c +++ b/mesalib/src/mesa/swrast/s_texfetch.c @@ -103,18 +103,6 @@ static void fetch_null_texelf( const struct swrast_texture_image *texImage, _mesa_warning(NULL, "fetch_null_texelf() called!"); } -static void store_null_texel(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - (void) texImage; - (void) i; - (void) j; - (void) k; - (void) texel; - /* no-op */ -} - - /** * Table to map MESA_FORMAT_ to texel fetch/store funcs. @@ -125,7 +113,6 @@ static struct { FetchTexelFunc Fetch1D; FetchTexelFunc Fetch2D; FetchTexelFunc Fetch3D; - StoreTexelFunc StoreTexel; } texfetch_funcs[MESA_FORMAT_COUNT] = { @@ -133,386 +120,331 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_NONE, fetch_null_texelf, fetch_null_texelf, - fetch_null_texelf, - store_null_texel + fetch_null_texelf }, { MESA_FORMAT_RGBA8888, fetch_texel_1d_f_rgba8888, fetch_texel_2d_f_rgba8888, - fetch_texel_3d_f_rgba8888, - store_texel_rgba8888 + fetch_texel_3d_f_rgba8888 }, { MESA_FORMAT_RGBA8888_REV, fetch_texel_1d_f_rgba8888_rev, fetch_texel_2d_f_rgba8888_rev, - fetch_texel_3d_f_rgba8888_rev, - store_texel_rgba8888_rev + fetch_texel_3d_f_rgba8888_rev }, { MESA_FORMAT_ARGB8888, fetch_texel_1d_f_argb8888, fetch_texel_2d_f_argb8888, - fetch_texel_3d_f_argb8888, - store_texel_argb8888 + fetch_texel_3d_f_argb8888 }, { MESA_FORMAT_ARGB8888_REV, fetch_texel_1d_f_argb8888_rev, fetch_texel_2d_f_argb8888_rev, - fetch_texel_3d_f_argb8888_rev, - store_texel_argb8888_rev + fetch_texel_3d_f_argb8888_rev }, { MESA_FORMAT_RGBX8888, fetch_texel_1d_f_rgbx8888, fetch_texel_2d_f_rgbx8888, - fetch_texel_3d_f_rgbx8888, - store_texel_rgbx8888 + fetch_texel_3d_f_rgbx8888 }, { MESA_FORMAT_RGBX8888_REV, fetch_texel_1d_f_rgbx8888_rev, fetch_texel_2d_f_rgbx8888_rev, - fetch_texel_3d_f_rgbx8888_rev, - store_texel_rgbx8888_rev, + fetch_texel_3d_f_rgbx8888_rev }, { MESA_FORMAT_XRGB8888, fetch_texel_1d_f_xrgb8888, fetch_texel_2d_f_xrgb8888, - fetch_texel_3d_f_xrgb8888, - store_texel_xrgb8888 + fetch_texel_3d_f_xrgb8888 }, { MESA_FORMAT_XRGB8888_REV, fetch_texel_1d_f_xrgb8888_rev, fetch_texel_2d_f_xrgb8888_rev, - fetch_texel_3d_f_xrgb8888_rev, - store_texel_xrgb8888_rev, + fetch_texel_3d_f_xrgb8888_rev }, { MESA_FORMAT_RGB888, fetch_texel_1d_f_rgb888, fetch_texel_2d_f_rgb888, - fetch_texel_3d_f_rgb888, - store_texel_rgb888 + fetch_texel_3d_f_rgb888 }, { MESA_FORMAT_BGR888, fetch_texel_1d_f_bgr888, fetch_texel_2d_f_bgr888, - fetch_texel_3d_f_bgr888, - store_texel_bgr888 + fetch_texel_3d_f_bgr888 }, { MESA_FORMAT_RGB565, fetch_texel_1d_f_rgb565, fetch_texel_2d_f_rgb565, - fetch_texel_3d_f_rgb565, - store_texel_rgb565 + fetch_texel_3d_f_rgb565 }, { MESA_FORMAT_RGB565_REV, fetch_texel_1d_f_rgb565_rev, fetch_texel_2d_f_rgb565_rev, - fetch_texel_3d_f_rgb565_rev, - store_texel_rgb565_rev + fetch_texel_3d_f_rgb565_rev }, { MESA_FORMAT_ARGB4444, fetch_texel_1d_f_argb4444, fetch_texel_2d_f_argb4444, - fetch_texel_3d_f_argb4444, - store_texel_argb4444 + fetch_texel_3d_f_argb4444 }, { MESA_FORMAT_ARGB4444_REV, fetch_texel_1d_f_argb4444_rev, fetch_texel_2d_f_argb4444_rev, - fetch_texel_3d_f_argb4444_rev, - store_texel_argb4444_rev + fetch_texel_3d_f_argb4444_rev }, { MESA_FORMAT_RGBA5551, fetch_texel_1d_f_rgba5551, fetch_texel_2d_f_rgba5551, - fetch_texel_3d_f_rgba5551, - store_texel_rgba5551 + fetch_texel_3d_f_rgba5551 }, { MESA_FORMAT_ARGB1555, fetch_texel_1d_f_argb1555, fetch_texel_2d_f_argb1555, - fetch_texel_3d_f_argb1555, - store_texel_argb1555 + fetch_texel_3d_f_argb1555 }, { MESA_FORMAT_ARGB1555_REV, fetch_texel_1d_f_argb1555_rev, fetch_texel_2d_f_argb1555_rev, - fetch_texel_3d_f_argb1555_rev, - store_texel_argb1555_rev + fetch_texel_3d_f_argb1555_rev }, { MESA_FORMAT_AL44, fetch_texel_1d_f_al44, fetch_texel_2d_f_al44, - fetch_texel_3d_f_al44, - store_texel_al44 + fetch_texel_3d_f_al44 }, { MESA_FORMAT_AL88, fetch_texel_1d_f_al88, fetch_texel_2d_f_al88, - fetch_texel_3d_f_al88, - store_texel_al88 + fetch_texel_3d_f_al88 }, { MESA_FORMAT_AL88_REV, fetch_texel_1d_f_al88_rev, fetch_texel_2d_f_al88_rev, - fetch_texel_3d_f_al88_rev, - store_texel_al88_rev + fetch_texel_3d_f_al88_rev }, { MESA_FORMAT_AL1616, fetch_texel_1d_f_al1616, fetch_texel_2d_f_al1616, - fetch_texel_3d_f_al1616, - store_texel_al1616 + fetch_texel_3d_f_al1616 }, { MESA_FORMAT_AL1616_REV, fetch_texel_1d_f_al1616_rev, fetch_texel_2d_f_al1616_rev, - fetch_texel_3d_f_al1616_rev, - store_texel_al1616_rev + fetch_texel_3d_f_al1616_rev }, { MESA_FORMAT_RGB332, fetch_texel_1d_f_rgb332, fetch_texel_2d_f_rgb332, - fetch_texel_3d_f_rgb332, - store_texel_rgb332 + fetch_texel_3d_f_rgb332 }, { MESA_FORMAT_A8, fetch_texel_1d_f_a8, fetch_texel_2d_f_a8, - fetch_texel_3d_f_a8, - store_texel_a8 + fetch_texel_3d_f_a8 }, { MESA_FORMAT_A16, fetch_texel_1d_f_a16, fetch_texel_2d_f_a16, - fetch_texel_3d_f_a16, - store_texel_a16 + fetch_texel_3d_f_a16 }, { MESA_FORMAT_L8, fetch_texel_1d_f_l8, fetch_texel_2d_f_l8, - fetch_texel_3d_f_l8, - store_texel_l8 + fetch_texel_3d_f_l8 }, { MESA_FORMAT_L16, fetch_texel_1d_f_l16, fetch_texel_2d_f_l16, - fetch_texel_3d_f_l16, - store_texel_l16 + fetch_texel_3d_f_l16 }, { MESA_FORMAT_I8, fetch_texel_1d_f_i8, fetch_texel_2d_f_i8, - fetch_texel_3d_f_i8, - store_texel_i8 + fetch_texel_3d_f_i8 }, { MESA_FORMAT_I16, fetch_texel_1d_f_i16, fetch_texel_2d_f_i16, - fetch_texel_3d_f_i16, - store_texel_i16 + fetch_texel_3d_f_i16 }, { MESA_FORMAT_YCBCR, fetch_texel_1d_f_ycbcr, fetch_texel_2d_f_ycbcr, - fetch_texel_3d_f_ycbcr, - store_texel_ycbcr + fetch_texel_3d_f_ycbcr }, { MESA_FORMAT_YCBCR_REV, fetch_texel_1d_f_ycbcr_rev, fetch_texel_2d_f_ycbcr_rev, - fetch_texel_3d_f_ycbcr_rev, - store_texel_ycbcr_rev + fetch_texel_3d_f_ycbcr_rev }, { MESA_FORMAT_R8, fetch_texel_1d_f_r8, fetch_texel_2d_f_r8, - fetch_texel_3d_f_r8, - store_texel_r8, + fetch_texel_3d_f_r8 }, { MESA_FORMAT_GR88, fetch_texel_1d_f_gr88, fetch_texel_2d_f_gr88, - fetch_texel_3d_f_gr88, - store_texel_gr88, + fetch_texel_3d_f_gr88 }, { MESA_FORMAT_RG88, fetch_texel_1d_f_rg88, fetch_texel_2d_f_rg88, - fetch_texel_3d_f_rg88, - store_texel_rg88, + fetch_texel_3d_f_rg88 }, { MESA_FORMAT_R16, fetch_texel_1d_f_r16, fetch_texel_2d_f_r16, - fetch_texel_3d_f_r16, - store_texel_r16, + fetch_texel_3d_f_r16 }, { MESA_FORMAT_RG1616, fetch_texel_1d_f_rg1616, fetch_texel_2d_f_rg1616, - fetch_texel_3d_f_rg1616, - store_texel_rg1616, + fetch_texel_3d_f_rg1616 }, { MESA_FORMAT_RG1616_REV, fetch_texel_1d_f_rg1616_rev, fetch_texel_2d_f_rg1616_rev, - fetch_texel_3d_f_rg1616_rev, - store_texel_rg1616_rev, + fetch_texel_3d_f_rg1616_rev }, { MESA_FORMAT_ARGB2101010, fetch_texel_1d_f_argb2101010, fetch_texel_2d_f_argb2101010, - fetch_texel_3d_f_argb2101010, - store_texel_argb2101010 + fetch_texel_3d_f_argb2101010 }, { MESA_FORMAT_Z24_S8, fetch_texel_1d_f_z24_s8, fetch_texel_2d_f_z24_s8, - fetch_texel_3d_f_z24_s8, - store_texel_z24_s8 + fetch_texel_3d_f_z24_s8 }, { MESA_FORMAT_S8_Z24, fetch_texel_1d_f_s8_z24, fetch_texel_2d_f_s8_z24, - fetch_texel_3d_f_s8_z24, - store_texel_s8_z24 + fetch_texel_3d_f_s8_z24 }, { MESA_FORMAT_Z16, fetch_texel_1d_f_z16, fetch_texel_2d_f_z16, - fetch_texel_3d_f_z16, - store_texel_z16 + fetch_texel_3d_f_z16 }, { MESA_FORMAT_X8_Z24, fetch_texel_1d_f_s8_z24, fetch_texel_2d_f_s8_z24, - fetch_texel_3d_f_s8_z24, - store_texel_s8_z24 + fetch_texel_3d_f_s8_z24 }, { MESA_FORMAT_Z24_X8, fetch_texel_1d_f_z24_s8, fetch_texel_2d_f_z24_s8, - fetch_texel_3d_f_z24_s8, - store_texel_z24_s8 + fetch_texel_3d_f_z24_s8 }, { MESA_FORMAT_Z32, fetch_texel_1d_f_z32, fetch_texel_2d_f_z32, - fetch_texel_3d_f_z32, - store_texel_z32 + fetch_texel_3d_f_z32 }, { MESA_FORMAT_S8, NULL, NULL, - NULL, NULL }, { MESA_FORMAT_SRGB8, fetch_texel_1d_srgb8, fetch_texel_2d_srgb8, - fetch_texel_3d_srgb8, - store_texel_srgb8 + fetch_texel_3d_srgb8 }, { MESA_FORMAT_SRGBA8, fetch_texel_1d_srgba8, fetch_texel_2d_srgba8, - fetch_texel_3d_srgba8, - store_texel_srgba8 + fetch_texel_3d_srgba8 }, { MESA_FORMAT_SARGB8, fetch_texel_1d_sargb8, fetch_texel_2d_sargb8, - fetch_texel_3d_sargb8, - store_texel_sargb8 + fetch_texel_3d_sargb8 }, { MESA_FORMAT_SL8, fetch_texel_1d_sl8, fetch_texel_2d_sl8, - fetch_texel_3d_sl8, - store_texel_sl8 + fetch_texel_3d_sl8 }, { MESA_FORMAT_SLA8, fetch_texel_1d_sla8, fetch_texel_2d_sla8, - fetch_texel_3d_sla8, - store_texel_sla8 + fetch_texel_3d_sla8 }, { MESA_FORMAT_SRGB_DXT1, NULL, _mesa_fetch_texel_2d_f_srgb_dxt1, - NULL, NULL }, { MESA_FORMAT_SRGBA_DXT1, NULL, _mesa_fetch_texel_2d_f_srgba_dxt1, - NULL, NULL }, { MESA_FORMAT_SRGBA_DXT3, NULL, _mesa_fetch_texel_2d_f_srgba_dxt3, - NULL, NULL }, { MESA_FORMAT_SRGBA_DXT5, NULL, _mesa_fetch_texel_2d_f_srgba_dxt5, - NULL, NULL }, @@ -520,162 +452,139 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_RGB_FXT1, NULL, _mesa_fetch_texel_2d_f_rgb_fxt1, - NULL, NULL }, { MESA_FORMAT_RGBA_FXT1, NULL, _mesa_fetch_texel_2d_f_rgba_fxt1, - NULL, NULL }, { MESA_FORMAT_RGB_DXT1, NULL, _mesa_fetch_texel_2d_f_rgb_dxt1, - NULL, NULL }, { MESA_FORMAT_RGBA_DXT1, NULL, _mesa_fetch_texel_2d_f_rgba_dxt1, - NULL, NULL }, { MESA_FORMAT_RGBA_DXT3, NULL, _mesa_fetch_texel_2d_f_rgba_dxt3, - NULL, NULL }, { MESA_FORMAT_RGBA_DXT5, NULL, _mesa_fetch_texel_2d_f_rgba_dxt5, - NULL, NULL }, { MESA_FORMAT_RGBA_FLOAT32, fetch_texel_1d_f_rgba_f32, fetch_texel_2d_f_rgba_f32, - fetch_texel_3d_f_rgba_f32, - store_texel_rgba_f32 + fetch_texel_3d_f_rgba_f32 }, { MESA_FORMAT_RGBA_FLOAT16, fetch_texel_1d_f_rgba_f16, fetch_texel_2d_f_rgba_f16, - fetch_texel_3d_f_rgba_f16, - store_texel_rgba_f16 + fetch_texel_3d_f_rgba_f16 }, { MESA_FORMAT_RGB_FLOAT32, fetch_texel_1d_f_rgb_f32, fetch_texel_2d_f_rgb_f32, - fetch_texel_3d_f_rgb_f32, - store_texel_rgb_f32 + fetch_texel_3d_f_rgb_f32 }, { MESA_FORMAT_RGB_FLOAT16, fetch_texel_1d_f_rgb_f16, fetch_texel_2d_f_rgb_f16, - fetch_texel_3d_f_rgb_f16, - store_texel_rgb_f16 + fetch_texel_3d_f_rgb_f16 }, { MESA_FORMAT_ALPHA_FLOAT32, fetch_texel_1d_f_alpha_f32, fetch_texel_2d_f_alpha_f32, - fetch_texel_3d_f_alpha_f32, - store_texel_alpha_f32 + fetch_texel_3d_f_alpha_f32 }, { MESA_FORMAT_ALPHA_FLOAT16, fetch_texel_1d_f_alpha_f16, fetch_texel_2d_f_alpha_f16, - fetch_texel_3d_f_alpha_f16, - store_texel_alpha_f16 + fetch_texel_3d_f_alpha_f16 }, { MESA_FORMAT_LUMINANCE_FLOAT32, fetch_texel_1d_f_luminance_f32, fetch_texel_2d_f_luminance_f32, - fetch_texel_3d_f_luminance_f32, - store_texel_luminance_f32 + fetch_texel_3d_f_luminance_f32 }, { MESA_FORMAT_LUMINANCE_FLOAT16, fetch_texel_1d_f_luminance_f16, fetch_texel_2d_f_luminance_f16, - fetch_texel_3d_f_luminance_f16, - store_texel_luminance_f16 + fetch_texel_3d_f_luminance_f16 }, { MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, fetch_texel_1d_f_luminance_alpha_f32, fetch_texel_2d_f_luminance_alpha_f32, - fetch_texel_3d_f_luminance_alpha_f32, - store_texel_luminance_alpha_f32 + fetch_texel_3d_f_luminance_alpha_f32 }, { MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, fetch_texel_1d_f_luminance_alpha_f16, fetch_texel_2d_f_luminance_alpha_f16, - fetch_texel_3d_f_luminance_alpha_f16, - store_texel_luminance_alpha_f16 + fetch_texel_3d_f_luminance_alpha_f16 }, { MESA_FORMAT_INTENSITY_FLOAT32, fetch_texel_1d_f_intensity_f32, fetch_texel_2d_f_intensity_f32, - fetch_texel_3d_f_intensity_f32, - store_texel_intensity_f32 + fetch_texel_3d_f_intensity_f32 }, { MESA_FORMAT_INTENSITY_FLOAT16, fetch_texel_1d_f_intensity_f16, fetch_texel_2d_f_intensity_f16, - fetch_texel_3d_f_intensity_f16, - store_texel_intensity_f16 + fetch_texel_3d_f_intensity_f16 }, { MESA_FORMAT_R_FLOAT32, fetch_texel_1d_f_r_f32, fetch_texel_2d_f_r_f32, - fetch_texel_3d_f_r_f32, - store_texel_r_f32 + fetch_texel_3d_f_r_f32 }, { MESA_FORMAT_R_FLOAT16, fetch_texel_1d_f_r_f16, fetch_texel_2d_f_r_f16, - fetch_texel_3d_f_r_f16, - store_texel_r_f16 + fetch_texel_3d_f_r_f16 }, { MESA_FORMAT_RG_FLOAT32, fetch_texel_1d_f_rg_f32, fetch_texel_2d_f_rg_f32, - fetch_texel_3d_f_rg_f32, - store_texel_rg_f32 + fetch_texel_3d_f_rg_f32 }, { MESA_FORMAT_RG_FLOAT16, fetch_texel_1d_f_rg_f16, fetch_texel_2d_f_rg_f16, - fetch_texel_3d_f_rg_f16, - store_texel_rg_f16 + fetch_texel_3d_f_rg_f16 }, { MESA_FORMAT_ALPHA_UINT8, NULL, NULL, - NULL, NULL }, @@ -683,7 +592,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_ALPHA_UINT16, NULL, NULL, - NULL, NULL }, @@ -691,7 +599,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_ALPHA_UINT32, NULL, NULL, - NULL, NULL }, @@ -699,7 +606,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_ALPHA_INT8, NULL, NULL, - NULL, NULL }, @@ -707,7 +613,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_ALPHA_INT16, NULL, NULL, - NULL, NULL }, @@ -715,7 +620,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_ALPHA_INT32, NULL, NULL, - NULL, NULL }, @@ -724,7 +628,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_INTENSITY_UINT8, NULL, NULL, - NULL, NULL }, @@ -732,7 +635,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_INTENSITY_UINT16, NULL, NULL, - NULL, NULL }, @@ -740,7 +642,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_INTENSITY_UINT32, NULL, NULL, - NULL, NULL }, @@ -748,7 +649,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_INTENSITY_INT8, NULL, NULL, - NULL, NULL }, @@ -756,7 +656,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_INTENSITY_INT16, NULL, NULL, - NULL, NULL }, @@ -764,7 +663,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_INTENSITY_INT32, NULL, NULL, - NULL, NULL }, @@ -773,7 +671,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_LUMINANCE_UINT8, NULL, NULL, - NULL, NULL }, @@ -781,7 +678,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_LUMINANCE_UINT16, NULL, NULL, - NULL, NULL }, @@ -789,7 +685,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_LUMINANCE_UINT32, NULL, NULL, - NULL, NULL }, @@ -797,7 +692,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_LUMINANCE_INT8, NULL, NULL, - NULL, NULL }, @@ -805,7 +699,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_LUMINANCE_INT16, NULL, NULL, - NULL, NULL }, @@ -813,7 +706,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_LUMINANCE_INT32, NULL, NULL, - NULL, NULL }, @@ -822,7 +714,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_LUMINANCE_ALPHA_UINT8, NULL, NULL, - NULL, NULL }, @@ -830,7 +721,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_LUMINANCE_ALPHA_UINT16, NULL, NULL, - NULL, NULL }, @@ -838,7 +728,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_LUMINANCE_ALPHA_UINT32, NULL, NULL, - NULL, NULL }, @@ -846,7 +735,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_LUMINANCE_ALPHA_INT8, NULL, NULL, - NULL, NULL }, @@ -854,7 +742,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_LUMINANCE_ALPHA_INT16, NULL, NULL, - NULL, NULL }, @@ -862,7 +749,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_LUMINANCE_ALPHA_INT32, NULL, NULL, - NULL, NULL }, @@ -871,7 +757,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_R_INT8, NULL, NULL, - NULL, NULL }, @@ -879,7 +764,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_RG_INT8, NULL, NULL, - NULL, NULL }, @@ -887,7 +771,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_RGB_INT8, NULL, NULL, - NULL, NULL }, @@ -896,64 +779,55 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_RGBA_INT8, fetch_texel_1d_rgba_int8, fetch_texel_2d_rgba_int8, - fetch_texel_3d_rgba_int8, - store_texel_rgba_int8 + fetch_texel_3d_rgba_int8 }, { MESA_FORMAT_R_INT16, NULL, NULL, - NULL, NULL }, { MESA_FORMAT_RG_INT16, NULL, NULL, - NULL, NULL }, { MESA_FORMAT_RGB_INT16, NULL, NULL, - NULL, NULL }, { MESA_FORMAT_RGBA_INT16, fetch_texel_1d_rgba_int16, fetch_texel_2d_rgba_int16, - fetch_texel_3d_rgba_int16, - store_texel_rgba_int16 + fetch_texel_3d_rgba_int16 }, { MESA_FORMAT_R_INT32, NULL, NULL, - NULL, NULL }, { MESA_FORMAT_RG_INT32, NULL, NULL, - NULL, NULL }, { MESA_FORMAT_RGB_INT32, NULL, NULL, - NULL, NULL }, { MESA_FORMAT_RGBA_INT32, fetch_texel_1d_rgba_int32, fetch_texel_2d_rgba_int32, - fetch_texel_3d_rgba_int32, - store_texel_rgba_int32 + fetch_texel_3d_rgba_int32 }, /* non-normalized, unsigned int */ @@ -961,85 +835,73 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_R_UINT8, NULL, NULL, - NULL, NULL }, { MESA_FORMAT_RG_UINT8, NULL, NULL, - NULL, NULL }, { MESA_FORMAT_RGB_UINT8, NULL, NULL, - NULL, NULL }, { MESA_FORMAT_RGBA_UINT8, fetch_texel_1d_rgba_uint8, fetch_texel_2d_rgba_uint8, - fetch_texel_3d_rgba_uint8, - store_texel_rgba_uint8 + fetch_texel_3d_rgba_uint8 }, { MESA_FORMAT_R_UINT16, NULL, NULL, - NULL, NULL }, { MESA_FORMAT_RG_UINT16, NULL, NULL, - NULL, NULL }, { MESA_FORMAT_RGB_UINT16, NULL, NULL, - NULL, NULL }, { MESA_FORMAT_RGBA_UINT16, fetch_texel_1d_rgba_uint16, fetch_texel_2d_rgba_uint16, - fetch_texel_3d_rgba_uint16, - store_texel_rgba_uint16 + fetch_texel_3d_rgba_uint16 }, { MESA_FORMAT_R_UINT32, NULL, NULL, - NULL, NULL }, { MESA_FORMAT_RG_UINT32, NULL, NULL, - NULL, NULL }, { MESA_FORMAT_RGB_UINT32, NULL, NULL, - NULL, NULL }, { MESA_FORMAT_RGBA_UINT32, fetch_texel_1d_rgba_uint32, fetch_texel_2d_rgba_uint32, - fetch_texel_3d_rgba_uint32, - store_texel_rgba_uint32 + fetch_texel_3d_rgba_uint32 }, /* dudv */ @@ -1047,8 +909,7 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_DUDV8, fetch_texel_1d_dudv8, fetch_texel_2d_dudv8, - fetch_texel_3d_dudv8, - NULL + fetch_texel_3d_dudv8 }, /* signed, normalized */ @@ -1056,224 +917,192 @@ texfetch_funcs[MESA_FORMAT_COUNT] = MESA_FORMAT_SIGNED_R8, fetch_texel_1d_signed_r8, fetch_texel_2d_signed_r8, - fetch_texel_3d_signed_r8, - store_texel_signed_r8 + fetch_texel_3d_signed_r8 }, { MESA_FORMAT_SIGNED_RG88_REV, fetch_texel_1d_signed_rg88_rev, fetch_texel_2d_signed_rg88_rev, - fetch_texel_3d_signed_rg88_rev, - store_texel_signed_rg88_rev + fetch_texel_3d_signed_rg88_rev }, { MESA_FORMAT_SIGNED_RGBX8888, fetch_texel_1d_signed_rgbx8888, fetch_texel_2d_signed_rgbx8888, - fetch_texel_3d_signed_rgbx8888, - store_texel_signed_rgbx8888 + fetch_texel_3d_signed_rgbx8888 }, { MESA_FORMAT_SIGNED_RGBA8888, fetch_texel_1d_signed_rgba8888, fetch_texel_2d_signed_rgba8888, - fetch_texel_3d_signed_rgba8888, - store_texel_signed_rgba8888 + fetch_texel_3d_signed_rgba8888 }, { MESA_FORMAT_SIGNED_RGBA8888_REV, fetch_texel_1d_signed_rgba8888_rev, fetch_texel_2d_signed_rgba8888_rev, - fetch_texel_3d_signed_rgba8888_rev, - store_texel_signed_rgba8888_rev + fetch_texel_3d_signed_rgba8888_rev }, { MESA_FORMAT_SIGNED_R16, fetch_texel_1d_signed_r16, fetch_texel_2d_signed_r16, - fetch_texel_3d_signed_r16, - store_texel_signed_r16 + fetch_texel_3d_signed_r16 }, { MESA_FORMAT_SIGNED_GR1616, fetch_texel_1d_signed_rg1616, fetch_texel_2d_signed_rg1616, - fetch_texel_3d_signed_rg1616, - store_texel_signed_rg1616 + fetch_texel_3d_signed_rg1616 }, { MESA_FORMAT_SIGNED_RGB_16, fetch_texel_1d_signed_rgb_16, fetch_texel_2d_signed_rgb_16, - fetch_texel_3d_signed_rgb_16, - store_texel_signed_rgb_16 + fetch_texel_3d_signed_rgb_16 }, { MESA_FORMAT_SIGNED_RGBA_16, fetch_texel_1d_signed_rgba_16, fetch_texel_2d_signed_rgba_16, - fetch_texel_3d_signed_rgba_16, - store_texel_signed_rgba_16 + fetch_texel_3d_signed_rgba_16 }, { MESA_FORMAT_RGBA_16, fetch_texel_1d_rgba_16, fetch_texel_2d_rgba_16, - fetch_texel_3d_rgba_16, - store_texel_rgba_16 + fetch_texel_3d_rgba_16 }, { MESA_FORMAT_RED_RGTC1, NULL, _mesa_fetch_texel_2d_f_red_rgtc1, - NULL, NULL }, { MESA_FORMAT_SIGNED_RED_RGTC1, NULL, _mesa_fetch_texel_2d_f_signed_red_rgtc1, - NULL, NULL }, { MESA_FORMAT_RG_RGTC2, NULL, _mesa_fetch_texel_2d_f_rg_rgtc2, - NULL, NULL }, { MESA_FORMAT_SIGNED_RG_RGTC2, NULL, _mesa_fetch_texel_2d_f_signed_rg_rgtc2, - NULL, NULL }, { MESA_FORMAT_L_LATC1, NULL, _mesa_fetch_texel_2d_f_l_latc1, - NULL, NULL }, { MESA_FORMAT_SIGNED_L_LATC1, NULL, _mesa_fetch_texel_2d_f_signed_l_latc1, - NULL, NULL }, { MESA_FORMAT_LA_LATC2, NULL, _mesa_fetch_texel_2d_f_la_latc2, - NULL, NULL }, { MESA_FORMAT_SIGNED_LA_LATC2, NULL, _mesa_fetch_texel_2d_f_signed_la_latc2, - NULL, NULL }, { MESA_FORMAT_ETC1_RGB8, NULL, _mesa_fetch_texel_2d_f_etc1_rgb8, - NULL, NULL }, { MESA_FORMAT_SIGNED_A8, fetch_texel_1d_signed_a8, fetch_texel_2d_signed_a8, - fetch_texel_3d_signed_a8, - store_texel_signed_a8 + fetch_texel_3d_signed_a8 }, { MESA_FORMAT_SIGNED_L8, fetch_texel_1d_signed_l8, fetch_texel_2d_signed_l8, - fetch_texel_3d_signed_l8, - store_texel_signed_l8 + fetch_texel_3d_signed_l8 }, { MESA_FORMAT_SIGNED_AL88, fetch_texel_1d_signed_al88, fetch_texel_2d_signed_al88, - fetch_texel_3d_signed_al88, - store_texel_signed_al88 + fetch_texel_3d_signed_al88 }, { MESA_FORMAT_SIGNED_I8, fetch_texel_1d_signed_i8, fetch_texel_2d_signed_i8, - fetch_texel_3d_signed_i8, - store_texel_signed_i8 + fetch_texel_3d_signed_i8 }, { MESA_FORMAT_SIGNED_A16, fetch_texel_1d_signed_a16, fetch_texel_2d_signed_a16, - fetch_texel_3d_signed_a16, - store_texel_signed_a16 + fetch_texel_3d_signed_a16 }, { MESA_FORMAT_SIGNED_L16, fetch_texel_1d_signed_l16, fetch_texel_2d_signed_l16, - fetch_texel_3d_signed_l16, - store_texel_signed_l16 + fetch_texel_3d_signed_l16 }, { MESA_FORMAT_SIGNED_AL1616, fetch_texel_1d_signed_al1616, fetch_texel_2d_signed_al1616, - fetch_texel_3d_signed_al1616, - store_texel_signed_al1616 + fetch_texel_3d_signed_al1616 }, { MESA_FORMAT_SIGNED_I16, fetch_texel_1d_signed_i16, fetch_texel_2d_signed_i16, - fetch_texel_3d_signed_i16, - store_texel_signed_i16 + fetch_texel_3d_signed_i16 }, { MESA_FORMAT_RGB9_E5_FLOAT, fetch_texel_1d_rgb9_e5, fetch_texel_2d_rgb9_e5, - fetch_texel_3d_rgb9_e5, - store_texel_rgb9_e5 + fetch_texel_3d_rgb9_e5 }, { MESA_FORMAT_R11_G11_B10_FLOAT, fetch_texel_1d_r11_g11_b10f, fetch_texel_2d_r11_g11_b10f, - fetch_texel_3d_r11_g11_b10f, - store_texel_r11_g11_b10f + fetch_texel_3d_r11_g11_b10f }, { MESA_FORMAT_Z32_FLOAT, fetch_texel_1d_f_r_f32, /* Reuse the R32F functions. */ fetch_texel_2d_f_r_f32, - fetch_texel_3d_f_r_f32, - store_texel_r_f32 + fetch_texel_3d_f_r_f32 }, { MESA_FORMAT_Z32_FLOAT_X24S8, fetch_texel_1d_z32f_x24s8, fetch_texel_2d_z32f_x24s8, - fetch_texel_3d_z32f_x24s8, - store_texel_z32f_x24s8 + fetch_texel_3d_z32f_x24s8 }, { MESA_FORMAT_ARGB2101010_UINT, NULL, NULL, - NULL, NULL } }; @@ -1308,14 +1137,6 @@ _mesa_get_texel_fetch_func(gl_format format, GLuint dims) } -StoreTexelFunc -_mesa_get_texel_store_func(gl_format format) -{ - assert(format < MESA_FORMAT_COUNT); - return texfetch_funcs[format].StoreTexel; -} - - /** * Initialize the texture image's FetchTexel methods. */ diff --git a/mesalib/src/mesa/swrast/s_texfetch.h b/mesalib/src/mesa/swrast/s_texfetch.h index c98aa5c5a..1aa7ce573 100644 --- a/mesalib/src/mesa/swrast/s_texfetch.h +++ b/mesalib/src/mesa/swrast/s_texfetch.h @@ -29,9 +29,6 @@ #include "swrast/s_context.h" -extern StoreTexelFunc -_mesa_get_texel_store_func(gl_format format); - extern FetchTexelFunc _mesa_get_texel_fetch_func(gl_format format, GLuint dims); diff --git a/mesalib/src/mesa/swrast/s_texfetch_tmp.h b/mesalib/src/mesa/swrast/s_texfetch_tmp.h index 877c29c9b..b65d33f04 100644 --- a/mesalib/src/mesa/swrast/s_texfetch_tmp.h +++ b/mesalib/src/mesa/swrast/s_texfetch_tmp.h @@ -43,7 +43,7 @@ #if DIM == 1 #define TEXEL_ADDR( type, image, i, j, k, size ) \ - ((void) (j), (void) (k), ((type *)(image)->Data + (i) * (size))) + ((void) (j), (void) (k), ((type *)(image)->Map + (i) * (size))) #define FETCH(x) fetch_texel_1d_##x @@ -51,14 +51,14 @@ #define TEXEL_ADDR( type, image, i, j, k, size ) \ ((void) (k), \ - ((type *)(image)->Data + ((image)->RowStride * (j) + (i)) * (size))) + ((type *)(image)->Map + ((image)->RowStride * (j) + (i)) * (size))) #define FETCH(x) fetch_texel_2d_##x #elif DIM == 3 #define TEXEL_ADDR( type, image, i, j, k, size ) \ - ((type *)(image)->Data + ((image)->ImageOffsets[k] \ + ((type *)(image)->Map + ((image)->ImageOffsets[k] \ + (image)->RowStride * (j) + (i)) * (size)) #define FETCH(x) fetch_texel_3d_##x @@ -81,16 +81,6 @@ static void FETCH(f_z32)( const struct swrast_texture_image *texImage, texel[0] = src[0] * (1.0F / 0xffffffff); } -#if DIM == 3 -static void store_texel_z32(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLuint *depth = (const GLuint *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - dst[0] = *depth; -} -#endif - /* MESA_FORMAT_Z16 ***********************************************************/ @@ -105,15 +95,6 @@ static void FETCH(f_z16)(const struct swrast_texture_image *texImage, texel[0] = src[0] * (1.0F / 65535.0F); } -#if DIM == 3 -static void store_texel_z16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLushort *depth = (const GLushort *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - dst[0] = *depth; -} -#endif /* MESA_FORMAT_RGBA_F32 ******************************************************/ @@ -130,18 +111,7 @@ static void FETCH(f_rgba_f32)( const struct swrast_texture_image *texImage, texel[ACOMP] = src[3]; } -#if DIM == 3 -static void store_texel_rgba_f32(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *depth = (const GLfloat *) texel; - GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 4); - dst[0] = depth[RCOMP]; - dst[1] = depth[GCOMP]; - dst[2] = depth[BCOMP]; - dst[3] = depth[ACOMP]; -} -#endif + /* MESA_FORMAT_RGBA_F16 ******************************************************/ @@ -159,18 +129,7 @@ static void FETCH(f_rgba_f16)( const struct swrast_texture_image *texImage, texel[ACOMP] = _mesa_half_to_float(src[3]); } -#if DIM == 3 -static void store_texel_rgba_f16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *src = (const GLfloat *) texel; - GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 4); - dst[0] = _mesa_float_to_half(src[RCOMP]); - dst[1] = _mesa_float_to_half(src[GCOMP]); - dst[2] = _mesa_float_to_half(src[BCOMP]); - dst[3] = _mesa_float_to_half(src[ACOMP]); -} -#endif + /* MESA_FORMAT_RGB_F32 *******************************************************/ @@ -187,17 +146,7 @@ static void FETCH(f_rgb_f32)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_rgb_f32(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *src = (const GLfloat *) texel; - GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 3); - dst[0] = src[RCOMP]; - dst[1] = src[GCOMP]; - dst[2] = src[BCOMP]; -} -#endif + /* MESA_FORMAT_RGB_F16 *******************************************************/ @@ -215,17 +164,7 @@ static void FETCH(f_rgb_f16)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_rgb_f16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *src = (const GLfloat *) texel; - GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 3); - dst[0] = _mesa_float_to_half(src[RCOMP]); - dst[1] = _mesa_float_to_half(src[GCOMP]); - dst[2] = _mesa_float_to_half(src[BCOMP]); -} -#endif + /* MESA_FORMAT_ALPHA_F32 *****************************************************/ @@ -243,15 +182,7 @@ static void FETCH(f_alpha_f32)( const struct swrast_texture_image *texImage, texel[ACOMP] = src[0]; } -#if DIM == 3 -static void store_texel_alpha_f32(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *rgba = (const GLfloat *) texel; - GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); - dst[0] = rgba[ACOMP]; -} -#endif + /* MESA_FORMAT_ALPHA_F32 *****************************************************/ @@ -269,15 +200,7 @@ static void FETCH(f_alpha_f16)( const struct swrast_texture_image *texImage, texel[ACOMP] = _mesa_half_to_float(src[0]); } -#if DIM == 3 -static void store_texel_alpha_f16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *rgba = (const GLfloat *) texel; - GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); - dst[0] = _mesa_float_to_half(rgba[ACOMP]); -} -#endif + /* MESA_FORMAT_LUMINANCE_F32 *************************************************/ @@ -295,15 +218,7 @@ static void FETCH(f_luminance_f32)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_luminance_f32(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *rgba = (const GLfloat *) texel; - GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); - dst[0] = rgba[RCOMP]; -} -#endif + /* MESA_FORMAT_LUMINANCE_F16 *************************************************/ @@ -321,15 +236,7 @@ static void FETCH(f_luminance_f16)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_luminance_f16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *rgba = (const GLfloat *) texel; - GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); - dst[0] = _mesa_float_to_half(rgba[RCOMP]); -} -#endif + /* MESA_FORMAT_LUMINANCE_ALPHA_F32 *******************************************/ @@ -347,16 +254,7 @@ static void FETCH(f_luminance_alpha_f32)( const struct swrast_texture_image *tex texel[ACOMP] = src[1]; } -#if DIM == 3 -static void store_texel_luminance_alpha_f32(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *rgba = (const GLfloat *) texel; - GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[ACOMP]; -} -#endif + /* MESA_FORMAT_LUMINANCE_ALPHA_F16 *******************************************/ @@ -374,16 +272,7 @@ static void FETCH(f_luminance_alpha_f16)( const struct swrast_texture_image *tex texel[ACOMP] = _mesa_half_to_float(src[1]); } -#if DIM == 3 -static void store_texel_luminance_alpha_f16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *rgba = (const GLfloat *) texel; - GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2); - dst[0] = _mesa_float_to_half(rgba[RCOMP]); - dst[1] = _mesa_float_to_half(rgba[ACOMP]); -} -#endif + /* MESA_FORMAT_INTENSITY_F32 *************************************************/ @@ -401,15 +290,7 @@ static void FETCH(f_intensity_f32)( const struct swrast_texture_image *texImage, texel[ACOMP] = src[0]; } -#if DIM == 3 -static void store_texel_intensity_f32(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *rgba = (const GLfloat *) texel; - GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); - dst[0] = rgba[RCOMP]; -} -#endif + /* MESA_FORMAT_INTENSITY_F16 *************************************************/ @@ -427,15 +308,7 @@ static void FETCH(f_intensity_f16)( const struct swrast_texture_image *texImage, texel[ACOMP] = _mesa_half_to_float(src[0]); } -#if DIM == 3 -static void store_texel_intensity_f16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *rgba = (const GLfloat *) texel; - GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); - dst[0] = _mesa_float_to_half(rgba[RCOMP]); -} -#endif + /* MESA_FORMAT_R_FLOAT32 *****************************************************/ @@ -453,15 +326,7 @@ static void FETCH(f_r_f32)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_r_f32(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *rgba = (const GLfloat *) texel; - GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); - dst[0] = rgba[RCOMP]; -} -#endif + /* MESA_FORMAT_R_FLOAT16 *****************************************************/ @@ -479,15 +344,7 @@ static void FETCH(f_r_f16)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_r_f16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *rgba = (const GLfloat *) texel; - GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); - dst[0] = _mesa_float_to_half(rgba[RCOMP]); -} -#endif + /* MESA_FORMAT_RG_FLOAT32 ****************************************************/ @@ -505,16 +362,7 @@ static void FETCH(f_rg_f32)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_rg_f32(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *rgba = (const GLfloat *) texel; - GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[GCOMP]; -} -#endif + /* MESA_FORMAT_RG_FLOAT16 ****************************************************/ @@ -532,16 +380,7 @@ static void FETCH(f_rg_f16)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_rg_f16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *rgba = (const GLfloat *) texel; - GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2); - dst[0] = _mesa_float_to_half(rgba[RCOMP]); - dst[1] = _mesa_float_to_half(rgba[GCOMP]); -} -#endif + /* @@ -563,15 +402,7 @@ static void FETCH(f_rgba8888)( const struct swrast_texture_image *texImage, -#if DIM == 3 -static void store_texel_rgba8888(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); -} -#endif + /* MESA_FORMAT_RGBA888_REV ***************************************************/ @@ -587,15 +418,7 @@ static void FETCH(f_rgba8888_rev)( const struct swrast_texture_image *texImage, texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); } -#if DIM == 3 -static void store_texel_rgba8888_rev(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); -} -#endif + /* MESA_FORMAT_ARGB8888 ******************************************************/ @@ -611,15 +434,7 @@ static void FETCH(f_argb8888)( const struct swrast_texture_image *texImage, texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); } -#if DIM == 3 -static void store_texel_argb8888(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); -} -#endif + /* MESA_FORMAT_ARGB8888_REV **************************************************/ @@ -635,15 +450,7 @@ static void FETCH(f_argb8888_rev)( const struct swrast_texture_image *texImage, texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); } -#if DIM == 3 -static void store_texel_argb8888_rev(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP], rgba[ACOMP]); -} -#endif + /* MESA_FORMAT_RGBX8888 ******************************************************/ @@ -659,15 +466,7 @@ static void FETCH(f_rgbx8888)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0f; } -#if DIM == 3 -static void store_texel_rgbx8888(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], 0xff); -} -#endif + /* MESA_FORMAT_RGBX888_REV ***************************************************/ @@ -683,15 +482,7 @@ static void FETCH(f_rgbx8888_rev)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0f; } -#if DIM == 3 -static void store_texel_rgbx8888_rev(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], 0xff); -} -#endif + /* MESA_FORMAT_XRGB8888 ******************************************************/ @@ -707,15 +498,7 @@ static void FETCH(f_xrgb8888)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0f; } -#if DIM == 3 -static void store_texel_xrgb8888(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888(0xff, rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); -} -#endif + /* MESA_FORMAT_XRGB8888_REV **************************************************/ @@ -731,15 +514,7 @@ static void FETCH(f_xrgb8888_rev)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0f; } -#if DIM == 3 -static void store_texel_xrgb8888_rev(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP], 0xff); -} -#endif + /* MESA_FORMAT_RGB888 ********************************************************/ @@ -755,17 +530,7 @@ static void FETCH(f_rgb888)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_rgb888(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); - dst[0] = rgba[BCOMP]; - dst[1] = rgba[GCOMP]; - dst[2] = rgba[RCOMP]; -} -#endif + /* MESA_FORMAT_BGR888 ********************************************************/ @@ -781,17 +546,7 @@ static void FETCH(f_bgr888)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_bgr888(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[GCOMP]; - dst[2] = rgba[BCOMP]; -} -#endif + /* use color expansion like (g << 2) | (g >> 4) (does somewhat random rounding) @@ -811,15 +566,7 @@ static void FETCH(f_rgb565)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_rgb565(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = PACK_COLOR_565(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); -} -#endif + /* MESA_FORMAT_RGB565_REV ****************************************************/ @@ -836,18 +583,7 @@ static void FETCH(f_rgb565_rev)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_rgb565_rev(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLchan *rgba = (const GLchan *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - GLushort p = PACK_COLOR_565(CHAN_TO_UBYTE(rgba[RCOMP]), - CHAN_TO_UBYTE(rgba[GCOMP]), - CHAN_TO_UBYTE(rgba[BCOMP])); - *dst = (p >> 8) | (p << 8); /* byte swap */ -} -#endif + /* MESA_FORMAT_ARGB4444 ******************************************************/ @@ -864,18 +600,7 @@ static void FETCH(f_argb4444)( const struct swrast_texture_image *texImage, texel[ACOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F); } -#if DIM == 3 -static void store_texel_argb4444(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLchan *rgba = (const GLchan *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = PACK_COLOR_4444(CHAN_TO_UBYTE(rgba[ACOMP]), - CHAN_TO_UBYTE(rgba[RCOMP]), - CHAN_TO_UBYTE(rgba[GCOMP]), - CHAN_TO_UBYTE(rgba[BCOMP])); -} -#endif + /* MESA_FORMAT_ARGB4444_REV **************************************************/ @@ -891,18 +616,7 @@ static void FETCH(f_argb4444_rev)( const struct swrast_texture_image *texImage, texel[ACOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F); } -#if DIM == 3 -static void store_texel_argb4444_rev(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLchan *rgba = (const GLchan *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = PACK_COLOR_4444(CHAN_TO_UBYTE(rgba[GCOMP]), - CHAN_TO_UBYTE(rgba[BCOMP]), - CHAN_TO_UBYTE(rgba[ACOMP]), - CHAN_TO_UBYTE(rgba[RCOMP])); -} -#endif + /* MESA_FORMAT_RGBA5551 ******************************************************/ @@ -918,15 +632,7 @@ static void FETCH(f_rgba5551)( const struct swrast_texture_image *texImage, texel[ACOMP] = ((s ) & 0x01) * 1.0F; } -#if DIM == 3 -static void store_texel_rgba5551(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = PACK_COLOR_5551(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); -} -#endif + /* MESA_FORMAT_ARGB1555 ******************************************************/ @@ -942,15 +648,7 @@ static void FETCH(f_argb1555)( const struct swrast_texture_image *texImage, texel[ACOMP] = ((s >> 15) & 0x01) * 1.0F; } -#if DIM == 3 -static void store_texel_argb1555(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = PACK_COLOR_1555(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); -} -#endif + /* MESA_FORMAT_ARGB1555_REV **************************************************/ @@ -967,15 +665,7 @@ static void FETCH(f_argb1555_rev)( const struct swrast_texture_image *texImage, texel[ACOMP] = UBYTE_TO_FLOAT( ((s >> 15) & 0x01) * 255 ); } -#if DIM == 3 -static void store_texel_argb1555_rev(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = PACK_COLOR_1555_REV(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); -} -#endif + /* MESA_FORMAT_ARGB2101010 ***************************************************/ @@ -992,19 +682,7 @@ static void FETCH(f_argb2101010)( const struct swrast_texture_image *texImage, texel[ACOMP] = ((s >> 30) & 0x03) * (1.0F / 3.0F); } -#if DIM == 3 -static void store_texel_argb2101010(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLchan *rgba = (const GLchan *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - GLushort r = CHAN_TO_USHORT(rgba[RCOMP]); - GLushort g = CHAN_TO_USHORT(rgba[GCOMP]); - GLushort b = CHAN_TO_USHORT(rgba[BCOMP]); - GLushort a = CHAN_TO_USHORT(rgba[ACOMP]); - *dst = PACK_COLOR_2101010_US(a, r, g, b); -} -#endif + /* MESA_FORMAT_GR88 **********************************************************/ @@ -1020,17 +698,7 @@ static void FETCH(f_gr88)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0; } -#if DIM == 3 -static void store_texel_gr88(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLchan *rgba = (const GLchan *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - GLubyte r = CHAN_TO_UBYTE(rgba[RCOMP]); - GLubyte g = CHAN_TO_UBYTE(rgba[GCOMP]); - *dst = PACK_COLOR_88(g, r); -} -#endif + /* MESA_FORMAT_RG88 ******************************************************/ @@ -1046,15 +714,7 @@ static void FETCH(f_rg88)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0; } -#if DIM == 3 -static void store_texel_rg88(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = PACK_COLOR_88(rgba[RCOMP], rgba[GCOMP]); -} -#endif + /* MESA_FORMAT_AL44 **********************************************************/ @@ -1070,15 +730,7 @@ static void FETCH(f_al44)( const struct swrast_texture_image *texImage, texel[ACOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F); } -#if DIM == 3 -static void store_texel_al44(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - *dst = PACK_COLOR_44(rgba[ACOMP], rgba[RCOMP]); -} -#endif + /* MESA_FORMAT_AL88 **********************************************************/ @@ -1094,15 +746,7 @@ static void FETCH(f_al88)( const struct swrast_texture_image *texImage, texel[ACOMP] = UBYTE_TO_FLOAT( s >> 8 ); } -#if DIM == 3 -static void store_texel_al88(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = PACK_COLOR_88(rgba[ACOMP], rgba[RCOMP]); -} -#endif + /* MESA_FORMAT_R8 ************************************************************/ @@ -1118,15 +762,7 @@ static void FETCH(f_r8)(const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0; } -#if DIM == 3 -static void store_texel_r8(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - *dst = rgba[RCOMP]; -} -#endif + /* MESA_FORMAT_R16 ***********************************************************/ @@ -1142,15 +778,7 @@ static void FETCH(f_r16)(const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0; } -#if DIM == 3 -static void store_texel_r16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLchan *rgba = (const GLchan *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = CHAN_TO_USHORT(rgba[RCOMP]); -} -#endif + /* MESA_FORMAT_AL88_REV ******************************************************/ @@ -1166,15 +794,7 @@ static void FETCH(f_al88_rev)( const struct swrast_texture_image *texImage, texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xff ); } -#if DIM == 3 -static void store_texel_al88_rev(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = PACK_COLOR_88(rgba[RCOMP], rgba[ACOMP]); -} -#endif + /* MESA_FORMAT_RG1616 ********************************************************/ @@ -1190,17 +810,7 @@ static void FETCH(f_rg1616)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0; } -#if DIM == 3 -static void store_texel_rg1616(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLchan *rgba = (const GLchan *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - GLushort r = CHAN_TO_USHORT(rgba[RCOMP]); - GLushort g = CHAN_TO_USHORT(rgba[GCOMP]); - *dst = PACK_COLOR_1616(g, r); -} -#endif + /* MESA_FORMAT_RG1616_REV ****************************************************/ @@ -1216,15 +826,7 @@ static void FETCH(f_rg1616_rev)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0; } -#if DIM == 3 -static void store_texel_rg1616_rev(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = PACK_COLOR_1616(rgba[GCOMP], rgba[RCOMP]); -} -#endif + /* MESA_FORMAT_AL1616 ********************************************************/ @@ -1240,17 +842,7 @@ static void FETCH(f_al1616)( const struct swrast_texture_image *texImage, texel[ACOMP] = USHORT_TO_FLOAT( s >> 16 ); } -#if DIM == 3 -static void store_texel_al1616(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLchan *rgba = (const GLchan *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - GLushort l = CHAN_TO_USHORT(rgba[RCOMP]); - GLushort a = CHAN_TO_USHORT(rgba[ACOMP]); - *dst = PACK_COLOR_1616(a, l); -} -#endif + /* MESA_FORMAT_AL1616_REV ****************************************************/ @@ -1266,15 +858,7 @@ static void FETCH(f_al1616_rev)( const struct swrast_texture_image *texImage, texel[ACOMP] = USHORT_TO_FLOAT( s & 0xffff ); } -#if DIM == 3 -static void store_texel_al1616_rev(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLushort *rgba = (const GLushort *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_1616(rgba[RCOMP], rgba[ACOMP]); -} -#endif + /* MESA_FORMAT_RGB332 ********************************************************/ @@ -1291,15 +875,7 @@ static void FETCH(f_rgb332)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_rgb332(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - *dst = PACK_COLOR_332(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); -} -#endif + /* MESA_FORMAT_A8 ************************************************************/ @@ -1315,15 +891,7 @@ static void FETCH(f_a8)( const struct swrast_texture_image *texImage, texel[ACOMP] = UBYTE_TO_FLOAT( src[0] ); } -#if DIM == 3 -static void store_texel_a8(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - *dst = rgba[ACOMP]; -} -#endif + /* MESA_FORMAT_A16 ************************************************************/ @@ -1339,15 +907,7 @@ static void FETCH(f_a16)( const struct swrast_texture_image *texImage, texel[ACOMP] = USHORT_TO_FLOAT( src[0] ); } -#if DIM == 3 -static void store_texel_a16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLchan *rgba = (const GLchan *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = CHAN_TO_USHORT(rgba[ACOMP]); -} -#endif + /* MESA_FORMAT_L8 ************************************************************/ @@ -1363,15 +923,7 @@ static void FETCH(f_l8)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_l8(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - *dst = rgba[RCOMP]; -} -#endif + /* MESA_FORMAT_L16 ***********************************************************/ @@ -1387,15 +939,7 @@ static void FETCH(f_l16)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_l16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLchan *rgba = (const GLchan *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = CHAN_TO_USHORT(rgba[RCOMP]); -} -#endif + /* MESA_FORMAT_I8 ************************************************************/ @@ -1411,15 +955,7 @@ static void FETCH(f_i8)( const struct swrast_texture_image *texImage, texel[ACOMP] = UBYTE_TO_FLOAT( src[0] ); } -#if DIM == 3 -static void store_texel_i8(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - *dst = rgba[RCOMP]; -} -#endif + /* MESA_FORMAT_I16 ***********************************************************/ @@ -1435,15 +971,7 @@ static void FETCH(f_i16)( const struct swrast_texture_image *texImage, texel[ACOMP] = USHORT_TO_FLOAT( src[0] ); } -#if DIM == 3 -static void store_texel_i16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLchan *rgba = (const GLchan *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = CHAN_TO_USHORT(rgba[RCOMP]); -} -#endif + /* Fetch texel from 1D, 2D or 3D srgb8 texture, return 4 GLfloats */ @@ -1458,17 +986,7 @@ static void FETCH(srgb8)(const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_srgb8(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); - dst[0] = rgba[BCOMP]; /* no conversion */ - dst[1] = rgba[GCOMP]; - dst[2] = rgba[RCOMP]; -} -#endif + /* Fetch texel from 1D, 2D or 3D srgba8 texture, return 4 GLfloats */ static void FETCH(srgba8)(const struct swrast_texture_image *texImage, @@ -1481,15 +999,7 @@ static void FETCH(srgba8)(const struct swrast_texture_image *texImage, texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); /* linear! */ } -#if DIM == 3 -static void store_texel_srgba8(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); -} -#endif + /* Fetch texel from 1D, 2D or 3D sargb8 texture, return 4 GLfloats */ static void FETCH(sargb8)(const struct swrast_texture_image *texImage, @@ -1502,15 +1012,7 @@ static void FETCH(sargb8)(const struct swrast_texture_image *texImage, texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); /* linear! */ } -#if DIM == 3 -static void store_texel_sargb8(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); -} -#endif + /* Fetch texel from 1D, 2D or 3D sl8 texture, return 4 GLfloats */ static void FETCH(sl8)(const struct swrast_texture_image *texImage, @@ -1523,15 +1025,7 @@ static void FETCH(sl8)(const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_sl8(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - dst[0] = rgba[RCOMP]; -} -#endif + /* Fetch texel from 1D, 2D or 3D sla8 texture, return 4 GLfloats */ static void FETCH(sla8)(const struct swrast_texture_image *texImage, @@ -1544,16 +1038,7 @@ static void FETCH(sla8)(const struct swrast_texture_image *texImage, texel[ACOMP] = UBYTE_TO_FLOAT(src[1]); /* linear */ } -#if DIM == 3 -static void store_texel_sla8(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 2); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[ACOMP]; -} -#endif + /* MESA_FORMAT_RGBA_INT8 **************************************************/ @@ -1569,19 +1054,7 @@ FETCH(rgba_int8)(const struct swrast_texture_image *texImage, texel[ACOMP] = (GLfloat) src[3]; } -#if DIM == 3 -static void -store_texel_rgba_int8(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLbyte *rgba = (const GLbyte *) texel; - GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 4); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[GCOMP]; - dst[2] = rgba[BCOMP]; - dst[3] = rgba[ACOMP]; -} -#endif + /* MESA_FORMAT_RGBA_INT16 **************************************************/ @@ -1597,19 +1070,7 @@ FETCH(rgba_int16)(const struct swrast_texture_image *texImage, texel[ACOMP] = (GLfloat) src[3]; } -#if DIM == 3 -static void -store_texel_rgba_int16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLshort *rgba = (const GLshort *) texel; - GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 4); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[GCOMP]; - dst[2] = rgba[BCOMP]; - dst[3] = rgba[ACOMP]; -} -#endif + /* MESA_FORMAT_RGBA_INT32 **************************************************/ @@ -1625,19 +1086,7 @@ FETCH(rgba_int32)(const struct swrast_texture_image *texImage, texel[ACOMP] = (GLfloat) src[3]; } -#if DIM == 3 -static void -store_texel_rgba_int32(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLint *rgba = (const GLint *) texel; - GLint *dst = TEXEL_ADDR(GLint, texImage, i, j, k, 4); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[GCOMP]; - dst[2] = rgba[BCOMP]; - dst[3] = rgba[ACOMP]; -} -#endif + /* MESA_FORMAT_RGBA_UINT8 **************************************************/ @@ -1653,19 +1102,7 @@ FETCH(rgba_uint8)(const struct swrast_texture_image *texImage, texel[ACOMP] = (GLfloat) src[3]; } -#if DIM == 3 -static void -store_texel_rgba_uint8(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[GCOMP]; - dst[2] = rgba[BCOMP]; - dst[3] = rgba[ACOMP]; -} -#endif + /* MESA_FORMAT_RGBA_UINT16 **************************************************/ @@ -1681,19 +1118,7 @@ FETCH(rgba_uint16)(const struct swrast_texture_image *texImage, texel[ACOMP] = (GLfloat) src[3]; } -#if DIM == 3 -static void -store_texel_rgba_uint16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLushort *rgba = (const GLushort *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 4); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[GCOMP]; - dst[2] = rgba[BCOMP]; - dst[3] = rgba[ACOMP]; -} -#endif + /* MESA_FORMAT_RGBA_UINT32 **************************************************/ @@ -1709,19 +1134,7 @@ FETCH(rgba_uint32)(const struct swrast_texture_image *texImage, texel[ACOMP] = (GLfloat) src[3]; } -#if DIM == 3 -static void -store_texel_rgba_uint32(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLuint *rgba = (const GLuint *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 4); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[GCOMP]; - dst[2] = rgba[BCOMP]; - dst[3] = rgba[ACOMP]; -} -#endif + /* MESA_FORMAT_DUDV8 ********************************************************/ @@ -1751,15 +1164,7 @@ static void FETCH(signed_r8)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_signed_r8(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLbyte *rgba = (const GLbyte *) texel; - GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1); - *dst = rgba[RCOMP]; -} -#endif + /* MESA_FORMAT_SIGNED_A8 ***********************************************/ @@ -1774,15 +1179,7 @@ static void FETCH(signed_a8)( const struct swrast_texture_image *texImage, texel[ACOMP] = BYTE_TO_FLOAT_TEX( s ); } -#if DIM == 3 -static void store_texel_signed_a8(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLbyte *rgba = (const GLbyte *) texel; - GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1); - *dst = rgba[ACOMP]; -} -#endif + /* MESA_FORMAT_SIGNED_L8 ***********************************************/ @@ -1797,15 +1194,7 @@ static void FETCH(signed_l8)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_signed_l8(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLbyte *rgba = (const GLbyte *) texel; - GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1); - *dst = rgba[RCOMP]; -} -#endif + /* MESA_FORMAT_SIGNED_I8 ***********************************************/ @@ -1820,15 +1209,7 @@ static void FETCH(signed_i8)( const struct swrast_texture_image *texImage, texel[ACOMP] = BYTE_TO_FLOAT_TEX( s ); } -#if DIM == 3 -static void store_texel_signed_i8(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLbyte *rgba = (const GLbyte *) texel; - GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1); - *dst = rgba[RCOMP]; -} -#endif + /* MESA_FORMAT_SIGNED_RG88_REV ***********************************************/ @@ -1843,15 +1224,7 @@ static void FETCH(signed_rg88_rev)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_signed_rg88_rev(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLbyte *rg = (const GLbyte *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - dst[0] = PACK_COLOR_88(rg[GCOMP], rg[RCOMP]); -} -#endif + /* MESA_FORMAT_SIGNED_AL88 ***********************************************/ @@ -1866,15 +1239,7 @@ static void FETCH(signed_al88)( const struct swrast_texture_image *texImage, texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) ); } -#if DIM == 3 -static void store_texel_signed_al88(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLbyte *rg = (const GLbyte *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - dst[0] = PACK_COLOR_88(rg[ACOMP], rg[RCOMP]); -} -#endif + /* MESA_FORMAT_SIGNED_RGBX8888 ***********************************************/ @@ -1889,15 +1254,7 @@ static void FETCH(signed_rgbx8888)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0f; } -#if DIM == 3 -static void store_texel_signed_rgbx8888(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLbyte *rgba = (const GLbyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], 255); -} -#endif + /* MESA_FORMAT_SIGNED_RGBA8888 ***********************************************/ @@ -1912,15 +1269,7 @@ static void FETCH(signed_rgba8888)( const struct swrast_texture_image *texImage, texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s ) ); } -#if DIM == 3 -static void store_texel_signed_rgba8888(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLbyte *rgba = (const GLbyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); -} -#endif + static void FETCH(signed_rgba8888_rev)( const struct swrast_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) @@ -1932,15 +1281,7 @@ static void FETCH(signed_rgba8888_rev)( const struct swrast_texture_image *texIm texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) ); } -#if DIM == 3 -static void store_texel_signed_rgba8888_rev(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); -} -#endif + @@ -1957,16 +1298,7 @@ FETCH(signed_r16)(const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void -store_texel_signed_r16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLshort *rgba = (const GLshort *) texel; - GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1); - *dst = rgba[0]; -} -#endif + /* MESA_FORMAT_SIGNED_A16 ***********************************************/ @@ -1982,16 +1314,7 @@ FETCH(signed_a16)(const struct swrast_texture_image *texImage, texel[ACOMP] = SHORT_TO_FLOAT_TEX( s ); } -#if DIM == 3 -static void -store_texel_signed_a16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLshort *rgba = (const GLshort *) texel; - GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1); - *dst = rgba[ACOMP]; -} -#endif + /* MESA_FORMAT_SIGNED_L16 ***********************************************/ @@ -2007,16 +1330,7 @@ FETCH(signed_l16)(const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void -store_texel_signed_l16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLshort *rgba = (const GLshort *) texel; - GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1); - *dst = rgba[RCOMP]; -} -#endif + /* MESA_FORMAT_SIGNED_I16 ***********************************************/ @@ -2032,16 +1346,7 @@ FETCH(signed_i16)(const struct swrast_texture_image *texImage, texel[ACOMP] = SHORT_TO_FLOAT_TEX( s ); } -#if DIM == 3 -static void -store_texel_signed_i16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLshort *rgba = (const GLshort *) texel; - GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1); - *dst = rgba[RCOMP]; -} -#endif + /* MESA_FORMAT_SIGNED_RG1616 ***********************************************/ @@ -2057,17 +1362,7 @@ FETCH(signed_rg1616)(const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void -store_texel_signed_rg1616(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLchan *rgba = (const GLchan *) texel; - GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 2); - dst[0] = CHAN_TO_SHORT(rgba[RCOMP]); - dst[1] = CHAN_TO_SHORT(rgba[GCOMP]); -} -#endif + /* MESA_FORMAT_SIGNED_AL1616 ***********************************************/ @@ -2083,17 +1378,7 @@ FETCH(signed_al1616)(const struct swrast_texture_image *texImage, texel[ACOMP] = SHORT_TO_FLOAT_TEX( s[1] ); } -#if DIM == 3 -static void -store_texel_signed_al1616(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLchan *rgba = (const GLchan *) texel; - GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 2); - dst[0] = CHAN_TO_SHORT(rgba[RCOMP]); - dst[1] = CHAN_TO_SHORT(rgba[ACOMP]); -} -#endif + /* MESA_FORMAT_SIGNED_RGB_16 ***********************************************/ @@ -2109,18 +1394,7 @@ FETCH(signed_rgb_16)(const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void -store_texel_signed_rgb_16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLchan *rgba = (const GLchan *) texel; - GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 3); - dst[0] = CHAN_TO_SHORT(rgba[RCOMP]); - dst[1] = CHAN_TO_SHORT(rgba[GCOMP]); - dst[2] = CHAN_TO_SHORT(rgba[BCOMP]); -} -#endif + /* MESA_FORMAT_SIGNED_RGBA_16 ***********************************************/ @@ -2136,19 +1410,7 @@ FETCH(signed_rgba_16)(const struct swrast_texture_image *texImage, texel[ACOMP] = SHORT_TO_FLOAT_TEX( s[3] ); } -#if DIM == 3 -static void -store_texel_signed_rgba_16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLchan *rgba = (const GLchan *) texel; - GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 4); - dst[0] = CHAN_TO_SHORT(rgba[RCOMP]); - dst[1] = CHAN_TO_SHORT(rgba[GCOMP]); - dst[2] = CHAN_TO_SHORT(rgba[BCOMP]); - dst[3] = CHAN_TO_SHORT(rgba[ACOMP]); -} -#endif + @@ -2165,19 +1427,7 @@ FETCH(rgba_16)(const struct swrast_texture_image *texImage, texel[ACOMP] = USHORT_TO_FLOAT( s[3] ); } -#if DIM == 3 -static void -store_texel_rgba_16(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLchan *rgba = (const GLchan *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 4); - dst[0] = CHAN_TO_USHORT(rgba[RCOMP]); - dst[1] = CHAN_TO_USHORT(rgba[GCOMP]); - dst[2] = CHAN_TO_USHORT(rgba[BCOMP]); - dst[3] = CHAN_TO_USHORT(rgba[ACOMP]); -} -#endif + @@ -2208,18 +1458,7 @@ static void FETCH(f_ycbcr)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_ycbcr(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - (void) texImage; - (void) i; - (void) j; - (void) k; - (void) texel; - /* XXX to do */ -} -#endif + /* MESA_FORMAT_YCBCR_REV *****************************************************/ @@ -2249,18 +1488,7 @@ static void FETCH(f_ycbcr_rev)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_ycbcr_rev(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - (void) texImage; - (void) i; - (void) j; - (void) k; - (void) texel; - /* XXX to do */ -} -#endif + /* MESA_TEXFORMAT_Z24_S8 ***************************************************/ @@ -2278,17 +1506,7 @@ static void FETCH(f_z24_s8)( const struct swrast_texture_image *texImage, ASSERT(texel[0] <= 1.0F); } -#if DIM == 3 -static void store_texel_z24_s8(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - /* only store Z, not stencil */ - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - GLfloat depth = *((GLfloat *) texel); - GLuint zi = ((GLuint) (depth * 0xffffff)) << 8; - *dst = zi | (*dst & 0xff); -} -#endif + /* MESA_TEXFORMAT_S8_Z24 ***************************************************/ @@ -2306,17 +1524,7 @@ static void FETCH(f_s8_z24)( const struct swrast_texture_image *texImage, ASSERT(texel[0] <= 1.0F); } -#if DIM == 3 -static void store_texel_s8_z24(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - /* only store Z, not stencil */ - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - GLfloat depth = *((GLfloat *) texel); - GLuint zi = (GLuint) (depth * 0xffffff); - *dst = zi | (*dst & 0xff000000); -} -#endif + /* MESA_FORMAT_RGB9_E5 ******************************************************/ @@ -2329,15 +1537,7 @@ static void FETCH(rgb9_e5)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_rgb9_e5(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *src = (const GLfloat *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = float3_to_rgb9e5(src); -} -#endif + /* MESA_FORMAT_R11_G11_B10_FLOAT *********************************************/ @@ -2350,15 +1550,7 @@ static void FETCH(r11_g11_b10f)( const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_r11_g11_b10f(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *src = (const GLfloat *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = float3_to_r11g11b10f(src); -} -#endif + /* MESA_FORMAT_Z32_FLOAT_X24S8 ***********************************************/ @@ -2373,15 +1565,6 @@ static void FETCH(z32f_x24s8)(const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0F; } -#if DIM == 3 -static void store_texel_z32f_x24s8(struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *src = (const GLfloat *) texel; - GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2); - dst[0] = src[0]; -} -#endif #undef TEXEL_ADDR diff --git a/mesalib/src/mesa/swrast/s_texfilter.c b/mesalib/src/mesa/swrast/s_texfilter.c index 21b55a801..d142d3d07 100644 --- a/mesalib/src/mesa/swrast/s_texfilter.c +++ b/mesalib/src/mesa/swrast/s_texfilter.c @@ -1380,7 +1380,7 @@ opt_sample_rgb_2d(struct gl_context *ctx, GLint i = IFLOOR(texcoords[k][0] * width) & colMask; GLint j = IFLOOR(texcoords[k][1] * height) & rowMask; GLint pos = (j << shift) | i; - GLubyte *texel = swImg->Data + 3 * pos; + GLubyte *texel = swImg->Map + 3 * pos; rgba[k][RCOMP] = UBYTE_TO_FLOAT(texel[2]); rgba[k][GCOMP] = UBYTE_TO_FLOAT(texel[1]); rgba[k][BCOMP] = UBYTE_TO_FLOAT(texel[0]); @@ -1424,7 +1424,7 @@ opt_sample_rgba_2d(struct gl_context *ctx, const GLint col = IFLOOR(texcoords[i][0] * width) & colMask; const GLint row = IFLOOR(texcoords[i][1] * height) & rowMask; const GLint pos = (row << shift) | col; - const GLuint texel = *((GLuint *) swImg->Data + pos); + const GLuint texel = *((GLuint *) swImg->Map + pos); rgba[i][RCOMP] = UBYTE_TO_FLOAT( (texel >> 24) ); rgba[i][GCOMP] = UBYTE_TO_FLOAT( (texel >> 16) & 0xff ); rgba[i][BCOMP] = UBYTE_TO_FLOAT( (texel >> 8) & 0xff ); diff --git a/mesalib/src/mesa/swrast/s_texrender.c b/mesalib/src/mesa/swrast/s_texrender.c index 523420205..140e4b50f 100644 --- a/mesalib/src/mesa/swrast/s_texrender.c +++ b/mesalib/src/mesa/swrast/s_texrender.c @@ -15,293 +15,6 @@ */ -/** - * Derived from gl_renderbuffer class - */ -struct texture_renderbuffer -{ - struct gl_renderbuffer Base; /**< Base class object */ - struct swrast_texture_image *TexImage; - StoreTexelFunc Store; - FetchTexelFunc Fetch; - GLint Yoffset; /**< Layer for 1D array textures. */ - GLint Zoffset; /**< Layer for 2D array textures, or slice - * for 3D textures - */ -}; - - -/** cast wrapper */ -static inline struct texture_renderbuffer * -texture_renderbuffer(struct gl_renderbuffer *rb) -{ - return (struct texture_renderbuffer *) rb; -} - - - -/** - * Get row of values from the renderbuffer that wraps a texture image. - */ -static void -texture_get_row(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values) -{ - struct texture_renderbuffer *trb = texture_renderbuffer(rb); - const GLint z = trb->Zoffset; - GLuint i; - - ASSERT(trb->TexImage->Base.Width == rb->Width); - ASSERT(trb->TexImage->Base.Height == rb->Height); - - y += trb->Yoffset; - - if (rb->DataType == CHAN_TYPE) { - GLchan *rgbaOut = (GLchan *) values; - for (i = 0; i < count; i++) { - GLfloat rgba[4]; - trb->Fetch(trb->TexImage, x + i, y, z, rgba); - UNCLAMPED_FLOAT_TO_RGBA_CHAN(rgbaOut + 4 * i, rgba); - } - } - else if (rb->DataType == GL_UNSIGNED_SHORT) { - GLushort *zValues = (GLushort *) values; - for (i = 0; i < count; i++) { - GLfloat flt; - trb->Fetch(trb->TexImage, x + i, y, z, &flt); - zValues[i] = (GLushort) (flt * 0xffff); - } - } - else if (rb->DataType == GL_UNSIGNED_INT) { - GLuint *zValues = (GLuint *) values; - /* - const GLdouble scale = (GLdouble) 0xffffffff; - */ - for (i = 0; i < count; i++) { - GLfloat flt; - trb->Fetch(trb->TexImage, x + i, y, z, &flt); -#if 0 - /* this should work, but doesn't (overflow due to low precision) */ - zValues[i] = (GLuint) (flt * scale); -#else - /* temporary hack */ - zValues[i] = ((GLuint) (flt * 0xffffff)) << 8; -#endif - } - } - else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { - GLuint *zValues = (GLuint *) values; - for (i = 0; i < count; i++) { - GLfloat flt; - trb->Fetch(trb->TexImage, x + i, y, z, &flt); - zValues[i] = ((GLuint) (flt * 0xffffff)) << 8; - } - } - else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) { - GLuint *zValues = (GLuint *) values; - for (i = 0; i < count; i++) { - GLfloat flt; - trb->Fetch(trb->TexImage, x + i, y, z, &flt); - zValues[i] = (GLuint) (flt * 0xffffff); - } - } - else { - _mesa_problem(ctx, "invalid rb->DataType in texture_get_row"); - } -} - - -static void -texture_get_values(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - struct texture_renderbuffer *trb = texture_renderbuffer(rb); - const GLint z = trb->Zoffset; - GLuint i; - - if (rb->DataType == CHAN_TYPE) { - GLchan *rgbaOut = (GLchan *) values; - for (i = 0; i < count; i++) { - GLfloat rgba[4]; - trb->Fetch(trb->TexImage, x[i], y[i] + trb->Yoffset, - z, rgba); - UNCLAMPED_FLOAT_TO_RGBA_CHAN(rgbaOut + 4 * i, rgba); - } - } - else if (rb->DataType == GL_UNSIGNED_SHORT) { - GLushort *zValues = (GLushort *) values; - for (i = 0; i < count; i++) { - GLfloat flt; - trb->Fetch(trb->TexImage, x[i], y[i] + trb->Yoffset, - z, &flt); - zValues[i] = (GLushort) (flt * 0xffff); - } - } - else if (rb->DataType == GL_UNSIGNED_INT) { - GLuint *zValues = (GLuint *) values; - for (i = 0; i < count; i++) { - GLfloat flt; - trb->Fetch(trb->TexImage, x[i], y[i] + trb->Yoffset, - z, &flt); -#if 0 - zValues[i] = (GLuint) (flt * 0xffffffff); -#else - zValues[i] = ((GLuint) (flt * 0xffffff)) << 8; -#endif - } - } - else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { - GLuint *zValues = (GLuint *) values; - for (i = 0; i < count; i++) { - GLfloat flt; - trb->Fetch(trb->TexImage, x[i], y[i] + trb->Yoffset, - z, &flt); - zValues[i] = ((GLuint) (flt * 0xffffff)) << 8; - } - } - else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) { - GLuint *zValues = (GLuint *) values; - for (i = 0; i < count; i++) { - GLfloat flt; - trb->Fetch(trb->TexImage, x[i], y[i] + trb->Yoffset, - z, &flt); - zValues[i] = (GLuint) (flt * 0xffffff); - } - } - else { - _mesa_problem(ctx, "invalid rb->DataType in texture_get_values"); - } -} - - -/** - * Put row of values into a renderbuffer that wraps a texture image. - */ -static void -texture_put_row(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - struct texture_renderbuffer *trb = texture_renderbuffer(rb); - const GLint z = trb->Zoffset; - GLuint i; - - y += trb->Yoffset; - - if (rb->DataType == CHAN_TYPE) { - const GLchan *rgba = (const GLchan *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x + i, y, z, rgba); - } - rgba += 4; - } - } - else if (rb->DataType == GL_UNSIGNED_SHORT) { - const GLushort *zValues = (const GLushort *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x + i, y, z, zValues + i); - } - } - } - else if (rb->DataType == GL_UNSIGNED_INT) { - const GLuint *zValues = (const GLuint *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x + i, y, z, zValues + i); - } - } - } - else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { - const GLuint *zValues = (const GLuint *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLfloat flt = (GLfloat) ((zValues[i] >> 8) * (1.0 / 0xffffff)); - trb->Store(trb->TexImage, x + i, y, z, &flt); - } - } - } - else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) { - const GLuint *zValues = (const GLuint *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLfloat flt = (GLfloat) ((zValues[i] & 0xffffff) * (1.0 / 0xffffff)); - trb->Store(trb->TexImage, x + i, y, z, &flt); - } - } - } - else { - _mesa_problem(ctx, "invalid rb->DataType in texture_put_row"); - } -} - - -static void -texture_put_values(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask) -{ - struct texture_renderbuffer *trb = texture_renderbuffer(rb); - const GLint z = trb->Zoffset; - GLuint i; - - if (rb->DataType == CHAN_TYPE) { - const GLchan *rgba = (const GLchan *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, rgba); - } - rgba += 4; - } - } - else if (rb->DataType == GL_UNSIGNED_SHORT) { - const GLushort *zValues = (const GLushort *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, zValues + i); - } - } - } - else if (rb->DataType == GL_UNSIGNED_INT) { - const GLuint *zValues = (const GLuint *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, zValues + i); - } - } - } - else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { - const GLuint *zValues = (const GLuint *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLfloat flt = (GLfloat) ((zValues[i] >> 8) * (1.0 / 0xffffff)); - trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &flt); - } - } - } - else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) { - const GLuint *zValues = (const GLuint *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLfloat flt = (GLfloat) ((zValues[i] & 0xffffff) * (1.0 / 0xffffff)); - trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &flt); - } - } - } - else { - _mesa_problem(ctx, "invalid rb->DataType in texture_put_values"); - } -} - - -static void -store_nop(struct swrast_texture_image *texImage, - GLint col, GLint row, GLint img, - const void *texel) -{ -} - - static void delete_texture_wrapper(struct gl_renderbuffer *rb) { @@ -318,30 +31,26 @@ delete_texture_wrapper(struct gl_renderbuffer *rb) static void wrap_texture(struct gl_context *ctx, struct gl_renderbuffer_attachment *att) { - struct texture_renderbuffer *trb; + struct gl_renderbuffer *rb; const GLuint name = 0; ASSERT(att->Type == GL_TEXTURE); ASSERT(att->Renderbuffer == NULL); - trb = CALLOC_STRUCT(texture_renderbuffer); - if (!trb) { + rb = ctx->Driver.NewRenderbuffer(ctx, name); + if (!rb) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "wrap_texture"); return; } /* init base gl_renderbuffer fields */ - _mesa_init_renderbuffer(&trb->Base, name); + _mesa_init_renderbuffer(rb, name); /* plug in our texture_renderbuffer-specific functions */ - trb->Base.Delete = delete_texture_wrapper; - trb->Base.AllocStorage = NULL; /* illegal! */ - trb->Base.GetRow = texture_get_row; - trb->Base.GetValues = texture_get_values; - trb->Base.PutRow = texture_put_row; - trb->Base.PutValues = texture_put_values; + rb->Delete = delete_texture_wrapper; + rb->AllocStorage = NULL; /* illegal! */ /* update attachment point */ - _mesa_reference_renderbuffer(&att->Renderbuffer, &(trb->Base)); + _mesa_reference_renderbuffer(&att->Renderbuffer, rb); } /** @@ -352,100 +61,44 @@ wrap_texture(struct gl_context *ctx, struct gl_renderbuffer_attachment *att) static void update_wrapper(struct gl_context *ctx, struct gl_renderbuffer_attachment *att) { - struct texture_renderbuffer *trb - = (struct texture_renderbuffer *) att->Renderbuffer; + struct gl_renderbuffer *rb = att->Renderbuffer; + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); + struct swrast_texture_image *swImage; + gl_format format; + GLuint zOffset; (void) ctx; - ASSERT(trb); - - trb->TexImage = swrast_texture_image(_mesa_get_attachment_teximage(att)); - ASSERT(trb->TexImage); - trb->Store = _mesa_get_texel_store_func(trb->TexImage->Base.TexFormat); - if (!trb->Store) { - /* we'll never draw into some textures (compressed formats) */ - trb->Store = store_nop; - } + swImage = swrast_texture_image(_mesa_get_attachment_teximage(att)); + assert(swImage); - if (!trb->TexImage->FetchTexel) { - _mesa_update_fetch_functions(trb->TexImage->Base.TexObject); - } - trb->Fetch = trb->TexImage->FetchTexel; - assert(trb->Fetch); + format = swImage->Base.TexFormat; if (att->Texture->Target == GL_TEXTURE_1D_ARRAY_EXT) { - trb->Yoffset = att->Zoffset; - trb->Zoffset = 0; + zOffset = 0; } else { - trb->Yoffset = 0; - trb->Zoffset = att->Zoffset; + zOffset = att->Zoffset; } - trb->Base.Width = trb->TexImage->Base.Width; - trb->Base.Height = trb->TexImage->Base.Height; - trb->Base.RowStride = trb->TexImage->RowStride; - trb->Base.InternalFormat = trb->TexImage->Base.InternalFormat; - trb->Base.Format = trb->TexImage->Base.TexFormat; + rb->Width = swImage->Base.Width; + rb->Height = swImage->Base.Height; + rb->InternalFormat = swImage->Base.InternalFormat; + rb->_BaseFormat = _mesa_get_format_base_format(format); - /* Set the gl_renderbuffer::Data field so that mapping the buffer - * in renderbuffer.c succeeds. - */ + /* Want to store linear values, not sRGB */ + rb->Format = _mesa_get_srgb_format_linear(format); + + /* Set the gl_renderbuffer::Buffer field so that mapping the buffer + * succeeds. + */ if (att->Texture->Target == GL_TEXTURE_3D || att->Texture->Target == GL_TEXTURE_2D_ARRAY_EXT) { - trb->Base.Data = trb->TexImage->Buffer + - trb->TexImage->ImageOffsets[trb->Zoffset] * - _mesa_get_format_bytes(trb->TexImage->Base.TexFormat); + srb->Buffer = swImage->Buffer + + swImage->ImageOffsets[zOffset] * _mesa_get_format_bytes(format); } else { - trb->Base.Data = trb->TexImage->Buffer; - } - - /* XXX may need more special cases here */ - switch (trb->TexImage->Base.TexFormat) { - case MESA_FORMAT_Z24_S8: - trb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT; - trb->Base._BaseFormat = GL_DEPTH_STENCIL; - break; - case MESA_FORMAT_S8_Z24: - trb->Base.DataType = GL_UNSIGNED_INT_8_24_REV_MESA; - trb->Base._BaseFormat = GL_DEPTH_STENCIL; - break; - case MESA_FORMAT_Z24_X8: - trb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT; - trb->Base._BaseFormat = GL_DEPTH_COMPONENT; - break; - case MESA_FORMAT_X8_Z24: - trb->Base.DataType = GL_UNSIGNED_INT_8_24_REV_MESA; - trb->Base._BaseFormat = GL_DEPTH_COMPONENT; - break; - case MESA_FORMAT_Z16: - trb->Base.DataType = GL_UNSIGNED_SHORT; - trb->Base._BaseFormat = GL_DEPTH_COMPONENT; - break; - case MESA_FORMAT_Z32: - trb->Base.DataType = GL_UNSIGNED_INT; - trb->Base._BaseFormat = GL_DEPTH_COMPONENT; - break; - /* SRGB formats pre EXT_framebuffer_sRGB don't do sRGB translations on FBO readback */ - case MESA_FORMAT_SRGB8: - trb->Fetch = _mesa_get_texel_fetch_func(MESA_FORMAT_RGB888, _mesa_get_texture_dimensions(att->Texture->Target)); - trb->Base.DataType = CHAN_TYPE; - trb->Base._BaseFormat = GL_RGBA; - break; - case MESA_FORMAT_SRGBA8: - trb->Fetch = _mesa_get_texel_fetch_func(MESA_FORMAT_RGBA8888, _mesa_get_texture_dimensions(att->Texture->Target)); - trb->Base.DataType = CHAN_TYPE; - trb->Base._BaseFormat = GL_RGBA; - break; - case MESA_FORMAT_SARGB8: - trb->Fetch = _mesa_get_texel_fetch_func(MESA_FORMAT_ARGB8888, _mesa_get_texture_dimensions(att->Texture->Target)); - trb->Base.DataType = CHAN_TYPE; - trb->Base._BaseFormat = GL_RGBA; - break; - default: - trb->Base.DataType = CHAN_TYPE; - trb->Base._BaseFormat = GL_RGBA; + srb->Buffer = swImage->Buffer; } } diff --git a/mesalib/src/mesa/swrast/s_texture.c b/mesalib/src/mesa/swrast/s_texture.c index 337a52f32..72d309300 100644 --- a/mesalib/src/mesa/swrast/s_texture.c +++ b/mesalib/src/mesa/swrast/s_texture.c @@ -247,7 +247,7 @@ _swrast_map_texture(struct gl_context *ctx, struct gl_texture_object *texObj) swrast_texture_image(texImage); /* XXX we'll eventually call _swrast_map_teximage() here */ - swImage->Data = swImage->Buffer; + swImage->Map = swImage->Buffer; } } } @@ -268,7 +268,7 @@ _swrast_unmap_texture(struct gl_context *ctx, struct gl_texture_object *texObj) = swrast_texture_image(texImage); /* XXX we'll eventually call _swrast_unmap_teximage() here */ - swImage->Data = NULL; + swImage->Map = NULL; } } } @@ -316,59 +316,6 @@ _swrast_unmap_textures(struct gl_context *ctx) /** - * Map or unmap any textures that we may be rendering to as renderbuffers. - */ -static void -map_unmap_renderbuffers(struct gl_context *ctx, - struct gl_framebuffer *fb, - GLboolean map) -{ - GLuint i; - - for (i = 0; i < Elements(fb->Attachment); i++) { - struct gl_texture_object *texObj = fb->Attachment[i].Texture; - if (texObj) { - const GLuint level = fb->Attachment[i].TextureLevel; - const GLuint face = fb->Attachment[i].CubeMapFace; - struct gl_texture_image *texImage = texObj->Image[face][level]; - if (texImage) { - struct swrast_texture_image *swImage - = swrast_texture_image(texImage); - - if (map) { - /* XXX we'll eventually call _swrast_map_teximage() here */ - swImage->Data = swImage->Buffer; - } - else { - /* XXX we'll eventually call _swrast_unmap_teximage() here */ - swImage->Data = NULL; - } - } - } - } -} - - -void -_swrast_map_renderbuffers(struct gl_context *ctx) -{ - map_unmap_renderbuffers(ctx, ctx->DrawBuffer, GL_TRUE); - if (ctx->ReadBuffer != ctx->DrawBuffer) - map_unmap_renderbuffers(ctx, ctx->ReadBuffer, GL_TRUE); -} - - -void -_swrast_unmap_renderbuffers(struct gl_context *ctx) -{ - map_unmap_renderbuffers(ctx, ctx->DrawBuffer, GL_FALSE); - if (ctx->ReadBuffer != ctx->DrawBuffer) - map_unmap_renderbuffers(ctx, ctx->ReadBuffer, GL_FALSE); -} - - - -/** * Called via ctx->Driver.AllocTextureStorage() * Just have to allocate memory for the texture images. */ diff --git a/mesalib/src/mesa/swrast/s_triangle.c b/mesalib/src/mesa/swrast/s_triangle.c index 43deaf47b..124aa5f8e 100644 --- a/mesalib/src/mesa/swrast/s_triangle.c +++ b/mesalib/src/mesa/swrast/s_triangle.c @@ -132,7 +132,7 @@ _swrast_culltriangle( struct gl_context *ctx, const GLfloat twidth = (GLfloat) texImg->Width; \ const GLfloat theight = (GLfloat) texImg->Height; \ const GLint twidth_log2 = texImg->WidthLog2; \ - const GLubyte *texture = (const GLubyte *) swImg->Data; \ + const GLubyte *texture = (const GLubyte *) swImg->Map; \ const GLint smask = texImg->Width - 1; \ const GLint tmask = texImg->Height - 1; \ ASSERT(texImg->TexFormat == MESA_FORMAT_RGB888); \ @@ -157,7 +157,8 @@ _swrast_culltriangle( struct gl_context *ctx, span.intTex[0] += span.intTexStep[0]; \ span.intTex[1] += span.intTexStep[1]; \ } \ - rb->PutRow(ctx, rb, span.end, span.x, span.y, rgba, NULL); + _swrast_put_row(ctx, rb, GL_UNSIGNED_BYTE, span.end, \ + span.x, span.y, rgba, NULL); #include "s_tritemp.h" @@ -189,7 +190,7 @@ _swrast_culltriangle( struct gl_context *ctx, const GLfloat twidth = (GLfloat) texImg->Width; \ const GLfloat theight = (GLfloat) texImg->Height; \ const GLint twidth_log2 = texImg->WidthLog2; \ - const GLubyte *texture = (const GLubyte *) swImg->Data; \ + const GLubyte *texture = (const GLubyte *) swImg->Map; \ const GLint smask = texImg->Width - 1; \ const GLint tmask = texImg->Height - 1; \ ASSERT(texImg->TexFormat == MESA_FORMAT_RGB888); \ @@ -223,7 +224,8 @@ _swrast_culltriangle( struct gl_context *ctx, span.intTex[1] += span.intTexStep[1]; \ span.z += span.zStep; \ } \ - rb->PutRow(ctx, rb, span.end, span.x, span.y, rgba, span.array->mask); + _swrast_put_row(ctx, rb, GL_UNSIGNED_BYTE, \ + span.end, span.x, span.y, rgba, span.array->mask); #include "s_tritemp.h" @@ -543,7 +545,7 @@ affine_span(struct gl_context *ctx, SWspan *span, swrast_texture_image_const(texImg); \ const GLfloat twidth = (GLfloat) texImg->Width; \ const GLfloat theight = (GLfloat) texImg->Height; \ - info.texture = (const GLchan *) swImg->Data; \ + info.texture = (const GLchan *) swImg->Map; \ info.twidth_log2 = texImg->WidthLog2; \ info.smask = texImg->Width - 1; \ info.tmask = texImg->Height - 1; \ @@ -810,7 +812,7 @@ fast_persp_span(struct gl_context *ctx, SWspan *span, obj->Image[0][obj->BaseLevel]; \ const struct swrast_texture_image *swImg = \ swrast_texture_image_const(texImg); \ - info.texture = (const GLchan *) swImg->Data; \ + info.texture = (const GLchan *) swImg->Map; \ info.twidth_log2 = texImg->WidthLog2; \ info.smask = texImg->Width - 1; \ info.tmask = texImg->Height - 1; \ diff --git a/mesalib/src/mesa/tnl/t_vb_program.c b/mesalib/src/mesa/tnl/t_vb_program.c index 8b060ff93..7687ae0b3 100644 --- a/mesalib/src/mesa/tnl/t_vb_program.c +++ b/mesalib/src/mesa/tnl/t_vb_program.c @@ -272,15 +272,12 @@ map_textures(struct gl_context *ctx, const struct gl_vertex_program *vp) { GLuint u; - if (!ctx->Driver.MapTexture) - return; - for (u = 0; u < ctx->Const.MaxVertexTextureImageUnits; u++) { if (vp->Base.TexturesUsed[u]) { /* Note: _Current *should* correspond to the target indicated * in TexturesUsed[u]. */ - ctx->Driver.MapTexture(ctx, ctx->Texture.Unit[u]._Current); + _swrast_map_texture(ctx, ctx->Texture.Unit[u]._Current); } } } @@ -294,15 +291,12 @@ unmap_textures(struct gl_context *ctx, const struct gl_vertex_program *vp) { GLuint u; - if (!ctx->Driver.MapTexture) - return; - for (u = 0; u < ctx->Const.MaxVertexTextureImageUnits; u++) { if (vp->Base.TexturesUsed[u]) { /* Note: _Current *should* correspond to the target indicated * in TexturesUsed[u]. */ - ctx->Driver.UnmapTexture(ctx, ctx->Texture.Unit[u]._Current); + _swrast_unmap_texture(ctx, ctx->Texture.Unit[u]._Current); } } } |