Skip to content

sRGB findings on various platforms #1652

@MarijnS95

Description

@MarijnS95

For the past while I've been working on and off on turning the current sRGB colorspace support into full-fledged color space support, with a focus on EGL (Wayland desktop and Android phones). As it turns out there are quite a few backend differences that only make this feasible for the EGL backend. But before we get into some design questions I'd like to ask (separate issue), let's first look at sRGB as every backend and implementation has already gotten me totally confused. This is not really a Glutin issue but more of a general OpenGL ecosystem mess, though it might definitely be relevant to keep our implementation and documentation in check so I'm sharing it anyway.

The following was tested on a:

  • Sony Xperia 1IV;
  • RX 6800 Sway (ArchLinux);
  • Intel UHD 620 on Sway;
  • RX 6800 XT on Windows.

Preface

  • GL_FRAMEBUFFER_SRGB is a feature that performs linear->sRGB conversion when writing to sRGB textures / framebuffers. It has no effect when the target is already linear (or so it is documented...);
  • This color space is queried using FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING;
  • I think support for GL_FRAMEBUFFER_SRGB is what is queried/filtered via FRAMEBUFFER_SRGB_CAPABLE_* on WGL and GLX. Though it works regardless if it is not capable (??);
  • For X11 there is no way to configure a color space via GLX. Perhaps this can be set on a window beforehand?

Android EGL

  • Default color space is linear;
  • GL_FRAMEBUFFER_SRGB (automatic linear->srgb conversion when writing to an srgb framebuffer) is on by default;
  • Querying FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING is not supported (it's GLES 3.2 though...);
  • Changing the color space via EGL_GL_COLORSPACE to EGL_GL_COLORSPACE_SRGB appropriately uses the default FRAMEBUFFER_SRGB conversion, the image is now brighter;
    • The image stays at the original darker color when in GL_COLORSPACE_SRGB with gl.Disable(gl::FRAMEBUFFER_SRGB).

👍, all working as expected.

Wayland EGL (AMD Mesa)

  • GL_SRGB is always reported by FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING;
  • Changing the color space via EGL_GL_COLORSPACE makes no difference (color stays the same, COLOR_ENCODING always returns GL_SRGB);
  • GL_FRAMEBUFFER_SRGB is off by default;
  • Enabling GL_FRAMEBUFFER_SRGB always makes the image brighter (makes sense given that the framebuffer is always considered to be in GL_SRGB colorspace);
  • The EGL_(GL_)COLORSPACE attributes follow which color is being set in CreatePlatformWindowSurface*.

Wayland EGL (AMD ProGL)

(using progl command)

  • Default color space is GL_LINEAR according to FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING;
  • EGL_COLORSPACE is EGL_GL_COLORSPACE_SRGB, but EGL_GL_COLORSPACE is EGL_GL_COLORSPACE_LINEAR;
  • Setting EGL_COLORSPACE has no effect;
  • Setting EGL_GL_COLORSPACE to SRGB correctly makes COLOR_ENCODING return GL_SRGB;
    • Turning on GL_FRAMEBUFFER_SRGB makes the image brighter (only when the color encoding is sRGB 👍).

X11 (AMD Mesa)

  • COLOR_ENCODING is always GL_SRGB;
  • Alternating configs are sRGB-capable;
  • GL_FRAMEBUFFER_SRGB makes the output lighter on every config (even those that are not "sRGB capable").

X11 (AMD ProGL)

  • COLOR_ENCODING always reports GL_LINEAR;
  • No config is "sRGB-capable" (??);
  • Enabling GL_FRAMEBUFFER_SRGB makes the output bright (this should not be the case for linear framebuffers?!).

Wayland EGL (Intel UHD 620 on Mesa)

  • FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING is always GL_SRGB;
  • EGL_COLORSPACE is EGL_COLORSPACE_SRGB, while EGL_GL_COLORSPACE is EGL_COLORSPACE_LINEAR;
    • Changing either of these has no effect on COLOR_ENCODING;
  • Enabling GL_FRAMEBUFFER_SRGB always makes the image brighter (as expected for COLOR_ENCODING = GL_SRGB).

X11 (Intel UHD 620 on Mesa)

  • Also alternating configs which are "sRGB-capable";
  • On all configs COLOR_ENCODING is GL_SRGB;
  • FRAMEBUFFER_SRGB is disabled by default, but enabling it always makes the image brighter.

Windows (RX 6800 XT)

  • COLOR_ENCODING is GL_LINEAR;
  • GL_FRAMEBUFFER_SRGB is disabled;
  • Enabling GL_FRAMEBUFFER_SRGB makes the image brighter (again, weird for a linear color encoding...);
  • All configs are sRGB-capable;
  • WGL_EXT_colorspace is not in the list of supported extensions;
  • As expected, querying WGL_COLORSPACE_EXT via wglGetPixelFormatAttribivARB() always fails;
  • However, setting WGL_COLORSPACE_EXT to WGL_COLORSPACE_SRGB_EXT via wglChoosePixelFormatARB():
    • Makes COLOR_ENCODING return GL_SRGB 👍;
    • Makes the image darker 👍;
    • Enabling GL_FRAMEBUFFER_SRGB gets the image back to normal colors 👍.
    • Very nice (especially that the image gets darker, means the compositor actually interprets the data differently as we expect...), but super confusing once again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions