backends/drm: move tracking of legacy direct scanout presentation to DrmPipeline

The behavior between direct scanout and normal presentation being different is an
implementation detail of DrmPipeline, the output layers shouldn't need to care
This commit is contained in:
Xaver Hugl 2024-03-06 21:42:26 +01:00
parent 1d57c9a5af
commit 4a42829841
6 changed files with 8 additions and 14 deletions

View file

@ -160,11 +160,6 @@ std::shared_ptr<DrmFramebuffer> EglGbmLayer::currentBuffer() const
return m_scanoutBuffer ? m_scanoutBuffer : m_surface.currentBuffer();
}
bool EglGbmLayer::hasDirectScanoutBuffer() const
{
return m_scanoutBuffer != nullptr;
}
void EglGbmLayer::releaseBuffers()
{
m_scanoutBuffer.reset();

View file

@ -33,7 +33,6 @@ public:
bool scanout(SurfaceItem *surfaceItem) override;
bool checkTestBuffer() override;
std::shared_ptr<DrmFramebuffer> currentBuffer() const override;
bool hasDirectScanoutBuffer() const override;
QRegion currentDamage() const override;
std::shared_ptr<GLTexture> texture() const override;
ColorDescription colorDescription() const;

View file

@ -31,9 +31,4 @@ DrmPipelineLayer::DrmPipelineLayer(DrmPipeline *pipeline)
: m_pipeline(pipeline)
{
}
bool DrmPipelineLayer::hasDirectScanoutBuffer() const
{
return false;
}
}

View file

@ -38,7 +38,6 @@ public:
virtual bool checkTestBuffer() = 0;
virtual std::shared_ptr<DrmFramebuffer> currentBuffer() const = 0;
virtual bool hasDirectScanoutBuffer() const;
protected:
DrmPipeline *const m_pipeline;

View file

@ -70,7 +70,11 @@ bool DrmPipeline::testScanout()
}
// no other way to test than to do it.
// As we only have a maximum of one test per scanout cycle, this is fine
return presentLegacy() == Error::None;
const bool ret = presentLegacy() == Error::None;
if (ret) {
m_didLegacyScanoutHack = true;
}
return ret;
}
}
@ -98,8 +102,9 @@ DrmPipeline::Error DrmPipeline::present()
m_commitThread->addCommit(std::move(primaryPlaneUpdate));
return Error::None;
} else {
if (m_primaryLayer->hasDirectScanoutBuffer()) {
if (m_didLegacyScanoutHack) {
// already presented
m_didLegacyScanoutHack = false;
return Error::None;
}
return presentLegacy();

View file

@ -167,6 +167,7 @@ private:
DrmConnector *m_connector = nullptr;
bool m_modesetPresentPending = false;
bool m_didLegacyScanoutHack = false;
struct State
{