[Mesa-dev] [PATCH 1/3] mesa/core: Add support for EXT_sRGB_write_control

Ilia Mirkin imirkin at alum.mit.edu
Wed Oct 17 16:49:57 UTC 2018


On Wed, Oct 17, 2018 at 12:38 PM Gert Wollny <gw.fossdev at gmail.com> wrote:
>
> From: Gert Wollny <gert.wollny at collabora.com>
>
> This GLES extension gives the applications the control over deciding whether
> the conversion from linear space to sRGB is necessary by enabling or
> disabling this conversion at framebuffer write or blending time just
> like it is possible for desktop GL.
>
> Signed-off-by: Gert Wollny <gert.wollny at collabora.com>
> ---
>  src/mesa/main/enable.c           | 4 ++--
>  src/mesa/main/extensions_table.h | 1 +
>  src/mesa/main/get.c              | 6 ++++++
>  src/mesa/main/get_hash_params.py | 1 +
>  src/mesa/main/mtypes.h           | 1 +
>  5 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
> index bd3e493da5..06c5a0eb68 100644
> --- a/src/mesa/main/enable.c
> +++ b/src/mesa/main/enable.c
> @@ -1125,7 +1125,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))
> +         if (!_mesa_is_desktop_gl(ctx) && !ctx->Extensions.EXT_sRGB_write_control)
>              goto invalid_enum_error;
>           CHECK_EXTENSION(EXT_framebuffer_sRGB, cap);
>           _mesa_set_framebuffer_srgb(ctx, state);
> @@ -1765,7 +1765,7 @@ _mesa_IsEnabled( GLenum cap )
>
>        /* GL3.0 - GL_framebuffer_sRGB */
>        case GL_FRAMEBUFFER_SRGB_EXT:
> -         if (!_mesa_is_desktop_gl(ctx))
> +         if (!_mesa_is_desktop_gl(ctx) && !ctx->Extensions.EXT_sRGB_write_control)
>              goto invalid_enum_error;
>           CHECK_EXTENSION(EXT_framebuffer_sRGB);
>           return ctx->Color.sRGBEnabled;
> diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
> index 09bf923bd0..1185156f23 100644
> --- a/src/mesa/main/extensions_table.h
> +++ b/src/mesa/main/extensions_table.h
> @@ -265,6 +265,7 @@ EXT(EXT_shader_integer_mix                  , EXT_shader_integer_mix
>  EXT(EXT_shader_io_blocks                    , dummy_true                             ,  x ,  x ,  x ,  31, 2014)
>  EXT(EXT_shader_samples_identical            , EXT_shader_samples_identical           , GLL, GLC,  x ,  31, 2015)
>  EXT(EXT_shadow_funcs                        , ARB_shadow                             , GLL,  x ,  x ,  x , 2002)
> +EXT(EXT_sRGB_write_control                  , EXT_sRGB_write_control                 , GLL,  x ,  x ,  30, 2013)

I think you want an "x" instead of "GLL" -- it's an ES-only ext. Also
I'd list "ES2" as the minimum. A driver that doesn't expose ES 3.0 or
EXT_sRGB just shouldn't set this enable to true.

>  EXT(EXT_stencil_two_side                    , EXT_stencil_two_side                   , GLL,  x ,  x ,  x , 2001)
>  EXT(EXT_stencil_wrap                        , dummy_true                             , GLL,  x ,  x ,  x , 2002)
>  EXT(EXT_subtexture                          , dummy_true                             , GLL,  x ,  x ,  x , 1995)
> diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
> index 1b1679e8bf..fd9d3885f5 100644
> --- a/src/mesa/main/get.c
> +++ b/src/mesa/main/get.c
> @@ -394,6 +394,12 @@ static const int extra_ARB_compute_shader_es31[] = {
>     EXTRA_END
>  };
>
> +static const int extra_EXT_sRGB_write_control_es30[] = {
> +   EXT(EXT_sRGB_write_control),
> +   EXTRA_API_ES3,
> +   EXTRA_END
> +};

These get OR'd, I believe, which is not what you want. Just leave the
EXT() in, leave the EXTRA_API out.

> +
>  static const int extra_ARB_shader_storage_buffer_object_es31[] = {
>     EXT(ARB_shader_storage_buffer_object),
>     EXTRA_API_ES31,
> diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
> index 1840db6ebb..822fab8151 100644
> --- a/src/mesa/main/get_hash_params.py
> +++ b/src/mesa/main/get_hash_params.py
> @@ -262,6 +262,7 @@ descriptor=[
>  # Enums in GLES2, GLES3
>  { "apis": ["GLES2", "GLES3"], "params": [
>    [ "GPU_DISJOINT_EXT", "LOC_CUSTOM, TYPE_INT, 0, extra_EXT_disjoint_timer_query" ],
> +  [ "FRAMEBUFFER_SRGB_EXT", "CONTEXT_BOOL(Color.sRGBEnabled), extra_EXT_sRGB_write_control_es30" ],
>  ]},
>
>  { "apis": ["GL", "GL_CORE", "GLES2"], "params": [
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 9ed49b7ff2..31cf62fdb6 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_write_control;
>     GLboolean EXT_stencil_two_side;
>     GLboolean EXT_texture_array;
>     GLboolean EXT_texture_compression_latc;
> --
> 2.18.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list