renderer/cm: allow gamma 2.2 instead of sRGB EOTF (#12094)
This commit is contained in:
parent
ce9787b3f4
commit
ff50dc36e9
7 changed files with 51 additions and 15 deletions
|
|
@ -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{} ?
|
||||
|
|
|
|||
|
|
@ -1555,9 +1555,10 @@ bool CHyprRenderer::commitPendingAndDoExplicitSync(PHLMONITOR pMonitor) {
|
|||
if (*PAUTOHDR && !(pMonitor->inHDR() && configuredHDR)) {
|
||||
// modify or restore monitor image description for auto-hdr
|
||||
// FIXME ok for now, will need some other logic if monitor image description can be modified some other way
|
||||
const auto targetCM = wantHDR ? (*PAUTOHDR == 2 ? NCMType::CM_HDR_EDID : NCMType::CM_HDR) : pMonitor->m_cmType;
|
||||
const auto targetCM = wantHDR ? (*PAUTOHDR == 2 ? NCMType::CM_HDR_EDID : NCMType::CM_HDR) : pMonitor->m_cmType;
|
||||
const auto targetSDREOTF = pMonitor->m_sdrEotf;
|
||||
Debug::log(INFO, "[CM] Auto HDR: changing monitor cm to {}", sc<uint8_t>(targetCM));
|
||||
pMonitor->applyCMType(targetCM);
|
||||
pMonitor->applyCMType(targetCM, targetSDREOTF);
|
||||
pMonitor->m_previousFSWindow.reset(); // trigger CTM update
|
||||
}
|
||||
Debug::log(INFO, wantHDR ? "[CM] Updating HDR metadata from monitor" : "[CM] Restoring SDR mode");
|
||||
|
|
|
|||
|
|
@ -416,7 +416,7 @@ vec4 doColorManagement(vec4 pixColor, int srcTF, int dstTF, mat4x2 dstPrimaries)
|
|||
mat3 dstxyz = primaries2xyz(dstPrimaries);
|
||||
pixColor = tonemap(pixColor, dstxyz);
|
||||
pixColor = fromLinearNit(pixColor, dstTF, dstTFRange);
|
||||
if (srcTF == CM_TRANSFER_FUNCTION_SRGB && dstTF == CM_TRANSFER_FUNCTION_ST2084_PQ) {
|
||||
if ((srcTF == CM_TRANSFER_FUNCTION_SRGB || srcTF == CM_TRANSFER_FUNCTION_GAMMA22) && dstTF == CM_TRANSFER_FUNCTION_ST2084_PQ) {
|
||||
pixColor = saturate(pixColor, dstxyz, sdrSaturation);
|
||||
pixColor.rgb *= sdrBrightnessMultiplier;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue