From 354d66e2f58bb19efcd9a0f8b2398d3f1dc4248d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 1 Oct 2009 16:30:47 -0600 Subject: mesa: simplify _mesa_compressed_texture_size() --- src/mesa/main/texcompress.c | 69 ++++++--------------------------------------- 1 file changed, 9 insertions(+), 60 deletions(-) (limited to 'src/mesa/main/texcompress.c') diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c index c1b8c7675a..a2b1218d0c 100644 --- a/src/mesa/main/texcompress.c +++ b/src/mesa/main/texcompress.c @@ -34,6 +34,7 @@ #include "imports.h" #include "colormac.h" #include "context.h" +#include "formats.h" #include "image.h" #include "mipmap.h" #include "texcompress.h" @@ -116,9 +117,10 @@ _mesa_get_compressed_formats(GLcontext *ctx, GLint *formats, GLboolean all) /** * Return number of bytes needed to store a texture of the given size - * using the specified compressed format. + * using the specified (compressed?) format. * This is called via the ctx->Driver.CompressedTextureSize function, - * unless a device driver overrides it. + * unless a device driver overrides it. A driver might override this + * if it needs to use an unusual or padded texture memory layout. * * \param width texture width in texels. * \param height texture height in texels. @@ -132,62 +134,7 @@ _mesa_compressed_texture_size( GLcontext *ctx, GLsizei width, GLsizei height, GLsizei depth, GLuint mesaFormat ) { - GLuint size; - - ASSERT(depth == 1); - (void) depth; - (void) size; - - switch (mesaFormat) { -#if FEATURE_texture_fxt1 - case MESA_FORMAT_RGB_FXT1: - case MESA_FORMAT_RGBA_FXT1: - /* round up width to next multiple of 8, height to next multiple of 4 */ - width = (width + 7) & ~7; - height = (height + 3) & ~3; - /* 16 bytes per 8x4 tile of RGB[A] texels */ - size = width * height / 2; - /* Textures smaller than 8x4 will effectively be made into 8x4 and - * take 16 bytes. - */ - return size; -#endif -#if FEATURE_texture_s3tc - case MESA_FORMAT_RGB_DXT1: - case MESA_FORMAT_RGBA_DXT1: -#if FEATURE_EXT_texture_sRGB - case MESA_FORMAT_SRGB_DXT1: - case MESA_FORMAT_SRGBA_DXT1: -#endif - /* round up width, height to next multiple of 4 */ - width = (width + 3) & ~3; - height = (height + 3) & ~3; - /* 8 bytes per 4x4 tile of RGB[A] texels */ - size = width * height / 2; - /* Textures smaller than 4x4 will effectively be made into 4x4 and - * take 8 bytes. - */ - return size; - case MESA_FORMAT_RGBA_DXT3: - case MESA_FORMAT_RGBA_DXT5: -#if FEATURE_EXT_texture_sRGB - case MESA_FORMAT_SRGBA_DXT3: - case MESA_FORMAT_SRGBA_DXT5: -#endif - /* round up width, height to next multiple of 4 */ - width = (width + 3) & ~3; - height = (height + 3) & ~3; - /* 16 bytes per 4x4 tile of RGBA texels */ - size = width * height; /* simple! */ - /* Textures smaller than 4x4 will effectively be made into 4x4 and - * take 16 bytes. - */ - return size; -#endif - default: - _mesa_problem(ctx, "bad mesaFormat in _mesa_compressed_texture_size"); - return 0; - } + return _mesa_format_image_size(mesaFormat, width, height, depth); } @@ -205,7 +152,7 @@ _mesa_compressed_texture_size_glenum(GLcontext *ctx, GLsizei width, GLsizei height, GLsizei depth, GLenum glformat) { - GLuint mesaFormat; + gl_format mesaFormat; switch (glformat) { #if FEATURE_texture_fxt1 @@ -252,7 +199,7 @@ _mesa_compressed_texture_size_glenum(GLcontext *ctx, return 0; } - return _mesa_compressed_texture_size(ctx, width, height, depth, mesaFormat); + return _mesa_format_image_size(mesaFormat, width, height, depth); } @@ -298,6 +245,8 @@ _mesa_compressed_row_stride(GLuint mesaFormat, GLsizei width) return 0; } + assert(stride == _mesa_format_row_stride(mesaFormat, width)); + return stride; } -- cgit v1.2.3 From 90cd968300b8490f6efd75ef751fd3b6554f16d3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 5 Oct 2009 17:56:31 -0600 Subject: mesa: don't include texformat.h --- src/mesa/main/debug.c | 1 - src/mesa/main/texcompress.c | 1 - src/mesa/main/texcompress_fxt1.c | 1 - src/mesa/main/texcompress_s3tc.c | 1 - src/mesa/main/texgetimage.c | 2 +- src/mesa/main/teximage.c | 1 - src/mesa/main/texstore.c | 1 - 7 files changed, 1 insertion(+), 7 deletions(-) (limited to 'src/mesa/main/texcompress.c') diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c index 391180a7c6..e55c2f02c9 100644 --- a/src/mesa/main/debug.c +++ b/src/mesa/main/debug.c @@ -35,7 +35,6 @@ #include "readpix.h" #include "texgetimage.h" #include "texobj.h" -#include "texformat.h" /** diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c index a2b1218d0c..5713b2c00d 100644 --- a/src/mesa/main/texcompress.c +++ b/src/mesa/main/texcompress.c @@ -38,7 +38,6 @@ #include "image.h" #include "mipmap.h" #include "texcompress.h" -#include "texformat.h" #include "texstore.h" diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c index 7a30806b60..ef42fb92b7 100644 --- a/src/mesa/main/texcompress_fxt1.c +++ b/src/mesa/main/texcompress_fxt1.c @@ -38,7 +38,6 @@ #include "mipmap.h" #include "texcompress.h" #include "texcompress_fxt1.h" -#include "texformat.h" #include "texstore.h" diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c index 2f7168c622..9fc73fec51 100644 --- a/src/mesa/main/texcompress_s3tc.c +++ b/src/mesa/main/texcompress_s3tc.c @@ -42,7 +42,6 @@ #include "image.h" #include "texcompress.h" #include "texcompress_s3tc.h" -#include "texformat.h" #include "texstore.h" #ifdef __MINGW32__ diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index 341ce6103f..d5cd4b2b9d 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -32,9 +32,9 @@ #include "glheader.h" #include "bufferobj.h" #include "context.h" +#include "formats.h" #include "image.h" #include "texcompress.h" -#include "texformat.h" #include "texgetimage.h" #include "teximage.h" #include "texstate.h" diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 457380b8fa..52d2886d0a 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -44,7 +44,6 @@ #include "state.h" #include "texcompress.h" #include "texfetch.h" -#include "texformat.h" #include "teximage.h" #include "texstate.h" #include "texstore.h" diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 52502b7033..83e349d010 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -64,7 +64,6 @@ #include "texcompress.h" #include "texcompress_fxt1.h" #include "texcompress_s3tc.h" -#include "texformat.h" #include "teximage.h" #include "texstore.h" #include "enums.h" -- cgit v1.2.3 From 1ad9671db7bd60fa84266f30f46555b4e45bcb08 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 24 Oct 2009 11:41:25 -0600 Subject: mesa: s/GLuint/gl_format/ --- src/mesa/main/texcompress.c | 6 +++--- src/mesa/main/texcompress.h | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src/mesa/main/texcompress.c') diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c index 5713b2c00d..76f2f232f4 100644 --- a/src/mesa/main/texcompress.c +++ b/src/mesa/main/texcompress.c @@ -131,7 +131,7 @@ _mesa_get_compressed_formats(GLcontext *ctx, GLint *formats, GLboolean all) GLuint _mesa_compressed_texture_size( GLcontext *ctx, GLsizei width, GLsizei height, GLsizei depth, - GLuint mesaFormat ) + gl_format mesaFormat ) { return _mesa_format_image_size(mesaFormat, width, height, depth); } @@ -210,7 +210,7 @@ _mesa_compressed_texture_size_glenum(GLcontext *ctx, * \return stride, in bytes, between rows for compressed image */ GLint -_mesa_compressed_row_stride(GLuint mesaFormat, GLsizei width) +_mesa_compressed_row_stride(gl_format mesaFormat, GLsizei width) { GLint stride; @@ -261,7 +261,7 @@ _mesa_compressed_row_stride(GLuint mesaFormat, GLsizei width) */ GLubyte * _mesa_compressed_image_address(GLint col, GLint row, GLint img, - GLuint mesaFormat, + gl_format mesaFormat, GLsizei width, const GLubyte *image) { GLubyte *addr; diff --git a/src/mesa/main/texcompress.h b/src/mesa/main/texcompress.h index 44f3338222..13af148394 100644 --- a/src/mesa/main/texcompress.h +++ b/src/mesa/main/texcompress.h @@ -26,6 +26,7 @@ #define TEXCOMPRESS_H #include "mtypes.h" +#include "formats.h" #if _HAVE_FULL_GL @@ -35,7 +36,7 @@ _mesa_get_compressed_formats(GLcontext *ctx, GLint *formats, GLboolean all); extern GLuint _mesa_compressed_texture_size( GLcontext *ctx, GLsizei width, GLsizei height, GLsizei depth, - GLuint mesaFormat ); + gl_format mesaFormat ); extern GLuint _mesa_compressed_texture_size_glenum(GLcontext *ctx, @@ -43,12 +44,12 @@ _mesa_compressed_texture_size_glenum(GLcontext *ctx, GLsizei depth, GLenum glformat); extern GLint -_mesa_compressed_row_stride(GLuint mesaFormat, GLsizei width); +_mesa_compressed_row_stride(gl_format mesaFormat, GLsizei width); extern GLubyte * _mesa_compressed_image_address(GLint col, GLint row, GLint img, - GLuint mesaFormat, + gl_format mesaFormat, GLsizei width, const GLubyte *image); -- cgit v1.2.3 From 5c8282769601ba30c00f04dac15d1dad6d67db6e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 24 Oct 2009 11:52:31 -0600 Subject: mesa: simplify _mesa_compressed_row_stride(), _mesa_compressed_image_address() _mesa_compressed_row_stride() can go away soon. _mesa_compressed_image_address() can be generalized and moved to formats.c --- src/mesa/main/texcompress.c | 91 ++++++++------------------------------------- 1 file changed, 15 insertions(+), 76 deletions(-) (limited to 'src/mesa/main/texcompress.c') diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c index 76f2f232f4..b07265d6d8 100644 --- a/src/mesa/main/texcompress.c +++ b/src/mesa/main/texcompress.c @@ -212,40 +212,7 @@ _mesa_compressed_texture_size_glenum(GLcontext *ctx, GLint _mesa_compressed_row_stride(gl_format mesaFormat, GLsizei width) { - GLint stride; - - switch (mesaFormat) { -#if FEATURE_texture_fxt1 - case MESA_FORMAT_RGB_FXT1: - case MESA_FORMAT_RGBA_FXT1: - stride = ((width + 7) / 8) * 16; /* 16 bytes per 8x4 tile */ - break; -#endif -#if FEATURE_texture_s3tc - case MESA_FORMAT_RGB_DXT1: - case MESA_FORMAT_RGBA_DXT1: -#if FEATURE_EXT_texture_sRGB - case MESA_FORMAT_SRGB_DXT1: - case MESA_FORMAT_SRGBA_DXT1: -#endif - stride = ((width + 3) / 4) * 8; /* 8 bytes per 4x4 tile */ - break; - case MESA_FORMAT_RGBA_DXT3: - case MESA_FORMAT_RGBA_DXT5: -#if FEATURE_EXT_texture_sRGB - case MESA_FORMAT_SRGBA_DXT3: - case MESA_FORMAT_SRGBA_DXT5: -#endif - stride = ((width + 3) / 4) * 16; /* 16 bytes per 4x4 tile */ - break; -#endif - default: - _mesa_problem(NULL, "bad mesaFormat in _mesa_compressed_row_stride"); - return 0; - } - - assert(stride == _mesa_format_row_stride(mesaFormat, width)); - + GLint stride = _mesa_format_row_stride(mesaFormat, width); return stride; } @@ -253,58 +220,30 @@ _mesa_compressed_row_stride(gl_format mesaFormat, GLsizei width) /* * Return the address of the pixel at (col, row, img) in a * compressed texture image. - * \param col, row, img - image position (3D) + * \param col, row, img - image position (3D), should be a multiple of the + * format's block size. * \param format - compressed image format - * \param width - image width + * \param width - image width (stride) in pixels * \param image - the image address - * \return address of pixel at (row, col) + * \return address of pixel at (row, col, img) */ GLubyte * _mesa_compressed_image_address(GLint col, GLint row, GLint img, gl_format mesaFormat, GLsizei width, const GLubyte *image) { - GLubyte *addr; + /* XXX only 2D images implemented, not 3D */ + const GLuint blockSize = _mesa_get_format_bytes(mesaFormat); + GLuint bw, bh; + GLint offset; - (void) img; + _mesa_get_format_block_size(mesaFormat, &bw, &bh); - /* We try to spot a "complete" subtexture "above" ROW, COL; - * this texture is given by appropriate rounding of WIDTH x ROW. - * Then we just add the amount left (usually on the left). - * - * Example for X*Y microtiles (Z bytes each) - * offset = Z * (((width + X - 1) / X) * (row / Y) + col / X); - */ + ASSERT(col % bw == 0); + ASSERT(row % bh == 0); - switch (mesaFormat) { -#if FEATURE_texture_fxt1 - case MESA_FORMAT_RGB_FXT1: - case MESA_FORMAT_RGBA_FXT1: - addr = (GLubyte *) image + 16 * (((width + 7) / 8) * (row / 4) + col / 8); - break; -#endif -#if FEATURE_texture_s3tc - case MESA_FORMAT_RGB_DXT1: - case MESA_FORMAT_RGBA_DXT1: -#if FEATURE_EXT_texture_sRGB - case MESA_FORMAT_SRGB_DXT1: - case MESA_FORMAT_SRGBA_DXT1: -#endif - addr = (GLubyte *) image + 8 * (((width + 3) / 4) * (row / 4) + col / 4); - break; - case MESA_FORMAT_RGBA_DXT3: - case MESA_FORMAT_RGBA_DXT5: -#if FEATURE_EXT_texture_sRGB - case MESA_FORMAT_SRGBA_DXT3: - case MESA_FORMAT_SRGBA_DXT5: -#endif - addr = (GLubyte *) image + 16 * (((width + 3) / 4) * (row / 4) + col / 4); - break; -#endif - default: - _mesa_problem(NULL, "bad mesaFormat in _mesa_compressed_image_address"); - addr = NULL; - } + offset = ((width + bw - 1) / bw) * (row / bh) + col / bw; + offset *= blockSize; - return addr; + return (GLubyte *) image + offset; } -- cgit v1.2.3 From d6ee86c77a8e1543557fd64c1f1c354baa0a8ad8 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 24 Oct 2009 16:49:57 -0600 Subject: mesa: remove _mesa_compressed_texture_size() Use _mesa_format_image_size() instead. --- src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c | 2 +- src/mesa/drivers/glide/fxddtex.c | 16 ++++++---------- src/mesa/main/texcompress.c | 24 ------------------------ src/mesa/main/texcompress.h | 6 ------ src/mesa/main/texgetimage.c | 10 ++++------ src/mesa/main/texparam.c | 8 ++------ 6 files changed, 13 insertions(+), 53 deletions(-) (limited to 'src/mesa/main/texcompress.c') diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c index 86f596deb9..dadc72f4c1 100644 --- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c +++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c @@ -37,7 +37,7 @@ static GLuint radeon_compressed_texture_size(GLcontext *ctx, GLsizei width, GLsizei height, GLsizei depth, GLuint mesaFormat) { - GLuint size = _mesa_compressed_texture_size(ctx, width, height, depth, mesaFormat); + GLuint size = _mesa_format_image_size(mesaFormat, width, height, depth); if (mesaFormat == MESA_FORMAT_RGB_DXT1 || mesaFormat == MESA_FORMAT_RGBA_DXT1) { diff --git a/src/mesa/drivers/glide/fxddtex.c b/src/mesa/drivers/glide/fxddtex.c index a820cb818e..128c17e08b 100644 --- a/src/mesa/drivers/glide/fxddtex.c +++ b/src/mesa/drivers/glide/fxddtex.c @@ -1397,11 +1397,9 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level, /* allocate mipmap buffer */ assert(!texImage->Data); if (_mesa_is_format_compressed(texImage->TexFormat)) { - texImage->CompressedSize = _mesa_compressed_texture_size(ctx, - mml->width, - mml->height, - 1, - internalFormat); + texImage->CompressedSize = _mesa_format_image_size(texImage->TexFormat, + mml->width, + mml->height, 1); dstRowStride = _mesa_compressed_row_stride(internalFormat, mml->width); texImage->Data = _mesa_malloc(texImage->CompressedSize); } else { @@ -1664,11 +1662,9 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target, /* allocate new storage for texture image, if needed */ if (!texImage->Data) { - texImage->CompressedSize = _mesa_compressed_texture_size(ctx, - mml->width, - mml->height, - 1, - internalFormat); + texImage->CompressedSize = _mesa_format_image_size(texImage->TexFormat, + mml->width, + mml->height, 1); texImage->Data = _mesa_malloc(texImage->CompressedSize); if (!texImage->Data) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D"); diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c index b07265d6d8..ad10993307 100644 --- a/src/mesa/main/texcompress.c +++ b/src/mesa/main/texcompress.c @@ -113,30 +113,6 @@ _mesa_get_compressed_formats(GLcontext *ctx, GLint *formats, GLboolean all) } - -/** - * Return number of bytes needed to store a texture of the given size - * using the specified (compressed?) format. - * This is called via the ctx->Driver.CompressedTextureSize function, - * unless a device driver overrides it. A driver might override this - * if it needs to use an unusual or padded texture memory layout. - * - * \param width texture width in texels. - * \param height texture height in texels. - * \param depth texture depth in texels. - * \param mesaFormat one of the MESA_FORMAT_* compressed formats - * - * \return size in bytes, or zero if bad format - */ -GLuint -_mesa_compressed_texture_size( GLcontext *ctx, - GLsizei width, GLsizei height, GLsizei depth, - gl_format mesaFormat ) -{ - return _mesa_format_image_size(mesaFormat, width, height, depth); -} - - /** * As above, but format is specified by a GLenum (GL_COMPRESSED_*) token. * diff --git a/src/mesa/main/texcompress.h b/src/mesa/main/texcompress.h index 13af148394..70247098b2 100644 --- a/src/mesa/main/texcompress.h +++ b/src/mesa/main/texcompress.h @@ -33,11 +33,6 @@ extern GLuint _mesa_get_compressed_formats(GLcontext *ctx, GLint *formats, GLboolean all); -extern GLuint -_mesa_compressed_texture_size( GLcontext *ctx, - GLsizei width, GLsizei height, GLsizei depth, - gl_format mesaFormat ); - extern GLuint _mesa_compressed_texture_size_glenum(GLcontext *ctx, GLsizei width, GLsizei height, @@ -64,7 +59,6 @@ _mesa_init_texture_fxt1( GLcontext *ctx ); /* no-op macros */ #define _mesa_get_compressed_formats( c, f ) 0 -#define _mesa_compressed_texture_size( c, w, h, d, f ) 0 #define _mesa_compressed_texture_size_glenum( c, w, h, d, f ) 0 #define _mesa_compressed_row_stride( f, w) 0 #define _mesa_compressed_image_address(c, r, i, f, w, i2 ) 0 diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index d5cd4b2b9d..1f0a3d793f 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -320,12 +320,10 @@ _mesa_get_compressed_teximage(GLcontext *ctx, GLenum target, GLint level, struct gl_texture_object *texObj, struct gl_texture_image *texImage) { - GLuint size; - - /* don't use texImage->CompressedSize since that may be padded out */ - size = _mesa_compressed_texture_size(ctx, texImage->Width, texImage->Height, - texImage->Depth, - texImage->TexFormat); + const GLuint size = _mesa_format_image_size(texImage->TexFormat, + texImage->Width, + texImage->Height, + texImage->Depth); if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* pack texture image into a PBO */ diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c index a6b611dffb..afa66f149c 100644 --- a/src/mesa/main/texparam.c +++ b/src/mesa/main/texparam.c @@ -853,12 +853,8 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, /* GL_ARB_texture_compression */ case GL_TEXTURE_COMPRESSED_IMAGE_SIZE: if (_mesa_is_format_compressed(img->TexFormat) && !isProxy) { - /* Don't use ctx->Driver.CompressedTextureSize() since that - * may returned a padded hardware size. - */ - *params = _mesa_compressed_texture_size(ctx, img->Width, - img->Height, img->Depth, - texFormat); + *params = _mesa_format_image_size(texFormat, img->Width, + img->Height, img->Depth); } else { _mesa_error(ctx, GL_INVALID_OPERATION, -- cgit v1.2.3 From 54bb414e00a4daedbe530b9933bc11bac4ae7149 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sun, 25 Oct 2009 16:59:08 -0600 Subject: mesa: clean-up, simplify compressed texture size checking --- src/mesa/main/texcompress.c | 61 +++++++++++++-------------------------------- src/mesa/main/texcompress.h | 6 ++--- src/mesa/main/teximage.c | 20 ++++++++++++--- 3 files changed, 36 insertions(+), 51 deletions(-) (limited to 'src/mesa/main/texcompress.c') diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c index ad10993307..423ad2490c 100644 --- a/src/mesa/main/texcompress.c +++ b/src/mesa/main/texcompress.c @@ -114,67 +114,42 @@ _mesa_get_compressed_formats(GLcontext *ctx, GLint *formats, GLboolean all) /** - * As above, but format is specified by a GLenum (GL_COMPRESSED_*) token. - * - * Note: This function CAN NOT return a padded hardware texture size. - * That's why we don't call the ctx->Driver.CompressedTextureSize() function. - * - * We use this function to validate the parameter - * of glCompressedTex[Sub]Image1/2/3D(), which must be an exact match. + * Convert a compressed MESA_FORMAT_x to a GLenum. */ -GLuint -_mesa_compressed_texture_size_glenum(GLcontext *ctx, - GLsizei width, GLsizei height, - GLsizei depth, GLenum glformat) +gl_format +_mesa_glenum_to_compressed_format(GLenum format) { - gl_format mesaFormat; - - switch (glformat) { -#if FEATURE_texture_fxt1 + switch (format) { case GL_COMPRESSED_RGB_FXT1_3DFX: - mesaFormat = MESA_FORMAT_RGB_FXT1; - break; + return MESA_FORMAT_RGB_FXT1; case GL_COMPRESSED_RGBA_FXT1_3DFX: - mesaFormat = MESA_FORMAT_RGBA_FXT1; - break; -#endif -#if FEATURE_texture_s3tc + return MESA_FORMAT_RGBA_FXT1; + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_RGB_S3TC: - mesaFormat = MESA_FORMAT_RGB_DXT1; - break; + return MESA_FORMAT_RGB_DXT1; case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: case GL_RGB4_S3TC: - mesaFormat = MESA_FORMAT_RGBA_DXT1; - break; + return MESA_FORMAT_RGBA_DXT1; case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: case GL_RGBA_S3TC: - mesaFormat = MESA_FORMAT_RGBA_DXT3; - break; + return MESA_FORMAT_RGBA_DXT3; case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: case GL_RGBA4_S3TC: - mesaFormat = MESA_FORMAT_RGBA_DXT5; - break; -#if FEATURE_EXT_texture_sRGB + return MESA_FORMAT_RGBA_DXT5; + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: - mesaFormat = MESA_FORMAT_SRGB_DXT1; - break; + return MESA_FORMAT_SRGB_DXT1; case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: - mesaFormat = MESA_FORMAT_SRGBA_DXT1; - break; + return MESA_FORMAT_SRGBA_DXT1; case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: - mesaFormat = MESA_FORMAT_SRGBA_DXT3; - break; + return MESA_FORMAT_SRGBA_DXT3; case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: - mesaFormat = MESA_FORMAT_SRGBA_DXT5; - break; -#endif -#endif + return MESA_FORMAT_SRGBA_DXT5; + default: - return 0; + return MESA_FORMAT_NONE; } - - return _mesa_format_image_size(mesaFormat, width, height, depth); } diff --git a/src/mesa/main/texcompress.h b/src/mesa/main/texcompress.h index 70247098b2..43cd741895 100644 --- a/src/mesa/main/texcompress.h +++ b/src/mesa/main/texcompress.h @@ -33,10 +33,8 @@ extern GLuint _mesa_get_compressed_formats(GLcontext *ctx, GLint *formats, GLboolean all); -extern GLuint -_mesa_compressed_texture_size_glenum(GLcontext *ctx, - GLsizei width, GLsizei height, - GLsizei depth, GLenum glformat); +extern gl_format +_mesa_glenum_to_compressed_format(GLenum format); extern GLint _mesa_compressed_row_stride(gl_format mesaFormat, GLsizei width); diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 52d2886d0a..4fbfeb8582 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -3034,6 +3034,20 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level, /**********************************************************************/ +/** + * Return expected size of a compressed texture. + */ +static GLuint +compressed_tex_size(GLsizei width, GLsizei height, GLsizei depth, + GLenum glformat) +{ + gl_format mesaFormat = _mesa_glenum_to_compressed_format(glformat); + return _mesa_format_image_size(mesaFormat, width, height, depth); +} + + + + /** * Error checking for glCompressedTexImage[123]D(). * \return error code or GL_NO_ERROR. @@ -3116,8 +3130,7 @@ compressed_texture_error_check(GLcontext *ctx, GLint dimensions, if (level < 0 || level >= maxLevels) return GL_INVALID_VALUE; - expectedSize = _mesa_compressed_texture_size_glenum(ctx, width, height, - depth, internalFormat); + expectedSize = compressed_tex_size(width, height, depth, internalFormat); if (expectedSize != imageSize) return GL_INVALID_VALUE; @@ -3211,8 +3224,7 @@ compressed_subtexture_error_check(GLcontext *ctx, GLint dimensions, if ((height & 3) != 0 && height != 2 && height != 1) return GL_INVALID_VALUE; - expectedSize = _mesa_compressed_texture_size_glenum(ctx, width, height, - depth, format); + expectedSize = compressed_tex_size(width, height, depth, format); if (expectedSize != imageSize) return GL_INVALID_VALUE; -- cgit v1.2.3 From 20c6c5853261b31ecd50d58e0aae9b92f25e41db Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sun, 25 Oct 2009 17:25:46 -0600 Subject: mesa: remove _mesa_compressed_row_stride() --- src/mesa/main/texcompress.c | 15 --------------- src/mesa/main/texcompress.h | 5 ----- 2 files changed, 20 deletions(-) (limited to 'src/mesa/main/texcompress.c') diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c index 423ad2490c..262e8236ed 100644 --- a/src/mesa/main/texcompress.c +++ b/src/mesa/main/texcompress.c @@ -153,21 +153,6 @@ _mesa_glenum_to_compressed_format(GLenum format) } -/* - * Compute the bytes per row in a compressed texture image. - * We use this for computing the destination address for sub-texture updates. - * \param mesaFormat one of the MESA_FORMAT_* compressed formats - * \param width image width in pixels - * \return stride, in bytes, between rows for compressed image - */ -GLint -_mesa_compressed_row_stride(gl_format mesaFormat, GLsizei width) -{ - GLint stride = _mesa_format_row_stride(mesaFormat, width); - return stride; -} - - /* * Return the address of the pixel at (col, row, img) in a * compressed texture image. diff --git a/src/mesa/main/texcompress.h b/src/mesa/main/texcompress.h index 43cd741895..d6c16e936c 100644 --- a/src/mesa/main/texcompress.h +++ b/src/mesa/main/texcompress.h @@ -36,10 +36,6 @@ _mesa_get_compressed_formats(GLcontext *ctx, GLint *formats, GLboolean all); extern gl_format _mesa_glenum_to_compressed_format(GLenum format); -extern GLint -_mesa_compressed_row_stride(gl_format mesaFormat, GLsizei width); - - extern GLubyte * _mesa_compressed_image_address(GLint col, GLint row, GLint img, gl_format mesaFormat, @@ -58,7 +54,6 @@ _mesa_init_texture_fxt1( GLcontext *ctx ); /* no-op macros */ #define _mesa_get_compressed_formats( c, f ) 0 #define _mesa_compressed_texture_size_glenum( c, w, h, d, f ) 0 -#define _mesa_compressed_row_stride( f, w) 0 #define _mesa_compressed_image_address(c, r, i, f, w, i2 ) 0 #define _mesa_compress_teximage( c, w, h, sF, s, sRS, dF, d, drs ) ((void)0) -- cgit v1.2.3