Skip to content

Commit bf44b06

Browse files
committed
cm: handle CM for SDR content with cm=hdr, cm_sdr_eotf=2
1 parent 64ee8f8 commit bf44b06

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/helpers/Monitor.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,8 +1789,8 @@ uint16_t CMonitor::isDSBlocked(bool full) {
17891789
return reasons;
17901790
}
17911791

1792-
if (needsCM() && *PNONSHADER != CM_NS_IGNORE && !canNoShaderCM() && (!inHDR() || (PSURFACE->m_colorManagement.valid() && PSURFACE->m_colorManagement->isWindowsScRGB())) &&
1793-
*PPASS != 1)
1792+
const bool surfaceIsHDR = PSURFACE->m_colorManagement.valid() && (PSURFACE->m_colorManagement->isHDR() || PSURFACE->m_colorManagement->isWindowsScRGB());
1793+
if (needsCM() && *PNONSHADER != CM_NS_IGNORE && !canNoShaderCM() && ((inHDR() && (*PPASS == 0 || !surfaceIsHDR)) || (!inHDR() && (*PPASS != 1 || surfaceIsHDR))))
17941794
reasons |= DS_BLOCK_CM;
17951795

17961796
return reasons;
@@ -2055,10 +2055,13 @@ bool CMonitor::canNoShaderCM() {
20552055
if (SRC_DESC->icc.fd >= 0 || m_imageDescription.icc.fd >= 0)
20562056
return false; // no ICC support
20572057

2058+
static auto PSDREOTF = CConfigValue<Hyprlang::INT>("render:cm_sdr_eotf");
20582059
// only primaries differ
2059-
if (SRC_DESC->transferFunction == m_imageDescription.transferFunction && SRC_DESC->transferFunctionPower == m_imageDescription.transferFunctionPower &&
2060-
(!inHDR() || SRC_DESC->luminances == m_imageDescription.luminances) && SRC_DESC->masteringLuminances == m_imageDescription.masteringLuminances &&
2061-
SRC_DESC->maxCLL == m_imageDescription.maxCLL && SRC_DESC->maxFALL == m_imageDescription.maxFALL)
2060+
if ((SRC_DESC->transferFunction == m_imageDescription.transferFunction ||
2061+
(*PSDREOTF == 2 && SRC_DESC->transferFunction == NColorManagement::CM_TRANSFER_FUNCTION_SRGB &&
2062+
m_imageDescription.transferFunction == NColorManagement::CM_TRANSFER_FUNCTION_GAMMA22)) &&
2063+
SRC_DESC->transferFunctionPower == m_imageDescription.transferFunctionPower && (!inHDR() || SRC_DESC->luminances == m_imageDescription.luminances) &&
2064+
SRC_DESC->masteringLuminances == m_imageDescription.masteringLuminances && SRC_DESC->maxCLL == m_imageDescription.maxCLL && SRC_DESC->maxFALL == m_imageDescription.maxFALL)
20622065
return true;
20632066

20642067
return false;

src/render/OpenGL.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1698,7 +1698,9 @@ void CHyprOpenGLImpl::renderTextureInternal(SP<CTexture> tex, const CBox& box, c
16981698
const bool skipCM = !*PENABLECM || !m_cmSupported /* CM unsupported or disabled */
16991699
|| m_renderData.pMonitor->doesNoShaderCM() /* no shader needed */
17001700
|| (imageDescription == m_renderData.pMonitor->m_imageDescription && !data.cmBackToSRGB) /* Source and target have the same image description */
1701-
|| (((*PPASS && canPassHDRSurface) || (*PPASS == 1 && !isHDRSurface)) && m_renderData.pMonitor->inFullscreenMode()) /* Fullscreen window with pass cm enabled */;
1701+
|| (((*PPASS && canPassHDRSurface) ||
1702+
(*PPASS == 1 && !isHDRSurface && m_renderData.pMonitor->m_cmType != NCMType::CM_HDR && m_renderData.pMonitor->m_cmType != NCMType::CM_HDR_EDID)) &&
1703+
m_renderData.pMonitor->inFullscreenMode()) /* Fullscreen window with pass cm enabled */;
17021704

17031705
if (!skipCM && !usingFinalShader && (texType == TEXTURE_RGBA || texType == TEXTURE_RGBX))
17041706
shader = &m_shaders->m_shCM;

0 commit comments

Comments
 (0)