[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
This commit is contained in:
parent
a49ba5054f
commit
d4423186b9
2 changed files with 11 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue