diff options
-rw-r--r-- | src/mesa/main/imports.c | 18 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 5 | ||||
-rw-r--r-- | src/mesa/main/texformat.c | 99 | ||||
-rw-r--r-- | src/mesa/main/texstore.c | 18 | ||||
-rw-r--r-- | src/mesa/main/texutil.c | 42 |
5 files changed, 131 insertions, 51 deletions
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 5dcd7fc64f..60cca8433e 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -1,4 +1,4 @@ -/* $Id: imports.c,v 1.8 2001/03/12 00:48:38 gareth Exp $ */ +/* $Id: imports.c,v 1.9 2001/03/27 19:18:02 gareth Exp $ */ /* * Mesa 3-D graphics library @@ -69,6 +69,15 @@ _mesa_Free(__GLcontext *gc, void *addr) FREE(addr); } +/* Must be before '#undef getenv' for inclusion in XFree86. + */ +static char * +_mesa_getenv(__GLcontext *gc, const char *var) +{ + (void) gc; + return getenv(var); +} + static void _mesa_warning(__GLcontext *gc, char *str) { @@ -100,13 +109,6 @@ _mesa_fatal(__GLcontext *gc, char *str) abort(); } -static char * -_mesa_getenv(__GLcontext *gc, const char *var) -{ - (void) gc; - return getenv(var); -} - static int _mesa_atoi(__GLcontext *gc, const char *str) { diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index c261756b5b..5aa3619e62 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1,4 +1,4 @@ -/* $Id: mtypes.h,v 1.32 2001/03/26 19:42:40 brianp Exp $ */ +/* $Id: mtypes.h,v 1.33 2001/03/27 19:18:02 gareth Exp $ */ /* * Mesa 3-D graphics library @@ -779,6 +779,9 @@ typedef void (*FetchTexelFunc)( const struct gl_texture_image *texImage, struct gl_texture_format { GLint IntFormat; /* One of the MESA_FORMAT_* values */ + GLenum BaseFormat; + GLenum BaseType; + GLubyte RedBits; /* Bits per texel component */ GLubyte GreenBits; GLubyte BlueBits; diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index 57e653af21..78f0df824c 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -1,4 +1,4 @@ -/* $Id: texformat.c,v 1.3 2001/03/18 13:31:52 gareth Exp $ */ +/* $Id: texformat.c,v 1.4 2001/03/27 19:18:02 gareth Exp $ */ /* * Mesa 3-D graphics library @@ -74,6 +74,8 @@ static void fetch_null_texel( const struct gl_texture_image *texImage, const struct gl_texture_format _mesa_texformat_rgba = { MESA_FORMAT_RGBA, /* IntFormat */ + GL_RGBA, /* BaseFormat */ + CHAN_TYPE, /* BaseType */ CHAN_BITS, /* RedBits */ CHAN_BITS, /* GreenBits */ CHAN_BITS, /* BlueBits */ @@ -90,6 +92,8 @@ const struct gl_texture_format _mesa_texformat_rgba = { const struct gl_texture_format _mesa_texformat_rgb = { MESA_FORMAT_RGBA, /* IntFormat */ + GL_RGB, /* BaseFormat */ + CHAN_TYPE, /* BaseType */ CHAN_BITS, /* RedBits */ CHAN_BITS, /* GreenBits */ CHAN_BITS, /* BlueBits */ @@ -106,6 +110,8 @@ const struct gl_texture_format _mesa_texformat_rgb = { const struct gl_texture_format _mesa_texformat_alpha = { MESA_FORMAT_ALPHA, /* IntFormat */ + GL_ALPHA, /* BaseFormat */ + CHAN_TYPE, /* BaseType */ 0, /* RedBits */ 0, /* GreenBits */ 0, /* BlueBits */ @@ -122,6 +128,8 @@ const struct gl_texture_format _mesa_texformat_alpha = { const struct gl_texture_format _mesa_texformat_luminance = { MESA_FORMAT_LUMINANCE, /* IntFormat */ + GL_LUMINANCE, /* BaseFormat */ + CHAN_TYPE, /* BaseType */ 0, /* RedBits */ 0, /* GreenBits */ 0, /* BlueBits */ @@ -138,6 +146,8 @@ const struct gl_texture_format _mesa_texformat_luminance = { const struct gl_texture_format _mesa_texformat_luminance_alpha = { MESA_FORMAT_LUMINANCE_ALPHA, /* IntFormat */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + CHAN_TYPE, /* BaseType */ 0, /* RedBits */ 0, /* GreenBits */ 0, /* BlueBits */ @@ -154,6 +164,8 @@ const struct gl_texture_format _mesa_texformat_luminance_alpha = { const struct gl_texture_format _mesa_texformat_intensity = { MESA_FORMAT_INTENSITY, /* IntFormat */ + GL_INTENSITY, /* BaseFormat */ + CHAN_TYPE, /* BaseType */ 0, /* RedBits */ 0, /* GreenBits */ 0, /* BlueBits */ @@ -170,6 +182,8 @@ const struct gl_texture_format _mesa_texformat_intensity = { const struct gl_texture_format _mesa_texformat_color_index = { MESA_FORMAT_COLOR_INDEX, /* IntFormat */ + GL_COLOR_INDEX, /* BaseFormat */ + CHAN_TYPE, /* BaseType */ 0, /* RedBits */ 0, /* GreenBits */ 0, /* BlueBits */ @@ -186,6 +200,8 @@ const struct gl_texture_format _mesa_texformat_color_index = { const struct gl_texture_format _mesa_texformat_depth_component = { MESA_FORMAT_DEPTH_COMPONENT, /* IntFormat */ + GL_DEPTH_COMPONENT, /* BaseFormat */ + GL_FLOAT, /* BaseType */ 0, /* RedBits */ 0, /* GreenBits */ 0, /* BlueBits */ @@ -207,6 +223,8 @@ const struct gl_texture_format _mesa_texformat_depth_component = { const struct gl_texture_format _mesa_texformat_rgba8888 = { MESA_FORMAT_RGBA8888, /* IntFormat */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_BYTE, /* BaseType */ 8, /* RedBits */ 8, /* GreenBits */ 8, /* BlueBits */ @@ -223,6 +241,8 @@ const struct gl_texture_format _mesa_texformat_rgba8888 = { const struct gl_texture_format _mesa_texformat_argb8888 = { MESA_FORMAT_ARGB8888, /* IntFormat */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_BYTE, /* FIXME: ??? */ /* BaseType */ 8, /* RedBits */ 8, /* GreenBits */ 8, /* BlueBits */ @@ -239,6 +259,8 @@ const struct gl_texture_format _mesa_texformat_argb8888 = { const struct gl_texture_format _mesa_texformat_rgb888 = { MESA_FORMAT_RGB888, /* IntFormat */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_BYTE, /* BaseType */ 8, /* RedBits */ 8, /* GreenBits */ 8, /* BlueBits */ @@ -255,6 +277,8 @@ const struct gl_texture_format _mesa_texformat_rgb888 = { const struct gl_texture_format _mesa_texformat_rgb565 = { MESA_FORMAT_RGB565, /* IntFormat */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_SHORT_5_6_5, /* BaseType */ 5, /* RedBits */ 6, /* GreenBits */ 5, /* BlueBits */ @@ -271,6 +295,8 @@ const struct gl_texture_format _mesa_texformat_rgb565 = { const struct gl_texture_format _mesa_texformat_argb4444 = { MESA_FORMAT_ARGB4444, /* IntFormat */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_SHORT_4_4_4_4_REV, /* BaseType */ 4, /* RedBits */ 4, /* GreenBits */ 4, /* BlueBits */ @@ -287,6 +313,8 @@ const struct gl_texture_format _mesa_texformat_argb4444 = { const struct gl_texture_format _mesa_texformat_argb1555 = { MESA_FORMAT_ARGB1555, /* IntFormat */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_SHORT_1_5_5_5_REV, /* BaseType */ 5, /* RedBits */ 5, /* GreenBits */ 5, /* BlueBits */ @@ -303,6 +331,8 @@ const struct gl_texture_format _mesa_texformat_argb1555 = { const struct gl_texture_format _mesa_texformat_al88 = { MESA_FORMAT_AL88, /* IntFormat */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + GL_UNSIGNED_BYTE, /* BaseType */ 0, /* RedBits */ 0, /* GreenBits */ 0, /* BlueBits */ @@ -319,6 +349,8 @@ const struct gl_texture_format _mesa_texformat_al88 = { const struct gl_texture_format _mesa_texformat_rgb332 = { MESA_FORMAT_RGB332, /* IntFormat */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_BYTE_3_3_2, /* BaseType */ 3, /* RedBits */ 3, /* GreenBits */ 2, /* BlueBits */ @@ -335,6 +367,8 @@ const struct gl_texture_format _mesa_texformat_rgb332 = { const struct gl_texture_format _mesa_texformat_a8 = { MESA_FORMAT_A8, /* IntFormat */ + GL_ALPHA, /* BaseFormat */ + GL_UNSIGNED_BYTE, /* BaseType */ 0, /* RedBits */ 0, /* GreenBits */ 0, /* BlueBits */ @@ -351,6 +385,8 @@ const struct gl_texture_format _mesa_texformat_a8 = { const struct gl_texture_format _mesa_texformat_l8 = { MESA_FORMAT_L8, /* IntFormat */ + GL_LUMINANCE, /* BaseFormat */ + GL_UNSIGNED_BYTE, /* BaseType */ 0, /* RedBits */ 0, /* GreenBits */ 0, /* BlueBits */ @@ -367,6 +403,8 @@ const struct gl_texture_format _mesa_texformat_l8 = { const struct gl_texture_format _mesa_texformat_i8 = { MESA_FORMAT_I8, /* IntFormat */ + GL_INTENSITY, /* BaseFormat */ + GL_UNSIGNED_BYTE, /* BaseType */ 0, /* RedBits */ 0, /* GreenBits */ 0, /* BlueBits */ @@ -383,6 +421,8 @@ const struct gl_texture_format _mesa_texformat_i8 = { const struct gl_texture_format _mesa_texformat_ci8 = { MESA_FORMAT_CI8, /* IntFormat */ + GL_COLOR_INDEX, /* BaseFormat */ + GL_UNSIGNED_BYTE, /* BaseType */ 0, /* RedBits */ 0, /* GreenBits */ 0, /* BlueBits */ @@ -404,6 +444,8 @@ const struct gl_texture_format _mesa_texformat_ci8 = { const struct gl_texture_format _mesa_null_texformat = { -1, /* IntFormat */ + 0, /* BaseFormat */ + 0, /* BaseType */ 0, /* RedBits */ 0, /* GreenBits */ 0, /* BlueBits */ @@ -428,6 +470,8 @@ const struct gl_texture_format _mesa_null_texformat = { void _mesa_init_tex_format( GLcontext *ctx, GLenum internalFormat, struct gl_texture_image *texImage ) { + const struct gl_texture_format *texFormat; + texImage->IntFormat = internalFormat; /* Ask the driver for the base format, if it doesn't know, it will @@ -448,16 +492,12 @@ void _mesa_init_tex_format( GLcontext *ctx, GLenum internalFormat, */ case 4: /* Quake3 uses this... */ case GL_RGBA: - texImage->Format = GL_RGBA; - texImage->Type = CHAN_TYPE; - texImage->TexFormat = &_mesa_texformat_rgba; + texFormat = &_mesa_texformat_rgba; break; case 3: /* ... and this. */ case GL_RGB: - texImage->Format = GL_RGB; - texImage->Type = CHAN_TYPE; - texImage->TexFormat = &_mesa_texformat_rgb; + texFormat = &_mesa_texformat_rgb; break; /* GH: Okay, keep checking as normal. Still test for GL_RGB, @@ -470,9 +510,7 @@ void _mesa_init_tex_format( GLcontext *ctx, GLenum internalFormat, case GL_RGB10_A2: case GL_RGBA12: case GL_RGBA16: - texImage->Format = GL_RGBA; - texImage->Type = CHAN_TYPE; - texImage->TexFormat = &_mesa_texformat_rgba; + texFormat = &_mesa_texformat_rgba; break; case GL_R3_G3_B2: @@ -482,9 +520,7 @@ void _mesa_init_tex_format( GLcontext *ctx, GLenum internalFormat, case GL_RGB10: case GL_RGB12: case GL_RGB16: - texImage->Format = GL_RGB; - texImage->Type = CHAN_TYPE; - texImage->TexFormat = &_mesa_texformat_rgb; + texFormat = &_mesa_texformat_rgb; break; case GL_ALPHA: @@ -492,9 +528,7 @@ void _mesa_init_tex_format( GLcontext *ctx, GLenum internalFormat, case GL_ALPHA8: case GL_ALPHA12: case GL_ALPHA16: - texImage->Format = GL_ALPHA; - texImage->Type = CHAN_TYPE; - texImage->TexFormat = &_mesa_texformat_alpha; + texFormat = &_mesa_texformat_alpha; break; case 1: @@ -503,9 +537,7 @@ void _mesa_init_tex_format( GLcontext *ctx, GLenum internalFormat, case GL_LUMINANCE8: case GL_LUMINANCE12: case GL_LUMINANCE16: - texImage->Format = GL_LUMINANCE; - texImage->Type = CHAN_TYPE; - texImage->TexFormat = &_mesa_texformat_luminance; + texFormat = &_mesa_texformat_luminance; break; case 2: @@ -516,9 +548,7 @@ void _mesa_init_tex_format( GLcontext *ctx, GLenum internalFormat, case GL_LUMINANCE12_ALPHA4: case GL_LUMINANCE12_ALPHA12: case GL_LUMINANCE16_ALPHA16: - texImage->Format = GL_LUMINANCE_ALPHA; - texImage->Type = CHAN_TYPE; - texImage->TexFormat = &_mesa_texformat_luminance_alpha; + texFormat = &_mesa_texformat_luminance_alpha; break; case GL_INTENSITY: @@ -526,9 +556,7 @@ void _mesa_init_tex_format( GLcontext *ctx, GLenum internalFormat, case GL_INTENSITY8: case GL_INTENSITY12: case GL_INTENSITY16: - texImage->Format = GL_INTENSITY; - texImage->Type = CHAN_TYPE; - texImage->TexFormat = &_mesa_texformat_intensity; + texFormat = &_mesa_texformat_intensity; break; case GL_COLOR_INDEX: @@ -538,28 +566,27 @@ void _mesa_init_tex_format( GLcontext *ctx, GLenum internalFormat, case GL_COLOR_INDEX8_EXT: case GL_COLOR_INDEX12_EXT: case GL_COLOR_INDEX16_EXT: - texImage->Format = GL_COLOR_INDEX; - texImage->Type = CHAN_TYPE; - texImage->TexFormat = &_mesa_texformat_color_index; + texFormat = &_mesa_texformat_color_index; break; case GL_DEPTH_COMPONENT: case GL_DEPTH_COMPONENT16_SGIX: case GL_DEPTH_COMPONENT24_SGIX: case GL_DEPTH_COMPONENT32_SGIX: - if ( ctx->Extensions.SGIX_depth_texture ) { - texImage->Format = GL_DEPTH_COMPONENT; - texImage->Type = GL_FLOAT; /* XXX or GL_UNSIGNED_INT? */ - texImage->TexFormat = &_mesa_texformat_depth_component; - } else { - /* This error should have already been caught and dealt with. - */ + if ( !ctx->Extensions.SGIX_depth_texture ) _mesa_problem( ctx, "depth format without GL_SGIX_depth_texture" ); - } + texFormat = &_mesa_texformat_depth_component; break; default: _mesa_problem( ctx, "unexpected format in _mesa_init_tex_format" ); return; } + + /* Initialize the base format and type. + */ + texImage->Format = texFormat->BaseFormat; + texImage->Type = texFormat->BaseType; + + texImage->TexFormat = texFormat; } diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 3c4a08371c..0d2807cf95 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -1,4 +1,4 @@ -/* $Id: texstore.c,v 1.18 2001/03/21 16:44:08 brianp Exp $ */ +/* $Id: texstore.c,v 1.19 2001/03/27 19:18:02 gareth Exp $ */ /* * Mesa 3-D graphics library @@ -398,6 +398,7 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level, struct gl_texture_image *texImage) { GLint postConvWidth = width; + GLint texelBytes; if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) { _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL); @@ -407,9 +408,10 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level, _mesa_init_tex_format( ctx, internalFormat, texImage ); texImage->FetchTexel = texImage->TexFormat->FetchTexel1D; + texelBytes = texImage->TexFormat->TexelBytes; + /* allocate memory */ - texImage->Data = (GLchan *) MALLOC(postConvWidth * - texImage->TexFormat->TexelBytes); + texImage->Data = (GLchan *) MALLOC(postConvWidth * texelBytes); if (!texImage->Data) return; /* out of memory */ @@ -484,13 +486,14 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level, struct gl_texture_object *texObj, struct gl_texture_image *texImage) { + const struct gl_texture_format *texFormat; GLint texelBytes; /* setup the teximage struct's fields */ _mesa_init_tex_format( ctx, internalFormat, texImage ); - texImage->FetchTexel = texImage->TexFormat->FetchTexel3D; + texImage->FetchTexel = texFormat->FetchTexel3D; - texelBytes = texImage->TexFormat->TexelBytes; + texelBytes = texFormat->TexelBytes; /* allocate memory */ texImage->Data = (GLchan *) MALLOC(width * height * depth * texelBytes); @@ -646,6 +649,7 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level, struct gl_texture_unit *texUnit; struct gl_texture_object *texObj; struct gl_texture_image *texImage; + const struct gl_texture_format *texFormat; (void) format; (void) type; @@ -662,5 +666,9 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level, /* setup the teximage struct's fields */ _mesa_init_tex_format( ctx, internalFormat, texImage ); + texFormat = texImage->TexFormat; + texImage->Format = texFormat->BaseFormat; + texImage->Type = texFormat->BaseType; + return GL_TRUE; } diff --git a/src/mesa/main/texutil.c b/src/mesa/main/texutil.c index 22733c8858..5b8edc1f16 100644 --- a/src/mesa/main/texutil.c +++ b/src/mesa/main/texutil.c @@ -1,4 +1,4 @@ -/* $Id: texutil.c,v 1.18 2001/03/22 06:23:56 gareth Exp $ */ +/* $Id: texutil.c,v 1.19 2001/03/27 19:18:02 gareth Exp $ */ /* * Mesa 3-D graphics library @@ -411,6 +411,22 @@ CONVERT_ARGB4444( texsubimage3d ) #define CONVERT_TEXEL( src ) \ + ({ GLushort s = *(GLushort *)src; \ + s = (s >> 1) | ((s & 1) << 15); s; }) + +#define CONVERT_TEXEL_DWORD( src ) \ + ({ GLuint s = *(GLuint *)src; \ + s = (((s & 0xfffefffe) >> 1) | \ + ((s & 0x00010001) << 15)); s; }) + +#define SRC_TEXEL_BYTES 2 + +#define TAG(x) x##_rgba5551_to_argb1555 +#define PRESERVE_DST_TYPE +#include "texutil_tmp.h" + + +#define CONVERT_TEXEL( src ) \ PACK_COLOR_1555( src[3], src[0], src[1], src[2] ) #define CONVERT_TEXEL_DWORD( src ) \ @@ -436,6 +452,11 @@ convert_##name##_argb1555( struct gl_texture_convert *convert ) \ tab = name##_tab_argb1555_direct; \ } \ else if ( convert->format == GL_RGBA && \ + convert->type == GL_UNSIGNED_SHORT_5_5_5_1 ) \ + { \ + tab = name##_tab_rgba5551_to_argb1555; \ + } \ + else if ( convert->format == GL_RGBA && \ convert->type == GL_UNSIGNED_BYTE ) \ { \ tab = name##_tab_rgba8888_to_argb1555; \ @@ -497,6 +518,20 @@ CONVERT_ARGB1555( texsubimage3d ) #define SRC_TEXEL_BYTES 1 #define TAG(x) x##_l8_to_al88 +#define PRESERVE_DST_TYPE +#include "texutil_tmp.h" + + +#define CONVERT_TEXEL( src ) \ + PACK_COLOR_88( src[3], src[0] ) + +#define CONVERT_TEXEL_DWORD( src ) \ + ((PACK_COLOR_88( src[3], src[0] )) | \ + (PACK_COLOR_88( src[7], src[1] ) << 16)) + +#define SRC_TEXEL_BYTES 4 + +#define TAG(x) x##_abgr8888_to_al88 #include "texutil_tmp.h" @@ -522,6 +557,11 @@ convert_##name##_al88( struct gl_texture_convert *convert ) \ { \ tab = name##_tab_l8_to_al88; \ } \ + else if ( convert->format == GL_RGBA && \ + convert->type == GL_UNSIGNED_BYTE ) \ + { \ + tab = name##_tab_abgr8888_to_al88; \ + } \ else \ { \ /* Can't handle this source format/type combination */ \ |