diff options
author | idr <idr> | 2003-05-16 19:05:41 +0000 |
---|---|---|
committer | idr <idr> | 2003-05-16 19:05:41 +0000 |
commit | b2d5759709b9d0c92f5d8c5052fa617024d79712 (patch) | |
tree | 0efa35ac3acebee4acd79da617310683e4a31226 | |
parent | 9bc09a468e65f0a4fc43f41c3bfbc688590130f1 (diff) |
Added (fake) support for ARB_texture_compression and support for
EXT_texture_filter_anisotropic.
-rw-r--r-- | xc/lib/GL/mesa/src/drv/i830/i830_tex.c | 135 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/i830/i830_tex.h | 58 |
2 files changed, 111 insertions, 82 deletions
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_tex.c b/xc/lib/GL/mesa/src/drv/i830/i830_tex.c index 93bbf90e4..2b2039094 100644 --- a/xc/lib/GL/mesa/src/drv/i830/i830_tex.c +++ b/xc/lib/GL/mesa/src/drv/i830/i830_tex.c @@ -56,9 +56,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* * Compute the 'S2.4' lod bias factor from the floating point OpenGL bias. */ -static void i830ComputeLodBias(i830ContextPtr imesa, - i830TextureObjectPtr t, - GLfloat bias) +static void i830ComputeLodBias( i830TextureObjectPtr t, GLfloat bias ) { int b; @@ -129,69 +127,88 @@ static void i830SetTexWrapping(i830TextureObjectPtr tex, } } -static void i830SetTexFilter(i830ContextPtr imesa, - i830TextureObjectPtr t, - GLenum minf, GLenum magf, - GLfloat bias) +static void i830SetTexMaxAnisotropy( i830TextureObjectPtr t, GLfloat max ) +{ + t->max_anisotropy = max; +} + + +/** + * Set the texture magnification and minification modes. + * + * \param t Texture whose filter modes are to be set + * \param minf Texture minification mode + * \param magf Texture magnification mode + * \param bias LOD bias for this texture unit. + */ + +static void i830SetTexFilter( i830TextureObjectPtr t, GLenum minf, GLenum magf, + GLfloat bias ) { int minFilt = 0, mipFilt = 0, magFilt = 0; if(I830_DEBUG&DEBUG_DRI) fprintf(stderr, "%s\n", __FUNCTION__); - switch (minf) { - case GL_NEAREST: - minFilt = FILTER_NEAREST; - mipFilt = MIPFILTER_NONE; - break; - case GL_LINEAR: - minFilt = FILTER_LINEAR; - mipFilt = MIPFILTER_NONE; - break; - case GL_NEAREST_MIPMAP_NEAREST: - minFilt = FILTER_NEAREST; - mipFilt = MIPFILTER_NEAREST; + if ( t->max_anisotropy > 1.0 ) { + minFilt = FILTER_ANISOTROPIC; + magFilt = FILTER_ANISOTROPIC; + } + else { + switch (minf) { + case GL_NEAREST: + minFilt = FILTER_NEAREST; + mipFilt = MIPFILTER_NONE; + break; + case GL_LINEAR: + minFilt = FILTER_LINEAR; + mipFilt = MIPFILTER_NONE; + break; + case GL_NEAREST_MIPMAP_NEAREST: + minFilt = FILTER_NEAREST; + mipFilt = MIPFILTER_NEAREST; /* if(magf == GL_LINEAR && 0) { */ /* bias -= 0.5; */ /* } */ - break; - case GL_LINEAR_MIPMAP_NEAREST: - minFilt = FILTER_LINEAR; - mipFilt = MIPFILTER_NEAREST; - break; - case GL_NEAREST_MIPMAP_LINEAR: - minFilt = FILTER_NEAREST; - mipFilt = MIPFILTER_LINEAR; + break; + case GL_LINEAR_MIPMAP_NEAREST: + minFilt = FILTER_LINEAR; + mipFilt = MIPFILTER_NEAREST; + break; + case GL_NEAREST_MIPMAP_LINEAR: + minFilt = FILTER_NEAREST; + mipFilt = MIPFILTER_LINEAR; /* if(magf == GL_LINEAR && 0) { */ /* bias -= 0.5; */ /* } */ - break; - case GL_LINEAR_MIPMAP_LINEAR: - minFilt = FILTER_LINEAR; - mipFilt = MIPFILTER_LINEAR; - break; - default: - fprintf(stderr, "i830SetTexFilter(): not supported min. filter %d\n", - (int)minf); - break; - } + break; + case GL_LINEAR_MIPMAP_LINEAR: + minFilt = FILTER_LINEAR; + mipFilt = MIPFILTER_LINEAR; + break; + default: + _mesa_problem(NULL, "%s: Unsupported min. filter %d", __FUNCTION__, + (int) minf ); + break; + } - switch (magf) { - case GL_NEAREST: - magFilt = FILTER_NEAREST; - break; - case GL_LINEAR: - magFilt = FILTER_LINEAR; - break; - default: - fprintf(stderr, "i830SetTexFilter(): not supported mag. filter %d\n", - (int)magf); - break; - } + switch (magf) { + case GL_NEAREST: + magFilt = FILTER_NEAREST; + break; + case GL_LINEAR: + magFilt = FILTER_LINEAR; + break; + default: + _mesa_problem(NULL, "%s: Unsupported mag. filter %d", __FUNCTION__, + (int) magf ); + break; + } + } t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MIN_FILTER_MASK; t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MIP_FILTER_MASK; @@ -200,7 +217,7 @@ static void i830SetTexFilter(i830ContextPtr imesa, (mipFilt << TM0S3_MIP_FILTER_SHIFT) | (magFilt << TM0S3_MAG_FILTER_SHIFT)); - i830ComputeLodBias(imesa, t, bias); + i830ComputeLodBias(t, bias); } static void i830SetTexBorderColor(i830TextureObjectPtr t, GLubyte color[4]) @@ -235,9 +252,11 @@ static void i830TexParameter( GLcontext *ctx, GLenum target, switch (pname) { case GL_TEXTURE_MIN_FILTER: case GL_TEXTURE_MAG_FILTER: + case GL_TEXTURE_MAX_ANISOTROPY_EXT: { GLfloat bias = ctx->Texture.Unit[unit].LodBias; - i830SetTexFilter( imesa, t, tObj->MinFilter, tObj->MagFilter, bias ); + i830SetTexMaxAnisotropy( t, tObj->MaxAnisotropy ); + i830SetTexFilter( t, tObj->MinFilter, tObj->MagFilter, bias ); } break; @@ -311,7 +330,7 @@ static void i830TexEnv( GLcontext *ctx, GLenum target, t = (i830TextureObjectPtr) tObj->DriverData; if (!t) return; - i830ComputeLodBias(imesa, t, *param); + i830ComputeLodBias(t, *param); /* Do a state change */ if (t == imesa->CurrentTexObj[unit]) { I830_STATECHANGE( imesa, I830_UPLOAD_TEX_N(unit) ); @@ -364,11 +383,11 @@ static void i830TexSubImage2D( GLcontext *ctx, } + static void i830BindTexture( GLcontext *ctx, GLenum target, struct gl_texture_object *tObj ) { if (target == GL_TEXTURE_2D) { - i830ContextPtr imesa = I830_CONTEXT( ctx ); i830TextureObjectPtr t = (i830TextureObjectPtr) tObj->DriverData; if (!t) { @@ -405,12 +424,14 @@ static void i830BindTexture( GLcontext *ctx, GLenum target, make_empty_list( t ); i830SetTexWrapping( t, tObj->WrapS, tObj->WrapT ); - i830SetTexFilter( imesa, t, tObj->MinFilter, tObj->MagFilter, bias ); + i830SetTexMaxAnisotropy( t, tObj->MaxAnisotropy ); + i830SetTexFilter( t, tObj->MinFilter, tObj->MagFilter, bias ); i830SetTexBorderColor( t, tObj->_BorderChan ); } } } + static void i830DeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj ) { i830TextureObjectPtr t = (i830TextureObjectPtr)tObj->DriverData; @@ -442,6 +463,7 @@ i830ChooseTextureFormat( GLcontext *ctx, GLint internalFormat, switch ( internalFormat ) { case 4: case GL_RGBA: + case GL_COMPRESSED_RGBA: if ( format == GL_BGRA ) { if ( type == GL_UNSIGNED_INT_8_8_8_8_REV ) { return &_mesa_texformat_argb8888; @@ -457,6 +479,7 @@ i830ChooseTextureFormat( GLcontext *ctx, GLint internalFormat, case 3: case GL_RGB: + case GL_COMPRESSED_RGB: if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) { return &_mesa_texformat_rgb565; } @@ -491,6 +514,7 @@ i830ChooseTextureFormat( GLcontext *ctx, GLint internalFormat, case GL_ALPHA8: case GL_ALPHA12: case GL_ALPHA16: + case GL_COMPRESSED_ALPHA: return &_mesa_texformat_al88; case 1: @@ -499,6 +523,7 @@ i830ChooseTextureFormat( GLcontext *ctx, GLint internalFormat, case GL_LUMINANCE8: case GL_LUMINANCE12: case GL_LUMINANCE16: + case GL_COMPRESSED_LUMINANCE: return &_mesa_texformat_l8; case 2: @@ -509,6 +534,7 @@ i830ChooseTextureFormat( GLcontext *ctx, GLint internalFormat, case GL_LUMINANCE12_ALPHA4: case GL_LUMINANCE12_ALPHA12: case GL_LUMINANCE16_ALPHA16: + case GL_COMPRESSED_LUMINANCE_ALPHA: return &_mesa_texformat_al88; case GL_INTENSITY: @@ -516,6 +542,7 @@ i830ChooseTextureFormat( GLcontext *ctx, GLint internalFormat, case GL_INTENSITY8: case GL_INTENSITY12: case GL_INTENSITY16: + case GL_COMPRESSED_INTENSITY: return &_mesa_texformat_i8; default: diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_tex.h b/xc/lib/GL/mesa/src/drv/i830/i830_tex.h index ec05c4272..431871e29 100644 --- a/xc/lib/GL/mesa/src/drv/i830/i830_tex.h +++ b/xc/lib/GL/mesa/src/drv/i830/i830_tex.h @@ -36,35 +36,37 @@ struct i830_texture_object_t { - struct i830_texture_object_t *next, *prev; - GLuint age; - struct gl_texture_object *globj; - int Pitch; - int Height; - int texelBytes; - int totalSize; - int bound; - PMemBlock MemBlock; - char *BufAddr; - GLuint min_level; - GLuint max_level; - GLuint dirty_images; - GLenum palette_format; - GLuint palette[256]; - struct - { - const struct gl_texture_image *image; - int offset; /* into BufAddr */ - int height; - int internalFormat; - }image[I830_TEX_MAXLEVELS]; + struct i830_texture_object_t *next, *prev; + GLuint age; + struct gl_texture_object *globj; + int Pitch; + int Height; + int texelBytes; + int totalSize; + int bound; + PMemBlock MemBlock; + char *BufAddr; + GLuint min_level; + GLuint max_level; + GLuint dirty_images; + GLenum palette_format; + GLuint palette[256]; + struct { + const struct gl_texture_image *image; + int offset; /* into BufAddr */ + int height; + int internalFormat; + } image[I830_TEX_MAXLEVELS]; + + /* Support for multitexture. + */ + + GLuint current_unit; + GLuint Setup[I830_TEX_SETUP_SIZE]; + GLuint dirty; + GLuint firstLevel,lastLevel; - /* Support for multitexture. - * */ - GLuint current_unit; - GLuint Setup[I830_TEX_SETUP_SIZE]; - GLuint dirty; - GLuint firstLevel,lastLevel; + GLfloat max_anisotropy; }; void i830UpdateTextureState( GLcontext *ctx ); |