From b08eefd4e22d2d770fd0a72aef1424a9e112bc46 Mon Sep 17 00:00:00 2001 From: UjinT34 Date: Tue, 28 Apr 2026 21:57:46 +0300 Subject: [PATCH] fix unmodified copy --- src/config/values/ConfigValues.cpp | 2 ++ src/helpers/Monitor.cpp | 13 ++++++++----- src/helpers/Monitor.hpp | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/config/values/ConfigValues.cpp b/src/config/values/ConfigValues.cpp index ac213a421..260425cf1 100644 --- a/src/config/values/ConfigValues.cpp +++ b/src/config/values/ConfigValues.cpp @@ -539,6 +539,8 @@ std::vector> Values::getConfigValues() { {.min = 0, .max = 2, .map = OptionMap{{"disable", 0}, {"enable", 1}, {"auto", 2}}}), MS("render:non_shader_cm_interop", "non_shader_cm interaction with ctm proto (hyprsunset and similar).", 2, {.min = 0, .max = 2, .map = OptionMap{{"disable", 0}, {"enable", 1}, {"auto", 2}}}), + MS("render:fp16_sdr_tf", "Internal workbuffer transfer function for fp16 in SDR mode", 0, + {.min = 0, .max = 2, .map = OptionMap{{"default", 0}, {"linear", 1}, {"monitor", 2}}}), /* * cursor: diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index af79a4e3b..4f4e9a7b4 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -2550,6 +2550,8 @@ bool CMonitor::useFP16() { } PImageDescription CMonitor::workBufferImageDescription() { + static const auto PFP16TF = CConfigValue("render:fp16_sdr_tf"); + if (!useFP16()) return m_imageDescription; @@ -2561,19 +2563,20 @@ PImageDescription CMonitor::workBufferImageDescription() { const auto& cached = m_cachedInternalDescription->value(); // HDR - if (isHDRLikeTF || value.windowsScRGB) { - if (cached.primariesNamed != NColorManagement::CM_PRIMARIES_SRGB || cached.luminances != value.luminances) + if (isHDRLikeTF || value.windowsScRGB || *PFP16TF != 2) { + if (cached.transferFunction != LINEAR_IMAGE_DESCRIPTION->value().transferFunction || cached.luminances != value.luminances) m_cachedInternalDescription = LINEAR_IMAGE_DESCRIPTION->with(value.luminances); return m_cachedInternalDescription; } // SDR - if (cached.primariesNamed != NColorManagement::CM_PRIMARIES_BT2020 || cached.transferFunction != chooseTF(m_sdrEotf)) + if (cached.transferFunction != chooseTF(m_sdrEotf)) m_cachedInternalDescription = CImageDescription::from(SImageDescription{ .transferFunction = chooseTF(m_sdrEotf), .primariesNameSet = true, - .primariesNamed = NColorManagement::CM_PRIMARIES_BT2020, - .primaries = NColorPrimaries::BT2020, + // render:keep_unmodified_copy and other conditions that trigger MRT for screen sharing expect a work buffer with sRGB primaries + .primariesNamed = NColorManagement::CM_PRIMARIES_SRGB, + .primaries = NColorPrimaries::BT709, }); return m_cachedInternalDescription; diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index 478d3fedb..8d26be45b 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -415,7 +415,7 @@ class CMonitor { // Resources UP m_resources; - // cached should contain one of predefined descriptions: BT2020 primaries with variable TF and SDR luminances or SRGB primaries with linear TF and variable luminances. + // cached should contain one of predefined descriptions for FP16: sRGB primaries with either linear TF by default and in HDR mode or monitor's TF in SDR with render:fp16_sdr_tf = 2 // avoids lookup for an id when ::from is used NColorManagement::PImageDescription m_cachedInternalDescription = NColorManagement::CImageDescription::from(NColorManagement::SImageDescription{});