diff options
author | marha <marha@users.sourceforge.net> | 2010-11-29 22:05:53 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2010-11-29 22:05:53 +0000 |
commit | fed109d6a33c0871291d1bb2f3f6b7a3d1a3e9d7 (patch) | |
tree | fa1ba494685a71e28a096990a8707680c7cb378b /mesalib/src/mesa/main/teximage.c | |
parent | ae340911c1ba1f98b418bd8f1a487fa4d79491b0 (diff) | |
parent | 6fda93be42ace9eeab0e82ceebb6798961c9105c (diff) | |
download | vcxsrv-fed109d6a33c0871291d1bb2f3f6b7a3d1a3e9d7.tar.gz vcxsrv-fed109d6a33c0871291d1bb2f3f6b7a3d1a3e9d7.tar.bz2 vcxsrv-fed109d6a33c0871291d1bb2f3f6b7a3d1a3e9d7.zip |
svn merge ^/branches/released .
Diffstat (limited to 'mesalib/src/mesa/main/teximage.c')
-rw-r--r-- | mesalib/src/mesa/main/teximage.c | 349 |
1 files changed, 250 insertions, 99 deletions
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c index d72e91b3a..ca1bd6096 100644 --- a/mesalib/src/mesa/main/teximage.c +++ b/mesalib/src/mesa/main/teximage.c @@ -46,6 +46,7 @@ #include "texfetch.h" #include "teximage.h" #include "texstate.h" +#include "texpal.h" #include "mtypes.h" @@ -347,41 +348,136 @@ _mesa_base_tex_format( GLcontext *ctx, GLint internalFormat ) case GL_SLUMINANCE8_EXT: return GL_LUMINANCE; default: - ; /* fallthrough */ + ; /* fallthrough */ } } - #endif /* FEATURE_EXT_texture_sRGB */ - return -1; /* error */ -} + if (ctx->Extensions.EXT_texture_integer) { + switch (internalFormat) { + case GL_RGBA8UI_EXT: + case GL_RGBA16UI_EXT: + case GL_RGBA32UI_EXT: + case GL_RGBA8I_EXT: + case GL_RGBA16I_EXT: + case GL_RGBA32I_EXT: + return GL_RGBA; + case GL_RGB8UI_EXT: + case GL_RGB16UI_EXT: + case GL_RGB32UI_EXT: + case GL_RGB8I_EXT: + case GL_RGB16I_EXT: + case GL_RGB32I_EXT: + return GL_RGB; + case GL_ALPHA8UI_EXT: + case GL_ALPHA16UI_EXT: + case GL_ALPHA32UI_EXT: + case GL_ALPHA8I_EXT: + case GL_ALPHA16I_EXT: + case GL_ALPHA32I_EXT: + return GL_ALPHA; + case GL_INTENSITY8UI_EXT: + case GL_INTENSITY16UI_EXT: + case GL_INTENSITY32UI_EXT: + case GL_INTENSITY8I_EXT: + case GL_INTENSITY16I_EXT: + case GL_INTENSITY32I_EXT: + return GL_INTENSITY; + case GL_LUMINANCE8UI_EXT: + case GL_LUMINANCE16UI_EXT: + case GL_LUMINANCE32UI_EXT: + case GL_LUMINANCE8I_EXT: + case GL_LUMINANCE16I_EXT: + case GL_LUMINANCE32I_EXT: + return GL_LUMINANCE; + case GL_LUMINANCE_ALPHA8UI_EXT: + case GL_LUMINANCE_ALPHA16UI_EXT: + case GL_LUMINANCE_ALPHA32UI_EXT: + case GL_LUMINANCE_ALPHA8I_EXT: + case GL_LUMINANCE_ALPHA16I_EXT: + case GL_LUMINANCE_ALPHA32I_EXT: + return GL_LUMINANCE_ALPHA; + default: + ; /* fallthrough */ + } + } + if (ctx->Extensions.ARB_texture_rg) { + switch (internalFormat) { + case GL_R8: + case GL_R16: + case GL_R16F: + case GL_R32F: + case GL_R8I: + case GL_R8UI: + case GL_R16I: + case GL_R16UI: + case GL_R32I: + case GL_R32UI: + return GL_R; + case GL_RG: + case GL_RG_INTEGER: + case GL_RG8: + case GL_RG16: + case GL_RG16F: + case GL_RG32F: + case GL_RG8I: + case GL_RG8UI: + case GL_RG16I: + case GL_RG16UI: + case GL_RG32I: + case GL_RG32UI: + return GL_RG; + default: + ; /* fallthrough */ + } + } -/** - * Test if it is a supported compressed format. - * - * \param internalFormat the internal format token provided by the user. - * - * \ret GL_TRUE if \p internalFormat is a supported compressed format, or - * GL_FALSE otherwise. - * - * Currently only GL_COMPRESSED_RGB_FXT1_3DFX and GL_COMPRESSED_RGBA_FXT1_3DFX - * are supported. - */ -static GLboolean -is_compressed_format(GLcontext *ctx, GLenum internalFormat) -{ - GLint supported[100]; /* 100 should be plenty */ - GLuint i, n; + if (ctx->Extensions.EXT_texture_shared_exponent) { + switch (internalFormat) { + case GL_RGB9_E5_EXT: + return GL_RGB; + default: + ; /* fallthrough */ + } + } - n = _mesa_get_compressed_formats(ctx, supported, GL_TRUE); - ASSERT(n < 100); - for (i = 0; i < n; i++) { - if ((GLint) internalFormat == supported[i]) { - return GL_TRUE; + if (ctx->Extensions.EXT_packed_float) { + switch (internalFormat) { + case GL_R11F_G11F_B10F_EXT: + return GL_RGB; + default: + ; /* fallthrough */ } } - return GL_FALSE; + + if (ctx->Extensions.ARB_depth_buffer_float) { + switch (internalFormat) { + case GL_DEPTH_COMPONENT32F: + return GL_DEPTH_COMPONENT; + case GL_DEPTH32F_STENCIL8: + return GL_DEPTH_STENCIL; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.EXT_texture_compression_rgtc) { + switch (internalFormat) { + case GL_COMPRESSED_RED: + case GL_COMPRESSED_RED_RGTC1_EXT: + case GL_COMPRESSED_SIGNED_RED_RGTC1_EXT: + return GL_RED; + case GL_COMPRESSED_RG: + case GL_COMPRESSED_RED_GREEN_RGTC2_EXT: + case GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: + return GL_RG; + default: + ; /* fallthrough */ + } + } + + return -1; /* error */ } @@ -1307,9 +1403,9 @@ texture_error_check( GLcontext *ctx, GLenum target, if (type != GL_UNSIGNED_SHORT_8_8_MESA && type != GL_UNSIGNED_SHORT_8_8_REV_MESA) { char message[100]; - sprintf(message, - "glTexImage%d(format/type YCBCR mismatch", dimensions); - _mesa_error(ctx, GL_INVALID_ENUM, message); + _mesa_snprintf(message, sizeof(message), + "glTexImage%dD(format/type YCBCR mismatch", dimensions); + _mesa_error(ctx, GL_INVALID_ENUM, "%s", message); return GL_TRUE; /* error */ } if (target != GL_TEXTURE_2D && @@ -1323,10 +1419,10 @@ texture_error_check( GLcontext *ctx, GLenum target, if (border != 0) { if (!isProxy) { char message[100]; - sprintf(message, - "glTexImage%d(format=GL_YCBCR_MESA and border=%d)", - dimensions, border); - _mesa_error(ctx, GL_INVALID_VALUE, message); + _mesa_snprintf(message, sizeof(message), + "glTexImage%dD(format=GL_YCBCR_MESA and border=%d)", + dimensions, border); + _mesa_error(ctx, GL_INVALID_VALUE, "%s", message); } return GL_TRUE; } @@ -1349,16 +1445,16 @@ texture_error_check( GLcontext *ctx, GLenum target, } /* additional checks for compressed textures */ - if (is_compressed_format(ctx, internalFormat)) { + if (_mesa_is_compressed_format(ctx, internalFormat)) { if (!target_can_be_compressed(ctx, target) && !isProxy) { _mesa_error(ctx, GL_INVALID_ENUM, - "glTexImage%d(target)", dimensions); + "glTexImage%dD(target)", dimensions); return GL_TRUE; } if (border != 0) { if (!isProxy) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexImage%D(border!=0)", dimensions); + "glTexImage%dD(border!=0)", dimensions); } return GL_TRUE; } @@ -1536,7 +1632,7 @@ subtexture_error_check2( GLcontext *ctx, GLuint dimensions, if (!target_can_be_compressed(ctx, target)) { _mesa_error(ctx, GL_INVALID_ENUM, - "glTexSubImage%D(target=%s)", dimensions, + "glTexSubImage%dD(target=%s)", dimensions, _mesa_lookup_enum_by_nr(target)); return GL_TRUE; } @@ -1547,19 +1643,19 @@ subtexture_error_check2( GLcontext *ctx, GLuint dimensions, /* offset must be multiple of block size */ if ((xoffset % bw != 0) || (yoffset % bh != 0)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexSubImage%D(xoffset = %d, yoffset = %d)", + "glTexSubImage%dD(xoffset = %d, yoffset = %d)", dimensions, xoffset, yoffset); return GL_TRUE; } /* size must be multiple of bw by bh or equal to whole texture size */ if ((width % bw != 0) && (GLuint) width != destTex->Width) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexSubImage%D(width = %d)", dimensions, width); + "glTexSubImage%dD(width = %d)", dimensions, width); return GL_TRUE; } if ((height % bh != 0) && (GLuint) height != destTex->Height) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexSubImage%D(height = %d)", dimensions, height); + "glTexSubImage%dD(height = %d)", dimensions, height); return GL_TRUE; } } @@ -1715,15 +1811,15 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions, return GL_TRUE; } - if (is_compressed_format(ctx, internalFormat)) { + if (_mesa_is_compressed_format(ctx, internalFormat)) { if (!target_can_be_compressed(ctx, target)) { _mesa_error(ctx, GL_INVALID_ENUM, - "glCopyTexImage%d(target)", dimensions); + "glCopyTexImage%dD(target)", dimensions); return GL_TRUE; } if (border != 0) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexImage%D(border!=0)", dimensions); + "glCopyTexImage%dD(border!=0)", dimensions); return GL_TRUE; } } @@ -1731,7 +1827,7 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions, /* make sure we have depth/stencil buffers */ if (!ctx->ReadBuffer->_DepthBuffer) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexImage%D(no depth)", dimensions); + "glCopyTexImage%dD(no depth)", dimensions); return GL_TRUE; } } @@ -1739,7 +1835,7 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions, /* make sure we have depth/stencil buffers */ if (!ctx->ReadBuffer->_DepthBuffer || !ctx->ReadBuffer->_StencilBuffer) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexImage%D(no depth/stencil buffer)", dimensions); + "glCopyTexImage%dD(no depth/stencil buffer)", dimensions); return GL_TRUE; } } @@ -1904,24 +2000,24 @@ copytexsubimage_error_check2( GLcontext *ctx, GLuint dimensions, if (_mesa_is_format_compressed(teximage->TexFormat)) { if (!target_can_be_compressed(ctx, target)) { _mesa_error(ctx, GL_INVALID_ENUM, - "glCopyTexSubImage%d(target)", dimensions); + "glCopyTexSubImage%dD(target)", dimensions); return GL_TRUE; } /* offset must be multiple of 4 */ if ((xoffset & 3) || (yoffset & 3)) { _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%D(xoffset or yoffset)", dimensions); + "glCopyTexSubImage%dD(xoffset or yoffset)", dimensions); return GL_TRUE; } /* size must be multiple of 4 */ if ((width & 3) != 0 && (GLuint) width != teximage->Width) { _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%D(width)", dimensions); + "glCopyTexSubImage%dD(width)", dimensions); return GL_TRUE; } if ((height & 3) != 0 && (GLuint) height != teximage->Height) { _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%D(height)", dimensions); + "glCopyTexSubImage%dD(height)", dimensions); return GL_TRUE; } } @@ -1941,7 +2037,7 @@ copytexsubimage_error_check2( GLcontext *ctx, GLuint dimensions, if (teximage->_BaseFormat == GL_DEPTH_COMPONENT) { if (!ctx->ReadBuffer->_DepthBuffer) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexSubImage%D(no depth buffer)", + "glCopyTexSubImage%dD(no depth buffer)", dimensions); return GL_TRUE; } @@ -1949,7 +2045,7 @@ copytexsubimage_error_check2( GLcontext *ctx, GLuint dimensions, else if (teximage->_BaseFormat == GL_DEPTH_STENCIL_EXT) { if (!ctx->ReadBuffer->_DepthBuffer || !ctx->ReadBuffer->_StencilBuffer) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexSubImage%D(no depth/stencil buffer)", + "glCopyTexSubImage%dD(no depth/stencil buffer)", dimensions); return GL_TRUE; } @@ -2087,6 +2183,45 @@ override_internal_format(GLenum internalFormat, GLint width, GLint height) } +/** + * Choose the actual hardware format for a texture image. + * Try to use the same format as the previous image level when possible. + * Otherwise, ask the driver for the best format. + * It's important to try to choose a consistant format for all levels + * for efficient texture memory layout/allocation. In particular, this + * comes up during automatic mipmap generation. + */ +void +_mesa_choose_texture_format(GLcontext *ctx, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage, + GLenum target, GLint level, + GLenum internalFormat, GLenum format, GLenum type) +{ + /* see if we've already chosen a format for the previous level */ + if (level > 0) { + struct gl_texture_image *prevImage = + _mesa_select_tex_image(ctx, texObj, target, level - 1); + /* See if the prev level is defined and has an internal format which + * matches the new internal format. + */ + if (prevImage && + prevImage->Width > 0 && + prevImage->InternalFormat == internalFormat) { + /* use the same format */ + texImage->TexFormat = prevImage->TexFormat; + return; + } + } + + /* choose format from scratch */ + texImage->TexFormat = ctx->Driver.ChooseTextureFormat(ctx, internalFormat, + format, type); + ASSERT(texImage->TexFormat != MESA_FORMAT_NONE); +} + + + /* * Called from the API. Note that width includes the border. */ @@ -2147,11 +2282,8 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, postConvWidth, 1, 1, border, internalFormat); - /* Choose actual texture format */ - texImage->TexFormat = - ctx->Driver.ChooseTextureFormat(ctx, internalFormat, - format, type); - ASSERT(texImage->TexFormat != MESA_FORMAT_NONE); + _mesa_choose_texture_format(ctx, texObj, texImage, target, level, + internalFormat, format, type); /* Give the texture to the driver. <pixels> may be null. */ ASSERT(ctx->Driver.TexImage1D); @@ -2186,12 +2318,14 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, } else { /* no error, set the tex image parameters */ + struct gl_texture_object *texObj = + _mesa_get_current_tex_object(ctx, target); ASSERT(texImage); _mesa_init_teximage_fields(ctx, target, texImage, postConvWidth, 1, 1, border, internalFormat); - texImage->TexFormat = - ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type); + _mesa_choose_texture_format(ctx, texObj, texImage, target, level, + internalFormat, format, type); } } else { @@ -2267,11 +2401,8 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, postConvWidth, postConvHeight, 1, border, internalFormat); - /* Choose actual texture format */ - texImage->TexFormat = - ctx->Driver.ChooseTextureFormat(ctx, internalFormat, - format, type); - ASSERT(texImage->TexFormat != MESA_FORMAT_NONE); + _mesa_choose_texture_format(ctx, texObj, texImage, target, level, + internalFormat, format, type); /* Give the texture to the driver. <pixels> may be null. */ ASSERT(ctx->Driver.TexImage2D); @@ -2313,11 +2444,13 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, } else { /* no error, set the tex image parameters */ + struct gl_texture_object *texObj = + _mesa_get_current_tex_object(ctx, target); _mesa_init_teximage_fields(ctx, target, texImage, postConvWidth, postConvHeight, 1, border, internalFormat); - texImage->TexFormat = - ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type); + _mesa_choose_texture_format(ctx, texObj, texImage, target, level, + internalFormat, format, type); } } else { @@ -2383,11 +2516,8 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat, width, height, depth, border, internalFormat); - /* Choose actual texture format */ - texImage->TexFormat = - ctx->Driver.ChooseTextureFormat(ctx, internalFormat, - format, type); - ASSERT(texImage->TexFormat != MESA_FORMAT_NONE); + _mesa_choose_texture_format(ctx, texObj, texImage, target, level, + internalFormat, format, type); /* Give the texture to the driver. <pixels> may be null. */ ASSERT(ctx->Driver.TexImage3D); @@ -2424,10 +2554,12 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat, } else { /* no error, set the tex image parameters */ + struct gl_texture_object *texObj = + _mesa_get_current_tex_object(ctx, target); _mesa_init_teximage_fields(ctx, target, texImage, width, height, depth, border, internalFormat); - texImage->TexFormat = - ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type); + _mesa_choose_texture_format(ctx, texObj, texImage, target, level, + internalFormat, format, type); } } else { @@ -2457,6 +2589,12 @@ _mesa_EGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + if (!ctx->Extensions.OES_EGL_image) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glEGLImageTargetTexture2DOES(unsupported)"); + return; + } + if (target != GL_TEXTURE_2D) { _mesa_error(ctx, GL_INVALID_ENUM, "glEGLImageTargetTexture2D(target=%d)", target); @@ -2734,11 +2872,8 @@ _mesa_CopyTexImage1D( GLenum target, GLint level, _mesa_init_teximage_fields(ctx, target, texImage, postConvWidth, 1, 1, border, internalFormat); - /* Choose actual texture format */ - texImage->TexFormat = - ctx->Driver.ChooseTextureFormat(ctx, internalFormat, - GL_NONE, GL_NONE); - ASSERT(texImage->TexFormat != MESA_FORMAT_NONE); + _mesa_choose_texture_format(ctx, texObj, texImage, target, level, + internalFormat, GL_NONE, GL_NONE); ASSERT(ctx->Driver.CopyTexImage1D); ctx->Driver.CopyTexImage1D(ctx, target, level, internalFormat, @@ -2815,11 +2950,8 @@ _mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat, postConvWidth, postConvHeight, 1, border, internalFormat); - /* Choose actual texture format */ - texImage->TexFormat = - ctx->Driver.ChooseTextureFormat(ctx, internalFormat, - GL_NONE, GL_NONE); - ASSERT(texImage->TexFormat != MESA_FORMAT_NONE); + _mesa_choose_texture_format(ctx, texObj, texImage, target, level, + internalFormat, GL_NONE, GL_NONE); ASSERT(ctx->Driver.CopyTexImage2D); ctx->Driver.CopyTexImage2D(ctx, target, level, internalFormat, @@ -3103,11 +3235,15 @@ compressed_texture_error_check(GLcontext *ctx, GLint dimensions, /* 3D compressed textures not allowed */ return GL_INVALID_ENUM; } + else { + assert(0); + return GL_INVALID_ENUM; + } maxTextureSize = 1 << (maxLevels - 1); /* This will detect any invalid internalFormat value */ - if (!is_compressed_format(ctx, internalFormat)) + if (!_mesa_is_compressed_format(ctx, internalFormat)) return GL_INVALID_ENUM; /* This should really never fail */ @@ -3212,7 +3348,7 @@ compressed_subtexture_error_check(GLcontext *ctx, GLint dimensions, maxTextureSize = 1 << (maxLevels - 1); /* this will catch any invalid compressed format token */ - if (!is_compressed_format(ctx, format)) + if (!_mesa_is_compressed_format(ctx, format)) return GL_INVALID_ENUM; if (width < 1 || width > maxTextureSize) @@ -3340,11 +3476,8 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level, _mesa_init_teximage_fields(ctx, target, texImage, width, 1, 1, border, internalFormat); - /* Choose actual texture format */ - texImage->TexFormat = - ctx->Driver.ChooseTextureFormat(ctx, internalFormat, - GL_NONE, GL_NONE); - ASSERT(texImage->TexFormat != MESA_FORMAT_NONE); + _mesa_choose_texture_format(ctx, texObj, texImage, target, level, + internalFormat, GL_NONE, GL_NONE); ASSERT(ctx->Driver.CompressedTexImage1D); ctx->Driver.CompressedTexImage1D(ctx, target, level, @@ -3392,6 +3525,8 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level, texImage = _mesa_select_tex_image(ctx, texObj, target, level); _mesa_init_teximage_fields(ctx, target, texImage, width, 1, 1, border, internalFormat); + _mesa_choose_texture_format(ctx, texObj, texImage, target, level, + internalFormat, GL_NONE, GL_NONE); } _mesa_unlock_texture(ctx, texObj); } @@ -3402,7 +3537,6 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level, } } - void GLAPIENTRY _mesa_CompressedTexImage2DARB(GLenum target, GLint level, GLenum internalFormat, GLsizei width, @@ -3418,6 +3552,24 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level, _mesa_lookup_enum_by_nr(internalFormat), width, height, border, imageSize, data); +#if FEATURE_ES + switch (internalFormat) { + case GL_PALETTE4_RGB8_OES: + case GL_PALETTE4_RGBA8_OES: + case GL_PALETTE4_R5_G6_B5_OES: + case GL_PALETTE4_RGBA4_OES: + case GL_PALETTE4_RGB5_A1_OES: + case GL_PALETTE8_RGB8_OES: + case GL_PALETTE8_RGBA8_OES: + case GL_PALETTE8_R5_G6_B5_OES: + case GL_PALETTE8_RGBA4_OES: + case GL_PALETTE8_RGB5_A1_OES: + _mesa_cpal_compressed_teximage2d(target, level, internalFormat, + width, height, imageSize, data); + return; + } +#endif + if (target == GL_TEXTURE_2D || (ctx->Extensions.ARB_texture_cube_map && target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && @@ -3450,11 +3602,8 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level, _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1, border, internalFormat); - /* Choose actual texture format */ - texImage->TexFormat = - ctx->Driver.ChooseTextureFormat(ctx, internalFormat, - GL_NONE, GL_NONE); - ASSERT(texImage->TexFormat != MESA_FORMAT_NONE); + _mesa_choose_texture_format(ctx, texObj, texImage, target, level, + internalFormat, GL_NONE, GL_NONE); ASSERT(ctx->Driver.CompressedTexImage2D); ctx->Driver.CompressedTexImage2D(ctx, target, level, @@ -3504,6 +3653,8 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level, texImage = _mesa_select_tex_image(ctx, texObj, target, level); _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1, border, internalFormat); + _mesa_choose_texture_format(ctx, texObj, texImage, target, level, + internalFormat, GL_NONE, GL_NONE); } _mesa_unlock_texture(ctx, texObj); } @@ -3560,10 +3711,8 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level, border, internalFormat); /* Choose actual texture format */ - texImage->TexFormat = - ctx->Driver.ChooseTextureFormat(ctx, internalFormat, - GL_NONE, GL_NONE); - ASSERT(texImage->TexFormat != MESA_FORMAT_NONE); + _mesa_choose_texture_format(ctx, texObj, texImage, target, level, + internalFormat, GL_NONE, GL_NONE); ASSERT(ctx->Driver.CompressedTexImage3D); ctx->Driver.CompressedTexImage3D(ctx, target, level, @@ -3612,6 +3761,8 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level, texImage = _mesa_select_tex_image(ctx, texObj, target, level); _mesa_init_teximage_fields(ctx, target, texImage, width, height, depth, border, internalFormat); + _mesa_choose_texture_format(ctx, texObj, texImage, target, level, + internalFormat, GL_NONE, GL_NONE); } _mesa_unlock_texture(ctx, texObj); } |