FetchTexel routines). - Initial hooks for GL_EXT_texture_filter_anisotropic.tags/mesa_3_5
| @@ -1,4 +1,4 @@ | |||
| # $Id: Makefile.X11,v 1.45 2001/02/16 18:14:41 keithw Exp $ | |||
| # $Id: Makefile.X11,v 1.46 2001/03/18 08:53:49 gareth Exp $ | |||
| # Mesa 3-D graphics library | |||
| # Version: 3.5 | |||
| @@ -99,6 +99,7 @@ CORE_SOURCES = \ | |||
| scissor.c \ | |||
| state.c \ | |||
| stencil.c \ | |||
| texformat.c \ | |||
| teximage.c \ | |||
| texobj.c \ | |||
| texstate.c \ | |||
| @@ -1,4 +1,4 @@ | |||
| # $Id: Makefile.X11,v 1.45 2001/02/16 18:14:41 keithw Exp $ | |||
| # $Id: Makefile.X11,v 1.46 2001/03/18 08:53:49 gareth Exp $ | |||
| # Mesa 3-D graphics library | |||
| # Version: 3.5 | |||
| @@ -99,6 +99,7 @@ CORE_SOURCES = \ | |||
| scissor.c \ | |||
| state.c \ | |||
| stencil.c \ | |||
| texformat.c \ | |||
| teximage.c \ | |||
| texobj.c \ | |||
| texstate.c \ | |||
| @@ -1,4 +1,4 @@ | |||
| /* $Id: attrib.c,v 1.46 2001/03/12 00:48:37 gareth Exp $ */ | |||
| /* $Id: attrib.c,v 1.47 2001/03/18 08:53:49 gareth Exp $ */ | |||
| /* | |||
| * Mesa 3-D graphics library | |||
| @@ -101,6 +101,7 @@ copy_texobj_state( struct gl_texture_object *dest, | |||
| dest->MaxLod = src->MaxLod; | |||
| dest->BaseLevel = src->BaseLevel; | |||
| dest->MaxLevel = src->MaxLevel; | |||
| dest->MaxAnisotropy = src->MaxAnisotropy; | |||
| dest->CompareFlag = src->CompareFlag; | |||
| dest->CompareOperator = src->CompareOperator; | |||
| dest->ShadowAmbient = src->ShadowAmbient; | |||
| @@ -1,4 +1,4 @@ | |||
| /* $Id: config.h,v 1.27 2001/03/12 00:48:37 gareth Exp $ */ | |||
| /* $Id: config.h,v 1.28 2001/03/18 08:53:49 gareth Exp $ */ | |||
| /* | |||
| * Mesa 3-D graphics library | |||
| @@ -125,6 +125,9 @@ | |||
| /* GL_ARB_texture_compression */ | |||
| #define MAX_COMPRESSED_TEXTURE_FORMATS 25 | |||
| /* GL_EXT_texture_filter_anisotropic */ | |||
| #define MAX_TEXTURE_MAX_ANISOTROPY 16.0 | |||
| /* | |||
| @@ -1,4 +1,4 @@ | |||
| /* $Id: context.c,v 1.128 2001/03/12 01:32:20 gareth Exp $ */ | |||
| /* $Id: context.c,v 1.129 2001/03/18 08:53:49 gareth Exp $ */ | |||
| /* | |||
| * Mesa 3-D graphics library | |||
| @@ -721,6 +721,7 @@ init_attrib_groups( GLcontext *ctx ) | |||
| ctx->Const.MaxTextureSize = 1 << (MAX_TEXTURE_LEVELS - 1); | |||
| ctx->Const.MaxCubeTextureSize = ctx->Const.MaxTextureSize; | |||
| ctx->Const.MaxTextureUnits = MAX_TEXTURE_UNITS; | |||
| ctx->Const.MaxTextureMaxAnisotropy = MAX_TEXTURE_MAX_ANISOTROPY; | |||
| ctx->Const.MaxArrayLockSize = MAX_ARRAY_LOCK_SIZE; | |||
| ctx->Const.SubPixelBits = SUB_PIXEL_BITS; | |||
| ctx->Const.MinPointSize = MIN_POINT_SIZE; | |||
| @@ -1,4 +1,4 @@ | |||
| /* $Id: extensions.c,v 1.52 2001/03/15 18:21:01 brianp Exp $ */ | |||
| /* $Id: extensions.c,v 1.53 2001/03/18 08:53:49 gareth Exp $ */ | |||
| /* | |||
| * Mesa 3-D graphics library | |||
| @@ -56,59 +56,60 @@ static struct { | |||
| const char *name; | |||
| int flag_offset; | |||
| } default_extensions[] = { | |||
| { OFF, "GL_ARB_imaging", F(ARB_imaging) }, | |||
| { OFF, "GL_ARB_multitexture", F(ARB_multitexture) }, | |||
| { OFF, "GL_ARB_texture_compression", F(ARB_texture_compression) }, | |||
| { OFF, "GL_ARB_texture_cube_map", F(ARB_texture_cube_map) }, | |||
| { OFF, "GL_ARB_texture_env_add", F(EXT_texture_env_add) }, | |||
| { ON, "GL_ARB_tranpose_matrix", 0 }, | |||
| { ON, "GL_EXT_abgr", 0 }, | |||
| { ON, "GL_EXT_bgra", 0 }, | |||
| { OFF, "GL_EXT_blend_color", F(EXT_blend_color) }, | |||
| { OFF, "GL_EXT_blend_func_separate", F(EXT_blend_func_separate) }, | |||
| { OFF, "GL_EXT_blend_logic_op", F(EXT_blend_logic_op) }, | |||
| { OFF, "GL_EXT_blend_minmax", F(EXT_blend_minmax) }, | |||
| { OFF, "GL_EXT_blend_subtract", F(EXT_blend_subtract) }, | |||
| { ON, "GL_EXT_clip_volume_hint", F(EXT_clip_volume_hint) }, | |||
| { OFF, "GL_EXT_cull_vertex", 0 }, | |||
| { OFF, "GL_EXT_convolution", F(EXT_convolution) }, | |||
| { ON, "GL_EXT_compiled_vertex_array", F(EXT_compiled_vertex_array) }, | |||
| { OFF, "GL_EXT_fog_coord", F(EXT_fog_coord) }, | |||
| { OFF, "GL_EXT_histogram", F(EXT_histogram) }, | |||
| { ON, "GL_EXT_packed_pixels", F(EXT_packed_pixels) }, | |||
| { OFF, "GL_EXT_paletted_texture", F(EXT_paletted_texture) }, | |||
| { OFF, "GL_EXT_point_parameters", F(EXT_point_parameters) }, | |||
| { ON, "GL_EXT_polygon_offset", F(EXT_polygon_offset) }, | |||
| { ON, "GL_EXT_rescale_normal", F(EXT_rescale_normal) }, | |||
| { OFF, "GL_EXT_secondary_color", F(EXT_secondary_color) }, | |||
| { OFF, "GL_EXT_shared_texture_palette", F(EXT_shared_texture_palette) }, | |||
| { OFF, "GL_EXT_stencil_wrap", F(EXT_stencil_wrap) }, | |||
| { ON, "GL_EXT_texture3D", F(EXT_texture3D) }, | |||
| { OFF, "GL_EXT_texture_compression_s3tc", F(EXT_texture_compression_s3tc)}, | |||
| { OFF, "GL_EXT_texture_env_add", F(EXT_texture_env_add) }, | |||
| { OFF, "GL_EXT_texture_env_combine", F(EXT_texture_env_combine) }, | |||
| { OFF, "GL_EXT_texture_env_dot3", F(EXT_texture_env_dot3) }, | |||
| { ON, "GL_EXT_texture_object", F(EXT_texture_object) }, | |||
| { OFF, "GL_EXT_texture_lod_bias", F(EXT_texture_lod_bias) }, | |||
| { ON, "GL_EXT_vertex_array", 0 }, | |||
| { OFF, "GL_EXT_vertex_array_set", F(EXT_vertex_array_set) }, | |||
| { OFF, "GL_HP_occlusion_test", F(HP_occlusion_test) }, | |||
| { OFF, "GL_INGR_blend_func_separate", F(INGR_blend_func_separate) }, | |||
| { OFF, "GL_MESA_packed_depth_stencil", 0 }, | |||
| { OFF, "GL_MESA_resize_buffers", F(MESA_resize_buffers) }, | |||
| { OFF, "GL_MESA_sprite_point", F(MESA_sprite_point) }, | |||
| { ON, "GL_MESA_window_pos", F(MESA_window_pos) }, | |||
| { OFF, "GL_NV_blend_square", F(NV_blend_square) }, | |||
| { ON, "GL_NV_texgen_reflection", F(NV_texgen_reflection) }, | |||
| { OFF, "GL_SGI_color_matrix", F(SGI_color_matrix) }, | |||
| { OFF, "GL_SGI_color_table", F(SGI_color_table) }, | |||
| { OFF, "GL_SGIS_pixel_texture", F(SGIS_pixel_texture) }, | |||
| { OFF, "GL_SGIS_texture_edge_clamp", F(SGIS_texture_edge_clamp) }, | |||
| { OFF, "GL_SGIX_depth_texture", F(SGIX_depth_texture) }, | |||
| { OFF, "GL_SGIX_pixel_texture", F(SGIX_pixel_texture) }, | |||
| { OFF, "GL_SGIX_shadow", F(SGIX_shadow) }, | |||
| { OFF, "GL_SGIX_shadow_ambient", F(SGIX_shadow_ambient) }, | |||
| { OFF, "GL_3DFX_texture_compression_FXT1", F(_3DFX_texture_compression_FXT1) } | |||
| { OFF, "GL_ARB_imaging", F(ARB_imaging) }, | |||
| { OFF, "GL_ARB_multitexture", F(ARB_multitexture) }, | |||
| { OFF, "GL_ARB_texture_compression", F(ARB_texture_compression) }, | |||
| { OFF, "GL_ARB_texture_cube_map", F(ARB_texture_cube_map) }, | |||
| { OFF, "GL_ARB_texture_env_add", F(EXT_texture_env_add) }, | |||
| { ON, "GL_ARB_tranpose_matrix", 0 }, | |||
| { ON, "GL_EXT_abgr", 0 }, | |||
| { ON, "GL_EXT_bgra", 0 }, | |||
| { OFF, "GL_EXT_blend_color", F(EXT_blend_color) }, | |||
| { OFF, "GL_EXT_blend_func_separate", F(EXT_blend_func_separate) }, | |||
| { OFF, "GL_EXT_blend_logic_op", F(EXT_blend_logic_op) }, | |||
| { OFF, "GL_EXT_blend_minmax", F(EXT_blend_minmax) }, | |||
| { OFF, "GL_EXT_blend_subtract", F(EXT_blend_subtract) }, | |||
| { ON, "GL_EXT_clip_volume_hint", F(EXT_clip_volume_hint) }, | |||
| { OFF, "GL_EXT_cull_vertex", 0 }, | |||
| { OFF, "GL_EXT_convolution", F(EXT_convolution) }, | |||
| { ON, "GL_EXT_compiled_vertex_array", F(EXT_compiled_vertex_array) }, | |||
| { OFF, "GL_EXT_fog_coord", F(EXT_fog_coord) }, | |||
| { OFF, "GL_EXT_histogram", F(EXT_histogram) }, | |||
| { ON, "GL_EXT_packed_pixels", F(EXT_packed_pixels) }, | |||
| { OFF, "GL_EXT_paletted_texture", F(EXT_paletted_texture) }, | |||
| { OFF, "GL_EXT_point_parameters", F(EXT_point_parameters) }, | |||
| { ON, "GL_EXT_polygon_offset", F(EXT_polygon_offset) }, | |||
| { ON, "GL_EXT_rescale_normal", F(EXT_rescale_normal) }, | |||
| { OFF, "GL_EXT_secondary_color", F(EXT_secondary_color) }, | |||
| { OFF, "GL_EXT_shared_texture_palette", F(EXT_shared_texture_palette) }, | |||
| { OFF, "GL_EXT_stencil_wrap", F(EXT_stencil_wrap) }, | |||
| { ON, "GL_EXT_texture3D", F(EXT_texture3D) }, | |||
| { OFF, "GL_EXT_texture_compression_s3tc", F(EXT_texture_compression_s3tc) }, | |||
| { OFF, "GL_EXT_texture_env_add", F(EXT_texture_env_add) }, | |||
| { OFF, "GL_EXT_texture_env_combine", F(EXT_texture_env_combine) }, | |||
| { OFF, "GL_EXT_texture_env_dot3", F(EXT_texture_env_dot3) }, | |||
| { OFF, "GL_EXT_texture_filter_anisotropic", F(EXT_texture_filter_anisotropic) }, | |||
| { ON, "GL_EXT_texture_object", F(EXT_texture_object) }, | |||
| { OFF, "GL_EXT_texture_lod_bias", F(EXT_texture_lod_bias) }, | |||
| { ON, "GL_EXT_vertex_array", 0 }, | |||
| { OFF, "GL_EXT_vertex_array_set", F(EXT_vertex_array_set) }, | |||
| { OFF, "GL_HP_occlusion_test", F(HP_occlusion_test) }, | |||
| { OFF, "GL_INGR_blend_func_separate", F(INGR_blend_func_separate) }, | |||
| { OFF, "GL_MESA_packed_depth_stencil", 0 }, | |||
| { OFF, "GL_MESA_resize_buffers", F(MESA_resize_buffers) }, | |||
| { OFF, "GL_MESA_sprite_point", F(MESA_sprite_point) }, | |||
| { ON, "GL_MESA_window_pos", F(MESA_window_pos) }, | |||
| { OFF, "GL_NV_blend_square", F(NV_blend_square) }, | |||
| { ON, "GL_NV_texgen_reflection", F(NV_texgen_reflection) }, | |||
| { OFF, "GL_SGI_color_matrix", F(SGI_color_matrix) }, | |||
| { OFF, "GL_SGI_color_table", F(SGI_color_table) }, | |||
| { OFF, "GL_SGIS_pixel_texture", F(SGIS_pixel_texture) }, | |||
| { OFF, "GL_SGIS_texture_edge_clamp", F(SGIS_texture_edge_clamp) }, | |||
| { OFF, "GL_SGIX_depth_texture", F(SGIX_depth_texture) }, | |||
| { OFF, "GL_SGIX_pixel_texture", F(SGIX_pixel_texture) }, | |||
| { OFF, "GL_SGIX_shadow", F(SGIX_shadow) }, | |||
| { OFF, "GL_SGIX_shadow_ambient", F(SGIX_shadow_ambient) }, | |||
| { OFF, "GL_3DFX_texture_compression_FXT1", F(_3DFX_texture_compression_FXT1) } | |||
| }; | |||
| @@ -1,4 +1,4 @@ | |||
| /* $Id: get.c,v 1.56 2001/03/12 00:48:37 gareth Exp $ */ | |||
| /* $Id: get.c,v 1.57 2001/03/18 08:53:49 gareth Exp $ */ | |||
| /* | |||
| * Mesa 3-D graphics library | |||
| @@ -1253,6 +1253,17 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) | |||
| *params = INT_TO_BOOL(ctx->Array.FogCoord.Stride); | |||
| break; | |||
| /* GL_EXT_texture_filter_anisotropic */ | |||
| case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: | |||
| if (ctx->Extensions.EXT_texture_filter_anisotropic) { | |||
| *params = FLOAT_TO_BOOL(ctx->Const.MaxTextureMaxAnisotropy); | |||
| } | |||
| else { | |||
| _mesa_error( ctx, GL_INVALID_ENUM, "glGetBooleanv" ); | |||
| return; | |||
| } | |||
| break; | |||
| /* GL_MESA_sprite_point */ | |||
| case GL_SPRITE_POINT_MESA: | |||
| if (ctx->Extensions.MESA_sprite_point) { | |||
| @@ -2441,6 +2452,17 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) | |||
| *params = (GLdouble) ctx->Array.FogCoord.Stride; | |||
| break; | |||
| /* GL_EXT_texture_filter_anisotropic */ | |||
| case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: | |||
| if (ctx->Extensions.EXT_texture_filter_anisotropic) { | |||
| *params = (GLdouble) ctx->Const.MaxTextureMaxAnisotropy; | |||
| } | |||
| else { | |||
| _mesa_error( ctx, GL_INVALID_ENUM, "glGetDoublev" ); | |||
| return; | |||
| } | |||
| break; | |||
| /* GL_MESA_sprite_point */ | |||
| case GL_SPRITE_POINT_MESA: | |||
| if (ctx->Extensions.MESA_sprite_point) { | |||
| @@ -3603,6 +3625,17 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) | |||
| *params = (GLfloat) ctx->Array.FogCoord.Stride; | |||
| break; | |||
| /* GL_EXT_texture_filter_anisotropic */ | |||
| case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: | |||
| if (ctx->Extensions.EXT_texture_filter_anisotropic) { | |||
| *params = ctx->Const.MaxTextureMaxAnisotropy; | |||
| } | |||
| else { | |||
| _mesa_error( ctx, GL_INVALID_ENUM, "glGetFloatv" ); | |||
| return; | |||
| } | |||
| break; | |||
| /* GL_MESA_sprite_point */ | |||
| case GL_SPRITE_POINT_MESA: | |||
| if (ctx->Extensions.MESA_sprite_point) { | |||
| @@ -4814,6 +4847,17 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) | |||
| } | |||
| break; | |||
| /* GL_EXT_texture_filter_anisotropic */ | |||
| case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: | |||
| if (ctx->Extensions.EXT_texture_filter_anisotropic) { | |||
| *params = (GLint) ctx->Const.MaxTextureMaxAnisotropy; | |||
| } | |||
| else { | |||
| _mesa_error( ctx, GL_INVALID_ENUM, "glGetIntegerv" ); | |||
| return; | |||
| } | |||
| break; | |||
| /* GL_MESA_sprite_point */ | |||
| case GL_SPRITE_POINT_MESA: | |||
| if (ctx->Extensions.MESA_sprite_point) { | |||
| @@ -1,4 +1,4 @@ | |||
| /* $Id: macros.h,v 1.19 2001/03/12 00:48:38 gareth Exp $ */ | |||
| /* $Id: macros.h,v 1.20 2001/03/18 08:53:49 gareth Exp $ */ | |||
| /* | |||
| * Mesa 3-D graphics library | |||
| @@ -443,4 +443,31 @@ do { \ | |||
| } while (0) | |||
| /* Generic color packing macros | |||
| */ | |||
| #define PACK_COLOR_8888( a, b, c, d ) \ | |||
| (((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) | |||
| #define PACK_COLOR_888( a, b, c ) \ | |||
| (((a) << 16) | ((b) << 8) | (c)) | |||
| #define PACK_COLOR_565( a, b, c ) \ | |||
| ((((a) & 0xf8) << 8) | (((b) & 0xfc) << 3) | (((c) & 0xf8) >> 3)) | |||
| #define PACK_COLOR_1555( a, b, c, d ) \ | |||
| ((((b) & 0xf8) << 7) | (((c) & 0xf8) << 2) | (((d) & 0xf8) >> 3) | \ | |||
| ((a) ? 0x8000 : 0)) | |||
| #define PACK_COLOR_4444( a, b, c, d ) \ | |||
| ((((a) & 0xf0) << 8) | (((b) & 0xf0) << 4) | ((c) & 0xf0) | ((d) >> 4)) | |||
| #define PACK_COLOR_88( a, b ) \ | |||
| (((a) << 8) | (b)) | |||
| #define PACK_COLOR_332( a, b, c ) \ | |||
| (((a) & 0xe0) | (((b) & 0xe0) >> 3) | (((c) & 0xc0) >> 6)) | |||
| #endif | |||
| @@ -1,4 +1,4 @@ | |||
| /* $Id: mtypes.h,v 1.26 2001/03/17 17:43:04 keithw Exp $ */ | |||
| /* $Id: mtypes.h,v 1.27 2001/03/18 08:53:49 gareth Exp $ */ | |||
| /* | |||
| * Mesa 3-D graphics library | |||
| @@ -775,6 +775,25 @@ typedef void (*FetchTexelFunc)( const struct gl_texture_image *texImage, | |||
| GLint col, GLint row, GLint img, | |||
| GLvoid *texelOut ); | |||
| /* Texture format record */ | |||
| struct gl_texture_format { | |||
| GLint IntFormat; /* One of the MESA_FORMAT_* values */ | |||
| GLubyte RedBits; /* Bits per texel component */ | |||
| GLubyte GreenBits; | |||
| GLubyte BlueBits; | |||
| GLubyte AlphaBits; | |||
| GLubyte LuminanceBits; | |||
| GLubyte IntensityBits; | |||
| GLubyte IndexBits; | |||
| GLubyte DepthBits; | |||
| GLint TexelBytes; | |||
| FetchTexelFunc FetchTexel1D; /* Texel fetch function pointers */ | |||
| FetchTexelFunc FetchTexel2D; | |||
| FetchTexelFunc FetchTexel3D; | |||
| }; | |||
| /* Texture image record */ | |||
| struct gl_texture_image { | |||
| @@ -784,14 +803,6 @@ struct gl_texture_image { | |||
| */ | |||
| GLenum Type; /* Texel type: GL_UNSIGNED_BYTE, etc. */ | |||
| GLenum IntFormat; /* Internal format as given by the user */ | |||
| GLubyte RedBits; /* Bits per texel component */ | |||
| GLubyte GreenBits; /* These are initialized by Mesa but */ | |||
| GLubyte BlueBits; /* may be reassigned by the device */ | |||
| GLubyte AlphaBits; /* driver to indicate the true texture */ | |||
| GLubyte IntensityBits; /* color resolution. */ | |||
| GLubyte LuminanceBits; | |||
| GLubyte IndexBits; | |||
| GLubyte DepthBits; | |||
| GLuint Border; /* 0 or 1 */ | |||
| GLuint Width; /* = 2^WidthLog2 + 2*Border */ | |||
| GLuint Height; /* = 2^HeightLog2 + 2*Border */ | |||
| @@ -805,7 +816,9 @@ struct gl_texture_image { | |||
| GLuint MaxLog2; /* = MAX(WidthLog2, HeightLog2) */ | |||
| GLvoid *Data; /* Image data, accessed via FetchTexel() */ | |||
| FetchTexelFunc FetchTexel; /* texel fetch function pointer */ | |||
| const struct gl_texture_format *TexFormat; | |||
| FetchTexelFunc FetchTexel; /* Texel fetch function pointer */ | |||
| GLboolean IsCompressed; /* GL_ARB_texture_compression */ | |||
| GLuint CompressedSize; /* GL_ARB_texture_compression */ | |||
| @@ -832,6 +845,7 @@ struct gl_texture_object { | |||
| GLfloat MaxLod; /* max lambda, OpenGL 1.2 */ | |||
| GLint BaseLevel; /* min mipmap level, OpenGL 1.2 */ | |||
| GLint MaxLevel; /* max mipmap level, OpenGL 1.2 */ | |||
| GLfloat MaxAnisotropy; /* GL_EXT_texture_filter_anisotropic */ | |||
| GLboolean CompareFlag; /* GL_SGIX_shadow */ | |||
| GLenum CompareOperator; /* GL_SGIX_shadow */ | |||
| GLchan ShadowAmbient; /* GL_SGIX_shadow_ambient */ | |||
| @@ -1157,6 +1171,7 @@ struct gl_constants { | |||
| GLint MaxCubeTextureSize; | |||
| GLint MaxTextureLevels; | |||
| GLuint MaxTextureUnits; | |||
| GLfloat MaxTextureMaxAnisotropy; /* GL_EXT_texture_filter_anisotropic */ | |||
| GLuint MaxArrayLockSize; | |||
| GLint SubPixelBits; | |||
| GLfloat MinPointSize, MaxPointSize; /* aliased */ | |||
| @@ -1213,6 +1228,7 @@ struct gl_extensions { | |||
| GLboolean EXT_texture_env_add; | |||
| GLboolean EXT_texture_env_combine; | |||
| GLboolean EXT_texture_env_dot3; | |||
| GLboolean EXT_texture_filter_anisotropic; | |||
| GLboolean EXT_texture_object; | |||
| GLboolean EXT_texture_lod_bias; | |||
| GLboolean EXT_vertex_array_set; | |||
| @@ -0,0 +1,566 @@ | |||
| /* $Id: texformat.c,v 1.2 2001/03/18 08:53:49 gareth Exp $ */ | |||
| /* | |||
| * Mesa 3-D graphics library | |||
| * Version: 3.5 | |||
| * | |||
| * Copyright (C) 1999-2001 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. | |||
| * | |||
| * Author: | |||
| * Gareth Hughes <gareth@valinux.com> | |||
| */ | |||
| #ifdef PC_HEADER | |||
| #include "all.h" | |||
| #else | |||
| #include "glheader.h" | |||
| #include "colormac.h" | |||
| #include "context.h" | |||
| #include "image.h" | |||
| #include "mem.h" | |||
| #include "mmath.h" | |||
| #include "mtypes.h" | |||
| #include "texformat.h" | |||
| #include "teximage.h" | |||
| #include "texstate.h" | |||
| #include "swrast/s_span.h" | |||
| #endif | |||
| /* Texel fetch routines for all supported formats: | |||
| */ | |||
| #define DIM 1 | |||
| #include "texformat_tmp.h" | |||
| #define DIM 2 | |||
| #include "texformat_tmp.h" | |||
| #define DIM 3 | |||
| #include "texformat_tmp.h" | |||
| /* Have to have this so the FetchTexel function pointer is never NULL. | |||
| */ | |||
| static void fetch_null_texel( const struct gl_texture_image *texImage, | |||
| GLint i, GLint j, GLint k, GLvoid *texel ) | |||
| { | |||
| GLchan *rgba = (GLchan *) texel; | |||
| rgba[RCOMP] = 0; | |||
| rgba[GCOMP] = 0; | |||
| rgba[BCOMP] = 0; | |||
| rgba[ACOMP] = 0; | |||
| } | |||
| /* ================================================================ | |||
| * Default GLchan-based formats: | |||
| */ | |||
| const struct gl_texture_format _mesa_texformat_rgba = { | |||
| MESA_FORMAT_RGBA, /* IntFormat */ | |||
| CHAN_BITS, /* RedBits */ | |||
| CHAN_BITS, /* GreenBits */ | |||
| CHAN_BITS, /* BlueBits */ | |||
| CHAN_BITS, /* AlphaBits */ | |||
| 0, /* LuminanceBits */ | |||
| 0, /* IntensityBits */ | |||
| 0, /* IndexBits */ | |||
| 0, /* DepthBits */ | |||
| 4 * CHAN_BITS / 8, /* TexelBytes */ | |||
| fetch_1d_texel_rgba, /* FetchTexel1D */ | |||
| fetch_2d_texel_rgba, /* FetchTexel2D */ | |||
| fetch_3d_texel_rgba, /* FetchTexel3D */ | |||
| }; | |||
| const struct gl_texture_format _mesa_texformat_rgb = { | |||
| MESA_FORMAT_RGBA, /* IntFormat */ | |||
| CHAN_BITS, /* RedBits */ | |||
| CHAN_BITS, /* GreenBits */ | |||
| CHAN_BITS, /* BlueBits */ | |||
| 0, /* AlphaBits */ | |||
| 0, /* LuminanceBits */ | |||
| 0, /* IntensityBits */ | |||
| 0, /* IndexBits */ | |||
| 0, /* DepthBits */ | |||
| 3 * CHAN_BITS / 8, /* TexelBytes */ | |||
| fetch_1d_texel_rgb, /* FetchTexel1D */ | |||
| fetch_2d_texel_rgb, /* FetchTexel2D */ | |||
| fetch_3d_texel_rgb, /* FetchTexel3D */ | |||
| }; | |||
| const struct gl_texture_format _mesa_texformat_alpha = { | |||
| MESA_FORMAT_ALPHA, /* IntFormat */ | |||
| 0, /* RedBits */ | |||
| 0, /* GreenBits */ | |||
| 0, /* BlueBits */ | |||
| CHAN_BITS, /* AlphaBits */ | |||
| 0, /* LuminanceBits */ | |||
| 0, /* IntensityBits */ | |||
| 0, /* IndexBits */ | |||
| 0, /* DepthBits */ | |||
| CHAN_BITS / 8, /* TexelBytes */ | |||
| fetch_1d_texel_alpha, /* FetchTexel1D */ | |||
| fetch_2d_texel_alpha, /* FetchTexel2D */ | |||
| fetch_3d_texel_alpha, /* FetchTexel3D */ | |||
| }; | |||
| const struct gl_texture_format _mesa_texformat_luminance = { | |||
| MESA_FORMAT_LUMINANCE, /* IntFormat */ | |||
| 0, /* RedBits */ | |||
| 0, /* GreenBits */ | |||
| 0, /* BlueBits */ | |||
| 0, /* AlphaBits */ | |||
| CHAN_BITS, /* LuminanceBits */ | |||
| 0, /* IntensityBits */ | |||
| 0, /* IndexBits */ | |||
| 0, /* DepthBits */ | |||
| CHAN_BITS / 8, /* TexelBytes */ | |||
| fetch_1d_texel_luminance, /* FetchTexel1D */ | |||
| fetch_2d_texel_luminance, /* FetchTexel2D */ | |||
| fetch_3d_texel_luminance, /* FetchTexel3D */ | |||
| }; | |||
| const struct gl_texture_format _mesa_texformat_luminance_alpha = { | |||
| MESA_FORMAT_LUMINANCE_ALPHA, /* IntFormat */ | |||
| 0, /* RedBits */ | |||
| 0, /* GreenBits */ | |||
| 0, /* BlueBits */ | |||
| CHAN_BITS, /* AlphaBits */ | |||
| CHAN_BITS, /* LuminanceBits */ | |||
| 0, /* IntensityBits */ | |||
| 0, /* IndexBits */ | |||
| 0, /* DepthBits */ | |||
| 2 * CHAN_BITS / 8, /* TexelBytes */ | |||
| fetch_1d_texel_luminance_alpha, /* FetchTexel1D */ | |||
| fetch_2d_texel_luminance_alpha, /* FetchTexel2D */ | |||
| fetch_3d_texel_luminance_alpha, /* FetchTexel3D */ | |||
| }; | |||
| const struct gl_texture_format _mesa_texformat_intensity = { | |||
| MESA_FORMAT_INTENSITY, /* IntFormat */ | |||
| 0, /* RedBits */ | |||
| 0, /* GreenBits */ | |||
| 0, /* BlueBits */ | |||
| 0, /* AlphaBits */ | |||
| 0, /* LuminanceBits */ | |||
| CHAN_BITS, /* IntensityBits */ | |||
| 0, /* IndexBits */ | |||
| 0, /* DepthBits */ | |||
| CHAN_BITS / 8, /* TexelBytes */ | |||
| fetch_1d_texel_intensity, /* FetchTexel1D */ | |||
| fetch_2d_texel_intensity, /* FetchTexel2D */ | |||
| fetch_3d_texel_intensity, /* FetchTexel3D */ | |||
| }; | |||
| const struct gl_texture_format _mesa_texformat_color_index = { | |||
| MESA_FORMAT_COLOR_INDEX, /* IntFormat */ | |||
| 0, /* RedBits */ | |||
| 0, /* GreenBits */ | |||
| 0, /* BlueBits */ | |||
| 0, /* AlphaBits */ | |||
| 0, /* LuminanceBits */ | |||
| 0, /* IntensityBits */ | |||
| CHAN_BITS, /* IndexBits */ | |||
| 0, /* DepthBits */ | |||
| CHAN_BITS / 8, /* TexelBytes */ | |||
| fetch_1d_texel_color_index, /* FetchTexel1D */ | |||
| fetch_2d_texel_color_index, /* FetchTexel2D */ | |||
| fetch_3d_texel_color_index, /* FetchTexel3D */ | |||
| }; | |||
| const struct gl_texture_format _mesa_texformat_depth_component = { | |||
| MESA_FORMAT_DEPTH_COMPONENT, /* IntFormat */ | |||
| 0, /* RedBits */ | |||
| 0, /* GreenBits */ | |||
| 0, /* BlueBits */ | |||
| 0, /* AlphaBits */ | |||
| 0, /* LuminanceBits */ | |||
| 0, /* IntensityBits */ | |||
| 0, /* IndexBits */ | |||
| sizeof(GLfloat) * 8, /* DepthBits */ | |||
| sizeof(GLfloat), /* TexelBytes */ | |||
| fetch_1d_texel_depth_component, /* FetchTexel1D */ | |||
| fetch_2d_texel_depth_component, /* FetchTexel2D */ | |||
| fetch_3d_texel_depth_component, /* FetchTexel3D */ | |||
| }; | |||
| /* ================================================================ | |||
| * Hardware formats: | |||
| */ | |||
| const struct gl_texture_format _mesa_texformat_rgba8888 = { | |||
| MESA_FORMAT_RGBA8888, /* IntFormat */ | |||
| 8, /* RedBits */ | |||
| 8, /* GreenBits */ | |||
| 8, /* BlueBits */ | |||
| 8, /* AlphaBits */ | |||
| 0, /* LuminanceBits */ | |||
| 0, /* IntensityBits */ | |||
| 0, /* IndexBits */ | |||
| 0, /* DepthBits */ | |||
| 4, /* TexelBytes */ | |||
| fetch_1d_texel_rgba8888, /* FetchTexel1D */ | |||
| fetch_2d_texel_rgba8888, /* FetchTexel2D */ | |||
| fetch_3d_texel_rgba8888, /* FetchTexel3D */ | |||
| }; | |||
| const struct gl_texture_format _mesa_texformat_argb8888 = { | |||
| MESA_FORMAT_ARGB8888, /* IntFormat */ | |||
| 8, /* RedBits */ | |||
| 8, /* GreenBits */ | |||
| 8, /* BlueBits */ | |||
| 8, /* AlphaBits */ | |||
| 0, /* LuminanceBits */ | |||
| 0, /* IntensityBits */ | |||
| 0, /* IndexBits */ | |||
| 0, /* DepthBits */ | |||
| 4, /* TexelBytes */ | |||
| fetch_1d_texel_argb8888, /* FetchTexel1D */ | |||
| fetch_2d_texel_argb8888, /* FetchTexel2D */ | |||
| fetch_3d_texel_argb8888, /* FetchTexel3D */ | |||
| }; | |||
| const struct gl_texture_format _mesa_texformat_rgb888 = { | |||
| MESA_FORMAT_RGB888, /* IntFormat */ | |||
| 8, /* RedBits */ | |||
| 8, /* GreenBits */ | |||
| 8, /* BlueBits */ | |||
| 0, /* AlphaBits */ | |||
| 0, /* LuminanceBits */ | |||
| 0, /* IntensityBits */ | |||
| 0, /* IndexBits */ | |||
| 0, /* DepthBits */ | |||
| 3, /* TexelBytes */ | |||
| fetch_1d_texel_rgb888, /* FetchTexel1D */ | |||
| fetch_2d_texel_rgb888, /* FetchTexel2D */ | |||
| fetch_3d_texel_rgb888, /* FetchTexel3D */ | |||
| }; | |||
| const struct gl_texture_format _mesa_texformat_rgb565 = { | |||
| MESA_FORMAT_RGB565, /* IntFormat */ | |||
| 5, /* RedBits */ | |||
| 6, /* GreenBits */ | |||
| 5, /* BlueBits */ | |||
| 0, /* AlphaBits */ | |||
| 0, /* LuminanceBits */ | |||
| 0, /* IntensityBits */ | |||
| 0, /* IndexBits */ | |||
| 0, /* DepthBits */ | |||
| 2, /* TexelBytes */ | |||
| fetch_1d_texel_rgb565, /* FetchTexel1D */ | |||
| fetch_2d_texel_rgb565, /* FetchTexel2D */ | |||
| fetch_3d_texel_rgb565, /* FetchTexel3D */ | |||
| }; | |||
| const struct gl_texture_format _mesa_texformat_argb4444 = { | |||
| MESA_FORMAT_ARGB4444, /* IntFormat */ | |||
| 4, /* RedBits */ | |||
| 4, /* GreenBits */ | |||
| 4, /* BlueBits */ | |||
| 4, /* AlphaBits */ | |||
| 0, /* LuminanceBits */ | |||
| 0, /* IntensityBits */ | |||
| 0, /* IndexBits */ | |||
| 0, /* DepthBits */ | |||
| 2, /* TexelBytes */ | |||
| fetch_1d_texel_argb4444, /* FetchTexel1D */ | |||
| fetch_2d_texel_argb4444, /* FetchTexel2D */ | |||
| fetch_3d_texel_argb4444, /* FetchTexel3D */ | |||
| }; | |||
| const struct gl_texture_format _mesa_texformat_argb1555 = { | |||
| MESA_FORMAT_ARGB1555, /* IntFormat */ | |||
| 5, /* RedBits */ | |||
| 5, /* GreenBits */ | |||
| 5, /* BlueBits */ | |||
| 1, /* AlphaBits */ | |||
| 0, /* LuminanceBits */ | |||
| 0, /* IntensityBits */ | |||
| 0, /* IndexBits */ | |||
| 0, /* DepthBits */ | |||
| 2, /* TexelBytes */ | |||
| fetch_1d_texel_argb1555, /* FetchTexel1D */ | |||
| fetch_2d_texel_argb1555, /* FetchTexel2D */ | |||
| fetch_3d_texel_argb1555, /* FetchTexel3D */ | |||
| }; | |||
| const struct gl_texture_format _mesa_texformat_al88 = { | |||
| MESA_FORMAT_AL88, /* IntFormat */ | |||
| 0, /* RedBits */ | |||
| 0, /* GreenBits */ | |||
| 0, /* BlueBits */ | |||
| 8, /* AlphaBits */ | |||
| 8, /* LuminanceBits */ | |||
| 0, /* IntensityBits */ | |||
| 0, /* IndexBits */ | |||
| 0, /* DepthBits */ | |||
| 2, /* TexelBytes */ | |||
| fetch_1d_texel_al88, /* FetchTexel1D */ | |||
| fetch_2d_texel_al88, /* FetchTexel2D */ | |||
| fetch_3d_texel_al88, /* FetchTexel3D */ | |||
| }; | |||
| const struct gl_texture_format _mesa_texformat_rgb332 = { | |||
| MESA_FORMAT_RGB332, /* IntFormat */ | |||
| 3, /* RedBits */ | |||
| 3, /* GreenBits */ | |||
| 2, /* BlueBits */ | |||
| 0, /* AlphaBits */ | |||
| 0, /* LuminanceBits */ | |||
| 0, /* IntensityBits */ | |||
| 0, /* IndexBits */ | |||
| 0, /* DepthBits */ | |||
| 1, /* TexelBytes */ | |||
| fetch_1d_texel_rgb332, /* FetchTexel1D */ | |||
| fetch_2d_texel_rgb332, /* FetchTexel2D */ | |||
| fetch_3d_texel_rgb332, /* FetchTexel3D */ | |||
| }; | |||
| const struct gl_texture_format _mesa_texformat_a8 = { | |||
| MESA_FORMAT_A8, /* IntFormat */ | |||
| 0, /* RedBits */ | |||
| 0, /* GreenBits */ | |||
| 0, /* BlueBits */ | |||
| 8, /* AlphaBits */ | |||
| 0, /* LuminanceBits */ | |||
| 0, /* IntensityBits */ | |||
| 0, /* IndexBits */ | |||
| 0, /* DepthBits */ | |||
| 1, /* TexelBytes */ | |||
| fetch_1d_texel_a8, /* FetchTexel1D */ | |||
| fetch_2d_texel_a8, /* FetchTexel2D */ | |||
| fetch_3d_texel_a8, /* FetchTexel3D */ | |||
| }; | |||
| const struct gl_texture_format _mesa_texformat_l8 = { | |||
| MESA_FORMAT_L8, /* IntFormat */ | |||
| 0, /* RedBits */ | |||
| 0, /* GreenBits */ | |||
| 0, /* BlueBits */ | |||
| 0, /* AlphaBits */ | |||
| 8, /* LuminanceBits */ | |||
| 0, /* IntensityBits */ | |||
| 0, /* IndexBits */ | |||
| 0, /* DepthBits */ | |||
| 1, /* TexelBytes */ | |||
| fetch_1d_texel_l8, /* FetchTexel1D */ | |||
| fetch_2d_texel_l8, /* FetchTexel2D */ | |||
| fetch_3d_texel_l8, /* FetchTexel3D */ | |||
| }; | |||
| const struct gl_texture_format _mesa_texformat_i8 = { | |||
| MESA_FORMAT_I8, /* IntFormat */ | |||
| 0, /* RedBits */ | |||
| 0, /* GreenBits */ | |||
| 0, /* BlueBits */ | |||
| 0, /* AlphaBits */ | |||
| 0, /* LuminanceBits */ | |||
| 8, /* IntensityBits */ | |||
| 0, /* IndexBits */ | |||
| 0, /* DepthBits */ | |||
| 1, /* TexelBytes */ | |||
| fetch_1d_texel_i8, /* FetchTexel1D */ | |||
| fetch_2d_texel_i8, /* FetchTexel2D */ | |||
| fetch_3d_texel_i8, /* FetchTexel3D */ | |||
| }; | |||
| const struct gl_texture_format _mesa_texformat_ci8 = { | |||
| MESA_FORMAT_CI8, /* IntFormat */ | |||
| 0, /* RedBits */ | |||
| 0, /* GreenBits */ | |||
| 0, /* BlueBits */ | |||
| 0, /* AlphaBits */ | |||
| 0, /* LuminanceBits */ | |||
| 0, /* IntensityBits */ | |||
| 8, /* IndexBits */ | |||
| 0, /* DepthBits */ | |||
| 1, /* TexelBytes */ | |||
| fetch_1d_texel_ci8, /* FetchTexel1D */ | |||
| fetch_2d_texel_ci8, /* FetchTexel2D */ | |||
| fetch_3d_texel_ci8, /* FetchTexel3D */ | |||
| }; | |||
| /* ================================================================ | |||
| * Null format: | |||
| */ | |||
| const struct gl_texture_format _mesa_null_texformat = { | |||
| -1, /* IntFormat */ | |||
| 0, /* RedBits */ | |||
| 0, /* GreenBits */ | |||
| 0, /* BlueBits */ | |||
| 0, /* AlphaBits */ | |||
| 0, /* LuminanceBits */ | |||
| 0, /* IntensityBits */ | |||
| 0, /* IndexBits */ | |||
| 0, /* DepthBits */ | |||
| 0, /* TexelBytes */ | |||
| fetch_null_texel, /* FetchTexel1D */ | |||
| fetch_null_texel, /* FetchTexel2D */ | |||
| fetch_null_texel, /* FetchTexel3D */ | |||
| }; | |||
| /* | |||
| * Given an internal texture format enum or 1, 2, 3, 4 return the | |||
| * corresponding _base_ internal format: GL_ALPHA, GL_LUMINANCE, | |||
| * GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, or GL_RGBA. | |||
| * Return -1 if invalid enum. | |||
| */ | |||
| void _mesa_init_tex_format( GLcontext *ctx, GLenum internalFormat, | |||
| struct gl_texture_image *texImage ) | |||
| { | |||
| texImage->IntFormat = internalFormat; | |||
| /* Ask the driver for the base format, if it doesn't know, it will | |||
| * return -1; | |||
| */ | |||
| if ( ctx->Driver.BaseCompressedTexFormat ) { | |||
| GLint format = 0; /* Silence compiler warning */ | |||
| format = (*ctx->Driver.BaseCompressedTexFormat)( ctx, format ); | |||
| if ( format >= 0 ) { | |||
| internalFormat = format; | |||
| } | |||
| } | |||
| switch ( internalFormat ) { | |||
| /* GH: Bias towards GL_RGB, GL_RGBA texture formats. This has | |||
| * got to be better than sticking them way down the end of this | |||
| * huge list. | |||
| */ | |||
| case 4: /* Quake3 uses this... */ | |||
| case GL_RGBA: | |||
| texImage->Format = GL_RGBA; | |||
| texImage->Type = CHAN_TYPE; | |||
| texImage->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; | |||
| break; | |||
| /* GH: Okay, keep checking as normal. Still test for GL_RGB, | |||
| * GL_RGBA formats first. | |||
| */ | |||
| case GL_RGBA2: | |||
| case GL_RGBA4: | |||
| case GL_RGB5_A1: | |||
| case GL_RGBA8: | |||
| case GL_RGB10_A2: | |||
| case GL_RGBA12: | |||
| case GL_RGBA16: | |||
| texImage->Format = GL_RGBA; | |||
| texImage->Type = CHAN_TYPE; | |||
| texImage->TexFormat = &_mesa_texformat_rgba; | |||
| break; | |||
| case GL_R3_G3_B2: | |||
| case GL_RGB4: | |||
| case GL_RGB5: | |||
| case GL_RGB8: | |||
| case GL_RGB10: | |||
| case GL_RGB12: | |||
| case GL_RGB16: | |||
| texImage->Format = GL_RGB; | |||
| texImage->Type = CHAN_TYPE; | |||
| texImage->TexFormat = &_mesa_texformat_rgb; | |||
| break; | |||
| case GL_ALPHA: | |||
| case GL_ALPHA4: | |||
| case GL_ALPHA8: | |||
| case GL_ALPHA12: | |||
| case GL_ALPHA16: | |||
| texImage->Format = GL_ALPHA; | |||
| texImage->Type = CHAN_TYPE; | |||
| texImage->TexFormat = &_mesa_texformat_alpha; | |||
| break; | |||
| case 1: | |||
| case GL_LUMINANCE: | |||
| case GL_LUMINANCE4: | |||
| case GL_LUMINANCE8: | |||
| case GL_LUMINANCE12: | |||
| case GL_LUMINANCE16: | |||
| texImage->Format = GL_LUMINANCE; | |||
| texImage->Type = CHAN_TYPE; | |||
| texImage->TexFormat = &_mesa_texformat_luminance; | |||
| break; | |||
| case 2: | |||
| case GL_LUMINANCE_ALPHA: | |||
| case GL_LUMINANCE4_ALPHA4: | |||
| case GL_LUMINANCE6_ALPHA2: | |||
| case GL_LUMINANCE8_ALPHA8: | |||
| 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; | |||
| break; | |||
| case GL_INTENSITY: | |||
| case GL_INTENSITY4: | |||
| case GL_INTENSITY8: | |||
| case GL_INTENSITY12: | |||
| case GL_INTENSITY16: | |||
| texImage->Format = GL_INTENSITY; | |||
| texImage->Type = CHAN_TYPE; | |||
| texImage->TexFormat = &_mesa_texformat_intensity; | |||
| break; | |||
| case GL_COLOR_INDEX: | |||
| case GL_COLOR_INDEX1_EXT: | |||
| case GL_COLOR_INDEX2_EXT: | |||
| case GL_COLOR_INDEX4_EXT: | |||
| 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; | |||
| 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. | |||
| */ | |||
| _mesa_problem( ctx, "depth format without GL_SGIX_depth_texture" ); | |||
| } | |||
| break; | |||
| default: | |||
| _mesa_problem( ctx, "unexpected format in _mesa_init_tex_format" ); | |||
| return; | |||
| } | |||
| } | |||
| @@ -0,0 +1,123 @@ | |||
| /* $Id: texformat.h,v 1.2 2001/03/18 08:53:49 gareth Exp $ */ | |||
| /* | |||
| * Mesa 3-D graphics library | |||
| * Version: 3.5 | |||
| * | |||
| * Copyright (C) 1999-2001 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. | |||
| * | |||
| * Author: | |||
| * Gareth Hughes <gareth@valinux.com> | |||
| */ | |||
| #ifndef TEXFORMAT_H | |||
| #define TEXFORMAT_H | |||
| #include "mtypes.h" | |||
| /* The Mesa internal texture image types. These will be set to their | |||
| * default value, but may be changed by drivers as required. | |||
| */ | |||
| enum _format { | |||
| /* Generic GLchan-based formats. These are the default formats used | |||
| * by the software rasterizer and, unless the driver overrides the | |||
| * texture image functions, incoming images will be converted to one | |||
| * of these formats. Components are arrays of GLchan values, so | |||
| * there will be no big/little endian issues. | |||
| * | |||
| * NOTE: Because these are based on the GLchan datatype, one cannot | |||
| * assume 8 bits per channel with these formats. If you require | |||
| * GLubyte per channel, use one of the hardware formats below. | |||
| */ | |||
| MESA_FORMAT_RGBA, | |||
| MESA_FORMAT_RGB, | |||
| MESA_FORMAT_ALPHA, | |||
| MESA_FORMAT_LUMINANCE, | |||
| MESA_FORMAT_LUMINANCE_ALPHA, | |||
| MESA_FORMAT_INTENSITY, | |||
| MESA_FORMAT_COLOR_INDEX, | |||
| MESA_FORMAT_DEPTH_COMPONENT, | |||
| /* Hardware-friendly formats. Drivers can override the default | |||
| * formats and convert texture images to one of these as required. | |||
| * These formats are all little endian, as shown below. They will be | |||
| * most useful for x86-based PC graphics card drivers. | |||
| * | |||
| * NOTE: In the default case, some of these formats will be | |||
| * duplicates of the default formats listed above. However, these | |||
| * formats guarantee their internal component sizes, while GLchan may | |||
| * vary betwen GLubyte, GLushort and GLfloat. | |||
| */ | |||
| /* msb <------ TEXEL BITS -----------> lsb */ | |||
| /* ---- ---- ---- ---- ---- ---- ---- ---- */ | |||
| MESA_FORMAT_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ | |||
| MESA_FORMAT_ARGB8888, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */ | |||
| MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */ | |||
| MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */ | |||
| MESA_FORMAT_ARGB4444, /* AAAA RRRR GGGG BBBB */ | |||
| MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB BBBB */ | |||
| MESA_FORMAT_AL88, /* AAAA AAAA LLLL LLLL */ | |||
| MESA_FORMAT_RGB332, /* RRRG GGBB */ | |||
| MESA_FORMAT_A8, /* AAAA AAAA */ | |||
| MESA_FORMAT_L8, /* LLLL LLLL */ | |||
| MESA_FORMAT_I8, /* IIII IIII */ | |||
| MESA_FORMAT_CI8 /* CCCC CCCC */ | |||
| }; | |||
| extern void | |||
| _mesa_init_tex_format( GLcontext *ctx, GLenum internalFormat, | |||
| struct gl_texture_image *texImage ); | |||
| /* The default formats, GLchan per component: | |||
| */ | |||
| extern const struct gl_texture_format _mesa_texformat_rgba; | |||
| extern const struct gl_texture_format _mesa_texformat_rgb; | |||
| extern const struct gl_texture_format _mesa_texformat_alpha; | |||
| extern const struct gl_texture_format _mesa_texformat_luminance; | |||
| extern const struct gl_texture_format _mesa_texformat_luminance_alpha; | |||
| extern const struct gl_texture_format _mesa_texformat_intensity; | |||
| extern const struct gl_texture_format _mesa_texformat_color_index; | |||
| extern const struct gl_texture_format _mesa_texformat_depth_component; | |||
| /* The hardware-friendly formats: | |||
| */ | |||
| extern const struct gl_texture_format _mesa_texformat_rgba8888; | |||
| extern const struct gl_texture_format _mesa_texformat_abgr8888; | |||
| extern const struct gl_texture_format _mesa_texformat_argb8888; | |||
| extern const struct gl_texture_format _mesa_texformat_rgb888; | |||
| extern const struct gl_texture_format _mesa_texformat_bgr888; | |||
| extern const struct gl_texture_format _mesa_texformat_rgb565; | |||
| extern const struct gl_texture_format _mesa_texformat_argb4444; | |||
| extern const struct gl_texture_format _mesa_texformat_argb1555; | |||
| extern const struct gl_texture_format _mesa_texformat_al88; | |||
| extern const struct gl_texture_format _mesa_texformat_rgb332; | |||
| extern const struct gl_texture_format _mesa_texformat_a8; | |||
| extern const struct gl_texture_format _mesa_texformat_l8; | |||
| extern const struct gl_texture_format _mesa_texformat_i8; | |||
| extern const struct gl_texture_format _mesa_texformat_ci8; | |||
| /* The null format: | |||
| */ | |||
| extern const struct gl_texture_format _mesa_null_texformat; | |||
| #endif | |||
| @@ -0,0 +1,264 @@ | |||
| #if DIM == 1 | |||
| #define CHAN_SRC( t, i, j, k, sz ) \ | |||
| ((GLchan *)(t)->Data + (i) * (sz)) | |||
| #define UBYTE_SRC( t, i, j, k, sz ) \ | |||
| ((GLubyte *)(t)->Data + (i) * (sz)) | |||
| #define USHORT_SRC( t, i, j, k ) \ | |||
| ((GLushort *)(t)->Data + (i)) | |||
| #define FLOAT_SRC( t, i, j, k ) \ | |||
| ((GLfloat *)(t)->Data + (i)) | |||
| #define FETCH(x) fetch_1d_texel_##x | |||
| #elif DIM == 2 | |||
| #define CHAN_SRC( t, i, j, k, sz ) \ | |||
| ((GLchan *)(t)->Data + ((t)->Width * (j) + (i)) * (sz)) | |||
| #define UBYTE_SRC( t, i, j, k, sz ) \ | |||
| ((GLubyte *)(t)->Data + ((t)->Width * (j) + (i)) * (sz)) | |||
| #define USHORT_SRC( t, i, j, k ) \ | |||
| ((GLushort *)(t)->Data + ((t)->Width * (j) + (i))) | |||
| #define FLOAT_SRC( t, i, j, k ) \ | |||
| ((GLfloat *)(t)->Data + ((t)->Width * (j) + (i))) | |||
| #define FETCH(x) fetch_2d_texel_##x | |||
| #elif DIM == 3 | |||
| #define CHAN_SRC( t, i, j, k, sz ) \ | |||
| (GLchan *)(t)->Data + (((t)->Height * (k) + (j)) * \ | |||
| (t)->Width + (i)) * (sz) | |||
| #define UBYTE_SRC( t, i, j, k, sz ) \ | |||
| ((GLubyte *)(t)->Data + (((t)->Height * (k) + (j)) * \ | |||
| (t)->Width + (i)) * (sz)) | |||
| #define USHORT_SRC( t, i, j, k ) \ | |||
| ((GLushort *)(t)->Data + (((t)->Height * (k) + (j)) * \ | |||
| (t)->Width + (i))) | |||
| #define FLOAT_SRC( t, i, j, k ) \ | |||
| ((GLfloat *)(t)->Data + (((t)->Height * (k) + (j)) * \ | |||
| (t)->Width + (i))) | |||
| #define FETCH(x) fetch_3d_texel_##x | |||
| #else | |||
| #error "..." | |||
| #endif | |||
| static void FETCH(rgba)( const struct gl_texture_image *texImage, | |||
| GLint i, GLint j, GLint k, GLvoid *texel ) | |||
| { | |||
| const GLchan *src = CHAN_SRC( texImage, i, j, k, 4 ); | |||
| GLchan *rgba = (GLchan *) texel; | |||
| COPY_CHAN4( rgba, src ); | |||
| } | |||
| static void FETCH(rgb)( const struct gl_texture_image *texImage, | |||
| GLint i, GLint j, GLint k, GLvoid *texel ) | |||
| { | |||
| const GLchan *src = CHAN_SRC( texImage, i, j, k, 3 ); | |||
| GLchan *rgba = (GLchan *) texel; | |||
| rgba[RCOMP] = src[0]; | |||
| rgba[GCOMP] = src[1]; | |||
| rgba[BCOMP] = src[2]; | |||
| rgba[ACOMP] = CHAN_MAX; | |||
| } | |||
| static void FETCH(alpha)( const struct gl_texture_image *texImage, | |||
| GLint i, GLint j, GLint k, GLvoid *texel ) | |||
| { | |||
| const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 ); | |||
| GLchan *rgba = (GLchan *) texel; | |||
| rgba[RCOMP] = 0; | |||
| rgba[GCOMP] = 0; | |||
| rgba[BCOMP] = 0; | |||
| rgba[ACOMP] = src[0]; | |||
| } | |||
| static void FETCH(luminance)( const struct gl_texture_image *texImage, | |||
| GLint i, GLint j, GLint k, GLvoid *texel ) | |||
| { | |||
| const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 ); | |||
| GLchan *rgba = (GLchan *) texel; | |||
| rgba[RCOMP] = src[0]; | |||
| rgba[GCOMP] = src[0]; | |||
| rgba[BCOMP] = src[0]; | |||
| rgba[ACOMP] = CHAN_MAX; | |||
| } | |||
| static void FETCH(luminance_alpha)( const struct gl_texture_image *texImage, | |||
| GLint i, GLint j, GLint k, GLvoid *texel ) | |||
| { | |||
| const GLchan *src = CHAN_SRC( texImage, i, j, k, 2 ); | |||
| GLchan *rgba = (GLchan *) texel; | |||
| rgba[RCOMP] = src[0]; | |||
| rgba[GCOMP] = src[0]; | |||
| rgba[BCOMP] = src[0]; | |||
| rgba[ACOMP] = src[1]; | |||
| } | |||
| static void FETCH(intensity)( const struct gl_texture_image *texImage, | |||
| GLint i, GLint j, GLint k, GLvoid *texel ) | |||
| { | |||
| const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 ); | |||
| GLchan *rgba = (GLchan *) texel; | |||
| rgba[RCOMP] = src[0]; | |||
| rgba[GCOMP] = src[0]; | |||
| rgba[BCOMP] = src[0]; | |||
| rgba[ACOMP] = src[0]; | |||
| } | |||
| static void FETCH(color_index)( const struct gl_texture_image *texImage, | |||
| GLint i, GLint j, GLint k, GLvoid *texel ) | |||
| { | |||
| const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 ); | |||
| GLchan *index = (GLchan *) texel; | |||
| *index = *src; | |||
| } | |||
| static void FETCH(depth_component)( const struct gl_texture_image *texImage, | |||
| GLint i, GLint j, GLint k, GLvoid *texel ) | |||
| { | |||
| const GLfloat *src = FLOAT_SRC( texImage, i, j, k ); | |||
| GLfloat *depth = (GLfloat *) texel; | |||
| *depth = *src; | |||
| } | |||
| static void FETCH(rgba8888)( const struct gl_texture_image *texImage, | |||
| GLint i, GLint j, GLint k, GLvoid *texel ) | |||
| { | |||
| const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); | |||
| GLchan *rgba = (GLchan *) texel; | |||
| rgba[RCOMP] = UBYTE_TO_CHAN( src[3] ); | |||
| rgba[GCOMP] = UBYTE_TO_CHAN( src[2] ); | |||
| rgba[BCOMP] = UBYTE_TO_CHAN( src[1] ); | |||
| rgba[ACOMP] = UBYTE_TO_CHAN( src[0] ); | |||
| } | |||
| static void FETCH(argb8888)( const struct gl_texture_image *texImage, | |||
| GLint i, GLint j, GLint k, GLvoid *texel ) | |||
| { | |||
| const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); | |||
| GLchan *rgba = (GLchan *) texel; | |||
| rgba[RCOMP] = UBYTE_TO_CHAN( src[2] ); | |||
| rgba[GCOMP] = UBYTE_TO_CHAN( src[1] ); | |||
| rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); | |||
| rgba[ACOMP] = UBYTE_TO_CHAN( src[3] ); | |||
| } | |||
| static void FETCH(rgb888)( const struct gl_texture_image *texImage, | |||
| GLint i, GLint j, GLint k, GLvoid *texel ) | |||
| { | |||
| const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 ); | |||
| GLchan *rgba = (GLchan *) texel; | |||
| rgba[RCOMP] = UBYTE_TO_CHAN( src[2] ); | |||
| rgba[GCOMP] = UBYTE_TO_CHAN( src[1] ); | |||
| rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); | |||
| rgba[ACOMP] = CHAN_MAX; | |||
| } | |||
| static void FETCH(rgb565)( const struct gl_texture_image *texImage, | |||
| GLint i, GLint j, GLint k, GLvoid *texel ) | |||
| { | |||
| const GLushort *src = USHORT_SRC( texImage, i, j, k ); | |||
| GLchan *rgba = (GLchan *) texel; GLushort s = *src; | |||
| rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 ); | |||
| rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc ); | |||
| rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 ); | |||
| rgba[ACOMP] = CHAN_MAX; | |||
| } | |||
| static void FETCH(argb4444)( const struct gl_texture_image *texImage, | |||
| GLint i, GLint j, GLint k, GLvoid *texel ) | |||
| { | |||
| const GLushort *src = USHORT_SRC( texImage, i, j, k ); | |||
| GLchan *rgba = (GLchan *) texel; GLushort s = *src; | |||
| rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf ); | |||
| rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf ); | |||
| rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf ); | |||
| rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf ); | |||
| } | |||
| static void FETCH(argb1555)( const struct gl_texture_image *texImage, | |||
| GLint i, GLint j, GLint k, GLvoid *texel ) | |||
| { | |||
| const GLushort *src = USHORT_SRC( texImage, i, j, k ); | |||
| GLchan *rgba = (GLchan *) texel; GLushort s = *src; | |||
| rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0xf8) * 255 / 0xf8 ); | |||
| rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0xf8) * 255 / 0xf8 ); | |||
| rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf8) * 255 / 0xf8 ); | |||
| rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 ); | |||
| } | |||
| static void FETCH(al88)( const struct gl_texture_image *texImage, | |||
| GLint i, GLint j, GLint k, GLvoid *texel ) | |||
| { | |||
| const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 ); | |||
| GLchan *rgba = (GLchan *) texel; | |||
| rgba[RCOMP] = UBYTE_TO_CHAN( src[0] ); | |||
| rgba[GCOMP] = UBYTE_TO_CHAN( src[0] ); | |||
| rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); | |||
| rgba[ACOMP] = UBYTE_TO_CHAN( src[1] ); | |||
| } | |||
| static void FETCH(rgb332)( const struct gl_texture_image *texImage, | |||
| GLint i, GLint j, GLint k, GLvoid *texel ) | |||
| { | |||
| const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); | |||
| GLchan *rgba = (GLchan *) texel; GLubyte s = *src; | |||
| rgba[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xe0) * 255 / 0xe0 ); | |||
| rgba[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 ); | |||
| rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 5) & 0xc0) * 255 / 0xc0 ); | |||
| rgba[ACOMP] = CHAN_MAX; | |||
| } | |||
| static void FETCH(a8)( const struct gl_texture_image *texImage, | |||
| GLint i, GLint j, GLint k, GLvoid *texel ) | |||
| { | |||
| const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); | |||
| GLchan *rgba = (GLchan *) texel; | |||
| rgba[RCOMP] = 0; | |||
| rgba[GCOMP] = 0; | |||
| rgba[BCOMP] = 0; | |||
| rgba[ACOMP] = UBYTE_TO_CHAN( src[0] ); | |||
| } | |||
| static void FETCH(l8)( const struct gl_texture_image *texImage, | |||
| GLint i, GLint j, GLint k, GLvoid *texel ) | |||
| { | |||
| const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); | |||
| GLchan *rgba = (GLchan *) texel; | |||
| rgba[RCOMP] = UBYTE_TO_CHAN( src[0] ); | |||
| rgba[GCOMP] = UBYTE_TO_CHAN( src[0] ); | |||
| rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); | |||
| rgba[ACOMP] = CHAN_MAX; | |||
| } | |||
| static void FETCH(i8)( const struct gl_texture_image *texImage, | |||
| GLint i, GLint j, GLint k, GLvoid *texel ) | |||
| { | |||
| const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); | |||
| GLchan *rgba = (GLchan *) texel; | |||
| rgba[RCOMP] = UBYTE_TO_CHAN( src[0] ); | |||
| rgba[GCOMP] = UBYTE_TO_CHAN( src[0] ); | |||
| rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); | |||
| rgba[ACOMP] = UBYTE_TO_CHAN( src[0] ); | |||
| } | |||
| static void FETCH(ci8)( const struct gl_texture_image *texImage, | |||
| GLint i, GLint j, GLint k, GLvoid *texel ) | |||
| { | |||
| const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); | |||
| GLchan *index = (GLchan *) texel; | |||
| *index = UBYTE_TO_CHAN( *src ); | |||
| } | |||
| #undef CHAN_SRC | |||
| #undef UBYTE_SRC | |||
| #undef USHORT_SRC | |||
| #undef FLOAT_SRC | |||
| #undef FETCH | |||
| #undef DIM | |||
| @@ -1,4 +1,4 @@ | |||
| /* $Id: teximage.c,v 1.84 2001/03/12 00:48:38 gareth Exp $ */ | |||
| /* $Id: teximage.c,v 1.85 2001/03/18 08:53:49 gareth Exp $ */ | |||
| /* | |||
| * Mesa 3-D graphics library | |||
| @@ -36,6 +36,7 @@ | |||
| #include "mem.h" | |||
| #include "mmath.h" | |||
| #include "state.h" | |||
| #include "texformat.h" | |||
| #include "teximage.h" | |||
| #include "texstate.h" | |||
| #include "mtypes.h" | |||
| @@ -559,13 +560,6 @@ clear_teximage_fields(struct gl_texture_image *img) | |||
| img->Format = 0; | |||
| img->Type = 0; | |||
| img->IntFormat = 0; | |||
| img->RedBits = 0; | |||
| img->GreenBits = 0; | |||
| img->BlueBits = 0; | |||
| img->AlphaBits = 0; | |||
| img->IntensityBits = 0; | |||
| img->LuminanceBits = 0; | |||
| img->IndexBits = 0; | |||
| img->Border = 0; | |||
| img->Width = 0; | |||
| img->Height = 0; | |||
| @@ -577,9 +571,10 @@ clear_teximage_fields(struct gl_texture_image *img) | |||
| img->HeightLog2 = 0; | |||
| img->DepthLog2 = 0; | |||
| img->Data = NULL; | |||
| img->TexFormat = &_mesa_null_texformat; | |||
| img->FetchTexel = NULL; | |||
| img->IsCompressed = 0; | |||
| img->CompressedSize = 0; | |||
| img->FetchTexel = NULL; | |||
| } | |||
| @@ -1102,11 +1097,10 @@ void | |||
| _mesa_GetTexImage( GLenum target, GLint level, GLenum format, | |||
| GLenum type, GLvoid *pixels ) | |||
| { | |||
| GET_CURRENT_CONTEXT(ctx); | |||
| const struct gl_texture_unit *texUnit; | |||
| const struct gl_texture_object *texObj; | |||
| struct gl_texture_image *texImage; | |||
| GET_CURRENT_CONTEXT(ctx); | |||
| ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); | |||
| if (level < 0 || level >= ctx->Const.MaxTextureLevels) { | |||
| @@ -1631,11 +1625,10 @@ _mesa_TexSubImage1D( GLenum target, GLint level, | |||
| const GLvoid *pixels ) | |||
| { | |||
| GLsizei postConvWidth = width; | |||
| GET_CURRENT_CONTEXT(ctx); | |||
| struct gl_texture_unit *texUnit; | |||
| struct gl_texture_object *texObj; | |||
| struct gl_texture_image *texImage; | |||
| GET_CURRENT_CONTEXT(ctx); | |||
| ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); | |||
| if (ctx->NewState & _NEW_PIXEL) | |||
| @@ -1675,11 +1668,10 @@ _mesa_TexSubImage2D( GLenum target, GLint level, | |||
| const GLvoid *pixels ) | |||
| { | |||
| GLsizei postConvWidth = width, postConvHeight = height; | |||
| GET_CURRENT_CONTEXT(ctx); | |||
| struct gl_texture_unit *texUnit; | |||
| struct gl_texture_object *texObj; | |||
| struct gl_texture_image *texImage; | |||
| GET_CURRENT_CONTEXT(ctx); | |||
| ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); | |||
| if (ctx->NewState & _NEW_PIXEL) | |||
| @@ -1720,11 +1712,10 @@ _mesa_TexSubImage3D( GLenum target, GLint level, | |||
| GLenum format, GLenum type, | |||
| const GLvoid *pixels ) | |||
| { | |||
| GET_CURRENT_CONTEXT(ctx); | |||
| struct gl_texture_unit *texUnit; | |||
| struct gl_texture_object *texObj; | |||
| struct gl_texture_image *texImage; | |||
| GET_CURRENT_CONTEXT(ctx); | |||
| ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); | |||
| if (ctx->NewState & _NEW_PIXEL) | |||
| @@ -2247,7 +2238,6 @@ _mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, | |||
| struct gl_texture_object *texObj; | |||
| struct gl_texture_image *texImage; | |||
| GET_CURRENT_CONTEXT(ctx); | |||
| ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); | |||
| if (subtexture_error_check(ctx, 1, target, level, xoffset, 0, 0, | |||
| @@ -2283,7 +2273,6 @@ _mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, | |||
| struct gl_texture_object *texObj; | |||
| struct gl_texture_image *texImage; | |||
| GET_CURRENT_CONTEXT(ctx); | |||
| ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); | |||
| if (subtexture_error_check(ctx, 2, target, level, xoffset, yoffset, 0, | |||
| @@ -2319,7 +2308,6 @@ _mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, | |||
| struct gl_texture_object *texObj; | |||
| struct gl_texture_image *texImage; | |||
| GET_CURRENT_CONTEXT(ctx); | |||
| ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); | |||
| if (subtexture_error_check(ctx, 3, target, level, xoffset, yoffset, zoffset, | |||
| @@ -2353,7 +2341,6 @@ _mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img) | |||
| const struct gl_texture_object *texObj; | |||
| struct gl_texture_image *texImage; | |||
| GET_CURRENT_CONTEXT(ctx); | |||
| ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); | |||
| if (level < 0 || level >= ctx->Const.MaxTextureLevels) { | |||
| @@ -1,4 +1,4 @@ | |||
| /* $Id: texobj.c,v 1.44 2001/03/12 00:48:39 gareth Exp $ */ | |||
| /* $Id: texobj.c,v 1.45 2001/03/18 08:53:49 gareth Exp $ */ | |||
| /* | |||
| * Mesa 3-D graphics library | |||
| @@ -79,6 +79,7 @@ _mesa_alloc_texture_object( struct gl_shared_state *shared, | |||
| obj->MaxLod = 1000.0; | |||
| obj->BaseLevel = 0; | |||
| obj->MaxLevel = 1000; | |||
| obj->MaxAnisotropy = 1.0; | |||
| obj->CompareFlag = GL_FALSE; | |||
| obj->CompareOperator = GL_TEXTURE_LEQUAL_R_SGIX; | |||
| obj->ShadowAmbient = 0; | |||
| @@ -1,4 +1,4 @@ | |||
| /* $Id: texstate.c,v 1.36 2001/03/07 05:06:12 brianp Exp $ */ | |||
| /* $Id: texstate.c,v 1.37 2001/03/18 08:53:50 gareth Exp $ */ | |||
| /* | |||
| * Mesa 3-D graphics library | |||
| @@ -770,6 +770,19 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params ) | |||
| /* (keithh@netcomuk.co.uk) */ | |||
| texObj->Priority = CLAMP( params[0], 0.0F, 1.0F ); | |||
| break; | |||
| case GL_TEXTURE_MAX_ANISOTROPY_EXT: | |||
| if (ctx->Extensions.EXT_texture_filter_anisotropic) { | |||
| if (params[0] < 1.0) { | |||
| _mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" ); | |||
| return; | |||
| } | |||
| texObj->MaxAnisotropy = params[0]; | |||
| } | |||
| else { | |||
| _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname)"); | |||
| return; | |||
| } | |||
| break; | |||
| case GL_TEXTURE_COMPARE_SGIX: | |||
| if (ctx->Extensions.SGIX_shadow) { | |||
| texObj->CompareFlag = params[0] ? GL_TRUE : GL_FALSE; | |||
| @@ -923,32 +936,32 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, | |||
| *params = img->Border; | |||
| return; | |||
| case GL_TEXTURE_RED_SIZE: | |||
| *params = img->RedBits; | |||
| *params = img->TexFormat->RedBits; | |||
| return; | |||
| case GL_TEXTURE_GREEN_SIZE: | |||
| *params = img->GreenBits; | |||
| *params = img->TexFormat->GreenBits; | |||
| return; | |||
| case GL_TEXTURE_BLUE_SIZE: | |||
| *params = img->BlueBits; | |||
| *params = img->TexFormat->BlueBits; | |||
| return; | |||
| case GL_TEXTURE_ALPHA_SIZE: | |||
| *params = img->AlphaBits; | |||
| *params = img->TexFormat->AlphaBits; | |||
| return; | |||
| case GL_TEXTURE_INTENSITY_SIZE: | |||
| *params = img->IntensityBits; | |||
| *params = img->TexFormat->IntensityBits; | |||
| return; | |||
| case GL_TEXTURE_LUMINANCE_SIZE: | |||
| *params = img->LuminanceBits; | |||
| *params = img->TexFormat->LuminanceBits; | |||
| return; | |||
| case GL_TEXTURE_INDEX_SIZE_EXT: | |||
| *params = img->IndexBits; | |||
| *params = img->TexFormat->IndexBits; | |||
| return; | |||
| case GL_DEPTH_BITS: | |||
| /* XXX this isn't in the GL_SGIX_depth_texture spec | |||
| * but seems appropriate. | |||
| */ | |||
| if (ctx->Extensions.SGIX_depth_texture) | |||
| *params = img->DepthBits; | |||
| *params = img->TexFormat->DepthBits; | |||
| else | |||
| _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)"); | |||
| return; | |||
| @@ -1,4 +1,4 @@ | |||
| /* $Id: texstore.c,v 1.11 2001/03/12 00:48:39 gareth Exp $ */ | |||
| /* $Id: texstore.c,v 1.12 2001/03/18 08:53:50 gareth Exp $ */ | |||
| /* | |||
| * Mesa 3-D graphics library | |||
| @@ -50,6 +50,7 @@ | |||
| #include "swrast/s_span.h" | |||
| #if 0 | |||
| /* | |||
| * Default 1-D texture texel fetch function. This will typically be | |||
| * overridden by hardware drivers which store their texture images in | |||
| @@ -446,6 +447,7 @@ set_teximage_component_sizes( struct gl_texture_image *texImage ) | |||
| _mesa_problem(NULL, "unexpected format in set_teximage_component_sizes"); | |||
| } | |||
| } | |||
| #endif | |||
| @@ -793,8 +795,6 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level, | |||
| struct gl_texture_object *texObj, | |||
| struct gl_texture_image *texImage) | |||
| { | |||
| const GLint components = components_in_intformat(internalFormat); | |||
| GLint compSize; | |||
| GLint postConvWidth = width; | |||
| if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) { | |||
| @@ -802,20 +802,12 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level, | |||
| } | |||
| /* setup the teximage struct's fields */ | |||
| texImage->Format = (GLenum) _mesa_base_tex_format(ctx, internalFormat); | |||
| if (format == GL_DEPTH_COMPONENT) { | |||
| texImage->Type = GL_FLOAT; /* XXX or GL_UNSIGNED_INT? */ | |||
| compSize = sizeof(GLfloat); | |||
| } | |||
| else { | |||
| texImage->Type = CHAN_TYPE; /* usually GL_UNSIGNED_BYTE */ | |||
| compSize = sizeof(CHAN_TYPE); | |||
| } | |||
| texImage->FetchTexel = fetch_1d_texel; | |||
| set_teximage_component_sizes(texImage); | |||
| _mesa_init_tex_format( ctx, internalFormat, texImage ); | |||
| texImage->FetchTexel = texImage->TexFormat->FetchTexel1D; | |||
| /* allocate memory */ | |||
| texImage->Data = (GLchan *) MALLOC(postConvWidth * components * compSize); | |||
| texImage->Data = (GLchan *) MALLOC(postConvWidth * | |||
| texImage->TexFormat->TexelBytes); | |||
| if (!texImage->Data) | |||
| return; /* out of memory */ | |||
| @@ -844,9 +836,8 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level, | |||
| struct gl_texture_object *texObj, | |||
| struct gl_texture_image *texImage) | |||
| { | |||
| const GLint components = components_in_intformat(internalFormat); | |||
| GLint compSize; | |||
| GLint postConvWidth = width, postConvHeight = height; | |||
| GLint texelBytes; | |||
| if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) { | |||
| _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, | |||
| @@ -854,28 +845,21 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level, | |||
| } | |||
| /* setup the teximage struct's fields */ | |||
| texImage->Format = (GLenum) _mesa_base_tex_format(ctx, internalFormat); | |||
| if (format == GL_DEPTH_COMPONENT) { | |||
| texImage->Type = GL_FLOAT; /* XXX or GL_UNSIGNED_INT? */ | |||
| compSize = sizeof(GLfloat); | |||
| } | |||
| else { | |||
| texImage->Type = CHAN_TYPE; /* usually GL_UNSIGNED_BYTE */ | |||
| compSize = sizeof(CHAN_TYPE); | |||
| } | |||
| texImage->FetchTexel = fetch_2d_texel; | |||
| set_teximage_component_sizes(texImage); | |||
| _mesa_init_tex_format( ctx, internalFormat, texImage ); | |||
| texImage->FetchTexel = texImage->TexFormat->FetchTexel2D; | |||
| texelBytes = texImage->TexFormat->TexelBytes; | |||
| /* allocate memory */ | |||
| texImage->Data = (GLchan *) MALLOC(postConvWidth * postConvHeight | |||
| * components * compSize); | |||
| texImage->Data = (GLchan *) MALLOC(postConvWidth * postConvHeight * | |||
| texelBytes); | |||
| if (!texImage->Data) | |||
| return; /* out of memory */ | |||
| /* unpack image, apply transfer ops and store in texImage->Data */ | |||
| _mesa_transfer_teximage(ctx, 2, texImage->Format, (GLchan *) texImage->Data, | |||
| width, height, 1, 0, 0, 0, | |||
| texImage->Width * components * sizeof(GLchan), | |||
| texImage->Width * texelBytes, | |||
| 0, /* dstImageStride */ | |||
| format, type, pixels, packing); | |||
| } | |||
| @@ -898,34 +882,24 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level, | |||
| struct gl_texture_object *texObj, | |||
| struct gl_texture_image *texImage) | |||
| { | |||
| const GLint components = components_in_intformat(internalFormat); | |||
| GLint compSize; | |||
| GLint texelBytes; | |||
| /* setup the teximage struct's fields */ | |||
| texImage->Format = (GLenum) _mesa_base_tex_format(ctx, internalFormat); | |||
| if (format == GL_DEPTH_COMPONENT) { | |||
| texImage->Type = GL_FLOAT; /* XXX or GL_UNSIGNED_INT? */ | |||
| compSize = sizeof(GLfloat); | |||
| } | |||
| else { | |||
| texImage->Type = CHAN_TYPE; /* usually GL_UNSIGNED_BYTE */ | |||
| compSize = sizeof(CHAN_TYPE); | |||
| } | |||
| texImage->FetchTexel = fetch_3d_texel; | |||
| set_teximage_component_sizes(texImage); | |||
| _mesa_init_tex_format( ctx, internalFormat, texImage ); | |||
| texImage->FetchTexel = texImage->TexFormat->FetchTexel3D; | |||
| texelBytes = texImage->TexFormat->TexelBytes; | |||
| /* allocate memory */ | |||
| texImage->Data = (GLchan *) MALLOC(width * height * depth | |||
| * components * compSize); | |||
| texImage->Data = (GLchan *) MALLOC(width * height * depth * texelBytes); | |||
| if (!texImage->Data) | |||
| return; /* out of memory */ | |||
| /* unpack image, apply transfer ops and store in texImage->Data */ | |||
| _mesa_transfer_teximage(ctx, 3, texImage->Format, (GLchan *) texImage->Data, | |||
| width, height, depth, 0, 0, 0, | |||
| texImage->Width * components * sizeof(GLchan), | |||
| texImage->Width * texImage->Height * components | |||
| * sizeof(GLchan), | |||
| texImage->Width * texelBytes, | |||
| texImage->Width * texImage->Height * texelBytes, | |||
| format, type, pixels, packing); | |||
| } | |||
| @@ -1422,7 +1396,6 @@ _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; | |||
| GLint compSize; | |||
| (void) format; | |||
| (void) type; | |||
| @@ -1437,16 +1410,7 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level, | |||
| * have to override this function. | |||
| */ | |||
| /* setup the teximage struct's fields */ | |||
| texImage->Format = (GLenum) _mesa_base_tex_format(ctx, internalFormat); | |||
| if (format == GL_DEPTH_COMPONENT) { | |||
| texImage->Type = GL_FLOAT; /* XXX or GL_UNSIGNED_INT? */ | |||
| compSize = sizeof(GLfloat); | |||
| } | |||
| else { | |||
| texImage->Type = CHAN_TYPE; /* usually GL_UNSIGNED_BYTE */ | |||
| compSize = sizeof(CHAN_TYPE); | |||
| } | |||
| set_teximage_component_sizes(texImage); | |||
| _mesa_init_tex_format( ctx, internalFormat, texImage ); | |||
| return GL_TRUE; | |||
| } | |||
| @@ -1,4 +1,4 @@ | |||
| /* $Id: texutil.h,v 1.8 2001/03/12 00:48:39 gareth Exp $ */ | |||
| /* $Id: texutil.h,v 1.9 2001/03/18 08:53:50 gareth Exp $ */ | |||
| /* | |||
| * Mesa 3-D graphics library | |||
| @@ -22,71 +22,51 @@ | |||
| * 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. | |||
| * | |||
| * Authors: | |||
| * Gareth Hughes <gareth@valinux.com> | |||
| */ | |||
| #ifndef TEXUTIL_H | |||
| #define TEXUTIL_H | |||
| #include "mtypes.h" | |||
| /* | |||
| * NOTE: "FF" means fill with byte value 0xff | |||
| */ | |||
| /* msb <------ TEXEL BITS -----------> lsb */ | |||
| typedef enum { /* ---- ---- ---- ---- ---- ---- ---- ---- */ | |||
| MESA_I8, /* IIII IIII */ | |||
| MESA_L8, /* LLLL LLLL */ | |||
| MESA_A8, /* AAAA AAAA */ | |||
| MESA_C8, /* CCCC CCCC */ | |||
| MESA_A8_L8, /* AAAA AAAA LLLL LLLL */ | |||
| MESA_R5_G6_B5, /* RRRR RGGG GGGB BBBB */ | |||
| MESA_A4_R4_G4_B4, /* AAAA RRRR GGGG BBBB */ | |||
| MESA_A1_R5_G5_B5, /* ARRR RRGG GGGB BBBB */ | |||
| MESA_A8_R8_G8_B8, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */ | |||
| MESA_FF_R8_G8_B8 /* FFFF FFFF RRRR RRRR GGGG GGGG BBBB BBBB */ | |||
| } MesaIntTexFormat; | |||
| #include "texformat.h" | |||
| extern GLboolean | |||
| _mesa_convert_teximage(MesaIntTexFormat dstFormat, | |||
| GLint dstWidth, GLint dstHeight, GLvoid *dstImage, | |||
| GLint dstRowStride, | |||
| GLint srcWidth, GLint srcHeight, | |||
| GLenum srcFormat, GLenum srcType, | |||
| const GLvoid *srcImage, | |||
| const struct gl_pixelstore_attrib *packing); | |||
| _mesa_convert_texsubimage1d( GLint mesaFormat, | |||
| GLint xoffset, | |||
| GLint width, | |||
| GLenum format, GLenum type, | |||
| const struct gl_pixelstore_attrib *packing, | |||
| const GLvoid *srcImage, GLvoid *dstImage ); | |||
| extern GLboolean | |||
| _mesa_convert_texsubimage(MesaIntTexFormat dstFormat, | |||
| GLint dstXoffset, GLint dstYoffset, | |||
| GLint dstWidth, GLint dstHeight, GLvoid *dstImage, | |||
| GLint dstRowStride, | |||
| GLint width, GLint height, | |||
| GLint srcWidth, GLint srcHeight, | |||
| GLenum srcFormat, GLenum srcType, | |||
| const GLvoid *srcImage, | |||
| const struct gl_pixelstore_attrib *packing); | |||
| extern void | |||
| _mesa_unconvert_teximage(MesaIntTexFormat srcFormat, | |||
| GLint srcWidth, GLint srcHeight, | |||
| const GLvoid *srcImage, GLint srcRowStride, | |||
| GLint dstWidth, GLint dstHeight, | |||
| GLenum dstFormat, GLubyte *dstImage); | |||
| _mesa_convert_texsubimage2d( GLint mesaFormat, | |||
| GLint xoffset, GLint yoffset, | |||
| GLint width, GLint height, | |||
| GLint imageWidth, | |||
| GLenum format, GLenum type, | |||
| const struct gl_pixelstore_attrib *packing, | |||
| const GLvoid *srcImage, GLvoid *dstImage ); | |||
| extern GLboolean | |||
| _mesa_convert_texsubimage3d( GLint mesaFormat, | |||
| GLint xoffset, GLint yoffset, GLint zoffset, | |||
| GLint width, GLint height, GLint depth, | |||
| GLint imageWidth, GLint imageHeight, | |||
| GLenum format, GLenum type, | |||
| const struct gl_pixelstore_attrib *packing, | |||
| const GLvoid *srcImage, GLvoid *dstImage ); | |||
| /* Nearest filtering only (for broken hardware that can't support | |||
| * all aspect ratios). FIXME: Make this a subimage update as well... | |||
| */ | |||
| extern void | |||
| _mesa_set_teximage_component_sizes(MesaIntTexFormat mesaFormat, | |||
| struct gl_texture_image *texImage); | |||
| _mesa_rescale_teximage2d( const struct gl_texture_format *texFormat, | |||
| GLint srcWidth, GLint srcHeight, | |||
| GLint dstWidth, GLint dstHeight, | |||
| const GLvoid *srcImage, GLvoid *dstImage ); | |||
| #endif | |||
| @@ -0,0 +1,375 @@ | |||
| /* | |||
| * NOTE: All 3D code is untested and most definitely broken... | |||
| */ | |||
| #define DST_TEXEL_BYTES (4 / DST_TEXELS_PER_DWORD) | |||
| #define DST_ROW_WIDTH (convert->width * DST_TEXEL_BYTES) | |||
| #define DST_ROW_STRIDE (convert->imageWidth * DST_TEXEL_BYTES) | |||
| #define DST_IMG_STRIDE (convert->imageWidth * \ | |||
| convert->imageHeight * DST_TEXEL_BYTES) | |||
| /* ================================================================ | |||
| * PRE: No pixelstore attribs, width == imageWidth. | |||
| */ | |||
| static GLboolean | |||
| TAG(texsubimage2d)( struct gl_texture_convert *convert ) | |||
| { | |||
| const GLubyte *src = (const GLubyte *)convert->srcImage; | |||
| GLuint *dst = (GLuint *)((GLubyte *)convert->dstImage + | |||
| (convert->yoffset * convert->imageWidth + | |||
| convert->xoffset) * DST_TEXEL_BYTES); | |||
| GLint dwords, i; | |||
| (void) dwords; (void) i; | |||
| if ( DBG ) | |||
| fprintf( stderr, __FUNCTION__ "\n" ); | |||
| #ifdef CONVERT_DIRECT | |||
| MEMCPY( dst, src, convert->height * DST_ROW_WIDTH ); | |||
| #else | |||
| dwords = (convert->width * convert->height + | |||
| DST_TEXELS_PER_DWORD - 1) / DST_TEXELS_PER_DWORD; | |||
| for ( i = 0 ; i < dwords ; i++ ) { | |||
| *dst++ = CONVERT_TEXEL_DWORD( src ); | |||
| src += SRC_TEXEL_BYTES * DST_TEXELS_PER_DWORD; | |||
| } | |||
| #endif | |||
| return GL_TRUE; | |||
| } | |||
| /* PRE: As above, height == imageHeight also. | |||
| */ | |||
| static GLboolean | |||
| TAG(texsubimage3d)( struct gl_texture_convert *convert ) | |||
| { | |||
| const GLubyte *src = (const GLubyte *)convert->srcImage; | |||
| GLuint *dst = (GLuint *)((GLubyte *)convert->dstImage + | |||
| ((convert->zoffset * convert->height + | |||
| convert->yoffset) * convert->width + | |||
| convert->xoffset) * DST_TEXEL_BYTES); | |||
| GLint dwords, i; | |||
| (void) dwords; (void) i; | |||
| if ( DBG ) | |||
| fprintf( stderr, __FUNCTION__ "\n" ); | |||
| #ifdef CONVERT_DIRECT | |||
| MEMCPY( dst, src, convert->depth * convert->height * DST_ROW_WIDTH ); | |||
| #else | |||
| dwords = (convert->width * convert->height * convert->depth + | |||
| DST_TEXELS_PER_DWORD - 1) / DST_TEXELS_PER_DWORD; | |||
| for ( i = 0 ; i < dwords ; i++ ) { | |||
| *dst++ = CONVERT_TEXEL_DWORD( src ); | |||
| src += SRC_TEXEL_BYTES * DST_TEXELS_PER_DWORD; | |||
| } | |||
| #endif | |||
| return GL_TRUE; | |||
| } | |||
| /* ================================================================ | |||
| * PRE: No pixelstore attribs, width != imageWidth. | |||
| */ | |||
| static GLboolean | |||
| TAG(texsubimage2d_stride)( struct gl_texture_convert *convert ) | |||
| { | |||
| const GLubyte *src = (const GLubyte *)convert->srcImage; | |||
| DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage + | |||
| (convert->yoffset * convert->imageWidth + | |||
| convert->xoffset) * DST_TEXEL_BYTES); | |||
| GLint adjust; | |||
| GLint row, col; | |||
| adjust = convert->imageWidth - convert->width; | |||
| if ( DBG ) { | |||
| fprintf( stderr, __FUNCTION__ ":\n" ); | |||
| fprintf( stderr, " x=%d y=%d w=%d h=%d s=%d\n", | |||
| convert->xoffset, convert->yoffset, convert->width, | |||
| convert->height, convert->imageWidth ); | |||
| fprintf( stderr, " adjust=%d\n", adjust ); | |||
| } | |||
| for ( row = 0 ; row < convert->height ; row++ ) { | |||
| for ( col = 0 ; col < convert->width ; col++ ) { | |||
| *dst++ = CONVERT_TEXEL( src ); | |||
| src += SRC_TEXEL_BYTES; | |||
| } | |||
| dst += adjust; | |||
| } | |||
| return GL_TRUE; | |||
| } | |||
| /* PRE: As above, or height != imageHeight also. | |||
| */ | |||
| static GLboolean | |||
| TAG(texsubimage3d_stride)( struct gl_texture_convert *convert ) | |||
| { | |||
| const GLubyte *src = (const GLubyte *)convert->srcImage; | |||
| DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage + | |||
| ((convert->zoffset * convert->imageHeight + | |||
| convert->yoffset) * convert->imageWidth + | |||
| convert->xoffset) * DST_TEXEL_BYTES); | |||
| GLint adjust; | |||
| GLint row, col, img; | |||
| adjust = convert->imageWidth - convert->width; | |||
| if ( DBG ) { | |||
| fprintf( stderr, __FUNCTION__ ":\n" ); | |||
| fprintf( stderr, " x=%d y=%d w=%d h=%d s=%d\n", | |||
| convert->xoffset, convert->yoffset, convert->width, | |||
| convert->height, convert->imageWidth ); | |||
| fprintf( stderr, " adjust=%d\n", adjust ); | |||
| } | |||
| for ( img = 0 ; img < convert->depth ; img++ ) { | |||
| for ( row = 0 ; row < convert->height ; row++ ) { | |||
| for ( col = 0 ; col < convert->width ; col++ ) { | |||
| *dst++ = CONVERT_TEXEL( src ); | |||
| src += SRC_TEXEL_BYTES; | |||
| } | |||
| dst += adjust; | |||
| } | |||
| /* FIXME: ... */ | |||
| } | |||
| return GL_TRUE; | |||
| } | |||
| /* ================================================================ | |||
| * PRE: Require pixelstore attribs, width == imageWidth. | |||
| */ | |||
| static GLboolean | |||
| TAG(texsubimage2d_pack)( struct gl_texture_convert *convert ) | |||
| { | |||
| const GLubyte *src = (const GLubyte *) | |||
| _mesa_image_address( convert->packing, convert->srcImage, | |||
| convert->width, convert->height, | |||
| convert->format, convert->type, 0, 0, 0 ); | |||
| const GLint srcRowStride = | |||
| _mesa_image_row_stride( convert->packing, convert->width, | |||
| convert->format, convert->type ); | |||
| GLuint *dst = (GLuint *)((GLubyte *)convert->dstImage + | |||
| (convert->yoffset * convert->width + | |||
| convert->xoffset) * DST_TEXEL_BYTES); | |||
| GLint width; | |||
| GLint row, col; | |||
| (void) col; | |||
| if ( DBG ) | |||
| fprintf( stderr, __FUNCTION__ "\n" ); | |||
| width = ((convert->width + DST_TEXELS_PER_DWORD - 1) | |||
| & ~(DST_TEXELS_PER_DWORD - 1)); | |||
| for ( row = 0 ; row < convert->height ; row++ ) { | |||
| #ifdef CONVERT_DIRECT | |||
| MEMCPY( dst, src, DST_ROW_STRIDE ); | |||
| src += srcRowStride; | |||
| dst = (GLuint *)((GLubyte *)dst + DST_ROW_STRIDE); | |||
| #else | |||
| const GLubyte *srcRow = src; | |||
| for ( col = width / DST_TEXELS_PER_DWORD ; col ; col-- ) { | |||
| *dst++ = CONVERT_TEXEL_DWORD( src ); | |||
| src += SRC_TEXEL_BYTES * DST_TEXELS_PER_DWORD; | |||
| } | |||
| src = srcRow + srcRowStride; | |||
| #endif | |||
| } | |||
| return GL_TRUE; | |||
| } | |||
| /* PRE: as above, height == imageHeight also. | |||
| */ | |||
| static GLboolean | |||
| TAG(texsubimage3d_pack)( struct gl_texture_convert *convert ) | |||
| { | |||
| const GLubyte *src = (const GLubyte *) | |||
| _mesa_image_address( convert->packing, convert->srcImage, | |||
| convert->width, convert->height, | |||
| convert->format, convert->type, 0, 0, 0 ); | |||
| const GLint srcRowStride = | |||
| _mesa_image_row_stride( convert->packing, convert->width, | |||
| convert->format, convert->type ); | |||
| GLuint *dst = (GLuint *)((GLubyte *)convert->dstImage + | |||
| ((convert->zoffset * convert->height + | |||
| convert->yoffset) * convert->width + | |||
| convert->xoffset) * DST_TEXEL_BYTES); | |||
| GLint width; | |||
| GLint row, col, img; | |||
| (void) col; | |||
| if ( DBG ) | |||
| fprintf( stderr, __FUNCTION__ "\n" ); | |||
| width = ((convert->width + DST_TEXELS_PER_DWORD - 1) | |||
| & ~(DST_TEXELS_PER_DWORD - 1)); | |||
| for ( img = 0 ; img < convert->depth ; img++ ) { | |||
| for ( row = 0 ; row < convert->height ; row++ ) { | |||
| #ifdef CONVERT_DIRECT | |||
| MEMCPY( dst, src, DST_ROW_STRIDE ); | |||
| src += srcRowStride; | |||
| dst = (GLuint *)((GLubyte *)dst + DST_ROW_STRIDE); | |||
| #else | |||
| const GLubyte *srcRow = src; | |||
| for ( col = width / DST_TEXELS_PER_DWORD ; col ; col-- ) { | |||
| *dst++ = CONVERT_TEXEL_DWORD( src ); | |||
| src += SRC_TEXEL_BYTES * DST_TEXELS_PER_DWORD; | |||
| } | |||
| src = srcRow + srcRowStride; | |||
| #endif | |||
| } | |||
| } | |||
| return GL_TRUE; | |||
| } | |||
| /* ================================================================ | |||
| * PRE: Require pixelstore attribs, width != imageWidth. | |||
| */ | |||
| static GLboolean | |||
| TAG(texsubimage2d_stride_pack)( struct gl_texture_convert *convert ) | |||
| { | |||
| const GLubyte *src = (const GLubyte *) | |||
| _mesa_image_address( convert->packing, convert->srcImage, | |||
| convert->width, convert->height, | |||
| convert->format, convert->type, 0, 0, 0 ); | |||
| const GLint srcRowStride = | |||
| _mesa_image_row_stride( convert->packing, convert->width, | |||
| convert->format, convert->type ); | |||
| DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage + | |||
| (convert->yoffset * convert->imageWidth + | |||
| convert->xoffset) * DST_TEXEL_BYTES); | |||
| GLint adjust; | |||
| GLint row, col; | |||
| (void) col; | |||
| adjust = convert->imageWidth - convert->width; | |||
| if ( DBG ) { | |||
| fprintf( stderr, __FUNCTION__ ":\n" ); | |||
| fprintf( stderr, " x=%d y=%d w=%d h=%d s=%d\n", | |||
| convert->xoffset, convert->yoffset, convert->width, | |||
| convert->height, convert->imageWidth ); | |||
| fprintf( stderr, " adjust=%d\n", adjust ); | |||
| } | |||
| for ( row = 0 ; row < convert->height ; row++ ) { | |||
| #ifdef CONVERT_DIRECT | |||
| MEMCPY( dst, src, DST_ROW_WIDTH ); | |||
| src += srcRowStride; | |||
| dst += convert->imageWidth; | |||
| #else | |||
| const GLubyte *srcRow = src; | |||
| for ( col = 0 ; col < convert->width ; col++ ) { | |||
| *dst++ = CONVERT_TEXEL( src ); | |||
| src += SRC_TEXEL_BYTES; | |||
| } | |||
| src = srcRow + srcRowStride; | |||
| dst += adjust; | |||
| #endif | |||
| } | |||
| return GL_TRUE; | |||
| } | |||
| /* PRE: As above, or height != imageHeight also. | |||
| */ | |||
| static GLboolean | |||
| TAG(texsubimage3d_stride_pack)( struct gl_texture_convert *convert ) | |||
| { | |||
| const GLubyte *src = (const GLubyte *) | |||
| _mesa_image_address( convert->packing, convert->srcImage, | |||
| convert->width, convert->height, | |||
| convert->format, convert->type, 0, 0, 0 ); | |||
| const GLint srcRowStride = | |||
| _mesa_image_row_stride( convert->packing, convert->width, | |||
| convert->format, convert->type ); | |||
| DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage + | |||
| ((convert->zoffset * convert->imageHeight + | |||
| convert->yoffset) * convert->imageWidth + | |||
| convert->xoffset) * DST_TEXEL_BYTES); | |||
| GLint adjust; | |||
| GLint row, col, img; | |||
| (void) col; | |||
| adjust = convert->imageWidth - convert->width; | |||
| if ( DBG ) { | |||
| fprintf( stderr, __FUNCTION__ ":\n" ); | |||
| fprintf( stderr, " x=%d y=%d w=%d h=%d s=%d\n", | |||
| convert->xoffset, convert->yoffset, convert->width, | |||
| convert->height, convert->imageWidth ); | |||
| fprintf( stderr, " adjust=%d\n", adjust ); | |||
| } | |||
| for ( img = 0 ; img < convert->depth ; img++ ) { | |||
| for ( row = 0 ; row < convert->height ; row++ ) { | |||
| #ifdef CONVERT_DIRECT | |||
| MEMCPY( dst, src, DST_ROW_WIDTH ); | |||
| src += srcRowStride; | |||
| dst += convert->imageWidth; | |||
| #else | |||
| const GLubyte *srcRow = src; | |||
| for ( col = 0 ; col < convert->width ; col++ ) { | |||
| *dst++ = CONVERT_TEXEL( src ); | |||
| src += SRC_TEXEL_BYTES; | |||
| } | |||
| src = srcRow + srcRowStride; | |||
| dst += adjust; | |||
| #endif | |||
| } | |||
| /* FIXME: ... */ | |||
| } | |||
| return GL_TRUE; | |||
| } | |||
| static convert_func TAG(texsubimage2d_tab)[] = { | |||
| TAG(texsubimage2d), | |||
| TAG(texsubimage2d_stride), | |||
| TAG(texsubimage2d_pack), | |||
| TAG(texsubimage2d_stride_pack), | |||
| }; | |||
| static convert_func TAG(texsubimage3d_tab)[] = { | |||
| TAG(texsubimage3d), | |||
| TAG(texsubimage3d_stride), | |||
| TAG(texsubimage3d_pack), | |||
| TAG(texsubimage3d_stride_pack), | |||
| }; | |||
| #ifndef PRESERVE_DST_TYPE | |||
| #undef DST_TYPE | |||
| #undef DST_TEXELS_PER_DWORD | |||
| #endif | |||
| #undef SRC_TEXEL_BYTES | |||
| #undef DST_TEXEL_BYTES | |||
| #undef DST_ROW_WIDTH | |||
| #undef DST_ROW_STRIDE | |||
| #undef CONVERT_TEXEL | |||
| #undef CONVERT_TEXEL_DWORD | |||
| #undef CONVERT_DIRECT | |||
| #undef TAG | |||
| #undef PRESERVE_DST_TYPE | |||