diff --git a/src/backends/drm/drm_egl_cursor_layer.cpp b/src/backends/drm/drm_egl_cursor_layer.cpp index 9097a5bf7a..03085e955f 100644 --- a/src/backends/drm/drm_egl_cursor_layer.cpp +++ b/src/backends/drm/drm_egl_cursor_layer.cpp @@ -46,7 +46,7 @@ EglGbmCursorLayer::EglGbmCursorLayer(EglGbmBackend *eglBackend, DrmPipeline *pip std::optional EglGbmCursorLayer::beginFrame() { - return m_surface.startRendering(m_pipeline->gpu()->cursorSize(), drmToTextureRotation(m_pipeline) | TextureTransform::MirrorY, m_pipeline->cursorFormats(), m_pipeline->colorDescription(), m_pipeline->output()->channelFactors()); + return m_surface.startRendering(m_pipeline->gpu()->cursorSize(), drmToTextureRotation(m_pipeline) | TextureTransform::MirrorY, m_pipeline->cursorFormats(), m_pipeline->colorDescription(), m_pipeline->output()->channelFactors(), m_pipeline->output()->needsColormanagement()); } bool EglGbmCursorLayer::endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) diff --git a/src/backends/drm/drm_egl_layer.cpp b/src/backends/drm/drm_egl_layer.cpp index 7a0b07ab71..0b8f9e862e 100644 --- a/src/backends/drm/drm_egl_layer.cpp +++ b/src/backends/drm/drm_egl_layer.cpp @@ -59,7 +59,7 @@ std::optional EglGbmLayer::beginFrame() m_scanoutBuffer.reset(); m_dmabufFeedback.renderingSurface(); - return m_surface.startRendering(m_pipeline->mode()->size(), drmToTextureRotation(m_pipeline) | TextureTransform::MirrorY, m_pipeline->formats(), m_pipeline->colorDescription(), m_pipeline->output()->channelFactors()); + return m_surface.startRendering(m_pipeline->mode()->size(), drmToTextureRotation(m_pipeline) | TextureTransform::MirrorY, m_pipeline->formats(), m_pipeline->colorDescription(), m_pipeline->output()->channelFactors(), m_pipeline->output()->needsColormanagement()); } bool EglGbmLayer::endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) diff --git a/src/backends/drm/drm_egl_layer_surface.cpp b/src/backends/drm/drm_egl_layer_surface.cpp index 80a0196348..ea086ec938 100644 --- a/src/backends/drm/drm_egl_layer_surface.cpp +++ b/src/backends/drm/drm_egl_layer_surface.cpp @@ -59,7 +59,7 @@ void EglGbmLayerSurface::destroyResources() m_oldSurface = {}; } -std::optional EglGbmLayerSurface::startRendering(const QSize &bufferSize, TextureTransforms transformation, const QMap> &formats, const ColorDescription &colorDescription, const QVector3D &channelFactors) +std::optional EglGbmLayerSurface::startRendering(const QSize &bufferSize, TextureTransforms transformation, const QMap> &formats, const ColorDescription &colorDescription, const QVector3D &channelFactors, bool enableColormanagement) { if (!checkSurface(bufferSize, formats)) { return std::nullopt; @@ -102,7 +102,7 @@ std::optional EglGbmLayerSurface::startRendering(cons m_surface.intermediaryColorDescription = colorDescription; } } - if (m_surface.intermediaryColorDescription != colorDescription) { + if (enableColormanagement) { if (!m_surface.shadowBuffer) { m_surface.shadowTexture = std::make_shared(GL_RGBA16F, m_surface.gbmSwapchain->size()); m_surface.shadowBuffer = std::make_shared(m_surface.shadowTexture.get()); @@ -123,7 +123,7 @@ std::optional EglGbmLayerSurface::startRendering(cons bool EglGbmLayerSurface::endRendering(const QRegion &damagedRegion) { - if (m_surface.intermediaryColorDescription != m_surface.targetColorDescription) { + if (m_surface.shadowTexture) { const auto &[texture, fbo] = m_surface.textureCache[m_surface.currentBuffer->bo()]; GLFramebuffer::pushFramebuffer(fbo.get()); ShaderBinder binder(ShaderTrait::MapTexture | ShaderTrait::TransformColorspace); diff --git a/src/backends/drm/drm_egl_layer_surface.h b/src/backends/drm/drm_egl_layer_surface.h index 3227ea2d2b..ef09b76256 100644 --- a/src/backends/drm/drm_egl_layer_surface.h +++ b/src/backends/drm/drm_egl_layer_surface.h @@ -48,7 +48,7 @@ public: EglGbmLayerSurface(DrmGpu *gpu, EglGbmBackend *eglBackend, BufferTarget target = BufferTarget::Normal, FormatOption formatOption = FormatOption::PreferAlpha); ~EglGbmLayerSurface(); - std::optional startRendering(const QSize &bufferSize, TextureTransforms transformation, const QMap> &formats, const ColorDescription &colorDescription, const QVector3D &channelFactors); + std::optional startRendering(const QSize &bufferSize, TextureTransforms transformation, const QMap> &formats, const ColorDescription &colorDescription, const QVector3D &channelFactors, bool enableColormanagement); bool endRendering(const QRegion &damagedRegion); bool doesSurfaceFit(const QSize &size, const QMap> &formats) const; diff --git a/src/backends/drm/drm_output.cpp b/src/backends/drm/drm_output.cpp index 8882e3c951..02f06eb6d8 100644 --- a/src/backends/drm/drm_output.cpp +++ b/src/backends/drm/drm_output.cpp @@ -479,7 +479,7 @@ DrmOutputLayer *DrmOutput::cursorLayer() const bool DrmOutput::setGammaRamp(const std::shared_ptr &transformation) { - if (!m_pipeline->active() || m_pipeline->colorimetry() != NamedColorimetry::BT709 || m_pipeline->transferFunction() != NamedTransferFunction::sRGB) { + if (!m_pipeline->active() || needsColormanagement()) { return false; } m_pipeline->setGammaRamp(transformation); @@ -500,7 +500,7 @@ bool DrmOutput::setChannelFactors(const QVector3D &rgb) return true; } m_channelFactors = rgb; - if (m_pipeline->colorimetry() == NamedColorimetry::BT709 && m_pipeline->transferFunction() == NamedTransferFunction::sRGB) { + if (needsColormanagement()) { if (!m_pipeline->active()) { return false; } @@ -527,4 +527,9 @@ QVector3D DrmOutput::channelFactors() const { return m_channelFactors; } + +bool DrmOutput::needsColormanagement() const +{ + return m_pipeline->colorimetry() != NamedColorimetry::BT709 || m_pipeline->transferFunction() != NamedTransferFunction::sRGB || m_gpu->isNVidia(); +} } diff --git a/src/backends/drm/drm_output.h b/src/backends/drm/drm_output.h index 32fac34cf4..1091e2c113 100644 --- a/src/backends/drm/drm_output.h +++ b/src/backends/drm/drm_output.h @@ -62,6 +62,7 @@ public: bool setGammaRamp(const std::shared_ptr &transformation) override; bool setChannelFactors(const QVector3D &rgb) override; QVector3D channelFactors() const; + bool needsColormanagement() const; private: bool setDrmDpmsMode(DpmsMode mode);