Mesa (master): gles3: Prohibit set/get of GL_FRAMEBUFFER_SRGB.

Paul Berry stereotype441 at kemper.freedesktop.org
Tue Sep 25 22:18:44 UTC 2012


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

Author: Paul Berry <stereotype441 at gmail.com>
Date:   Mon Sep 24 14:47:12 2012 -0700

gles3: Prohibit set/get of GL_FRAMEBUFFER_SRGB.

GLES 3 supports sRGB functionality, but it does not expose the
GL_FRAMEBUFFER_SRGB enable/disable bit.  Instead the implementation
is expected to behave as though that bit is always enabled.

This patch ensures that ctx->Color.sRGBEnabled (the internal variable
tracking GL_FRAMEBUFFER_SRGB) is initially true in GLES 2/3 contexts,
and that it cannot be modified through the GLES 3 API.

This is safe for GLES 2, since ctx->Color.sRGBEnabled has no effect on
non-sRGB formats, and GLES 2 doesn't support any sRGB formats.

Reviewed-by: Brian Paul <brianp at vmware.com>
Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>

---

 src/mesa/main/blend.c  |    7 +++++++
 src/mesa/main/enable.c |    4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index de871a9..5d55311 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -858,6 +858,13 @@ void _mesa_init_color( struct gl_context * ctx )
    ctx->Color._ClampFragmentColor = GL_TRUE;
    ctx->Color.ClampReadColor = GL_FIXED_ONLY_ARB;
    ctx->Color._ClampReadColor = GL_TRUE;
+
+   if (ctx->API == API_OPENGLES2) {
+      /* GLES 3 behaves as though GL_FRAMEBUFFER_SRGB is always enabled. */
+      ctx->Color.sRGBEnabled = GL_TRUE;
+   } else {
+      ctx->Color.sRGBEnabled = GL_FALSE;
+   }
 }
 
 /*@}*/
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 676cd9b..a607bdc 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -1061,7 +1061,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
 
       /* GL3.0 - GL_framebuffer_sRGB */
       case GL_FRAMEBUFFER_SRGB_EXT:
-         if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+         if (!_mesa_is_desktop_gl(ctx))
             goto invalid_enum_error;
          CHECK_EXTENSION(EXT_framebuffer_sRGB, cap);
          _mesa_set_framebuffer_srgb(ctx, state);
@@ -1715,7 +1715,7 @@ _mesa_IsEnabled( GLenum cap )
 
       /* GL3.0 - GL_framebuffer_sRGB */
       case GL_FRAMEBUFFER_SRGB_EXT:
-         if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+         if (!_mesa_is_desktop_gl(ctx))
             goto invalid_enum_error;
 	 CHECK_EXTENSION(EXT_framebuffer_sRGB);
 	 return ctx->Color.sRGBEnabled;




More information about the mesa-commit mailing list