Commit d4423186 authored by Roman Gilg's avatar Roman Gilg

[platforms/drm] Delete buffer on all errors in present

Summary:
When returning early in DrmOutput::present() because of some error KWin
didn't delete the proposed buffer, therefore not releasing the surface
lock of the GBM buffer to the EGL surface.

This patch makes sure that on any error in present we cleanup the proposed
DrmBuffer.

Reviewers: #kwin

Subscribers: #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D6660
parent a49ba505
......@@ -561,11 +561,20 @@ DrmOutput *DrmBackend::findOutput(const QByteArray &uuid)
void DrmBackend::present(DrmBuffer *buffer, DrmOutput *output)
{
if (!buffer || buffer->bufferId() == 0) {
if (m_deleteBufferAfterPageFlip) {
delete buffer;
}
return;
}
if (output->present(buffer)) {
m_pageFlipsPending++;
if (m_pageFlipsPending == 1 && Compositor::self()) {
Compositor::self()->aboutToSwapBuffers();
}
} else if (m_deleteBufferAfterPageFlip) {
delete buffer;
}
}
......
......@@ -765,9 +765,6 @@ void DrmOutput::pageFlipped()
bool DrmOutput::present(DrmBuffer *buffer)
{
if (!buffer || buffer->bufferId() == 0) {
return false;
}
if (m_backend->atomicModeSetting()) {
return presentAtomically(buffer);
} else {
......@@ -816,14 +813,13 @@ bool DrmOutput::presentAtomically(DrmBuffer *buffer)
if (!doAtomicCommit(AtomicCommitMode::Test)) {
//TODO: When we use planes for layered rendering, fallback to renderer instead. Also for direct scanout?
//TODO: Probably should undo setNext and reset the flip list
qCDebug(KWIN_DRM) << "Atomic test commit failed. Aborting present.";
if (this->m_backend->deleteBufferAfterPageFlip()) {
delete buffer;
}
return false;
}
if (!doAtomicCommit(AtomicCommitMode::Real)) {
qCDebug(KWIN_DRM) << "Atomic commit failed. This should have never happened! Aborting present.";
//TODO: Probably should undo setNext and reset the flip list
return false;
}
m_pageFlipPending = true;
......@@ -856,7 +852,6 @@ bool DrmOutput::presentLegacy(DrmBuffer *buffer)
} else {
errno_save = errno;
qCWarning(KWIN_DRM) << "Page flip failed:" << strerror(errno);
delete buffer;
}
return ok;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment