[Mesa-dev] [PATCH v2 08/18] copyteximage: make sure is_srgb(src) == is_srgb(dst)

Jordan Justen jordan.l.justen at intel.com
Sat Jan 12 20:10:58 PST 2013


v2:
 * Remove _EXT on enums
 * Remove compressed forms of sRGB from is_srgb_format
 * Add comment referencing GL Core spec

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

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index d62fea6..ed52577 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2323,6 +2323,20 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions,
 }
 
 
+static bool
+is_srgb_format(GLenum internalFormat)
+{
+   switch (internalFormat) {
+   case GL_SRGB:
+   case GL_SRGB8:
+   case GL_SRGB_ALPHA:
+   case GL_SRGB8_ALPHA8:
+      return true;
+   default:
+      return false;
+   }
+}
+
 /**
  * Test glCopyTexImage[12]D() parameters for errors.
  * 
@@ -2426,6 +2440,24 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions,
    }
 
    rb_internal_format = rb->InternalFormat;
+   if (is_srgb_format(internalFormat) != is_srgb_format(rb_internal_format)) {
+      /* Page 190 (page 211 of the PDF) in section 8.6 of the OpenGL 4.3
+       * Core Profile spec says:
+       *
+       *     "An INVALID_OPERATION error is generated under any of the
+       *     following conditions:
+       *
+       *     ...
+       *
+       *     - if the value of FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING
+       *       for the framebuffer attachment corresponding to the read
+       *       buffer is SRGB and internalformat is not one of the sRGB
+       *       formats. in table 8.23."
+       */
+      _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,
-- 
1.7.10.4



More information about the mesa-dev mailing list