Skip to content

Instantly share code, notes, and snippets.

@Zoxc
Created September 9, 2012 00:47
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Zoxc/3681678 to your computer and use it in GitHub Desktop.
Wayland Color Management
- Reads from client buffers in weston must be converted to linear gamma. Client buffers can be presented to weston with sRGB or linear gamma.
The server-side wl_drm will use sRGB formats to convert it for weston if that's available.
Should the existing SHM/DRM formats be declared as having sRGB gamma? If so, should the premultiplied color format be linear_to_srgb(color * alpha) (the format OpenGL and pixman uses for sRGB)?
How should you pass on whether or not the compositor prefers linear gamma to wayland_drm_init in mesa? (This is needed to disable gamma correction for performance reasons)
Options:
- Replace the eglQueryWaylandBufferWL, eglCreateImageKHR sequence with:
EGLBoolean eglSetupWaylandBufferWL(EGLDisplay dpy, struct wl_buffer *buffer, const EGLint *attrib_list, EGLint *format, EGLint *planes, EGLImageKHR *images);
- Call an eglSetupWaylandBufferWL function before doing anything with a wl_buffer (but keep the eglQueryWaylandBufferWL, eglCreateImageKHR sequence)
- Add eglDisplayAttribWL to allow you to set the preferred gamma in the EGL display.
- The result of eglQueryWaylandBufferWL's value argument or eglSetupWaylandBufferWL's format argument should indicate if RGB(A) buffers are in linear space.
eglQueryWaylandBufferWL needs to be changed to return whether or not the buffer has sRGB gamma.
GLES 2 extensions or another GL version is required to add sRGB support for BGR(A) textures for SHM surfaces.
- Mesa's DRI interface needs to add support sRGB buffers and/or images.
- wl_drm should only announce sRGB formats which the hardware supports if gamma management is enabled.
There should be an error if there are no sRGB formats available.
- weston needs to support converting all inputs to linear space and convert back into sRGB as required.
If the hardware doesn't support sRGB framebuffer or textures this has to be done with shaders.
A larger than 8bpp temporary buffer is needed to do the compositing in linear gamma (without hardware sRGB support). 16bpp textures requires GLES 2 extensions or another GL version.
A more flexible way of generating shaders would be useful.
- Applications needs to be able to specifiy that their output isn't sRGB.
Something like void wl_egl_window_srgb(int enable) needs to be added for that.
EGL can use an sRGB framebuffer to avoid precision issues as long as reads and writes are converted from linear gamma.
- Get a profile from a CMS backend.
CMS backends should be dynamic libraries selectable at runtime.
weston should inform the CMS backend when outputs are connected/disconnected and it returns/generates a ICC profile/settings for it.
The CMS backend can also inform weston than the profile/settings for an output has changed.
Oyranos and colord would be two CMSes to support. colord requires dbus integration.
- Convert the gamut from sRGB into the display gamut.
This can be done with a 3D texture (more unsupported GL features) and should be with the indirect rendering. CompICC contains similar functionality for Compiz.
- Further work
Support surfaces with larger than sRGB gamut.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment