[compiz] [PATCH] Rendering: swap buffers and copy only needed
parts
David Reveman
davidr at novell.com
Thu Mar 29 04:25:58 PDT 2007
On Sat, 2007-03-17 at 08:20 +0200, Pyry Haulos wrote:
> 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.
"Sync To Vblank" works perfectly for me last time I tried it. Your
driver need to support it. Direct rendering is required and nvidia's
driver is the only way to get this right now.
Relying on the driver to force "Sync To Vblank" when glXSwapBuffers is
called is usually a very bad idea as if used with indirect rendering it
most likely causes the X server to block when swapping buffers and this
has horrible performance affects on the X server.
>
> 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.
There's a few cases where this is very hard to prevent. The current
design relies on it being allowed to draw things outside the screen
region we're updating. It's especially important for the blur plugin.
- David
More information about the compiz
mailing list