backends/drm: fix color management with sRGB output

We need to target the linear EOTF for rendering, even if the output EOTF
is sRGB
This commit is contained in:
Xaver Hugl 2023-06-14 12:59:29 +02:00
parent bc62760186
commit c112bb5c56
2 changed files with 5 additions and 3 deletions

View file

@ -89,12 +89,13 @@ std::optional<OutputLayerBeginFrameInfo> EglGbmLayerSurface::startRendering(cons
}
m_surface.currentBuffer = buffer;
if (m_surface.targetColorDescription != colorDescription || m_surface.channelFactors != channelFactors) {
if (m_surface.targetColorDescription != colorDescription || m_surface.channelFactors != channelFactors || m_surface.colormanagementEnabled != enableColormanagement) {
m_surface.gbmSwapchain->resetDamage();
repaint = infiniteRegion();
m_surface.colormanagementEnabled = enableColormanagement;
m_surface.targetColorDescription = colorDescription;
m_surface.channelFactors = channelFactors;
if (colorDescription != ColorDescription::sRGB) {
if (enableColormanagement) {
m_surface.intermediaryColorDescription = ColorDescription(colorDescription.colorimetry(), NamedTransferFunction::linear,
colorDescription.sdrBrightness(), colorDescription.minHdrBrightness(),
colorDescription.maxHdrBrightness(), colorDescription.maxHdrHighlightBrightness());
@ -126,7 +127,7 @@ std::optional<OutputLayerBeginFrameInfo> EglGbmLayerSurface::startRendering(cons
bool EglGbmLayerSurface::endRendering(const QRegion &damagedRegion)
{
if (m_surface.shadowTexture) {
if (m_surface.colormanagementEnabled) {
const auto &[texture, fbo] = m_surface.textureCache[m_surface.currentBuffer->bo()];
GLFramebuffer::pushFramebuffer(fbo.get());
ShaderBinder binder(ShaderTrait::MapTexture | ShaderTrait::TransformColorspace);

View file

@ -69,6 +69,7 @@ private:
};
struct Surface
{
bool colormanagementEnabled = false;
std::shared_ptr<GLTexture> shadowTexture;
std::shared_ptr<GLFramebuffer> shadowBuffer;
ColorDescription targetColorDescription = ColorDescription::sRGB;