diff --git a/plugins/platforms/drm/drm_backend.cpp b/plugins/platforms/drm/drm_backend.cpp --- a/plugins/platforms/drm/drm_backend.cpp +++ b/plugins/platforms/drm/drm_backend.cpp @@ -561,11 +561,20 @@ 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; } } diff --git a/plugins/platforms/drm/drm_output.cpp b/plugins/platforms/drm/drm_output.cpp --- a/plugins/platforms/drm/drm_output.cpp +++ b/plugins/platforms/drm/drm_output.cpp @@ -765,9 +765,6 @@ bool DrmOutput::present(DrmBuffer *buffer) { - if (!buffer || buffer->bufferId() == 0) { - return false; - } if (m_backend->atomicModeSetting()) { return presentAtomically(buffer); } else { @@ -816,14 +813,13 @@ 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 @@ } else { errno_save = errno; qCWarning(KWIN_DRM) << "Page flip failed:" << strerror(errno); - delete buffer; } return ok; }