summaryrefslogtreecommitdiff
path: root/src/mesa/main/texutil.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2002-06-03 16:06:34 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2002-06-03 16:06:34 +0000
commitf5a078197552bc956322e2fa292b034e4ccb9d82 (patch)
tree868c34dd27374bdb07d2e20ef4a1dd72e23d66b3 /src/mesa/main/texutil.c
parent91d6f12b4ad4d5dde42ef0c86e4531a60f770dbd (diff)
bring over Michel Daenzer's DRI changes
Diffstat (limited to 'src/mesa/main/texutil.c')
-rw-r--r--src/mesa/main/texutil.c86
1 files changed, 54 insertions, 32 deletions
diff --git a/src/mesa/main/texutil.c b/src/mesa/main/texutil.c
index 8a7483128c..d840747a04 100644
--- a/src/mesa/main/texutil.c
+++ b/src/mesa/main/texutil.c
@@ -1,4 +1,4 @@
-/* $Id: texutil.c,v 1.27 2002/03/15 18:05:49 brianp Exp $ */
+/* $Id: texutil.c,v 1.28 2002/06/03 16:06:34 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -44,6 +44,13 @@
#define DEBUG_TEXUTIL 0
+#ifdef __BIG_ENDIAN
+#define APPEND16( a, b ) ( (a) << 16 | (b) )
+#else
+#define APPEND16( a, b ) ( (a) | (b) << 16 )
+#endif
+
+
struct gl_texture_convert {
GLint xoffset, yoffset, zoffset; /* Subimage offset */
GLint width, height, depth; /* Subimage region */
@@ -75,7 +82,7 @@ typedef GLboolean (*convert_func)( struct gl_texture_convert *convert );
#define DST_TEXELS_PER_DWORD 1
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_8888( src[3], src[2], src[1], src[0] )
+ dst = PACK_COLOR_8888_LE( src[3], src[2], src[1], src[0] )
#define CONVERT_DIRECT
@@ -87,7 +94,7 @@ typedef GLboolean (*convert_func)( struct gl_texture_convert *convert );
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_8888( src[0], src[1], src[2], src[3] )
+ dst = PACK_COLOR_8888_LE( src[0], src[1], src[2], src[3] )
#define CONVERT_TEXEL_DWORD( dst, src ) CONVERT_TEXEL( dst, src )
@@ -99,7 +106,7 @@ typedef GLboolean (*convert_func)( struct gl_texture_convert *convert );
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_8888( src[0], src[1], src[2], 0xff )
+ dst = PACK_COLOR_8888_LE( src[0], src[1], src[2], 0xff )
#define CONVERT_TEXEL_DWORD( dst, src ) CONVERT_TEXEL( dst, src )
@@ -154,7 +161,7 @@ CONVERT_RGBA8888( texsubimage3d )
#define DST_TEXELS_PER_DWORD 1
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_8888( src[3], src[2], src[1], src[0] )
+ dst = PACK_COLOR_8888_LE( src[3], src[2], src[1], src[0] )
#define CONVERT_DIRECT
@@ -166,7 +173,7 @@ CONVERT_RGBA8888( texsubimage3d )
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_8888( src[3], src[0], src[1], src[2] )
+ dst = PACK_COLOR_8888_LE( src[3], src[0], src[1], src[2] )
#define CONVERT_TEXEL_DWORD( dst, src ) CONVERT_TEXEL( dst, src )
@@ -178,7 +185,7 @@ CONVERT_RGBA8888( texsubimage3d )
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_8888( 0xff, src[0], src[1], src[2] )
+ dst = PACK_COLOR_8888_LE( 0xff, src[0], src[1], src[2] )
#define CONVERT_TEXEL_DWORD( dst, src ) CONVERT_TEXEL( dst, src )
@@ -254,7 +261,7 @@ convert_texsubimage3d_rgb888( struct gl_texture_convert *convert )
#define DST_TEXELS_PER_DWORD 2
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_565( src[0], src[1], src[2] )
+ dst = PACK_COLOR_565_LE( src[0], src[1], src[2] )
#define CONVERT_DIRECT
@@ -266,11 +273,11 @@ convert_texsubimage3d_rgb888( struct gl_texture_convert *convert )
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_565( src[0], src[1], src[2] )
+ dst = PACK_COLOR_565_LE( src[0], src[1], src[2] )
#define CONVERT_TEXEL_DWORD( dst, src ) \
- dst = ((PACK_COLOR_565( src[0], src[1], src[2] )) | \
- (PACK_COLOR_565( src[3], src[4], src[5] ) << 16))
+ dst = APPEND16( PACK_COLOR_565_LE( src[0], src[1], src[2] ), \
+ PACK_COLOR_565_LE( src[3], src[4], src[5] ) )
#define SRC_TEXEL_BYTES 3
@@ -280,11 +287,11 @@ convert_texsubimage3d_rgb888( struct gl_texture_convert *convert )
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_565( src[0], src[1], src[2] )
+ dst = PACK_COLOR_565_LE( src[0], src[1], src[2] )
#define CONVERT_TEXEL_DWORD( dst, src ) \
- dst = ((PACK_COLOR_565( src[0], src[1], src[2] )) | \
- (PACK_COLOR_565( src[4], src[5], src[6] ) << 16))
+ dst = APPEND16( PACK_COLOR_565_LE( src[0], src[1], src[2] ), \
+ PACK_COLOR_565_LE( src[4], src[5], src[6] ) )
#define SRC_TEXEL_BYTES 4
@@ -336,7 +343,7 @@ CONVERT_RGB565( texsubimage3d )
#define DST_TEXELS_PER_DWORD 2
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_4444( src[3], src[0], src[1], src[2] )
+ dst = PACK_COLOR_4444_LE( src[3], src[0], src[1], src[2] )
#define CONVERT_DIRECT
@@ -348,11 +355,11 @@ CONVERT_RGB565( texsubimage3d )
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_4444( src[3], src[0], src[1], src[2] )
+ dst = PACK_COLOR_4444_LE( src[3], src[0], src[1], src[2] )
#define CONVERT_TEXEL_DWORD( dst, src ) \
- dst = ((PACK_COLOR_4444( src[3], src[0], src[1], src[2] )) | \
- (PACK_COLOR_4444( src[7], src[4], src[5], src[6] ) << 16))
+ dst = APPEND16( PACK_COLOR_4444_LE( src[3], src[0], src[1], src[2] ), \
+ PACK_COLOR_4444_LE( src[7], src[4], src[5], src[6] ) )
#define SRC_TEXEL_BYTES 4
@@ -399,7 +406,7 @@ CONVERT_ARGB4444( texsubimage3d )
#define DST_TEXELS_PER_DWORD 2
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_1555( src[3], src[0], src[1], src[2] )
+ dst = PACK_COLOR_1555_LE( src[3], src[0], src[1], src[2] )
#define CONVERT_DIRECT
@@ -410,6 +417,19 @@ CONVERT_ARGB4444( texsubimage3d )
#include "texutil_tmp.h"
+#ifdef __BIG_ENDIAN
+
+#define CONVERT_TEXEL( dst, src ) \
+ { const GLushort s = *(GLushort *)src; \
+ dst = (s >> 9) | ((s & 0x1ff) << 7); }
+
+#define CONVERT_TEXEL_DWORD( dst, src ) \
+ { const GLuint s = ((fi_type *)src)->i; \
+ dst = (((s & 0xfe00fe00) >> 9) | \
+ ((s & 0x01ff01ff) << 7)); }
+
+#else
+
#define CONVERT_TEXEL( dst, src ) \
{ const GLushort s = *(GLushort *)src; \
dst = (s >> 1) | ((s & 1) << 15); }
@@ -419,6 +439,8 @@ CONVERT_ARGB4444( texsubimage3d )
dst = (((s & 0xfffefffe) >> 1) | \
((s & 0x00010001) << 15)); }
+#endif
+
#define SRC_TEXEL_BYTES 2
#define TAG(x) x##_rgba5551_to_argb1555
@@ -427,11 +449,11 @@ CONVERT_ARGB4444( texsubimage3d )
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_1555( src[3], src[0], src[1], src[2] )
+ dst = PACK_COLOR_1555_LE( src[3], src[0], src[1], src[2] )
#define CONVERT_TEXEL_DWORD( dst, src ) \
- dst = ((PACK_COLOR_1555( src[3], src[0], src[1], src[2] )) | \
- (PACK_COLOR_1555( src[7], src[4], src[5], src[6] ) << 16))
+ dst = APPEND16( PACK_COLOR_1555_LE( src[3], src[0], src[1], src[2] ), \
+ PACK_COLOR_1555_LE( src[7], src[4], src[5], src[6] ) )
#define SRC_TEXEL_BYTES 4
@@ -483,7 +505,7 @@ CONVERT_ARGB1555( texsubimage3d )
#define DST_TEXELS_PER_DWORD 2
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_88( src[0], src[1] )
+ dst = PACK_COLOR_88_LE( src[0], src[1] )
#define CONVERT_DIRECT
@@ -495,11 +517,11 @@ CONVERT_ARGB1555( texsubimage3d )
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_88( src[0], 0x00 )
+ dst = PACK_COLOR_88_LE( src[0], 0x00 )
#define CONVERT_TEXEL_DWORD( dst, src ) \
- dst = ((PACK_COLOR_88( src[0], 0x00 )) | \
- (PACK_COLOR_88( src[1], 0x00 ) << 16))
+ dst = APPEND16( PACK_COLOR_88_LE( src[0], 0x00 ), \
+ PACK_COLOR_88_LE( src[1], 0x00 ) )
#define SRC_TEXEL_BYTES 1
@@ -509,11 +531,11 @@ CONVERT_ARGB1555( texsubimage3d )
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_88( 0xff, src[0] )
+ dst = PACK_COLOR_88_LE( 0xff, src[0] )
#define CONVERT_TEXEL_DWORD( dst, src ) \
- dst = ((PACK_COLOR_88( 0xff, src[0] )) | \
- (PACK_COLOR_88( 0xff, src[1] ) << 16))
+ dst = APPEND16( PACK_COLOR_88_LE( 0xff, src[0] ), \
+ PACK_COLOR_88_LE( 0xff, src[1] ) )
#define SRC_TEXEL_BYTES 1
@@ -523,11 +545,11 @@ CONVERT_ARGB1555( texsubimage3d )
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_88( src[3], src[0] )
+ dst = PACK_COLOR_88_LE( src[3], src[0] )
#define CONVERT_TEXEL_DWORD( dst, src ) \
- dst = ((PACK_COLOR_88( src[3], src[0] )) | \
- (PACK_COLOR_88( src[7], src[4] ) << 16))
+ dst = APPEND16( PACK_COLOR_88_LE( src[3], src[0] ), \
+ PACK_COLOR_88_LE( src[7], src[4] ) )
#define SRC_TEXEL_BYTES 4