From 11a03a18addacb2c893786830331029e7ab79f93 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 15 Jul 2004 08:08:44 +0000 Subject: enable FXT1 texture compression for ixxx chipsets commented out Keiths extensions strings --- src/mesa/drivers/dri/i915/i830_context.c | 3 +- src/mesa/drivers/dri/i915/i830_texstate.c | 6 ++ src/mesa/drivers/dri/i915/i915_texstate.c | 6 ++ src/mesa/drivers/dri/i915/intel_context.c | 2 + src/mesa/drivers/dri/i915/intel_tex.c | 98 +++++++++++++++++++++++++++++++ 5 files changed, 114 insertions(+), 1 deletion(-) (limited to 'src/mesa/drivers') diff --git a/src/mesa/drivers/dri/i915/i830_context.c b/src/mesa/drivers/dri/i915/i830_context.c index d34fbb0d26..093a2f96f2 100644 --- a/src/mesa/drivers/dri/i915/i830_context.c +++ b/src/mesa/drivers/dri/i915/i830_context.c @@ -45,6 +45,7 @@ */ static const GLubyte *i830GetString( GLcontext *ctx, GLenum name ) { +#if 0 if (name == GL_EXTENSIONS) return "GL_ARB_multitexture " @@ -82,7 +83,7 @@ static const GLubyte *i830GetString( GLcontext *ctx, GLenum name ) "GL_MESA_window_pos " "GL_NV_texgen_reflection " "GL_SGIS_generate_mipmap "; - +#endif return intelGetString( ctx, name ); } diff --git a/src/mesa/drivers/dri/i915/i830_texstate.c b/src/mesa/drivers/dri/i915/i830_texstate.c index a10359e6b3..476ee19391 100644 --- a/src/mesa/drivers/dri/i915/i830_texstate.c +++ b/src/mesa/drivers/dri/i915/i830_texstate.c @@ -106,6 +106,12 @@ static GLboolean i830SetTexImages( i830ContextPtr i830, TM0S1_COLORSPACE_CONVERSION); break; + case MESA_FORMAT_RGB_FXT1: + case MESA_FORMAT_RGBA_FXT1: + t->intel.texelBytes = 2; + textureFormat = MAPSURF_COMPRESSED | MT_COMPRESS_FXT1; + break; + default: fprintf(stderr, "%s: bad image format\n", __FUNCTION__); abort(); diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c b/src/mesa/drivers/dri/i915/i915_texstate.c index 319a34c8b0..ec8f1fa202 100644 --- a/src/mesa/drivers/dri/i915/i915_texstate.c +++ b/src/mesa/drivers/dri/i915/i915_texstate.c @@ -122,6 +122,12 @@ static void i915SetTexImages( i915ContextPtr i915, ss2 |= SS2_COLORSPACE_CONVERSION; break; + case MESA_FORMAT_RGB_FXT1: + case MESA_FORMAT_RGBA_FXT1: + t->intel.texelBytes = 2; + textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_FXT1); + break; + default: fprintf(stderr, "%s: bad image format\n", __FUNCTION__); abort(); diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c index 67b9df83a7..12489433bc 100644 --- a/src/mesa/drivers/dri/i915/intel_context.c +++ b/src/mesa/drivers/dri/i915/intel_context.c @@ -179,6 +179,8 @@ static const char * const card_extensions[] = "GL_SGIS_generate_mipmap", "GL_SGIS_texture_border_clamp", "GL_SGIS_texture_edge_clamp", + "GL_3DFX_texture_compression_FXT1", + NULL }; diff --git a/src/mesa/drivers/dri/i915/intel_tex.c b/src/mesa/drivers/dri/i915/intel_tex.c index 3a67943fef..6475950585 100644 --- a/src/mesa/drivers/dri/i915/intel_tex.c +++ b/src/mesa/drivers/dri/i915/intel_tex.c @@ -304,6 +304,83 @@ static void intelTexSubImage2D( GLcontext *ctx, } } +static void intelCompressedTexImage2D( GLcontext *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ) +{ + driTextureObject * t = (driTextureObject *) texObj->DriverData; + GLuint face; + + /* which cube face or ordinary 2D image */ + switch (target) { + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X; + ASSERT(face < 6); + break; + default: + face = 0; + } + + assert(t); + intelFlush( ctx ); + + driSwapOutTextureObject( t ); + texImage->IsClientData = GL_FALSE; + + if (INTEL_DEBUG & DEBUG_TEXTURE) + fprintf(stderr, "%s: Using normal storage\n", __FUNCTION__); + + _mesa_store_compressed_teximage2d(ctx, target, level, internalFormat, width, + height, border, imageSize, data, texObj, texImage); + + t->dirty_images[face] |= (1 << level); +} + + +static void intelCompressedTexSubImage2D( GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ) +{ + driTextureObject * t = (driTextureObject *) texObj->DriverData; + GLuint face; + + + /* which cube face or ordinary 2D image */ + switch (target) { + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X; + ASSERT(face < 6); + break; + default: + face = 0; + } + + assert( t ); /* this _should_ be true */ + intelFlush( ctx ); + driSwapOutTextureObject( t ); + + _mesa_store_compressed_texsubimage2d(ctx, target, level, xoffset, yoffset, width, + height, format, imageSize, data, texObj, texImage); + + t->dirty_images[face] |= (1 << level); +} static void intelTexImage3D( GLcontext *ctx, GLenum target, GLint level, @@ -472,6 +549,11 @@ intelChooseTextureFormat( GLcontext *ctx, GLint internalFormat, else return &_mesa_texformat_ycbcr_rev; + case GL_COMPRESSED_RGB_FXT1_3DFX: + return &_mesa_texformat_rgb_fxt1; + case GL_COMPRESSED_RGBA_FXT1_3DFX: + return &_mesa_texformat_rgba_fxt1; + default: fprintf(stderr, "unexpected texture format in %s\n", __FUNCTION__); return NULL; @@ -529,6 +611,20 @@ static void intelUploadTexImage( intelContextPtr intel, image->Width, image->Height); } + else if (image->IsCompressed) { + GLuint row_len = image->Width * 2; + GLubyte *dst = (GLubyte *)(t->BufAddr + offset); + GLubyte *src = (GLubyte *)image->Data; + GLuint j; + + if ((image->IntFormat == GL_COMPRESSED_RGB_FXT1_3DFX || image->IntFormat == GL_COMPRESSED_RGBA_FXT1_3DFX)) + { + for (j = 0 ; j < image->Height/4 ; j++, dst += (t->Pitch)) { + __memcpy(dst, src, row_len ); + src += row_len; + } + } + } else { GLuint row_len = image->Width * image->TexFormat->TexelBytes; GLubyte *dst = (GLubyte *)(t->BufAddr + offset); @@ -682,4 +778,6 @@ void intelInitTextureFuncs( struct dd_function_table *functions ) functions->IsTextureResident = driIsTextureResident; functions->TestProxyTexImage = _mesa_test_proxy_teximage; functions->DeleteTexture = intelDeleteTexture; + functions->CompressedTexImage2D = intelCompressedTexImage2D; + functions->CompressedTexSubImage2D = intelCompressedTexSubImage2D; } -- cgit v1.2.3