[Mesa-dev] [PATCH 11/23] copytexture: make sure is_srgb(src) == is_srgb(dst)

Jordan Justen jordan.l.justen at intel.com
Fri Jan 4 18:41:34 PST 2013


Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 src/mesa/main/teximage.c |   29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index ac60a21..169e768 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);
-- 
1.7.10.4



More information about the mesa-dev mailing list