[Mesa-dev] [RFC PATCH 3/8] mesa/main: Add flag for EXT_sRGB and use it parallel with EXT_framebuffer_sRGB

Gert Wollny gw.fossdev at gmail.com
Tue Nov 13 17:27:43 UTC 2018


From: Gert Wollny <gert.wollny at collabora.com>

EXT_sRGB is an (incomplete) GLES extension that provides support for sRGB
framebuffer attachments, hence it can be used to check for this support
as an alternative to EXT_framebuffer_sRGB that provies the same
functionality but also sRGB write control support.

All drivers that support EXT_framebuffer_sRGB also support EXT_sRGB, but
in order to keep this commit minial, and not to break any drivers both
flags are checked.

Since EXT_sRGB  is incomplete and superseted by GLES 3.0 it will not be
exposed as an extension.

Signed-off-by: Gert Wollny <gert.wollny at collabora.com>
---
 src/mesa/main/fbobject.c    | 2 +-
 src/mesa/main/formatquery.c | 3 ++-
 src/mesa/main/framebuffer.c | 3 ++-
 src/mesa/main/mtypes.h      | 1 +
 src/mesa/main/teximage.c    | 3 ++-
 5 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 68e0daf342..ca3f3f7f76 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -4253,7 +4253,7 @@ get_framebuffer_attachment_parameter(struct gl_context *ctx,
          }
       }
       else {
-         if (ctx->Extensions.EXT_framebuffer_sRGB) {
+         if (ctx->Extensions.EXT_framebuffer_sRGB || ctx->Extensions.EXT_sRGB) {
             *params =
                _mesa_get_format_color_encoding(att->Renderbuffer->Format);
          }
diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
index 84b5f512ba..1d43c1e860 100644
--- a/src/mesa/main/formatquery.c
+++ b/src/mesa/main/formatquery.c
@@ -1241,7 +1241,8 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname,
       break;
 
    case GL_SRGB_WRITE:
-      if (!_mesa_has_EXT_framebuffer_sRGB(ctx) ||
+      if ((!_mesa_has_EXT_framebuffer_sRGB(ctx) &&
+           !ctx->Extensions.EXT_sRGB) ||
           !_mesa_is_color_format(internalformat)) {
          goto end;
       }
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 10dd2fde44..90314ee1bd 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -459,7 +459,8 @@ _mesa_update_framebuffer_visual(struct gl_context *ctx,
             fb->Visual.rgbBits = fb->Visual.redBits
                + fb->Visual.greenBits + fb->Visual.blueBits;
             if (_mesa_get_format_color_encoding(fmt) == GL_SRGB)
-                fb->Visual.sRGBCapable = ctx->Extensions.EXT_framebuffer_sRGB;
+                fb->Visual.sRGBCapable = ctx->Extensions.EXT_framebuffer_sRGB ||
+                                         ctx->Extensions.EXT_sRGB;
             break;
          }
       }
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 656e1226f9..4ee55266e5 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4253,6 +4253,7 @@ struct gl_extensions
    GLboolean EXT_semaphore_fd;
    GLboolean EXT_shader_integer_mix;
    GLboolean EXT_shader_samples_identical;
+   GLboolean EXT_sRGB;
    GLboolean EXT_stencil_two_side;
    GLboolean EXT_texture_array;
    GLboolean EXT_texture_compression_latc;
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 6805b47c72..e1d652824e 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2438,7 +2438,8 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions,
       bool rb_is_srgb = false;
       bool dst_is_srgb = false;
 
-      if (ctx->Extensions.EXT_framebuffer_sRGB &&
+      if ((ctx->Extensions.EXT_framebuffer_sRGB ||
+           ctx->Extensions.EXT_sRGB) &&
           _mesa_get_format_color_encoding(rb->Format) == GL_SRGB) {
          rb_is_srgb = true;
       }
-- 
2.18.1



More information about the mesa-dev mailing list