3
0
mirror of https://github.com/hyprwm/Hyprland.git synced 2026-02-04 13:35:32 +00:00

renderer: add quirks:prefer_hdr to fix HDR activation for some clients (#12436)

This commit is contained in:
UjinT34
2025-12-03 04:30:43 +03:00
committed by GitHub
parent 2cadc8abab
commit 3cf0280b11
5 changed files with 40 additions and 0 deletions

View File

@ -2899,6 +2899,27 @@ SImageDescription CCompositor::getPreferredImageDescription() {
return m_monitors.size() == 1 ? m_monitors[0]->m_imageDescription : SImageDescription{.primaries = NColorPrimaries::BT709};
}
SImageDescription CCompositor::getHDRImageDescription() {
if (!PROTO::colorManagement) {
Debug::log(ERR, "FIXME: color management protocol is not enabled, returning empty image description");
return SImageDescription{};
}
return m_monitors.size() == 1 && m_monitors[0]->m_output && m_monitors[0]->m_output->parsedEDID.hdrMetadata.has_value() ?
SImageDescription{.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_ST2084_PQ,
.primariesNameSet = true,
.primariesNamed = NColorManagement::CM_PRIMARIES_BT2020,
.primaries = NColorManagement::getPrimaries(NColorManagement::CM_PRIMARIES_BT2020),
.luminances = {.min = m_monitors[0]->m_output->parsedEDID.hdrMetadata->desiredContentMinLuminance,
.max = m_monitors[0]->m_output->parsedEDID.hdrMetadata->desiredContentMaxLuminance,
.reference = m_monitors[0]->m_output->parsedEDID.hdrMetadata->desiredMaxFrameAverageLuminance}} :
SImageDescription{.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_ST2084_PQ,
.primariesNameSet = true,
.primariesNamed = NColorManagement::CM_PRIMARIES_BT2020,
.primaries = NColorManagement::getPrimaries(NColorManagement::CM_PRIMARIES_BT2020),
.luminances = {.min = 0, .max = 10000, .reference = 203}};
}
bool CCompositor::shouldChangePreferredImageDescription() {
Debug::log(WARN, "FIXME: color management protocol is enabled and outputs changed, check preferred image description changes");
return false;

View File

@ -160,6 +160,7 @@ class CCompositor {
std::optional<unsigned int> getVTNr();
NColorManagement::SImageDescription getPreferredImageDescription();
NColorManagement::SImageDescription getHDRImageDescription();
bool shouldChangePreferredImageDescription();
bool supportsDrmSyncobjTimeline() const;

View File

@ -1993,4 +1993,16 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
.type = CONFIG_OPTION_BOOL,
.data = SConfigOptionDescription::SBoolData{false},
},
/*
* Quirks
*/
SConfigOptionDescription{
.value = "quirks:prefer_hdr",
.description = "Prefer HDR mode. 0 - off, 1 - always, 2 - gamescope only",
.type = CONFIG_OPTION_INT,
.data = SConfigOptionDescription::SRangeData{.value = 0, .min = 0, .max = 2},
},
};

View File

@ -770,6 +770,8 @@ CConfigManager::CConfigManager() {
registerConfigVar("experimental:xx_color_management_v4", Hyprlang::INT{0});
registerConfigVar("quirks:prefer_hdr", Hyprlang::INT{0});
// devices
m_config->addSpecialCategory("device", {"name"});
m_config->addSpecialConfigValue("device", "sensitivity", {0.F});

View File

@ -557,6 +557,10 @@ void CWLSurfaceResource::commitState(SSurfaceState& state) {
}
SImageDescription CWLSurfaceResource::getPreferredImageDescription() {
static const auto PFORCE_HDR = CConfigValue<Hyprlang::INT>("quirks:prefer_hdr");
if (*PFORCE_HDR == 1 || (*PFORCE_HDR == 2 && m_hlSurface && m_hlSurface->getWindow() && m_hlSurface->getWindow()->m_class == "gamescope"))
return g_pCompositor->getHDRImageDescription();
auto parent = m_self;
if (parent->m_role->role() == SURFACE_ROLE_SUBSURFACE) {
auto subsurface = sc<CSubsurfaceRole*>(parent->m_role.get())->m_subsurface.lock();