render: fix blur transparency on ICC outputs

This commit is contained in:
LwhJesse 2026-04-30 16:59:24 +08:00
parent e61976233e
commit 53d6884969
5 changed files with 21 additions and 12 deletions

View file

@ -2551,7 +2551,7 @@ bool CMonitor::useFP16() {
WP<CMonitorResources> CMonitor::resources() {
const auto DRM_FORMAT = useFP16() ? DRM_FORMAT_ABGR16161616F : m_output->state->state().drmFormat;
const auto DESC = useFP16() ? LINEAR_IMAGE_DESCRIPTION : m_imageDescription;
const auto DESC = useFP16() ? LINEAR_IMAGE_DESCRIPTION : (m_imageDescription->value().icc.present ? getDefaultImageDescription() : m_imageDescription);
if (!m_resources || m_resources->m_drmFormat != DRM_FORMAT || m_resources->m_size != m_pixelSize)
m_resources = makeUnique<CMonitorResources>(m_self, DRM_FORMAT, m_pixelSize, DESC);

View file

@ -1789,10 +1789,11 @@ SP<IFramebuffer> CHyprOpenGLImpl::blurFramebufferWithDamage(float a, CRegion* or
currentTex->setTexParameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR);
// From FB to sRGB
// From sRGB back to the work buffer/output description
const bool skipCM = !m_cmSupported || !g_pHyprRenderer->workBufferImageDescription()->needsCM(getDefaultImageDescription());
const bool isICC = g_pHyprRenderer->workBufferImageDescription()->value().icc.present;
if (!skipCM) {
shader = useShader(getShaderVariant(SH_FRAG_BLURFINISH, SH_FEAT_CM));
shader = useShader(getShaderVariant(SH_FRAG_BLURFINISH, SH_FEAT_CM | (isICC ? SH_FEAT_ICC : 0)));
passCMUniforms(shader, getDefaultImageDescription(), g_pHyprRenderer->workBufferImageDescription());
shader->setUniformFloat(SHADER_SDR_SATURATION,
m_renderData.pMonitor->m_sdrSaturation > 0 &&

View file

@ -3256,14 +3256,9 @@ void IHyprRenderer::renderSnapshot(WP<Desktop::View::CPopup> popup) {
}
NColorManagement::PImageDescription IHyprRenderer::workBufferImageDescription() {
// TODO
// const bool IS_MONITOR_ICC = m_renderData.pMonitor->m_imageDescription.valid() && m_renderData.pMonitor->m_imageDescription->value().icc.present;
// const auto sdrEOTF = NTransferFunction::fromConfig(IS_MONITOR_ICC);
// const auto CHOSEN_SDR_EOTF = sdrEOTF != NTransferFunction::TF_SRGB ? NColorManagement::CM_TRANSFER_FUNCTION_GAMMA22 : NColorManagement::CM_TRANSFER_FUNCTION_SRGB;
return m_renderData.pMonitor->useFP16() ?
LINEAR_IMAGE_DESCRIPTION :
m_renderData.pMonitor->m_imageDescription; //CImageDescription::from(NColorManagement::SImageDescription{.transferFunction = CHOSEN_SDR_EOTF});
return m_renderData.pMonitor->useFP16() ? LINEAR_IMAGE_DESCRIPTION :
// Keep intermediate passes in the default SDR space and apply monitor ICC on the final output pass.
(m_renderData.pMonitor->m_imageDescription->value().icc.present ? getDefaultImageDescription() : m_renderData.pMonitor->m_imageDescription);
}
bool IHyprRenderer::shouldBlur(PHLLS ls) {

View file

@ -19,6 +19,10 @@ vec4 blurFinish(vec4 pixColor, vec2 v_texcoord, float noise, float brightness
#if USE_CM
,
int sourceTF, int targetTF, mat3 convertMatrix, vec2 srcTFRange, vec2 dstTFRange
#if USE_ICC
,
highp sampler3D iccLut3D, float iccLutSize
#endif
#endif
) {
// noise
@ -30,7 +34,12 @@ vec4 blurFinish(vec4 pixColor, vec2 v_texcoord, float noise, float brightness
pixColor.rgb *= min(1.0, brightness);
#if USE_CM
pixColor = doColorManagement(pixColor, sourceTF, targetTF, convertMatrix, srcTFRange, dstTFRange);
pixColor = doColorManagement(pixColor, sourceTF, targetTF, convertMatrix, srcTFRange, dstTFRange
#if USE_ICC
,
iccLut3D, iccLutSize
#endif
);
#endif
return pixColor;

View file

@ -26,6 +26,10 @@ void main() {
#if USE_CM
,
sourceTF, targetTF, convertMatrix, srcTFRange, dstTFRange
#if USE_ICC
,
iccLut3D, iccLutSize
#endif
#endif
);
}