diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index afda0ea..cb08fb9 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1921,6 +1921,36 @@ texture_error_check( struct gl_context *ctx, return GL_FALSE; } +/** + *Hack, fixes compressed texture size, most likley breaks everything else. + */ +static void +compressed_texture_fix_size(struct gl_context *ctx, GLenum target, + GLenum internalFormat, + GLsizei *width, GLsizei *height) +{ + GLenum choose_format; + GLenum choose_type; + GLenum proxy_format; + + choose_format = GL_NONE; + choose_type = GL_NONE; + proxy_format = internalFormat; + + + gl_format texFormat = + ctx->Driver.ChooseTextureFormat(ctx, target, proxy_format, + choose_format, choose_type); + GLuint bw, bh; + + _mesa_get_format_block_size(texFormat, &bw, &bh); + + if (*width > bw && *width % bw > 0) + *width = ((*width / bw) + 1) * bw; + + if (*height > bh && *height % bh > 0) + *height = ((*height / bh) + 1) * bh; +} /** * Error checking for glCompressedTexImage[123]D(). @@ -2043,28 +2073,6 @@ compressed_texture_error_check(struct gl_context *ctx, GLint dimensions, goto error; } - /* check image size against compression block size */ - /* XXX possibly move this into the _mesa_legal_texture_dimensions() func */ - { - gl_format texFormat = - ctx->Driver.ChooseTextureFormat(ctx, target, proxy_format, - choose_format, choose_type); - GLuint bw, bh; - - _mesa_get_format_block_size(texFormat, &bw, &bh); - if ((width > bw && width % bw > 0) || - (height > bh && height % bh > 0)) { - /* - * Per GL_ARB_texture_compression: GL_INVALID_OPERATION is - * generated [...] if any parameter combinations are not - * supported by the specific compressed internal format. - */ - reason = "invalid width or height for compression format"; - error = GL_INVALID_OPERATION; - goto error; - } - } - /* check image size in bytes */ if (expectedSize != imageSize) { /* Per GL_ARB_texture_compression: GL_INVALID_VALUE is generated [...] @@ -2773,6 +2781,10 @@ teximage(struct gl_context *ctx, GLboolean compressed, GLuint dims, width, height, depth, border, imageSize)) return; + + /*Hack*/ + compressed_texture_fix_size(ctx, target, internalFormat, + &width, &height); } else { if (texture_error_check(ctx, dims, target, level, internalFormat,