[kwin] Use "buffer age" in QPainterDRMBackend
Open, LowPublic


The QPainterDRMBackend uses a double buffered setup. Thus we know which parts changed in last frame and don't need to repaint the complete buffer, but just the changes.

sitter added a subscriber: sitter.
graesslin triaged this task as Low priority.Jan 28 2017, 8:01 PM
graesslin added a project: KWin.
garg added a subscriber: garg.Jun 13 2017, 4:54 PM

I've been looking at this and wanted to make sure if I understood this correctly before writing a patch.

In order to implement this, we would need to adjust DrmQPainterBackend::needsFullRepaint to return false and then just adjust DrmQPainterBackend::present to use the damage region? Or is there more to this?

garg added a comment.EditedJun 13 2017, 9:10 PM

Oh, after reading the code a bit more, would it be more sensible to simply skip presenting the buffer if it hasn't changed? Something like so ( I couldn't quite figure out how else to compare two DrmDumbBuffers ) :

diff --git a/plugins/platforms/drm/scene_qpainter_drm_backend.cpp b/plugins/platforms/drm/scene_qpainter_drm_backend.cpp
index bf5a000a3..624fe42e6 100644
--- a/plugins/platforms/drm/scene_qpainter_drm_backend.cpp
+++ b/plugins/platforms/drm/scene_qpainter_drm_backend.cpp
@@ -106,6 +106,13 @@ void DrmQPainterBackend::present(int mask, const QRegion &damage)
     for (auto it = m_outputs.begin(); it != m_outputs.end(); ++it) {
         const Output &o = *it;
+        auto *old_buffer = o.buffer[o.index - 1]->image();
+        auto *new_buffer = o.buffer[o.index]->image();
+        if (*old_buffer == *new_buffer) {
+            continue;
+        }
         m_backend->present(o.buffer[o.index], o.output);

Not really you're doing a full pixel by pixel image comparison, that'll take more time than you'll save.

If you want to see if nothing changed you can check if damage is empty.

garg added a comment.Jun 15 2017, 12:02 PM

So I was thinking of somehow clipping the buffer that we present to the backend to only represent the damaged region. I'm not quite sure yet how to clip the QImage to the damaged QRegion we have, but does that sound sensible?

garg added a comment.Jun 20 2017, 10:43 AM

Poke? Could someone point me in the right direction here? :)