renderer: fix screen export back to srgb (#13148)
This commit is contained in:
parent
a0ec2e4daf
commit
9433060760
1 changed files with 23 additions and 21 deletions
|
|
@ -1374,16 +1374,21 @@ void CHyprOpenGLImpl::renderTextureInternal(SP<CTexture> tex, const CBox& box, c
|
||||||
tex->setTexParameter(GL_TEXTURE_MIN_FILTER, tex->minFilter);
|
tex->setTexParameter(GL_TEXTURE_MIN_FILTER, tex->minFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool isHDRSurface = m_renderData.surface.valid() && m_renderData.surface->m_colorManagement.valid() ? m_renderData.surface->m_colorManagement->isHDR() : false;
|
const bool isHDRSurface = m_renderData.surface.valid() && m_renderData.surface->m_colorManagement.valid() ? m_renderData.surface->m_colorManagement->isHDR() : false;
|
||||||
const bool canPassHDRSurface = isHDRSurface && !m_renderData.surface->m_colorManagement->isWindowsScRGB(); // windows scRGB requires CM shader
|
const bool canPassHDRSurface = isHDRSurface && !m_renderData.surface->m_colorManagement->isWindowsScRGB(); // windows scRGB requires CM shader
|
||||||
|
|
||||||
const auto imageDescription = m_renderData.surface.valid() && m_renderData.surface->m_colorManagement.valid() ?
|
const auto imageDescription = m_renderData.surface.valid() && m_renderData.surface->m_colorManagement.valid() ?
|
||||||
CImageDescription::from(m_renderData.surface->m_colorManagement->imageDescription()) :
|
CImageDescription::from(m_renderData.surface->m_colorManagement->imageDescription()) :
|
||||||
(data.cmBackToSRGB ? data.cmBackToSRGBSource->m_imageDescription : DEFAULT_IMAGE_DESCRIPTION);
|
(data.cmBackToSRGB ? data.cmBackToSRGBSource->m_imageDescription : DEFAULT_IMAGE_DESCRIPTION);
|
||||||
|
|
||||||
const bool skipCM = !*PENABLECM || !m_cmSupported /* CM unsupported or disabled */
|
static auto PSDREOTF = CConfigValue<Hyprlang::INT>("render:cm_sdr_eotf");
|
||||||
|| m_renderData.pMonitor->doesNoShaderCM() /* no shader needed */
|
auto chosenSdrEotf = *PSDREOTF != 3 ? NColorManagement::CM_TRANSFER_FUNCTION_GAMMA22 : NColorManagement::CM_TRANSFER_FUNCTION_SRGB;
|
||||||
|| (imageDescription->id() == m_renderData.pMonitor->m_imageDescription->id() && !data.cmBackToSRGB) /* Source and target have the same image description */
|
const auto targetImageDescription =
|
||||||
|
data.cmBackToSRGB ? CImageDescription::from(NColorManagement::SImageDescription{.transferFunction = chosenSdrEotf}) : m_renderData.pMonitor->m_imageDescription;
|
||||||
|
|
||||||
|
const bool skipCM = !*PENABLECM || !m_cmSupported /* CM unsupported or disabled */
|
||||||
|
|| m_renderData.pMonitor->doesNoShaderCM() /* no shader needed */
|
||||||
|
|| (imageDescription->id() == targetImageDescription->id() && !data.cmBackToSRGB) /* Source and target have the same image description */
|
||||||
|| (((*PPASS && canPassHDRSurface) ||
|
|| (((*PPASS && canPassHDRSurface) ||
|
||||||
(*PPASS == 1 && !isHDRSurface && m_renderData.pMonitor->m_cmType != NCMType::CM_HDR && m_renderData.pMonitor->m_cmType != NCMType::CM_HDR_EDID)) &&
|
(*PPASS == 1 && !isHDRSurface && m_renderData.pMonitor->m_cmType != NCMType::CM_HDR && m_renderData.pMonitor->m_cmType != NCMType::CM_HDR_EDID)) &&
|
||||||
m_renderData.pMonitor->inFullscreenMode()) /* Fullscreen window with pass cm enabled */;
|
m_renderData.pMonitor->inFullscreenMode()) /* Fullscreen window with pass cm enabled */;
|
||||||
|
|
@ -1401,20 +1406,19 @@ void CHyprOpenGLImpl::renderTextureInternal(SP<CTexture> tex, const CBox& box, c
|
||||||
if (!skipCM) {
|
if (!skipCM) {
|
||||||
shaderFeatures |= SH_FEAT_CM;
|
shaderFeatures |= SH_FEAT_CM;
|
||||||
|
|
||||||
const bool needsSDRmod = isSDR2HDR(imageDescription->value(), m_renderData.pMonitor->m_imageDescription->value());
|
const bool needsSDRmod = isSDR2HDR(imageDescription->value(), targetImageDescription->value());
|
||||||
const bool needsHDRmod = !needsSDRmod && isHDR2SDR(imageDescription->value(), m_renderData.pMonitor->m_imageDescription->value());
|
const bool needsHDRmod = !needsSDRmod && isHDR2SDR(imageDescription->value(), targetImageDescription->value());
|
||||||
const float maxLuminance = needsHDRmod ?
|
const float maxLuminance = needsHDRmod ?
|
||||||
imageDescription->value().getTFMaxLuminance(-1) :
|
imageDescription->value().getTFMaxLuminance(-1) :
|
||||||
(imageDescription->value().luminances.max > 0 ? imageDescription->value().luminances.max : imageDescription->value().luminances.reference);
|
(imageDescription->value().luminances.max > 0 ? imageDescription->value().luminances.max : imageDescription->value().luminances.reference);
|
||||||
const auto dstMaxLuminance =
|
const auto dstMaxLuminance = targetImageDescription->value().luminances.max > 0 ? targetImageDescription->value().luminances.max : 10000;
|
||||||
m_renderData.pMonitor->m_imageDescription->value().luminances.max > 0 ? m_renderData.pMonitor->m_imageDescription->value().luminances.max : 10000;
|
|
||||||
|
|
||||||
if (maxLuminance >= dstMaxLuminance * 1.01)
|
if (maxLuminance >= dstMaxLuminance * 1.01)
|
||||||
shaderFeatures |= SH_FEAT_TONEMAP;
|
shaderFeatures |= SH_FEAT_TONEMAP;
|
||||||
|
|
||||||
if (!data.cmBackToSRGB &&
|
if (!data.cmBackToSRGB &&
|
||||||
(imageDescription->value().transferFunction == CM_TRANSFER_FUNCTION_SRGB || imageDescription->value().transferFunction == CM_TRANSFER_FUNCTION_GAMMA22) &&
|
(imageDescription->value().transferFunction == CM_TRANSFER_FUNCTION_SRGB || imageDescription->value().transferFunction == CM_TRANSFER_FUNCTION_GAMMA22) &&
|
||||||
m_renderData.pMonitor->m_imageDescription->value().transferFunction == CM_TRANSFER_FUNCTION_ST2084_PQ &&
|
targetImageDescription->value().transferFunction == CM_TRANSFER_FUNCTION_ST2084_PQ &&
|
||||||
((m_renderData.pMonitor->m_sdrSaturation > 0 && m_renderData.pMonitor->m_sdrSaturation != 1.0f) ||
|
((m_renderData.pMonitor->m_sdrSaturation > 0 && m_renderData.pMonitor->m_sdrSaturation != 1.0f) ||
|
||||||
(m_renderData.pMonitor->m_sdrBrightness > 0 && m_renderData.pMonitor->m_sdrBrightness != 1.0f)))
|
(m_renderData.pMonitor->m_sdrBrightness > 0 && m_renderData.pMonitor->m_sdrBrightness != 1.0f)))
|
||||||
shaderFeatures |= SH_FEAT_SDR_MOD;
|
shaderFeatures |= SH_FEAT_SDR_MOD;
|
||||||
|
|
@ -1427,11 +1431,9 @@ void CHyprOpenGLImpl::renderTextureInternal(SP<CTexture> tex, const CBox& box, c
|
||||||
shader = useShader(shader);
|
shader = useShader(shader);
|
||||||
|
|
||||||
if (!skipCM && !usingFinalShader) {
|
if (!skipCM && !usingFinalShader) {
|
||||||
if (data.cmBackToSRGB) {
|
if (data.cmBackToSRGB)
|
||||||
static auto PSDREOTF = CConfigValue<Hyprlang::INT>("render:cm_sdr_eotf");
|
passCMUniforms(shader, imageDescription, targetImageDescription, true, -1, -1);
|
||||||
auto chosenSdrEotf = *PSDREOTF != 3 ? NColorManagement::CM_TRANSFER_FUNCTION_GAMMA22 : NColorManagement::CM_TRANSFER_FUNCTION_SRGB;
|
else
|
||||||
passCMUniforms(shader, imageDescription, CImageDescription::from(NColorManagement::SImageDescription{.transferFunction = chosenSdrEotf}), true, -1, -1);
|
|
||||||
} else
|
|
||||||
passCMUniforms(shader, imageDescription);
|
passCMUniforms(shader, imageDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue