aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/teximage.c
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/main/teximage.c')
-rw-r--r--mesalib/src/mesa/main/teximage.c60
1 files changed, 53 insertions, 7 deletions
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index 2bc7abdc2..99905de3a 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -493,6 +493,15 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
}
}
+ if (ctx->Extensions.OES_compressed_ETC1_RGB8_texture) {
+ switch (internalFormat) {
+ case GL_ETC1_RGB8_OES:
+ return GL_RGB;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
if (ctx->API == API_OPENGLES) {
switch (internalFormat) {
case GL_PALETTE4_RGB8_OES:
@@ -1292,6 +1301,20 @@ legal_texture_size(struct gl_context *ctx, gl_format format,
}
+/**
+ * Return true if the format is only valid for glCompressedTexImage.
+ */
+static GLboolean
+compressedteximage_only_format(const struct gl_context *ctx, GLenum format)
+{
+ switch (format) {
+ case GL_ETC1_RGB8_OES:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
/**
* Helper function to determine whether a target and specific compression
@@ -1639,6 +1662,11 @@ texture_error_check( struct gl_context *ctx,
"glTexImage%dD(target)", dimensions);
return GL_TRUE;
}
+ if (compressedteximage_only_format(ctx, internalFormat)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTexImage%dD(no compression for format)", dimensions);
+ return GL_TRUE;
+ }
if (border != 0) {
if (!isProxy) {
_mesa_error(ctx, GL_INVALID_OPERATION,
@@ -1793,6 +1821,12 @@ subtexture_error_check2( struct gl_context *ctx, GLuint dimensions,
if (_mesa_is_format_compressed(destTex->TexFormat)) {
GLuint bw, bh;
+ if (compressedteximage_only_format(ctx, destTex->InternalFormat)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTexSubImage%dD(no compression for format)", dimensions);
+ return GL_TRUE;
+ }
+
/* do tests which depend on compression block size */
_mesa_get_format_block_size(destTex->TexFormat, &bw, &bh);
@@ -1922,6 +1956,11 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions,
"glCopyTexImage%dD(target)", dimensions);
return GL_TRUE;
}
+ if (compressedteximage_only_format(ctx, internalFormat)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCopyTexImage%dD(no compression for format)", dimensions);
+ return GL_TRUE;
+ }
if (border != 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glCopyTexImage%dD(border!=0)", dimensions);
@@ -2061,6 +2100,11 @@ copytexsubimage_error_check2( struct gl_context *ctx, GLuint dimensions,
}
if (_mesa_is_format_compressed(teximage->TexFormat)) {
+ if (compressedteximage_only_format(ctx, teximage->InternalFormat)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCopyTexSubImage%dD(no compression for format)", dimensions);
+ return GL_TRUE;
+ }
/* offset must be multiple of 4 */
if ((xoffset & 3) || (yoffset & 3)) {
_mesa_error(ctx, GL_INVALID_VALUE,
@@ -3244,6 +3288,13 @@ compressed_subtexture_error_check2(struct gl_context *ctx, GLuint dims,
return GL_TRUE;
}
+ if (compressedteximage_only_format(ctx, format)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCompressedTexSubImage%uD(format=0x%x cannot be updated)"
+ , dims, format);
+ return GL_TRUE;
+ }
+
if (((width == 1 || width == 2) &&
width != (GLsizei) texImage->Width) ||
(width > (GLsizei) texImage->Width)) {
@@ -3310,14 +3361,9 @@ compressedteximage(struct gl_context *ctx, GLuint dims,
internalFormat, width, height, depth,
border, imageSize, &reason);
- if (error) {
- _mesa_error(ctx, error, "glCompressedTexImage%uD(%s)", dims, reason);
- return;
- }
-
#if FEATURE_ES
/* XXX this is kind of a hack */
- if (dims == 2) {
+ if (!error && dims == 2) {
switch (internalFormat) {
case GL_PALETTE4_RGB8_OES:
case GL_PALETTE4_RGBA8_OES:
@@ -3371,7 +3417,7 @@ compressedteximage(struct gl_context *ctx, GLuint dims,
struct gl_texture_image *texImage;
if (error) {
- _mesa_error(ctx, error, "glCompressedTexImage%uD", dims);
+ _mesa_error(ctx, error, "glCompressedTexImage%uD(%s)", dims, reason);
return;
}