Module: Mesa
Branch: master
Commit: 3b51d71c8544ee198008bbf3545bf3def6e9e77f
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3b51d71c8544ee198008bbf3545bf3def6e9e77f

Author: Jordan Justen <[email protected]>
Date:   Fri Dec 28 11:00:50 2012 -0800

copyteximage: check that sRGB usage is valid for GLES3 / GL

Reviewed-by: Ian Romanick <[email protected]>
Signed-off-by: Jordan Justen <[email protected]>

---

 src/mesa/main/teximage.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 2539d86..1124b58 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2428,6 +2428,45 @@ copytexture_error_check( struct gl_context *ctx, GLuint 
dimensions,
 
    rb_internal_format = rb->InternalFormat;
 
+   if ((_mesa_is_desktop_gl(ctx) &&
+        ctx->Extensions.ARB_framebuffer_object) ||
+       _mesa_is_gles3(ctx)) {
+      bool rb_is_srgb = false;
+      bool dst_is_srgb = false;
+
+      if (ctx->Extensions.EXT_framebuffer_sRGB &&
+          _mesa_get_format_color_encoding(rb->Format) == GL_SRGB) {
+         rb_is_srgb = true;
+      }
+
+      if (_mesa_get_linear_internalformat(internalFormat) != internalFormat) {
+         dst_is_srgb = true;
+      }
+
+      if (rb_is_srgb != dst_is_srgb) {
+         /* 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 LINEAR (see section 9.2.3) and internalformat
+          *       is one of the sRGB formats in table 8.23
+          *     - 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,
                   "glCopyTexImage%dD(missing readbuffer)", dimensions);

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to