From ff50dc36e912b6ad764802d51be838bc7f6ed323 Mon Sep 17 00:00:00 2001 From: Dominick DiMaggio Date: Wed, 29 Oct 2025 08:53:42 -0400 Subject: renderer/cm: allow gamma 2.2 instead of sRGB EOTF (#12094) --- src/render/OpenGL.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/render/OpenGL.cpp') diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index c16cbf15..02da142f 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -1552,14 +1552,24 @@ static std::map, std::array> primaries static bool isSDR2HDR(const NColorManagement::SImageDescription& imageDescription, const NColorManagement::SImageDescription& targetImageDescription) { // might be too strict - return imageDescription.transferFunction == NColorManagement::CM_TRANSFER_FUNCTION_SRGB && + return (imageDescription.transferFunction == NColorManagement::CM_TRANSFER_FUNCTION_SRGB || + imageDescription.transferFunction == NColorManagement::CM_TRANSFER_FUNCTION_GAMMA22) && (targetImageDescription.transferFunction == NColorManagement::CM_TRANSFER_FUNCTION_ST2084_PQ || targetImageDescription.transferFunction == NColorManagement::CM_TRANSFER_FUNCTION_HLG); } void CHyprOpenGLImpl::passCMUniforms(SShader& shader, const NColorManagement::SImageDescription& imageDescription, const NColorManagement::SImageDescription& targetImageDescription, bool modifySDR, float sdrMinLuminance, int sdrMaxLuminance) { - shader.setUniformInt(SHADER_SOURCE_TF, imageDescription.transferFunction); + static auto PSDREOTF = CConfigValue("render:cm_sdr_eotf"); + + if (m_renderData.surface.valid() && + ((!m_renderData.surface->m_colorManagement.valid() && *PSDREOTF >= 1) || + (*PSDREOTF == 2 && m_renderData.surface->m_colorManagement.valid() && + imageDescription.transferFunction == NColorManagement::eTransferFunction::CM_TRANSFER_FUNCTION_SRGB))) { + shader.setUniformInt(SHADER_SOURCE_TF, NColorManagement::eTransferFunction::CM_TRANSFER_FUNCTION_GAMMA22); + } else + shader.setUniformInt(SHADER_SOURCE_TF, imageDescription.transferFunction); + shader.setUniformInt(SHADER_TARGET_TF, targetImageDescription.transferFunction); const auto targetPrimaries = targetImageDescription.primariesNameSet || targetImageDescription.primaries == SPCPRimaries{} ? -- cgit v1.2.3