renderer/cm: allow gamma 2.2 instead of sRGB EOTF (#12094)

This commit is contained in:
Dominick DiMaggio 2025-10-29 08:53:42 -04:00 committed by GitHub
parent ce9787b3f4
commit ff50dc36e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 51 additions and 15 deletions

View file

@ -1552,14 +1552,24 @@ static std::map<std::pair<uint32_t, uint32_t>, std::array<GLfloat, 9>> 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<Hyprlang::INT>("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{} ?