diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index afda0ea..8babcbc 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1921,6 +1921,37 @@ texture_error_check( struct gl_context *ctx, return GL_FALSE; } +/** + *Hack, fix texture size, most likley brake 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 +2074,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 [...] @@ -2768,11 +2777,17 @@ teximage(struct gl_context *ctx, GLboolean compressed, GLuint dims, /* general error checking */ if (compressed) { + if (compressed_texture_error_check(ctx, dims, target, level, internalFormat, 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,