diff options
| author | UjinT34 <41110182+UjinT34@users.noreply.github.com> | 2026-02-26 15:01:59 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-26 12:01:59 +0000 |
| commit | c71fbd854dfdedaae011f4b8b1fdb81f8054b309 (patch) | |
| tree | 89d600037ab206f800acca1b2567eb60af67c7e9 /src/render/OpenGL.cpp | |
| parent | 0e9196867b4f602e1e5a599d4f3565faff615b3c (diff) | |
renderer: better sdr eotf settings (#12812)
Diffstat (limited to 'src/render/OpenGL.cpp')
| -rw-r--r-- | src/render/OpenGL.cpp | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index d6c2c024..916091db 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -10,6 +10,7 @@ #include "../Compositor.hpp" #include "../helpers/MiscFunctions.hpp" #include "../helpers/CursorShapes.hpp" +#include "../helpers/TransferFunction.hpp" #include "../config/ConfigValue.hpp" #include "../config/ConfigManager.hpp" #include "../managers/PointerManager.hpp" @@ -1245,13 +1246,20 @@ static bool isHDR2SDR(const NColorManagement::SImageDescription& imageDescriptio void CHyprOpenGLImpl::passCMUniforms(WP<CShader> shader, const NColorManagement::PImageDescription imageDescription, const NColorManagement::PImageDescription targetImageDescription, bool modifySDR, float sdrMinLuminance, int sdrMaxLuminance) { - static auto PSDREOTF = CConfigValue<Hyprlang::INT>("render:cm_sdr_eotf"); + const auto sdrEOTF = NTransferFunction::fromConfig(); - if (m_renderData.surface.valid() && - ((!m_renderData.surface->m_colorManagement.valid() && *PSDREOTF >= 1) || - (*PSDREOTF == 2 && m_renderData.surface->m_colorManagement.valid() && - imageDescription->value().transferFunction == NColorManagement::eTransferFunction::CM_TRANSFER_FUNCTION_SRGB))) { - shader->setUniformInt(SHADER_SOURCE_TF, NColorManagement::eTransferFunction::CM_TRANSFER_FUNCTION_GAMMA22); + if (m_renderData.surface.valid()) { + if (m_renderData.surface->m_colorManagement.valid()) { + if (sdrEOTF == NTransferFunction::TF_FORCED_GAMMA22 && imageDescription->value().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->value().transferFunction); + } else if (sdrEOTF == NTransferFunction::TF_SRGB) + shader->setUniformInt(SHADER_SOURCE_TF, NColorManagement::eTransferFunction::CM_TRANSFER_FUNCTION_SRGB); + else if (sdrEOTF == NTransferFunction::TF_GAMMA22 || sdrEOTF == NTransferFunction::TF_FORCED_GAMMA22) + shader->setUniformInt(SHADER_SOURCE_TF, NColorManagement::eTransferFunction::CM_TRANSFER_FUNCTION_GAMMA22); + else + shader->setUniformInt(SHADER_SOURCE_TF, imageDescription->value().transferFunction); } else shader->setUniformInt(SHADER_SOURCE_TF, imageDescription->value().transferFunction); @@ -1377,16 +1385,16 @@ void CHyprOpenGLImpl::renderTextureInternal(SP<CTexture> tex, const CBox& box, c 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 canPassHDRSurface = isHDRSurface && !m_renderData.surface->m_colorManagement->isWindowsScRGB(); // windows scRGB requires CM shader + 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 auto imageDescription = m_renderData.surface.valid() && m_renderData.surface->m_colorManagement.valid() ? - CImageDescription::from(m_renderData.surface->m_colorManagement->imageDescription()) : - (data.cmBackToSRGB ? data.cmBackToSRGBSource->m_imageDescription : DEFAULT_IMAGE_DESCRIPTION); + const auto imageDescription = m_renderData.surface.valid() && m_renderData.surface->m_colorManagement.valid() ? + CImageDescription::from(m_renderData.surface->m_colorManagement->imageDescription()) : + (data.cmBackToSRGB ? data.cmBackToSRGBSource->m_imageDescription : DEFAULT_IMAGE_DESCRIPTION); - static auto PSDREOTF = CConfigValue<Hyprlang::INT>("render:cm_sdr_eotf"); - auto chosenSdrEotf = *PSDREOTF != 3 ? NColorManagement::CM_TRANSFER_FUNCTION_GAMMA22 : NColorManagement::CM_TRANSFER_FUNCTION_SRGB; - const auto targetImageDescription = + const auto sdrEOTF = NTransferFunction::fromConfig(); + auto chosenSdrEotf = sdrEOTF != NTransferFunction::TF_SRGB ? NColorManagement::CM_TRANSFER_FUNCTION_GAMMA22 : NColorManagement::CM_TRANSFER_FUNCTION_SRGB; + 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 */ |
