From e8dcbddea03900174694a1d19d4d7ec0f08c4e1d Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Thu, 16 Jul 2026 09:28:01 +1000 Subject: [PATCH] [idd/client] correct HDR luminance when PQ conversion is in use --- client/displayservers/Wayland/gl.c | 12 +++++++++++- idd/LGIdd/effect/CHDR16to10Effect.h | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/client/displayservers/Wayland/gl.c b/client/displayservers/Wayland/gl.c index 22c8d541..e103d57f 100644 --- a/client/displayservers/Wayland/gl.c +++ b/client/displayservers/Wayland/gl.c @@ -286,7 +286,7 @@ void waylandSetHDRImageDescription(const uint16_t displayPrimary[3][2], if (wlWm.cmHasLuminances) wp_image_description_creator_params_v1_set_luminances( wlWm.hdrImageCreator, - minDisplayLuminance > 0 ? minDisplayLuminance / 10000 : 50, + minDisplayLuminance > 0 ? minDisplayLuminance : 50, maxDisplayLuminance > 0 ? maxDisplayLuminance / 10000 : 1000, hdrPQ ? 203 : 80); @@ -295,6 +295,7 @@ void waylandSetHDRImageDescription(const uint16_t displayPrimary[3][2], // primaries from the metadata (even if zero, in which case the // compositor uses its own defaults). if (wlWm.cmHasMasteringPrimaries) + { wp_image_description_creator_params_v1_set_mastering_display_primaries( wlWm.hdrImageCreator, displayPrimary[0][0], displayPrimary[0][1], @@ -302,6 +303,15 @@ void waylandSetHDRImageDescription(const uint16_t displayPrimary[3][2], displayPrimary[2][0], displayPrimary[2][1], whitePoint[0], whitePoint[1]); + // Set mastering luminance range so the compositor knows the target + // color volume for tone mapping. min_lum is in ×10000 units (0.0001 cd/m²), + // max_lum is in unscaled cd/m². + wp_image_description_creator_params_v1_set_mastering_luminance( + wlWm.hdrImageCreator, + minDisplayLuminance > 0 ? minDisplayLuminance : 50, + maxDisplayLuminance > 0 ? maxDisplayLuminance / 10000 : 1000); + } + if (maxCLL > 0) wp_image_description_creator_params_v1_set_max_cll(wlWm.hdrImageCreator, maxCLL); if (maxFALL > 0) diff --git a/idd/LGIdd/effect/CHDR16to10Effect.h b/idd/LGIdd/effect/CHDR16to10Effect.h index cf701f73..4da4b0b4 100644 --- a/idd/LGIdd/effect/CHDR16to10Effect.h +++ b/idd/LGIdd/effect/CHDR16to10Effect.h @@ -18,8 +18,8 @@ class CHDR16to10Effect : public CComputeEffect private: struct Consts { - float ReferenceWhiteNits; // scRGB reference white in nits (typically 80) - } m_consts = { 80.0f }; + float ReferenceWhiteNits; // scRGB reference white in nits (BT.2408 recommends 203) + } m_consts = { 203.0f }; ComPtr m_constBuffer; public: