A guided tour of the AMD display driver code to identify hardware color
capabilities on different versions, connect relevant parts of the shared code
to DRM, and ultimately deliver a broader range of color features to the
userspace. This work is another step towards advanced GPU-accelerated color
management for Linux compositors, and it has already enabled improvements to
HDR display support in SteamOS/Gamescope. So, what's the next treasure hunt?
(c) X.Org Developer's Conference (XDC) 2023
October 17-19, 2023
A Coruña (Spain)
https://indico.freedesktop.org/event/4/
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
The rainbow treasure map: Advanced color management on Linux with AMD/Steam Deck – XDC 2023
1. The Rainbow Treasure Map
Advanced Color Management on Linux with AMD/SteamDeck
Melissa Wen
XDC 2023 - A Coruña - Spain
1
2. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
Technical Talk
2
1. XDC 2022 | "I'm not an AMD expert, but..." | Melissa Wen
2. XDC 2022 | Is HDR Harder? | Harry Wentland
3. XDC 2022 Lightning | HDR Workshop Summary | Harry Wentland
4. Color management and HDR documentation for FOSS graphics | Pekka Paalanen et al.
5. Cinematic Color - 2012 SIGGRAPH course notes | Jeremy Selan
6. AMD Driver-specific Properties for Color Management on Linux (Part 1) | Melissa Wen
3. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
Advanced Color Management on Linux
● Wide variety of source content colorimetry (SDR/HDR/different
color gamuts, profiles, etc.)
● Wide variety of output display devices
● Internal processing (window composition, etc)
● Users expect consistent color reproduction
● Linux kernel lacks an interface to manage the diversity of color
profiles
3
4. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
AMD Driver-Specific Color Properties
[PATCH v4 00/32] drm/amd/display: add AMD driver-specific properties for color mgmt
➔ Endless KMS generic color API
➔ Many uncertainties regarding the diversity of color capabilities among hardware
vendors
➔ Gamescope is the userspace case (SteamOS 3.5)
➔ Advanced color management: gamut mapping, HDR rendering, SDR on HDR,
HDR on SDR
4
5. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
AMD Steam Deck Kernel Driver
➔ Accelerated Processing Unit (APU)
➔ Product Name: STEAMDECK
➔ Code Reference: VANGOGH
➔ Display Driver: DCN3.01 (DCN3 family)
5
6. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
AMD Display Driver in the Linux/DRM
DRM/KMS
AMD Display Manager (DM)
AMD Display Core (DC)
kernel space
6
7. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
Connecting DC and DRM
DRM/KMS
AMD Display Manager (DM)
AMD Display Core (DC)
kernel space
7
8. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
Examining AMD DC
DRM/KMS
AMD Display Manager (DM)
AMD Display Core (DC)
kernel space
8
9. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
AMD Display Core Next (DCN)
9
https://dri.freedesktop.org/docs/drm/gpu/amdgpu/display/dcn-overview.html
10. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
AMD Display Core Next (DCN) - Color Caps
10
Pre-blending
DPP: Display Pipe and Plane
Post-blending
MPC: Multiple Pipe/Plane Combined
11. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
Pre-blending: DRM plane
11
12. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
Pre-blending: DRM plane
12
John Travolta in Pulp Fiction
13. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
Pre-blending: DRM plane + AMD DC DPP
input func gamut
remap
hdr
mult
shaper
func
3dlut
func
blend
func
Degam
ROM
Gamma
Corr
Gamut
Remap
HDR
Mult
Shaper
RAM
3D LUT
CTM
gamut
remap
Gamut
Remap
Gamma
LUT
Degam
LUT
out
func
Gamma
RAM
DRM CRTC
AMD DC
13
Blending
Blend
Gamma
14. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
Pre-blending: DRM plane + AMD DC DPP
input func gamut
remap
hdr
mult
shaper
func
3dlut
func
blend
func
Degam
ROM
Gamma
Corr
Gamut
Remap
HDR
Mult
Shaper
RAM
3D LUT
DRM/AMD plane
CTM
gamut
remap
Gamut
Remap
Gamma
LUT
Degam
LUT
out
func
Gamma
RAM
DRM CRTC
AMD DC
14
Blending
Blend
Gamma
15. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
Pre-blending: DRM plane + AMD DC DPP
input func gamut
remap
hdr
mult
shaper
func
3dlut
func
blend
func
Degam
ROM
Gamut
Remap
HDR
Mult
Shaper
RAM
3D LUT
Degamma
LUT
CTM
HDR
Mult
Shaper
TF
3D LUT
Degamma
TF
Blend
TF
Shaper
LUT
Blend
LUT
DRM/AMD plane
CTM
gamut
remap
Gamut
Remap
Gamma
LUT
Degam
LUT
out
func
Gamma
RAM
DRM CRTC
AMD DC
15
Blending
Gamma
Corr
Blend
Gamma
16. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
Pre-blending: DRM plane + AMD DC DPP
input func gamut
remap
hdr
mult
shaper
func
3dlut
func
blend
func
Degam
ROM
Gamut
Remap
HDR
Mult
Shaper
RAM
3D LUT
Degamma
LUT
CTM
HDR
Mult
Shaper
TF
3D LUT
Degamma
TF
Blend
TF
Shaper
LUT
Blend
LUT
DRM/AMD plane
CTM
gamut
remap
Gamut
Remap
Gamma
LUT
Degam
LUT
out
func
Gamma
RAM
DRM CRTC
16
Blending
Gamma
Corr
Blend
Gamma
17. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
AMD Plane Degamma TF and LUT
Transition from encoded values to linear values for precise arithmetic operations
Pre-defined TFs are hardcoded curves to DPP Degamma ROM block
● sRGB EOTF;
● BT.709 inverse OETF;
● PQ EOTF;
● Gamma 2.2, Gamma 2.4 and Gamma 2.6 EOTF
1D LUT supports 4096 entries to DPP Gamma Correction block
The data is interpreted as an array of struct drm_color_lut elements
17
input func
Degam
ROM
Gamma
Corr
Degamma
LUT
Degamma
TF
18. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
Pre-blending: DRM plane + AMD DC DPP
input func gamut
remap
hdr
mult
shaper
func
3dlut
func
blend
func
Degam
ROM
Gamut
Remap
HDR
Mult
Shaper
RAM
3D LUT
Degamma
LUT
CTM
HDR
Mult
Shaper
TF
3D LUT
Degamma
TF
Blend
TF
Shaper
LUT
Blend
LUT
DRM/AMD plane
CTM
gamut
remap
Gamut
Remap
Gamma
LUT
Degam
LUT
out
func
Gamma
RAM
DRM CRTC
18
Blending
Gamma
Corr
Blend
Gamma
19. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
AMD Plane CTM
For color space conversion
3x4-dimensions matrix of fixed-points s31.32 set to DPP Gamut Remap block
Remapping CRTC CTM to MPC Gamut Remap block
19
gamut
remap
Gamut
Remap
CTM
20. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
Pre-blending: DRM plane + AMD DC DPP
input func gamut
remap
hdr
mult
shaper
func
3dlut
func
blend
func
Degam
ROM
Gamut
Remap
HDR
Mult
Shaper
RAM
3D LUT
Degamma
LUT
CTM
HDR
Mult
Shaper
TF
3D LUT
Degamma
TF
Blend
TF
Shaper
LUT
Blend
LUT
DRM/AMD plane
CTM
gamut
remap
Gamut
Remap
Gamma
LUT
Degam
LUT
out
func
Gamma
RAM
DRM CRTC
20
Blending
Gamma
Corr
Blend
Gamma
21. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
Pre-blending: DRM plane + AMD DC DPP
input func gamut
remap
hdr
mult
shaper
func
3dlut
func
blend
func
Degam
ROM
Gamut
Remap
HDR
Mult
Shaper
RAM
3D LUT
Degamma
LUT
CTM
HDR
Mult
Shaper
TF
3D LUT
Degamma
TF
Blend
TF
Shaper
LUT
Blend
LUT
DRM/AMD plane
CTM
gamut
remap
Gamut
Remap
Gamma
LUT
Degam
LUT
out
func
Gamma
RAM
DRM CRTC
21
Blending
Gamma
Corr
Blend
Gamma
22. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
AMD Plane HDR Multiplier
Applied to the color values of an image to increase their overall brightness
Useful for converting images from SDR to HDR
PQ TF is needed for any subsequent transforms
22
hdr
mult
HDR
Mult
HDR
Mult
23. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
Pre-blending: DRM plane + AMD DC DPP
input func gamut
remap
hdr
mult
shaper
func
3dlut
func
blend
func
Degam
ROM
Gamut
Remap
HDR
Mult
Shaper
RAM
3D LUT
Degamma
LUT
CTM
HDR
Mult
Shaper
TF
3D LUT
Degamma
TF
Blend
TF
Shaper
LUT
Blend
LUT
DRM/AMD plane
CTM
gamut
remap
Gamut
Remap
Gamma
LUT
Degam
LUT
out
func
Gamma
RAM
DRM CRTC
23
Blending
Gamma
Corr
Blend
Gamma
24. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
AMD Plane Shaper TF and LUT
Delinearize/normalize the color space before applying a 3D LUT
NO hardcoded curves
Pre-defined TFs are calculated by AMD color module
● sRGB inverse EOTF;
● BT.709 OETF;
● PQ inverse EOTF;
● Gamma 2.2, Gamma 2.4 and Gamma 2.6 inverse EOTF.
The color module combines TF and user LUT into the LUT to DPP Shaper LUT RAM block
24
shaper
func
Shaper
RAM
Shaper
TF
Shaper
LUT
25. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
Pre-blending: DRM plane + AMD DC DPP
input func gamut
remap
hdr
mult
shaper
func
3dlut
func
blend
func
Degam
ROM
Gamut
Remap
HDR
Mult
Shaper
RAM
3D LUT
Degamma
LUT
CTM
HDR
Mult
Shaper
TF
3D LUT
Degamma
TF
Blend
TF
Shaper
LUT
Blend
LUT
DRM/AMD plane
CTM
gamut
remap
Gamut
Remap
Gamma
LUT
Degam
LUT
out
func
Gamma
RAM
DRM CRTC
25
Blending
Gamma
Corr
Blend
Gamma
26. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
AMD Plane 3D LUT
Suitable for complex color transformations and adjustments between color channels
Supported size: 17x17x17 (4913 entries) and 9x9x9 (729)
Tetrahedral interpolation
Blue is the outermost dimension, red the innermost.
26
3dlut
func
3D LUT
3D LUT
27. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
Pre-blending: DRM plane + AMD DC DPP
input func gamut
remap
hdr
mult
shaper
func
3dlut
func
blend
func
Degam
ROM
Gamut
Remap
HDR
Mult
Shaper
RAM
3D LUT
Degamma
LUT
CTM
HDR
Mult
Shaper
TF
3D LUT
Degamma
TF
Blend
TF
Shaper
LUT
Blend
LUT
DRM/AMD plane
CTM
gamut
remap
Gamut
Remap
Gamma
LUT
Degam
LUT
out
func
Gamma
RAM
DRM CRTC
27
Blending
Gamma
Corr
Blend
Gamma
28. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
AMD Plane Blend TF and LUT
Linearize the color space again, after 3D LUT and before blending
NO hardcoded curves
Pre-defined TFs are calculated by AMD color module
● sRGB EOTF;
● BT.709 inverse OETF;
● PQ EOTF;
● Gamma 2.2, Gamma 2.4 and Gamma 2.6 EOTF.
The color module combines TF and user LUT into the LUT to DPP Blend Gamma block
28
blend
func
Blend
Gamma
Blend
TF
Blend
LUT
29. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
Pre-blending: DRM plane + AMD DC DPP
input func gamut
remap
hdr
mult
shaper
func
3dlut
func
blend
func
Degam
ROM
Gamut
Remap
HDR
Mult
Shaper
RAM
3D LUT
Degamma
LUT
CTM
HDR
Mult
Shaper
TF
3D LUT
Degamma
TF
Blend
TF
Shaper
LUT
Blend
LUT
DRM/AMD plane
CTM
gamut
remap
Gamut
Remap
Gamma
LUT
Degam
LUT
out
func
Gamma
RAM
DRM CRTC
29
Blending
Gamma
Corr
Blend
Gamma
30. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
Post-blending: DRM CRTC + AMD DC MPC
input func gamut
remap
hdr
mult
shaper
func
3dlut
func
blend
func
Degam
ROM
Gamut
Remap
HDR
Mult
Shaper
RAM
3D LUT
Degamma
LUT
CTM
HDR
Mult
Shaper
TF
3D LUT
Degamma
TF
Blend
TF
Shaper
LUT
Blend
LUT
DRM/AMD plane
CTM
gamut
remap
Gamut
Remap
Gamma
TF
Gamma
LUT
Degam
LUT
out
func
Gamma
RAM
DRM CRTC
30
Blending
Gamma
Corr
Blend
Gamma
31. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
AMD CRTC Gamma TF
Delinearize/convert to wire encoding
NO hardcoded curves
Pre-defined TFs are calculated by AMD color module
● sRGB inverse EOTF;
● BT.709 OETF;
● PQ inverse EOTF;
● Gamma 2.2, Gamma 2.4 and Gamma 2.6 inverse EOTF.
The color module combines TF and user LUT into the LUT to MPC Gamma RAM block.
31
Gamma
TF
Gamma
LUT
out
func
Gamma
RAM
32. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
DRM/AMD Color Management Pipeline
input func gamut
remap
hdr
mult
shaper
func
3dlut
func
blend
func
Degam
ROM
Gamut
Remap
HDR
Mult
Shaper
RAM
3D LUT Blend
Gamma
Degamma
LUT
CTM
HDR
Mult
Shaper
TF
3D LUT
Degamma
TF
Blend
TF
Shaper
LUT
Blend
LUT
DRM/AMD plane
CTM
gamut
remap
Gamut
Remap
Gamma
TF
Gamma
LUT
Degam
LUT
out
func
Gamma
RAM
DRM CRTC
32
Blending
Gamma
Corr
33. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023 33
Steam Deck Color Pipeline
AMD Driver-Specific Color Properties
Image by catalyststuff on Freepik
34. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023 34
https://github.com/ValveSoftware/gamescope/blob/master/src/docs/Steam%20Deck%20Display%20Pipeline.png
35. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023 35
36. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
The search for the Rainbow
treasure is not over!
36
37. The Rainbow Treasure Map: advanced color management on Linux with AMD/SteamDeck
Melissa Wen, XDC 2023
Thank You!
We're hiring
www.igalia.com/jobs
37