backends/drm: always do color management on NVidia GPUs

This comes with a small performance hit but ensures that night color works

BUG: 450327
BUG: 468895
This commit is contained in:
Xaver Hugl 2023-05-23 14:58:36 +02:00
parent 964254e2a5
commit cdafbbbd6f
6 changed files with 14 additions and 8 deletions

View file

@ -46,7 +46,7 @@ EglGbmCursorLayer::EglGbmCursorLayer(EglGbmBackend *eglBackend, DrmPipeline *pip
std::optional<OutputLayerBeginFrameInfo> EglGbmCursorLayer::beginFrame() std::optional<OutputLayerBeginFrameInfo> 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) bool EglGbmCursorLayer::endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion)

View file

@ -59,7 +59,7 @@ std::optional<OutputLayerBeginFrameInfo> EglGbmLayer::beginFrame()
m_scanoutBuffer.reset(); m_scanoutBuffer.reset();
m_dmabufFeedback.renderingSurface(); 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) bool EglGbmLayer::endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion)

View file

@ -59,7 +59,7 @@ void EglGbmLayerSurface::destroyResources()
m_oldSurface = {}; m_oldSurface = {};
} }
std::optional<OutputLayerBeginFrameInfo> EglGbmLayerSurface::startRendering(const QSize &bufferSize, TextureTransforms transformation, const QMap<uint32_t, QVector<uint64_t>> &formats, const ColorDescription &colorDescription, const QVector3D &channelFactors) std::optional<OutputLayerBeginFrameInfo> EglGbmLayerSurface::startRendering(const QSize &bufferSize, TextureTransforms transformation, const QMap<uint32_t, QVector<uint64_t>> &formats, const ColorDescription &colorDescription, const QVector3D &channelFactors, bool enableColormanagement)
{ {
if (!checkSurface(bufferSize, formats)) { if (!checkSurface(bufferSize, formats)) {
return std::nullopt; return std::nullopt;
@ -102,7 +102,7 @@ std::optional<OutputLayerBeginFrameInfo> EglGbmLayerSurface::startRendering(cons
m_surface.intermediaryColorDescription = colorDescription; m_surface.intermediaryColorDescription = colorDescription;
} }
} }
if (m_surface.intermediaryColorDescription != colorDescription) { if (enableColormanagement) {
if (!m_surface.shadowBuffer) { if (!m_surface.shadowBuffer) {
m_surface.shadowTexture = std::make_shared<GLTexture>(GL_RGBA16F, m_surface.gbmSwapchain->size()); m_surface.shadowTexture = std::make_shared<GLTexture>(GL_RGBA16F, m_surface.gbmSwapchain->size());
m_surface.shadowBuffer = std::make_shared<GLFramebuffer>(m_surface.shadowTexture.get()); m_surface.shadowBuffer = std::make_shared<GLFramebuffer>(m_surface.shadowTexture.get());
@ -123,7 +123,7 @@ std::optional<OutputLayerBeginFrameInfo> EglGbmLayerSurface::startRendering(cons
bool EglGbmLayerSurface::endRendering(const QRegion &damagedRegion) 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()]; const auto &[texture, fbo] = m_surface.textureCache[m_surface.currentBuffer->bo()];
GLFramebuffer::pushFramebuffer(fbo.get()); GLFramebuffer::pushFramebuffer(fbo.get());
ShaderBinder binder(ShaderTrait::MapTexture | ShaderTrait::TransformColorspace); ShaderBinder binder(ShaderTrait::MapTexture | ShaderTrait::TransformColorspace);

View file

@ -48,7 +48,7 @@ public:
EglGbmLayerSurface(DrmGpu *gpu, EglGbmBackend *eglBackend, BufferTarget target = BufferTarget::Normal, FormatOption formatOption = FormatOption::PreferAlpha); EglGbmLayerSurface(DrmGpu *gpu, EglGbmBackend *eglBackend, BufferTarget target = BufferTarget::Normal, FormatOption formatOption = FormatOption::PreferAlpha);
~EglGbmLayerSurface(); ~EglGbmLayerSurface();
std::optional<OutputLayerBeginFrameInfo> startRendering(const QSize &bufferSize, TextureTransforms transformation, const QMap<uint32_t, QVector<uint64_t>> &formats, const ColorDescription &colorDescription, const QVector3D &channelFactors); std::optional<OutputLayerBeginFrameInfo> startRendering(const QSize &bufferSize, TextureTransforms transformation, const QMap<uint32_t, QVector<uint64_t>> &formats, const ColorDescription &colorDescription, const QVector3D &channelFactors, bool enableColormanagement);
bool endRendering(const QRegion &damagedRegion); bool endRendering(const QRegion &damagedRegion);
bool doesSurfaceFit(const QSize &size, const QMap<uint32_t, QVector<uint64_t>> &formats) const; bool doesSurfaceFit(const QSize &size, const QMap<uint32_t, QVector<uint64_t>> &formats) const;

View file

@ -479,7 +479,7 @@ DrmOutputLayer *DrmOutput::cursorLayer() const
bool DrmOutput::setGammaRamp(const std::shared_ptr<ColorTransformation> &transformation) bool DrmOutput::setGammaRamp(const std::shared_ptr<ColorTransformation> &transformation)
{ {
if (!m_pipeline->active() || m_pipeline->colorimetry() != NamedColorimetry::BT709 || m_pipeline->transferFunction() != NamedTransferFunction::sRGB) { if (!m_pipeline->active() || needsColormanagement()) {
return false; return false;
} }
m_pipeline->setGammaRamp(transformation); m_pipeline->setGammaRamp(transformation);
@ -500,7 +500,7 @@ bool DrmOutput::setChannelFactors(const QVector3D &rgb)
return true; return true;
} }
m_channelFactors = rgb; m_channelFactors = rgb;
if (m_pipeline->colorimetry() == NamedColorimetry::BT709 && m_pipeline->transferFunction() == NamedTransferFunction::sRGB) { if (needsColormanagement()) {
if (!m_pipeline->active()) { if (!m_pipeline->active()) {
return false; return false;
} }
@ -527,4 +527,9 @@ QVector3D DrmOutput::channelFactors() const
{ {
return m_channelFactors; return m_channelFactors;
} }
bool DrmOutput::needsColormanagement() const
{
return m_pipeline->colorimetry() != NamedColorimetry::BT709 || m_pipeline->transferFunction() != NamedTransferFunction::sRGB || m_gpu->isNVidia();
}
} }

View file

@ -62,6 +62,7 @@ public:
bool setGammaRamp(const std::shared_ptr<ColorTransformation> &transformation) override; bool setGammaRamp(const std::shared_ptr<ColorTransformation> &transformation) override;
bool setChannelFactors(const QVector3D &rgb) override; bool setChannelFactors(const QVector3D &rgb) override;
QVector3D channelFactors() const; QVector3D channelFactors() const;
bool needsColormanagement() const;
private: private:
bool setDrmDpmsMode(DpmsMode mode); bool setDrmDpmsMode(DpmsMode mode);