Skip to content

Draft: Color management (Pt. 2, color mapping functions)

Naveen Kumar requested to merge (removed):cm/cm-part-2 into main

This is a rough plan on how the Mutter implementation for color management support will be upstreamed. The upstreaming is split into two major phases:

  • Features that can be implemented without any protocol extensions by assuming that client content is always standard sRGB.
  • Implementing CM protocol extension and follow-up work.

The CM&HDR protocol development is tracked at wayland/wayland-protocols!14.

Implementation

As for the structure, it introduces the following types:

MetaColorManager

  • Main object aiming to do high level color management. It adds and removes color devices, listens for updates and applies profiles.
  • Map target color space to client color space
  • Decide on the csc path
  • Handle destroy surface color space

MetaWaylandColorManagement

  • Wayland-protocols for color management server side implementation

MetaBackendNative

  • Wayland based color management

MetaBackendX11

  • X11 based color management - Not implementing as part of this MR

MetaColorProfile

  • Standard color profiles, e.g. sRGB, BT709, BT2020
  • Other types of color profile can be implemented in future such as ICC profiles, fetching display color profiles using colord.

MetaColorSpace

  • Stores color definitions of the standard known colorspaces (i.e. color primaries, white-point etc)

MetaColorUtility

  • A common color utility for complex color computations. Currently it is being used by DRM/KMS path only.
  • Performs the color specific computations to generate LUT values & color transformation matrices for various color spaces.

MetaOnScreenNative

  • Checks for every frame if there are changes in the surface or target colorspace, it triggers colorspace change. Later checks for display hardware/gl shader based csc.

Display hardware or GL shaders path for color correction:

GL shaders path

MetaGLShaders

  • Performs the colorspace conversion
  • Adds functionality to create the fragment shader and layer shader snippets
  • Initially, these shaders have been implemented by assuming the input is RGB format.
  • When converting from YUV BT.709 to BT.2020, below stages will be involved
  • Stage1 : YUV to RGB --> After this conversion, RGB is in non-linear fashion
  • Stage2 : Apply EOTF curve --> non-linear to Linear conversion
  • Stage3 : convert BT.709 RGB colorspace to BT.2020 colorspace
  • Stage4 : Apply OETF curve --> Linear to non-linear conversion

MetaShapedTexture

  • Check if color space conversion is needed through gl shaders. if so, then based on the client and target CS, create the shader requirements. These shader requirements are needed to create the shaders dynamically.
  • Get the Fragment shader and layer shader snippets and add them to the cogl pipeline

Display hardware KMS path

MetaCrtcKms

  • Performs crtc level color management. Adds support for crtc degamma|ctm|gamma csc interface

MetaKmsCrtc

  • This reads crtc KMS/DRM properties for gamma|degamma hardware lut size.
  • Checks for advance gamma mode capability * if supported, it sets the DRM_CLIENT_CAP & advance gamma lut based on gamma modes available * if not supported, usage legacy gamma mode instead.

MetaKmsImplDeviceAtomic

  • This will prepare the degamma|ctm values for final atomic process update (gamma setting is already available in mutter). Atomic commit will happen on each entries queued in process_update for atomic commit.
  • Later performs atomic commit for queued degamma|ctm|gamma process_update.

EDID

  • Decode the Colorimetry extension data from edid to read the supported colorspaces by the monitor and expose them.
  • Edid parsing is done based on CTA-861-G standards.

Split Color management support in following parts.

  • Color management (Pt. 1, legacy color management) - !2141 (merged) , !2164 (merged) , !2165 (merged) & !2166 (merged)
  • Color management (Pt. 2, color mapping functions) - helpers without using gl shaders. (this one)
  • Color management (Pt. 3, blending with sRGB - gl shaders) -> Something similar to Gamma correct blending with sRGB -> use LCMS for srgb
  • Color management (Pt. 4, color transformations - gl shaders) -> support other colorspaces using LCMS -> explore LCMS transforms matrices code
  • Color management (Pt. 5, parse colorimetry info from the EDID)
  • Color management (Pt. 6, introduce KMS stuff for off-loading CM workloads such as fetching hw lut size, color transformation matrices, color transformations in KMS degamma|ctm|gamma etc)
Edited by Naveen Kumar

Merge request reports