Questions about XPresent

Po Lu luangruo at yahoo.com
Wed Oct 19 00:53:37 UTC 2022


Michel Dänzer <michel.daenzer at mailbox.org> writes:

> I'm thinking of this kind of scenario with a direct rendering compositor:
>
> 1. Compositor retrieves window pixmap, creates OpenGL texture object for it.
> 2. Client sends PresentPixmap request, which results in replacing the window pixmap.
> 3. Client starts drawing new frame to the old window pixmap buffer.
> 4. Compositor samples from texture object created in step 1.
>
>
> I did actually try this a while ago, and saw artifacts due to this issue.

Hmm, okay.  I don't want to work out yet another ugly synchronization
protocol, so how about this: the compositing manager makes a new
"CompositeRedirectSubwindowPresentation" request on the root window, and
receives every PresentPixmap request made by clients to a subwindow of
the root window.  It must then present the pixmap and send
completion/idle notify events itself.

That being said, there are definitely more details to work out here.
For example, as I said earlier, what if a client draws to the window
after PresentCompleteNotify?  In that case, a damage notification will
be generated, but the drawing will probably have been done to outdated
display contents, so the compositor must also tell the X server the the
pixmap that was presented in order for future drawing to work correctly.

Does that make any sense?  I'm thinking of a control flow that looks
like this, when the client draws to the window after a pixmap has been
presented by the compositor:

Client                  Server                  Compositing manager
PresentPixmap --------> PresentRequest -------> actually takes the pixmap
                                                specified and composites
                                                it to display.

        (window damage between PresentRequest and PresentCompleteNotify
         is ignored by the compositor.)

                         SetPresentedPixmap <--- compositing manager completes
PresentCompleteNotify <------------------------- presentation by "flipping".
XDrawRectangle --------> X server copies from
                         the presented pixmap
                         to the window's off
                         screen storage, and
                         then draws the
                         rectangle ------------> DamageNotify
PresentIdleNotify <----------------------------- compositing manager
                                                 composites the window
                                                 pixmap and sends
                                                 PresentIdleNotify for
                                                 previously flipped
                                                 pixmap.


More information about the xorg-devel mailing list