-
-
Notifications
You must be signed in to change notification settings - Fork 488
Description
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 viaFRAMEBUFFER_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
toEGL_GL_COLORSPACE_SRGB
appropriately uses the defaultFRAMEBUFFER_SRGB
conversion, the image is now brighter;- The image stays at the original darker color when in
GL_COLORSPACE_SRGB
withgl.Disable(gl::FRAMEBUFFER_SRGB)
.
- The image stays at the original darker color when in
👍, all working as expected.
Wayland EGL (AMD Mesa)
GL_SRGB
is always reported byFRAMEBUFFER_ATTACHMENT_COLOR_ENCODING
;- Changing the color space via
EGL_GL_COLORSPACE
makes no difference (color stays the same,COLOR_ENCODING
always returnsGL_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 inGL_SRGB
colorspace); - The
EGL_(GL_)COLORSPACE
attributes follow which color is being set inCreatePlatformWindowSurface*
.
Wayland EGL (AMD ProGL)
(using progl
command)
- Default color space is
GL_LINEAR
according toFRAMEBUFFER_ATTACHMENT_COLOR_ENCODING
; EGL_COLORSPACE
isEGL_GL_COLORSPACE_SRGB
, butEGL_GL_COLORSPACE
isEGL_GL_COLORSPACE_LINEAR
;- Setting
EGL_COLORSPACE
has no effect; - Setting
EGL_GL_COLORSPACE
toSRGB
correctly makesCOLOR_ENCODING
returnGL_SRGB
;- Turning on
GL_FRAMEBUFFER_SRGB
makes the image brighter (only when the color encoding is sRGB 👍).
- Turning on
X11 (AMD Mesa)
COLOR_ENCODING
is alwaysGL_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 reportsGL_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 alwaysGL_SRGB
;EGL_COLORSPACE
isEGL_COLORSPACE_SRGB
, whileEGL_GL_COLORSPACE
isEGL_COLORSPACE_LINEAR
;- Changing either of these has no effect on
COLOR_ENCODING
;
- Changing either of these has no effect on
- Enabling
GL_FRAMEBUFFER_SRGB
always makes the image brighter (as expected forCOLOR_ENCODING
=GL_SRGB
).
X11 (Intel UHD 620 on Mesa)
- Also alternating configs which are "sRGB-capable";
- On all configs
COLOR_ENCODING
isGL_SRGB
; FRAMEBUFFER_SRGB
is disabled by default, but enabling it always makes the image brighter.
Windows (RX 6800 XT)
COLOR_ENCODING
isGL_LINEAR
;GL_FRAMEBUFFER_SRGB
is disabled;- Enabling
GL_FRAMEBUFFER_SRGB
makes the image brighter (again, weird for alinear
color encoding...); - All configs are sRGB-capable;
WGL_EXT_colorspace
is not in the list of supported extensions;- As expected, querying
WGL_COLORSPACE_EXT
viawglGetPixelFormatAttribivARB()
always fails; - However, setting
WGL_COLORSPACE_EXT
toWGL_COLORSPACE_SRGB_EXT
viawglChoosePixelFormatARB()
:- Makes
COLOR_ENCODING
returnGL_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.
- Makes