diff options
| -rw-r--r-- | src/mesa/drivers/common/t_dd_vbtmp.h | 24 | ||||
| -rw-r--r-- | src/mesa/drivers/common/t_dd_vertex.h | 24 | ||||
| -rw-r--r-- | src/mesa/main/macros.h | 45 | ||||
| -rw-r--r-- | src/mesa/main/texutil.c | 86 | ||||
| -rw-r--r-- | src/mesa/math/m_clip_tmp.h | 10 | 
5 files changed, 128 insertions, 61 deletions
| diff --git a/src/mesa/drivers/common/t_dd_vbtmp.h b/src/mesa/drivers/common/t_dd_vbtmp.h index 5d07beb3e7..8f7b638daf 100644 --- a/src/mesa/drivers/common/t_dd_vbtmp.h +++ b/src/mesa/drivers/common/t_dd_vbtmp.h @@ -1,10 +1,10 @@ -/* $Id: t_dd_vbtmp.h,v 1.16 2002/02/13 00:53:20 keithw Exp $ */ +/* $Id: t_dd_vbtmp.h,v 1.17 2002/06/03 16:06:35 brianp Exp $ */  /*   * Mesa 3-D graphics library - * Version:  3.5 + * Version:  4.0.3   * - * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved. + * Copyright (C) 1999-2002  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"), @@ -235,7 +235,7 @@ static void TAG(emit)( GLcontext *ctx,  	 }  	 if (DO_RGBA) {  	    if (HAVE_RGBA_COLOR) { -	       *(GLuint *)&v->v.color = *(GLuint *)&col[0]; +	       *(GLuint *)&v->v.color = LE32_TO_CPU(*(GLuint *)&col[0]);  	       STRIDE_4UB(col, col_stride);  	    } else {  	       v->v.color.blue  = col[0][2]; @@ -336,7 +336,7 @@ static void TAG(emit)( GLcontext *ctx,  	 }  	 if (DO_RGBA) {  	    if (HAVE_RGBA_COLOR) { -	       *(GLuint *)&v->v.color = *(GLuint *)&col[i]; +	       *(GLuint *)&v->v.color = LE32_TO_CPU(*(GLuint *)&col[i]);  	    }  	    else {  	       v->v.color.blue  = col[i][2]; @@ -443,7 +443,7 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end,  	 coord =  (GLfloat (*)[4])((GLubyte *)coord +  coord_stride);  	 if (DO_RGBA) {  	    if (HAVE_RGBA_COLOR) { -	       *(GLuint *)&v[3] = *(GLuint *)col; +	       *(GLuint *)&v[3] = LE32_TO_CPU(*(GLuint *)col);  	    }  	    else {  	       GLubyte *b = (GLubyte *)&v[3]; @@ -467,7 +467,7 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end,  	 }  	 if (DO_RGBA) {  	    if (HAVE_RGBA_COLOR) { -	       *(GLuint *)&v[3] = *(GLuint *)&col[i]; +	       *(GLuint *)&v[3] = LE32_TO_CPU(*(GLuint *)&col[i]);  	    }  	    else {  	       GLubyte *b = (GLubyte *)&v[3]; @@ -512,7 +512,7 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end,     for (i=start; i < end; i++, STRIDE_F(v, stride)) {        if (HAVE_RGBA_COLOR) { -	 *(GLuint *)v = *(GLuint *)col[0]; +	 *(GLuint *)v = LE32_TO_CPU(*(GLuint *)col[0]);        }        else {  	 GLubyte *b = (GLubyte *)v; @@ -644,12 +644,12 @@ static void TAG(interp)( GLcontext *ctx,        INTERP_UB( t, dst->ub4[4][3], out->ub4[4][3], in->ub4[4][3] );        if (DO_SPEC) { -	 INTERP_UB( t, dst->ub4[5][0], out->ub4[5][0], in->ub4[5][0] ); -	 INTERP_UB( t, dst->ub4[5][1], out->ub4[5][1], in->ub4[5][1] ); -	 INTERP_UB( t, dst->ub4[5][2], out->ub4[5][2], in->ub4[5][2] ); +	 INTERP_UB( t, dst->v.specular.red,   out->v.specular.red,   in->v.specular.red ); +	 INTERP_UB( t, dst->v.specular.green, out->v.specular.green, in->v.specular.green ); +	 INTERP_UB( t, dst->v.specular.blue,  out->v.specular.blue,  in->v.specular.blue );        }        if (DO_FOG) { -	 INTERP_UB( t, dst->ub4[5][3], out->ub4[5][3], in->ub4[5][3] ); +	 INTERP_UB( t, dst->v.specular.alpha, out->v.specular.alpha, in->v.specular.alpha );        }        if (DO_TEX0) {  	 if (DO_PTEX) { diff --git a/src/mesa/drivers/common/t_dd_vertex.h b/src/mesa/drivers/common/t_dd_vertex.h index 9ebeeee61b..01773af7aa 100644 --- a/src/mesa/drivers/common/t_dd_vertex.h +++ b/src/mesa/drivers/common/t_dd_vertex.h @@ -1,10 +1,10 @@ -/* $Id: t_dd_vertex.h,v 1.9 2001/09/23 15:19:16 keithw Exp $ */ +/* $Id: t_dd_vertex.h,v 1.10 2002/06/03 16:06:35 brianp Exp $ */  /*   * Mesa 3-D graphics library - * Version:  3.5 + * Version:  4.0.3   * - * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved. + * Copyright (C) 1999-2002  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"), @@ -33,17 +33,19 @@ typedef struct {  #ifdef COLOR_IS_RGBA  typedef struct { -   GLubyte red; -   GLubyte green; -   GLubyte blue; -   GLubyte alpha; +#ifdef __BIG_ENDIAN +   GLubyte alpha, blue, green, red; +#else +   GLubyte red, green, blue, alpha; +#endif  } TAG(_color_t);  #else  typedef struct { -   GLubyte blue; -   GLubyte green; -   GLubyte red; -   GLubyte alpha; +#ifdef __BIG_ENDIAN +   GLubyte alpha, red, green, blue; +#else +   GLubyte blue, green, red, alpha; +#endif  } TAG(_color_t);  #endif diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h index bb83b30d5d..9444975ab1 100644 --- a/src/mesa/main/macros.h +++ b/src/mesa/main/macros.h @@ -1,4 +1,3 @@ -/* $Id: macros.h,v 1.25 2002/02/13 00:53:19 keithw Exp $ */  /*   * Mesa 3-D graphics library @@ -454,6 +453,19 @@ do {						\ +/* Byte swapping + */ + +#ifdef __BIG_ENDIAN +#include <byteswap.h> +#define CPU_TO_LE32( x )	bswap_32( x ) +#else +#define CPU_TO_LE32( x )	( x ) +#endif + +#define LE32_TO_CPU( x )	CPU_TO_LE32( x ) + +  /* Generic color packing macros   */ @@ -480,4 +492,35 @@ do {						\     (((a) & 0xe0) | (((b) & 0xe0) >> 3) | (((c) & 0xc0) >> 6)) +#ifdef __BIG_ENDIAN + +#define PACK_COLOR_8888_LE( a, b, c, d )	PACK_COLOR_8888( d, c, b, a ) + +#define PACK_COLOR_565_LE( a, b, c )					\ +   (((a) & 0xf8) | (((b) & 0xe0) >> 5) | (((b) & 0x1c) << 11) |		\ +   (((c) & 0xf8) << 5)) + +#define PACK_COLOR_1555_LE( a, b, c, d )				\ +   ((((b) & 0xf8) >> 1) | (((c) & 0xc0) >> 6) | (((c) & 0x38) << 10) |	\ +    (((d) & 0xf8) << 5) | ((a) ? 0x80 : 0)) + +#define PACK_COLOR_4444_LE( a, b, c, d )	PACK_COLOR_4444( c, d, a, b ) + +#define PACK_COLOR_88_LE( a, b )		PACK_COLOR_88( b, a ) + +#else	/* little endian */ + +#define PACK_COLOR_8888_LE( a, b, c, d )	PACK_COLOR_8888( a, b, c, d ) + +#define PACK_COLOR_565_LE( a, b, c )		PACK_COLOR_565( a, b, c ) + +#define PACK_COLOR_1555_LE( a, b, c, d )	PACK_COLOR_1555( a, b, c, d ) + +#define PACK_COLOR_4444_LE( a, b, c, d )	PACK_COLOR_4444( a, b, c, d ) + +#define PACK_COLOR_88_LE( a, b )		PACK_COLOR_88( a, b ) + +#endif	/* endianness */ + +  #endif 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 diff --git a/src/mesa/math/m_clip_tmp.h b/src/mesa/math/m_clip_tmp.h index b4426f5609..bdb538a2dd 100644 --- a/src/mesa/math/m_clip_tmp.h +++ b/src/mesa/math/m_clip_tmp.h @@ -1,10 +1,10 @@ -/* $Id: m_clip_tmp.h,v 1.7 2001/05/21 16:33:41 gareth Exp $ */ +/* $Id: m_clip_tmp.h,v 1.8 2002/06/03 16:06:34 brianp Exp $ */  /*   * Mesa 3-D graphics library - * Version:  3.5 + * Version:  4.0.3   * - * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved. + * Copyright (C) 1999-2002  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"), @@ -54,7 +54,7 @@ static GLvector4f * _XFORMAPI TAG(cliptest_points4)( GLvector4f *clip_vec,        const GLfloat cy = from[1];        const GLfloat cz = from[2];        const GLfloat cw = from[3]; -#if defined(macintosh) +#if defined(macintosh) || defined(__powerpc__)        /* on powerpc cliptest is 17% faster in this way. */        GLuint mask;        mask = (((cw < cx) << CLIP_RIGHT_SHIFT)); @@ -120,7 +120,7 @@ static GLvector4f * _XFORMAPI TAG(cliptest_np_points4)( GLvector4f *clip_vec,        const GLfloat cy = from[1];        const GLfloat cz = from[2];        const GLfloat cw = from[3]; -#if defined(macintosh) +#if defined(macintosh) || defined(__powerpc__)        /* on powerpc cliptest is 17% faster in this way. */        GLuint mask;        mask = (((cw < cx) << CLIP_RIGHT_SHIFT)); | 
