aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/teximage.c
diff options
context:
space:
mode:
authorJordan Justen <[email protected]>2012-12-28 11:00:50 -0800
committerJordan Justen <[email protected]>2013-01-04 17:26:01 -0800
commitfef9526cb6b251516db49613341cfb7046ac502a (patch)
treebeb4464b4f8fa39ac99c28b15e36018f8dd612d8 /src/mesa/main/teximage.c
parenta33dc45d2f53c3e5645ef97db3f53734847ec0e9 (diff)
copytexture: make sure is_srgb(src) == is_srgb(dst)
Signed-off-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/mesa/main/teximage.c')
-rw-r--r--src/mesa/main/teximage.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index ac60a21539d..169e768149d 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2323,6 +2323,29 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions,
}
+static bool
+is_srgb_format(GLenum internalFormat)
+{
+ switch (internalFormat) {
+ case GL_SRGB_EXT:
+ case GL_SRGB8_EXT:
+ case GL_COMPRESSED_SRGB_EXT:
+ case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
+ case GL_SRGB_ALPHA_EXT:
+ case GL_SRGB8_ALPHA8_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
+ case GL_COMPRESSED_SRGB8_ETC2:
+ case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
+ case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+ return true;
+ default:
+ return false;
+ }
+}
+
/**
* Test glCopyTexImage[12]D() parameters for errors.
*
@@ -2416,6 +2439,12 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions,
return GL_TRUE;
}
+ if (is_srgb_format(internalFormat) != is_srgb_format(rb_internal_format)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCopyTexImage%dD(srgb usage mismatch)", dimensions);
+ return GL_TRUE;
+ }
+
if (!_mesa_source_buffer_exists(ctx, baseFormat)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glCopyTexImage%dD(missing readbuffer)", dimensions);