[compiz] [PATCH] Rendering: swap buffers and copy only needed parts

Pyry Haulos pyry.haulos at gmail.com
Fri Mar 16 23:20:12 PDT 2007


Hi,

I've been experiencing serious tearing in compiz when screen is painted only 
partly. Either "Sync To Vblank" option in compiz doesn't work or copying 
repainted parts from backbuffer to frontbuffer is too slow. And since many 
people rely on driver's implementation of Sync to Vblank, it would be optimal 
to always use glXSwapBuffers. This can be accomplished via keeping up-to-date 
copy of frontbuffer in backbuffer and painting updates over it.

My patch (swap-buffers-and-copy-only-needed.patch) keeps copy of last painted 
region and in case of partial screen repaint uses it to determine which parts 
should be copied from frontbuffer to backbuffer. Since region going to be 
painted this time is known, it can be substracted from last painted region. 
Thus only parts that were painted in previous pass and aren't going to be 
repainted, are copied saving expensive pixel copy operations.

Since glxCopySubBufferMESA does only implement copy-from-backbuffer (correct 
me if I'm wrong) it is no longer needed (remove-copySubBuffer.patch).

I've been using this a quite long time and it works generally well. Problem 
arises only when a plugin paints outside of the given region. For example 
screenshot (quick-n-dirty patch provided) and scale (shadows don't belong to 
damaged area, causing slowly darkening and finally solid black border around 
scaled windows) do that.

Pyry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: remove-copySubBuffer.patch
Type: text/x-diff
Size: 1444 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/compiz/attachments/20070317/b21ad045/remove-copySubBuffer.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: screenshot-dont-paint-outside-damage-region.patch
Type: text/x-diff
Size: 1523 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/compiz/attachments/20070317/b21ad045/screenshot-dont-paint-outside-damage-region.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: swap-buffers-and-copy-only-needed.patch
Type: text/x-diff
Size: 3567 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/compiz/attachments/20070317/b21ad045/swap-buffers-and-copy-only-needed.bin


More information about the compiz mailing list