renderer: better sdr eotf settings (#12812)

This commit is contained in:
UjinT34 2026-02-26 15:01:59 +03:00 committed by GitHub
parent 0e9196867b
commit c71fbd854d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 174 additions and 65 deletions

View file

@ -1568,10 +1568,10 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
},
SConfigOptionDescription{
.value = "render:cm_sdr_eotf",
.description = "Default transfer function for displaying SDR apps. 0 - Use default value (Gamma 2.2), 1 - Treat unspecified as Gamma 2.2, 2 - Treat "
"unspecified and sRGB as Gamma 2.2, 3 - Treat unspecified as sRGB",
.type = CONFIG_OPTION_CHOICE,
.data = SConfigOptionDescription::SChoiceData{0, "default,gamma22,gamma22force,srgb"},
.description = "Default transfer function for displaying SDR apps. default - Use default value (Gamma 2.2), gamma22 - Treat unspecified as Gamma 2.2, gamma22force - Treat "
"unspecified and sRGB as Gamma 2.2, srgb - Treat unspecified as sRGB",
.type = CONFIG_OPTION_STRING_SHORT,
.data = SConfigOptionDescription::SStringData{"default"},
},
SConfigOptionDescription{
.value = "render:commit_timing_enabled",

View file

@ -795,7 +795,7 @@ CConfigManager::CConfigManager() {
registerConfigVar("render:cm_auto_hdr", Hyprlang::INT{1});
registerConfigVar("render:new_render_scheduling", Hyprlang::INT{0});
registerConfigVar("render:non_shader_cm", Hyprlang::INT{3});
registerConfigVar("render:cm_sdr_eotf", Hyprlang::INT{0});
registerConfigVar("render:cm_sdr_eotf", {"default"});
registerConfigVar("render:commit_timing_enabled", Hyprlang::INT{1});
registerConfigVar("ecosystem:no_update_news", Hyprlang::INT{0});
@ -859,7 +859,7 @@ CConfigManager::CConfigManager() {
m_config->addSpecialConfigValue("monitorv2", "mirror", {STRVAL_EMPTY});
m_config->addSpecialConfigValue("monitorv2", "bitdepth", {STRVAL_EMPTY}); // TODO use correct type
m_config->addSpecialConfigValue("monitorv2", "cm", {"auto"});
m_config->addSpecialConfigValue("monitorv2", "sdr_eotf", Hyprlang::INT{0});
m_config->addSpecialConfigValue("monitorv2", "sdr_eotf", {"default"});
m_config->addSpecialConfigValue("monitorv2", "sdrbrightness", Hyprlang::FLOAT{1.0});
m_config->addSpecialConfigValue("monitorv2", "sdrsaturation", Hyprlang::FLOAT{1.0});
m_config->addSpecialConfigValue("monitorv2", "vrr", Hyprlang::INT{0});
@ -1209,8 +1209,18 @@ std::optional<std::string> CConfigManager::handleMonitorv2(const std::string& ou
if (VAL && VAL->m_bSetByUser)
parser.parseCM(std::any_cast<Hyprlang::STRING>(VAL->getValue()));
VAL = m_config->getSpecialConfigValuePtr("monitorv2", "sdr_eotf", output.c_str());
if (VAL && VAL->m_bSetByUser)
parser.rule().sdrEotf = std::any_cast<Hyprlang::INT>(VAL->getValue());
if (VAL && VAL->m_bSetByUser) {
const std::string value = std::any_cast<Hyprlang::STRING>(VAL->getValue());
// remap legacy
if (value == "0")
parser.rule().sdrEotf = NTransferFunction::TF_AUTO;
else if (value == "1")
parser.rule().sdrEotf = NTransferFunction::TF_SRGB;
else if (value == "2")
parser.rule().sdrEotf = NTransferFunction::TF_GAMMA22;
else
parser.rule().sdrEotf = NTransferFunction::fromString(value);
}
VAL = m_config->getSpecialConfigValuePtr("monitorv2", "sdrbrightness", output.c_str());
if (VAL && VAL->m_bSetByUser)
parser.rule().sdrBrightness = std::any_cast<Hyprlang::FLOAT>(VAL->getValue());