Questions about XPresent

Po Lu luangruo at yahoo.com
Fri Oct 7 07:09:40 UTC 2022


Hello.  I have recently been working on a Wayland compositor that runs
on X, and have several questions about the presentation extension.

My compositor utilizes XRender for compositing subsurfaces with the
contents of a toplevel window, and _NET_WM_SYNC_REQUEST to handle frame
synchronization.  However, I would like to use the presentation
extension to efficiently copy surface contents provided by Wayland
clients to the X toplevel window when there is no need for any
compositing at all.

Since _NET_WM_SYNC_REQUEST is being used to provide frame
synchronization functionality, there is no need to have XPresent wait
for vblank before copying or flipping the pixmap contents onto the
toplevel window.  That is ensured by specifying PresentOptionAsync and a
target-msc of 0, which brings me to my first question.  The
documentation for PresentPixmap says:

	If 'options' contains PresentOptionAsync, and the 'target-msc'
	is less than or equal to the current msc for 'window', then
	the operation will be performed as soon as possible, not
	necessarily waiting for the next vertical blank interval.

What does the "necessarily" here mean?  That the presentation might
still wait for vblank, even if PresentOptionAsync is specified, and the
target MSC is less than the MSC of the window?

What will a following SyncSetCounter do?  Will the counter always be set
to the new value after the presentation happens and the window damage is
sent to the compositor?

My second question is about drawing to the window after presentation
happens.  When direct presentation becomes impossible (by, for example,
the Wayland client attaching a subsurface), then the results of any
previously made presentation must be overwritten by the following
Composite requests.  What happens if a Composite request is made,
targeting a window whose contents have been previously specified with
PresentPixmap, especially if the pixmap has been flipped and not copied?

Do I have to present an empty pixmap, wait for any PresentIdleNotify
for the previously attached pixmap, or what?  Or is there simply no safe
way to draw to a window after presenting a pixmap onto it?

That brings me to the third question.  Wouldn't a good optimization be
to "flip" the presented pixmap, if possible, into the contents of the
window pixmap if the window were to be redirected?  Compositing managers
would then be able to read from the window immediately after
presentation, without needing the contents of the presented pixmap to be
copied to the window pixmap first.

I also have another question not quite related to XPresent: is there a
way to be notified once a window is unredirected by the compositing
manager, because it is fullscreen and has no opaque region?

Thanks in advance.


More information about the xorg-devel mailing list