presentproto.txt revision 68872e7f
117ca54c3Smrg			The Present Extension
268872e7fSmrg			     Version 1.3
368872e7fSmrg			      2023-06-13
417ca54c3Smrg      
517ca54c3Smrg			    Keith Packard
617ca54c3Smrg			  keithp@keithp.com
717ca54c3Smrg			  Intel Corporation
817ca54c3Smrg
917ca54c3Smrg1. Introduction
1017ca54c3Smrg
1117ca54c3SmrgThe Present extension provides a way for applications to update their
1217ca54c3Smrgwindow contents from a pixmap in a well defined fashion, synchronizing
1317ca54c3Smrgwith the display refresh and potentially using a more efficient
1417ca54c3Smrgmechanism than copying the contents of the source pixmap.
1517ca54c3Smrg
1617ca54c3Smrg1.1. Future Present extension versions
1717ca54c3Smrg
1817ca54c3SmrgThis document includes speculation about future 'redirect' support
1917ca54c3Smrgwithin the Present extension. All such information is subject to
2017ca54c3Smrgchange and is provided only as an aid to further Present development.
2117ca54c3Smrg
2217ca54c3Smrg1.2. Acknowledgments
2317ca54c3Smrg
2417ca54c3SmrgEric Anholt <eric@anholt.net>
2517ca54c3SmrgOwen Taylor <otaylor@redhat.com>
2617ca54c3SmrgJames Jones <jajones@nvidia.com>
2717ca54c3SmrgLouis-Francis Ratté-Boulianne <lfrb@collabora.com>
2817ca54c3Smrg
2917ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 
3017ca54c3Smrg
3117ca54c3Smrg2. Data Types
3217ca54c3Smrg
3317ca54c3SmrgPRESENTEVENTID { XID }
3417ca54c3Smrg
3517ca54c3Smrg	Defines a unique event delivery target for Present
3617ca54c3Smrg	events. Multiple event IDs can be allocated to provide
3717ca54c3Smrg	multiple distinct event delivery contexts.
3817ca54c3Smrg
3917ca54c3SmrgPRESENTNOTIFY {
4017ca54c3Smrg	window: WINDOW
4117ca54c3Smrg	serial: CARD32
4217ca54c3Smrg	}
4317ca54c3Smrg
4417ca54c3Smrg	A list of these is passed to PresentPixmap; when the indicated
4517ca54c3Smrg	PresentPixmap completes, PresentCompletNotify events will be
4617ca54c3Smrg	delivered both to the PresentPixmap window/serial parameter as
4717ca54c3Smrg	well as each of the entries in the list of PRESENTNOTIFY parameter.
4817ca54c3Smrg
4917ca54c3SmrgPRESENTEVENTTYPE { PresentConfigureNotify,
5017ca54c3Smrg		   PresentCompleteNotify,
5117ca54c3Smrg		   PresentIdleNotify }
5217ca54c3Smrg
5317ca54c3SmrgPRESENTEVENTMASK { PresentConfigureNotifyMask,
5417ca54c3Smrg		   PresentCompleteNotifyMask,
5517ca54c3Smrg		   PresentIdleNotifyMask }
5617ca54c3Smrg
5717ca54c3SmrgPRESENTOPTION { PresentOptionAsync,
5817ca54c3Smrg                PresentOptionCopy,
5917ca54c3Smrg		PresentOptionUST,
6068872e7fSmrg		PresentOptionSuboptimal,
6168872e7fSmrg		PresentOptionAsyncMayTear }
6217ca54c3Smrg
6317ca54c3SmrgPRESENTCAPABILITY { PresentCapabilityAsync,
6417ca54c3Smrg		    PresentCapabilityFence,
6568872e7fSmrg		    PresentCapabilityUST,
6668872e7fSmrg		    PresentCapabilityAsyncMayTear }
6717ca54c3Smrg
6817ca54c3SmrgPRESENTCOMPLETEKIND { PresentCompleteKindPixmap,
6917ca54c3Smrg		      PresentCompleteKindMSCNotify }
7017ca54c3Smrg
7117ca54c3SmrgPRESENTCOMPLETEMODE { PresentCompleteModeCopy,
7217ca54c3Smrg		      PresentCompleteModeFlip,
7317ca54c3Smrg		      PresentCompleteModeSkip,
7417ca54c3Smrg		      PresentCompleteModeSuboptimalCopy }
7517ca54c3Smrg
7617ca54c3SmrgThe Present extension also uses the Sync extension Fence data type to
7717ca54c3Smrgprovide synchronization for pixmaps.
7817ca54c3Smrg
7917ca54c3Smrg2.1. Data Types proposed for a later Present extension version
8017ca54c3Smrg
8117ca54c3SmrgPRESENTEVENTTYPE { ...
8217ca54c3Smrg		   PresentRedirectNotify }
8317ca54c3Smrg
8417ca54c3SmrgPRESENTEVENTMASK { ...
8517ca54c3Smrg		   PresentSubredirectNotifyMask }
8617ca54c3Smrg
8717ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 
8817ca54c3Smrg
8917ca54c3Smrg3. Errors
9017ca54c3Smrg
9117ca54c3SmrgEventID
9217ca54c3Smrg	A value for an EventID argument does not name a defined EventID
9317ca54c3Smrg
9417ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 
9517ca54c3Smrg
9617ca54c3Smrg5. Events
9717ca54c3Smrg
9817ca54c3SmrgConfigureNotify events inform clients about window configuration
9917ca54c3Smrgchanges which can affect the allocation of window-related buffers.
10017ca54c3Smrg
10117ca54c3SmrgCompleteNotify events inform clients about the completion of a pending
10217ca54c3SmrgPresentPixmap request.
10317ca54c3Smrg
10417ca54c3SmrgIdleNotify events inform clients when pixmaps are available for re-use.
10517ca54c3Smrg
10617ca54c3Smrg5.1. Events proposed for a later Present extension version
10717ca54c3Smrg
10817ca54c3SmrgRedirectNotify events inform clients about other clients PresentPixmap
10917ca54c3Smrgrequests.
11017ca54c3Smrg
11117ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 
11217ca54c3Smrg
11317ca54c3Smrg6. Extension Initialization
11417ca54c3Smrg
11517ca54c3SmrgThe name of this extension is "Present"
11617ca54c3Smrg
11717ca54c3Smrg┌───
11817ca54c3Smrg    PresentQueryVersion
11917ca54c3Smrg	client-major-version:	CARD32
12017ca54c3Smrg	client-minor-version:	CARD32
12117ca54c3Smrg12217ca54c3Smrg	major-version:		CARD32
12317ca54c3Smrg	minor-version:		CARD32
12417ca54c3Smrg└───
12517ca54c3Smrg
12617ca54c3Smrg	The client sends the highest supported version to the server
12717ca54c3Smrg	and the server sends the highest version it supports, but no
12817ca54c3Smrg	higher than the requested version. Major versions changes can
12917ca54c3Smrg	introduce incompatibilities in existing functionality, minor
13017ca54c3Smrg	version changes introduce only backward compatible changes.
13117ca54c3Smrg	It is the clients responsibility to ensure that the server
13217ca54c3Smrg	supports a version which is compatible with its expectations.
13317ca54c3Smrg
13468872e7fSmrg	Backwards compatible changes include addition of new
13517ca54c3Smrg	requests.
13617ca54c3Smrg
13717ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 
13817ca54c3Smrg
13917ca54c3Smrg7. Extension Requests
14017ca54c3Smrg
14117ca54c3Smrg┌───
14217ca54c3Smrg    PresentPixmap
14317ca54c3Smrg	window: WINDOW
14417ca54c3Smrg	pixmap: PIXMAP
14517ca54c3Smrg	serial: CARD32
14617ca54c3Smrg	valid-area: REGION or None
14717ca54c3Smrg	update-area: REGION or None
14817ca54c3Smrg	x-off, y-off: INT16
14917ca54c3Smrg	target-crtc: CRTC or None
15017ca54c3Smrg	wait-fence: FENCE
15117ca54c3Smrg	idle-fence: FENCE
15217ca54c3Smrg	options: SETofPRESENTOPTION
15317ca54c3Smrg	target-msc: CARD64
15417ca54c3Smrg	divisor: CARD64
15517ca54c3Smrg	remainder: CARD64
15617ca54c3Smrg	notifies: LISTofPRESENTNOTIFY
15717ca54c3Smrg└───
15817ca54c3Smrg	Errors: Window, Pixmap, Match
15917ca54c3Smrg
16017ca54c3Smrg	Provides new content for the specified window, to be made
16117ca54c3Smrg	visible at the specified time (defined by 'target-msc', 'divisor'
16217ca54c3Smrg	and 'remainder'). If the depth of 'pixmap' and 'window' do not
16317ca54c3Smrg	match, a Match error will be generated.
16417ca54c3Smrg
16517ca54c3Smrg	'serial' is an arbitrary client-specified value which will
16617ca54c3Smrg	be returned in the associated PresentCompleteNotify event so
16717ca54c3Smrg	that the client can associate the event and request.
16817ca54c3Smrg
16917ca54c3Smrg	'valid-area' defines the portion of 'pixmap' which contains
17017ca54c3Smrg	valid window contents, or None if the pixmap contains valid
17117ca54c3Smrg	contents for the whole window.
17217ca54c3Smrg
17317ca54c3Smrg	'update-area' defines the subset of the window to be updated,
17417ca54c3Smrg	or None if the whole window is to be updated.
17517ca54c3Smrg
17617ca54c3Smrg	PresentPixmap may use any region of 'pixmap' which contains
17717ca54c3Smrg	'update-area' and which is contained by 'valid-area'. In other
17817ca54c3Smrg	words, areas inside 'update-area' will be presented from
17917ca54c3Smrg	'pixmap', areas outside 'valid-area' will not be presented
18017ca54c3Smrg	from 'pixmap' and areas inside 'valid-area' but outside
18117ca54c3Smrg	'update-area' may or may not be presented at the discretion of
18217ca54c3Smrg	the X server.
18317ca54c3Smrg
18417ca54c3Smrg	'x-off' and 'y-off' define the location in the window where
18517ca54c3Smrg	the 0,0 location of the pixmap will be presented. valid-area
18617ca54c3Smrg	and update-area are relative to the pixmap.
18717ca54c3Smrg
18817ca54c3Smrg	PresentPixmap will block until 'wait-fence' is triggered.
18917ca54c3Smrg	
19017ca54c3Smrg	When the X server has finished using 'pixmap' for this
19117ca54c3Smrg	operation, it will send a PresentIdleNotify event and arrange
19217ca54c3Smrg	for any 'idle-fence' to be triggered. This may be at any time
19317ca54c3Smrg	following the PresentPixmap request -- the contents may be
19417ca54c3Smrg	immediately copied to another buffer, copied just in time for
19517ca54c3Smrg	the vblank interrupt or the pixmap may be used directly for
19617ca54c3Smrg	display (in which case it will be busy until some future
19717ca54c3Smrg	PresentPixmap operation).
19817ca54c3Smrg
19917ca54c3Smrg	If 'idle-fence' is not None, then the client guarantees to the
20017ca54c3Smrg	X server that it will wait for that fence to be signalled
20117ca54c3Smrg	before it uses the pixmap again. If 'idle-fence' is None, then
20217ca54c3Smrg	the X server must arrange for the pixmap to be re-usable by
20317ca54c3Smrg	the client as soon as the PresentIdleNotify event has been
20417ca54c3Smrg	received. Note that if PresentCapabilityFence is set for the
20517ca54c3Smrg	associated CRTC, then clients should use fences to improve
206d63b911fSmrg	overall system performance. If PresentCapabilityFence is not
20717ca54c3Smrg	set, then using fences offers no benefit, but also no cost.
20817ca54c3Smrg
20917ca54c3Smrg	If 'target-msc' is greater than the current msc for 'window',
21017ca54c3Smrg	the presentation will occur at (or after) the 'target-msc'
21117ca54c3Smrg	field. Otherwise, the presentation will occur after the next
21217ca54c3Smrg	field where msc % 'divisor' == 'remainder'.
21317ca54c3Smrg	
21417ca54c3Smrg	If 'target-crtc' is None, then the X server will choose a
21517ca54c3Smrg	suitable CRTC for synchronization.
21617ca54c3Smrg	
21717ca54c3Smrg	If 'options' contains PresentOptionAsync, and the 'target-msc'
21817ca54c3Smrg	is less than or equal to the current msc for 'window', then
21917ca54c3Smrg	the operation will be performed as soon as possible, not
22068872e7fSmrg	necessarily waiting for the next vertical blank interval. If
22168872e7fSmrg	the target-crtc does not support PresentCapabilityAsyncMayTear,
22268872e7fSmrg	this may result in tearing.
22368872e7fSmrg
22468872e7fSmrg	If the target-crtc supports PresentCapabilityAsyncMayTear,
22568872e7fSmrg	'options' contains PresentOptionAsyncMayTear, and the 'target-msc'
22668872e7fSmrg	is less than or equal to the current msc for 'window', then
22768872e7fSmrg	the operation will be performed as soon as possible, not
22868872e7fSmrg	necessarily waiting for the next vertical blank interval, and
22968872e7fSmrg	possibly resulting in tearing.
23017ca54c3Smrg
23117ca54c3Smrg	If 'options' contains PresentOptionCopy, then 'pixmap' will be
23217ca54c3Smrg	idle, and 'idle-fence' triggered as soon as the operation occurs.
23317ca54c3Smrg
23417ca54c3Smrg	If 'options' contains PresentOptionUST, then target-msc,
23517ca54c3Smrg	divisor and remainder will all be interpreted as UST values
23617ca54c3Smrg	instead of MSC values and the frame update will be scheduled
23717ca54c3Smrg	for the specified UST time, If the target-crtc supports
23817ca54c3Smrg	PresentCapabilityUST, then the swap time will be as close to
23917ca54c3Smrg	the target time as the driver can manage. Otherwise, the
24017ca54c3Smrg	server will take the target UST time and convert it to a
24117ca54c3Smrg	suitable target MSC value.
24217ca54c3Smrg
24317ca54c3Smrg	If 'options' contains PresentOptionSuboptimal, then the
24417ca54c3Smrg	PresentCompleteNotify event can have mode
24517ca54c3Smrg	PresentCompleteModeSuboptimalCopy as the client supports it.
24617ca54c3Smrg
24717ca54c3Smrg	After the presentation occurs, a PresentCompleteNotify event
24817ca54c3Smrg	with kind PresentCompleteKindPixmap will be generated, both to
24917ca54c3Smrg	'window' as well as all members of 'notifies'.
25017ca54c3Smrg
25117ca54c3Smrg	If 'window' is destroyed before the presentation occurs, then
25217ca54c3Smrg	the presentation action will not be completed.
25317ca54c3Smrg
25417ca54c3Smrg	PresentPixmap holds a reference to 'pixmap' until the
25517ca54c3Smrg	presentation occurs, so 'pixmap' may be immediately freed
25617ca54c3Smrg	after the request executes, even if that is before the
25717ca54c3Smrg	presentation occurs.
25817ca54c3Smrg
25917ca54c3Smrg	If 'idle-fence' is destroyed before the presentation occurs,
26017ca54c3Smrg	then idle-fence will not be signaled but the presentation will
26117ca54c3Smrg	occur normally.
26217ca54c3Smrg
26317ca54c3Smrg	If 'wait-fence' is destroyed before it becomes triggered, then
26417ca54c3Smrg	the presentation operation will no longer wait for it and will
26517ca54c3Smrg	occur when the other conditions are satisfied.
26617ca54c3Smrg
26717ca54c3Smrg┌───
26817ca54c3Smrg    PresentNotifyMSC
26917ca54c3Smrg	window: WINDOW
27017ca54c3Smrg	serial: CARD32
27117ca54c3Smrg	target-msc: CARD64
27217ca54c3Smrg	divisor: CARD64
27317ca54c3Smrg	remainder: CARD64
27417ca54c3Smrg└───
27517ca54c3Smrg	Errors: Window
27617ca54c3Smrg
27717ca54c3Smrg	Delivers a PresentCompleteNotifyEvent with kind
27817ca54c3Smrg	PresentCompleteKindNotifyMSC after the time specified by
27968872e7fSmrg	'target-msc', 'divisor' and 'remainder'.
28017ca54c3Smrg
28117ca54c3Smrg	'serial' is an arbitrary client-specified value which will be
28217ca54c3Smrg	returned in the event so that the client can associate the
28317ca54c3Smrg	event and request.
28417ca54c3Smrg
28517ca54c3Smrg	If 'target-msc' is greater than the current msc for 'window',
28617ca54c3Smrg	the event will be delivered at (or after) the 'target-msc'
28717ca54c3Smrg	field. Otherwise, the event delivery will occur after the next
28817ca54c3Smrg	field where msc % 'divisor' == 'remainder'.
28917ca54c3Smrg	
29017ca54c3Smrg	If 'window' is destroyed before the event is delivered, then
29117ca54c3Smrg	the event delivery will not be completed.
29217ca54c3Smrg
29317ca54c3Smrg┌───
29417ca54c3Smrg    PresentSelectInput
29517ca54c3Smrg	event-id: PRESENTEVENTID
29617ca54c3Smrg	window: WINDOW
29717ca54c3Smrg	eventMask: SETofPRESENTEVENT
29817ca54c3Smrg└───
29917ca54c3Smrg	Errors: Window, Value, Match, IDchoice, Access
30017ca54c3Smrg
30117ca54c3Smrg	Selects the set of Present events to be delivered for the
30217ca54c3Smrg	specified window and event context. PresentSelectInput can
30317ca54c3Smrg	create, modify, or delete event contexts. An event context is
30417ca54c3Smrg	associated with a specific window; using an existing event
30517ca54c3Smrg	context with a different window generates a Match error.
30617ca54c3Smrg
30717ca54c3Smrg	If eventContext specifies an existing event context, then if
30817ca54c3Smrg	eventMask is empty, PresentSelectInput deletes the specified
30917ca54c3Smrg	context, otherwise the specified event context is changed to
31017ca54c3Smrg	select a different set of events.
31117ca54c3Smrg
31217ca54c3Smrg	If eventContext is an unused XID, then if eventMask is empty
31317ca54c3Smrg	no operation is performed. Otherwise, a new event context is
31417ca54c3Smrg	created selecting the specified events.
31517ca54c3Smrg
31617ca54c3Smrg┌───
31717ca54c3Smrg    PresentQueryCapabilities
31817ca54c3Smrg	target:			CRTC or WINDOW
31917ca54c3Smrg32017ca54c3Smrg	capabilities:		SETofPRESENTCAPABILITY
32117ca54c3Smrg└───
32217ca54c3Smrg	Errors: Window, CRTC
32317ca54c3Smrg
32417ca54c3Smrg	Returns the supported capabilities for the target CRTC.  If
32517ca54c3Smrg	'target' is a CRTC, then it is used as the target CRTC.  If
32617ca54c3Smrg	'target' is a WINDOW, then the target CRTC is selected by the
32717ca54c3Smrg	X server from among the CRTCs on the screen specified by the window.
32817ca54c3Smrg
32968872e7fSmrg	PresentCapabilityAsyncMayTear means that the target device may be
33068872e7fSmrg	able to flip the scanout buffer mid-frame instead of waiting for
33168872e7fSmrg	a vertical blank interval. The precise latency between the flip
33268872e7fSmrg	request and the actual scanout transition is not defined by this
33317ca54c3Smrg	specification, but is intended to be no more than a few
33417ca54c3Smrg	scanlines.
33517ca54c3Smrg
33668872e7fSmrg	If PresentCapabilityAsyncMayTear is not supported,
33768872e7fSmrg	PresentCapabilityAsync means the same as
33868872e7fSmrg	PresentCapabilityAsyncMayTear described above.
33968872e7fSmrg
34068872e7fSmrg	If PresentCapabilityAsyncMayTear is supported,
34168872e7fSmrg	PresentCapabilityAsync means that even if there is already a flip
34268872e7fSmrg	pending in the target device, it may be possible to replace that
34368872e7fSmrg	flip before the next vertical blank interval. The scanout buffer
34468872e7fSmrg	does not change mid-frame though, i.e. there is no tearing.
34568872e7fSmrg
34617ca54c3Smrg	PresentCapabilityFence means that the target device can take
34717ca54c3Smrg	advantage of SyncFences in the Present operations to improve
34817ca54c3Smrg	GPU throughput. The driver must operate correctly in the
34917ca54c3Smrg	absence of fences, but may have reduced performance. Using
35017ca54c3Smrg	fences for drivers not advertising this capability should have
35117ca54c3Smrg	no performance impact.
35217ca54c3Smrg
35317ca54c3Smrg	PresentCapabilityUST means that the target device can scanout
35417ca54c3Smrg	the image at an arbitrary UST time value, and is not driven by
35517ca54c3Smrg	a periodic scanout timer. Applications specifying UST times
35617ca54c3Smrg	for PresentPixmap can expect that their image will appear to
35717ca54c3Smrg	the user within a short amount of time from that specified in
35817ca54c3Smrg	the request. The precise accuracy of the scanout time is not
35917ca54c3Smrg	defined by the extension, but is expected to be on the order
36017ca54c3Smrg	of milliseconds or less.
36117ca54c3Smrg
36217ca54c3Smrg
36317ca54c3Smrg7.1 Requests proposed for a later Present extension version
36417ca54c3Smrg
36517ca54c3Smrg	These are not part of the standard and represent future plans
36617ca54c3Smrg	for the Present extension.
36717ca54c3Smrg
36817ca54c3Smrg┌───
36917ca54c3Smrg    PresentSelectInput
37017ca54c3Smrg    ...
37117ca54c3Smrg└───
37217ca54c3Smrg	...
37317ca54c3Smrg
37417ca54c3Smrg	Specifying PresentSubredirectNotify Mask causes PresentPixmap
37517ca54c3Smrg	requests on any child of 'window' from other clients to
37617ca54c3Smrg	generate PresentRedirectNotify events to 'window' instead of
37717ca54c3Smrg	actually performing the operation. However, only one client at
37817ca54c3Smrg	a time can select for PresentRedirect on a window. An attempt
37917ca54c3Smrg	to violate this restriction results in an Access error.
38017ca54c3Smrg
38117ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 
38217ca54c3Smrg
38317ca54c3Smrg8. Extension Events
38417ca54c3Smrg
38517ca54c3Smrg┌───
38617ca54c3Smrg    PresentConfigureNotify
38717ca54c3Smrg	type: CARD8			XGE event type (35)
38817ca54c3Smrg	extension: CARD8		Present extension request number
38917ca54c3Smrg	sequence-number: CARD16
39017ca54c3Smrg	length: CARD32			2
39117ca54c3Smrg	evtype: CARD16			Present_ConfigureNotify
39217ca54c3Smrg	eventID: PRESENTEVENTID
39317ca54c3Smrg	window: WINDOW
39417ca54c3Smrg	x: INT16
39517ca54c3Smrg	y: INT16
39617ca54c3Smrg	width: CARD16
39717ca54c3Smrg	height: CARD16
39817ca54c3Smrg	off_x: INT16
39917ca54c3Smrg	off_y: INT16
40017ca54c3Smrg	pixmap_width: CARD16
40117ca54c3Smrg	pixmap_height: CARD16
40217ca54c3Smrg	pixmap_flags: CARD32
40317ca54c3Smrg└───
40417ca54c3Smrg
40517ca54c3Smrg	PresentConfigureNotify events are sent when the window
40617ca54c3Smrg	configuration changes if PresentSelectInput has requested
40717ca54c3Smrg	it. PresentConfigureNotify events are XGE events and so do not
40817ca54c3Smrg	have a unique event type.
40917ca54c3Smrg
41017ca54c3Smrg	'x' and 'y' are the parent-relative location of 'window'. 
41117ca54c3Smrg
41217ca54c3Smrg┌───
41317ca54c3Smrg    PresentCompleteNotify
41417ca54c3Smrg	type: CARD8			XGE event type (35)
41517ca54c3Smrg	extension: CARD8		Present extension request number
41617ca54c3Smrg	sequence-number: CARD16
41717ca54c3Smrg	length: CARD32			2
41817ca54c3Smrg	evtype: PRESENTEVENTTYPE	PresentCompleteNotify
41917ca54c3Smrg	eventID: PRESENTEVENTID
42017ca54c3Smrg	window: WINDOW
42117ca54c3Smrg	kind: PRESENTCOMPLETEKIND
42217ca54c3Smrg	mode: PRESENTCOMPLETEMODE
42317ca54c3Smrg	serial: CARD32
42417ca54c3Smrg	ust: CARD64
42517ca54c3Smrg	msc: CARD64
42617ca54c3Smrg└───
42717ca54c3Smrg
42817ca54c3Smrg	CompleteNotify events are delivered when a PresentPixmap or
42917ca54c3Smrg	PresentNotifyMSC operation has completed.
43017ca54c3Smrg
43117ca54c3Smrg	'kind' is PresentCompleteKindPixmap when generated by a
43217ca54c3Smrg	PresentPixmap operation completion or
43317ca54c3Smrg	PresentCompleteKindNotifyMsc when generated by a
43417ca54c3Smrg	PresentNotifyMSC operation completion.
43517ca54c3Smrg
43617ca54c3Smrg	'mode' is PresentCompleteModeCopy when the source pixmap
43717ca54c3Smrg	contents are taken from the pixmap and the pixmap is idle
43817ca54c3Smrg	immediately after the presentation completes. 'mode' is
43917ca54c3Smrg	PresentCompleteModeSuboptimalCopy when the source pixmap
44017ca54c3Smrg	contents are copied but it would be possible to flip the
44117ca54c3Smrg	pixmap if the buffer format/modifier was different (options
44217ca54c3Smrg	given to PresentPixmap must contain PresentOptionSuboptimal).
44317ca54c3Smrg	'mode' is PresentCompleteModeFlip when the pixmap remains in-use
44417ca54c3Smrg	even after the presentation completes. It will become idle no
44517ca54c3Smrg	later than when the next PresentPixmap operation targeting the
44617ca54c3Smrg	same window by any client completes. If the presentation
44717ca54c3Smrg	operation was skipped because some later operation made it
44817ca54c3Smrg	irrelevant, then 'mode' will be PresentCompleteModeSkip.
44917ca54c3Smrg
45017ca54c3Smrg	'serial' is the value provided in the generating PresentPixmap
45117ca54c3Smrg	request.
45217ca54c3Smrg
45317ca54c3Smrg	'msc' and 'ust' indicate the frame count and system time when
45417ca54c3Smrg	the presentation actually occurred.
45517ca54c3Smrg
45617ca54c3Smrg┌───
45717ca54c3Smrg    PresentIdleNotify
45817ca54c3Smrg	type: CARD8			XGE event type (35)
45917ca54c3Smrg	extension: CARD8		Present extension request number
46017ca54c3Smrg	sequence-number: CARD16
46117ca54c3Smrg	length: CARD32			0
46217ca54c3Smrg	evtype: PRESENTEVENTTYPE	PresentIdleNotify
46317ca54c3Smrg	eventID: PRESENTEVENTID
46417ca54c3Smrg	window: WINDOW
46517ca54c3Smrg	serial: CARD32
46617ca54c3Smrg	pixmap: PIXMAP
46717ca54c3Smrg	idle-fence: FENCE
46817ca54c3Smrg└───
46917ca54c3Smrg
47017ca54c3Smrg	IdleNotify events are delivered when a pixmap used in a
47117ca54c3Smrg	PresentPixmap operation may be re-used by the client.
47217ca54c3Smrg
47317ca54c3Smrg	'window' is the window from the PresentPixmap to which this
47417ca54c3Smrg	event is delivered.
47517ca54c3Smrg
47617ca54c3Smrg	'serial' is the value provided in the associated PresentPixmap
47717ca54c3Smrg	request.
47817ca54c3Smrg
47917ca54c3Smrg	'pixmap' is the pixmap which is ready for re-use.
48017ca54c3Smrg
48117ca54c3Smrg	'idle-fence' is the fence which was provided in the
48217ca54c3Smrg	originating PresentPixmap request and is used to synchronize
48317ca54c3Smrg	rendering between the client and the X server's use of the
48417ca54c3Smrg	buffer. If not None, then the client must wait for the fence
48517ca54c3Smrg	to be signaled before using the pixmap.
48617ca54c3Smrg
48717ca54c3Smrg8.1. Extension Events proposed for a later Present extension version
48817ca54c3Smrg
48917ca54c3Smrg┌───
49017ca54c3Smrg    PresentRedirectNotify
49117ca54c3Smrg	type: CARD8			XGE event type (35)
49217ca54c3Smrg	extension: CARD8		Present extension request number
49317ca54c3Smrg	sequence-number: CARD16
49417ca54c3Smrg	length: CARD32			17 + 2 n
49517ca54c3Smrg	evtype: CARD16			Present_RedirectNotify
49617ca54c3Smrg	update-window: BOOL
49717ca54c3Smrg
49817ca54c3Smrg	eventID: PRESENTEVENTID
49917ca54c3Smrg	event-window: WINDOW
50017ca54c3Smrg	window: WINDOW
50117ca54c3Smrg	pixmap: PIXMAP
50217ca54c3Smrg	serial: CARD32
50317ca54c3Smrg
50417ca54c3Smrg	valid-area: REGION
50517ca54c3Smrg	update-area: REGION
50617ca54c3Smrg	valid-rect: RECTANGLE
50717ca54c3Smrg	update-rect: RECTANGLE
50817ca54c3Smrg	x-off, y-off: INT16
50917ca54c3Smrg	target-crtc: CRTC
51017ca54c3Smrg	wait-fence: FENCE
51117ca54c3Smrg	idle-fence: FENCE
51217ca54c3Smrg	options: SETofPRESENTOPTION
51317ca54c3Smrg	target-msc: CARD64
51417ca54c3Smrg	divisor: CARD64
51517ca54c3Smrg	remainder: CARD64
51617ca54c3Smrg	notifies: LISTofPRESENTNOTIFY
51717ca54c3Smrg└───
51817ca54c3Smrg
51917ca54c3Smrg	RedirectNotify events are delivered when the client has
52017ca54c3Smrg	selected for SubredirectNotify the parent of the target
52117ca54c3Smrg	window. All of the values provided to the PresentPixmap
52217ca54c3Smrg	request are provided. If the client simply passes these
52317ca54c3Smrg	parameters back to the X server, the effect will be as if the
52417ca54c3Smrg	original client executed the request.
52517ca54c3Smrg
52617ca54c3Smrg	If 'update-window' is TRUE, then there are clients who have
52717ca54c3Smrg	requested composite automatic redirect on the window and who
52817ca54c3Smrg	presumably expect the window buffer to eventually contain
52917ca54c3Smrg	the application provided contents. The compositing manager
53017ca54c3Smrg	should at least occasionally update the window buffer with
53117ca54c3Smrg	suitable contents. The precise update interval is left to the
53217ca54c3Smrg	discretion of the client receiving this event.
53317ca54c3Smrg
53417ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄
53517ca54c3Smrg
53617ca54c3Smrg9. Extension Versioning
53717ca54c3Smrg
53817ca54c3Smrg	1.0: First published version
53917ca54c3Smrg
54017ca54c3Smrg	1.2: Added PresentCompleteModeSuboptimalCopy flag and
54117ca54c3Smrg	     PresentOptionSuboptimal option
54217ca54c3Smrg
54317ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄
54417ca54c3Smrg
54517ca54c3Smrg
54617ca54c3Smrg10. Relationship with other extensions
54717ca54c3Smrg
54817ca54c3SmrgAs an extension designed to support other extensions, there is
54917ca54c3Smrgnaturally some interactions with other extensions.
55017ca54c3Smrg
55117ca54c3Smrg10.1 GLX
55217ca54c3Smrg
55317ca54c3SmrgGLX is both an application interface and an X extension. OpenGL
55417ca54c3Smrgapplications using the GLX API will use the GLX extension and may use
55517ca54c3Smrgthe Present extension to display application contents.
55617ca54c3Smrg
55717ca54c3Smrg10.2 DRI3
55817ca54c3Smrg
55917ca54c3SmrgThe DRI3 extension provides a way to share direct rendered pixel data
56017ca54c3Smrgwith the X server as X pixmaps. When used in conjunction with Present,
56117ca54c3Smrgthey provide a complete direct rendering solution for OpenGL or other
56217ca54c3SmrgAPIs.
56317ca54c3Smrg
56417ca54c3Smrg10.3 DRI2
56517ca54c3Smrg
56617ca54c3SmrgPresent provides similar functionality to the DRI2SwapBuffers and
56717ca54c3Smrgrequests, however Present uses X pixmaps to refer to the new window
56817ca54c3Smrgcontents instead of the DRI2 buffer attachments.
56917ca54c3Smrg
57068872e7fSmrgPresent and DRI3 are designed in conjunction to replace DRI2.
57117ca54c3Smrg
57217ca54c3Smrg10.4 XvMC / Xv
57317ca54c3Smrg
57417ca54c3SmrgIt might be nice to be able to use YUV formatted objects as Present
57517ca54c3Smrgsources.
57617ca54c3Smrg
57717ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄
57817ca54c3Smrg
57917ca54c3SmrgAppendix A. Protocol Encoding
58017ca54c3Smrg
58117ca54c3SmrgSyntactic Conventions
58217ca54c3Smrg
58317ca54c3SmrgThis document uses the same syntactic conventions as the core X
58417ca54c3Smrgprotocol encoding document.
58517ca54c3Smrg
58617ca54c3Smrg
58717ca54c3SmrgA.1 Common Types
58817ca54c3Smrg┌───
58917ca54c3Smrg    PresentEventType
59017ca54c3Smrg	0	PresentConfigureNotify
59117ca54c3Smrg	1	PresentCompleteNotify
59217ca54c3Smrg	2	PresentIdleNotify
59317ca54c3Smrg└───
59417ca54c3Smrg
59517ca54c3Smrg┌───
59617ca54c3Smrg    PresentEventMask
59717ca54c3Smrg	1	PresentConfigureNotifyMask
59817ca54c3Smrg	2	PresentCompleteNotifyMask
59917ca54c3Smrg	4	PresentIdleNotifyMask
60017ca54c3Smrg└───
60117ca54c3Smrg
60217ca54c3Smrg┌───
60317ca54c3Smrg    PresentOption
60417ca54c3Smrg	1	PresentOptionAsync
60517ca54c3Smrg	2	PresentOptionCopy;
60617ca54c3Smrg	4	PresentOptionUST
60717ca54c3Smrg	8	PresentOptionSuboptimal
60868872e7fSmrg	16	PresentOptionAsyncMayTear
60917ca54c3Smrg└───
61017ca54c3Smrg
61117ca54c3Smrg┌───
61217ca54c3Smrg    PresentCapability
61317ca54c3Smrg	1	PresentCapabilityAsync
61417ca54c3Smrg	2	PresentCapabilityFence
61517ca54c3Smrg	4	PresentCapabilityUST
61668872e7fSmrg	8	PresentCapabilityAsyncMayTear
61717ca54c3Smrg└───
61817ca54c3Smrg
61917ca54c3Smrg┌───
62017ca54c3Smrg    PresentCompleteKind
62117ca54c3Smrg	0	PresentCompleteKindPixmap
62217ca54c3Smrg	1	PresentCompleteKindMSCNotify
62317ca54c3Smrg└───
62417ca54c3Smrg
62517ca54c3Smrg┌───
62617ca54c3Smrg    PresentCompleteMode
62717ca54c3Smrg	0	PresentCompleteModeCopy
62817ca54c3Smrg	1	PresentCompleteModeFlip
62917ca54c3Smrg	2	PresentCompleteModeSkip
63017ca54c3Smrg	3	PresentCompleteModeSuboptimalCopy
63117ca54c3Smrg└───
63217ca54c3Smrg
63317ca54c3Smrg┌───
63417ca54c3Smrg    PresentNotify
63517ca54c3Smrg	4	Window			window
63617ca54c3Smrg	4	CARD32			serial
63717ca54c3Smrg└───
63817ca54c3Smrg
63917ca54c3SmrgA.1.1 Common Types proposed for a later Present extension version
64017ca54c3Smrg
64117ca54c3Smrg┌───
64217ca54c3Smrg    PresentEventType
64317ca54c3Smrg	...
64417ca54c3Smrg	3	PresentRedirectNotify
64517ca54c3Smrg└───
64617ca54c3Smrg
64717ca54c3Smrg┌───
64817ca54c3Smrg    PresentEventMask
64917ca54c3Smrg	...
65017ca54c3Smrg	8	PresentSubredirectNotifyMask
65117ca54c3Smrg└───
65217ca54c3Smrg
65317ca54c3SmrgA.2 Protocol Requests
65417ca54c3Smrg
65517ca54c3Smrg┌───
65617ca54c3Smrg    PresentQueryVersion
65717ca54c3Smrg	1	CARD8			major opcode
65817ca54c3Smrg	1	0			Present opcode
65917ca54c3Smrg	2	3			length
66017ca54c3Smrg	4	CARD32			major version
66117ca54c3Smrg	4	CARD32			minor version
66217ca54c3Smrg66317ca54c3Smrg	1	1			Reply
66417ca54c3Smrg        1				unused
66517ca54c3Smrg	2	CARD16			sequence number
66617ca54c3Smrg	4	0			reply length
66717ca54c3Smrg	4	CARD32			major version
66817ca54c3Smrg        4	CARD32			minor version
66917ca54c3Smrg	16				unused	
67017ca54c3Smrg└───
67117ca54c3Smrg
67217ca54c3Smrg┌───
67317ca54c3Smrg    PresentPixmap
67417ca54c3Smrg	1	CARD8			major opcode
67517ca54c3Smrg	1	1			Present opcode
67617ca54c3Smrg	2	18+2n			length
67717ca54c3Smrg	4	Window			window
67817ca54c3Smrg	4	Pixmap			pixmap
67917ca54c3Smrg	4	CARD32			serial
68017ca54c3Smrg	4	Region			valid-area
68117ca54c3Smrg	4	Region			update-area
68217ca54c3Smrg	2	INT16			x-off
68317ca54c3Smrg	2	INT16			y-off
68417ca54c3Smrg	4	CRTC			target-crtc
68517ca54c3Smrg	4	SyncFence		wait-fence
68617ca54c3Smrg	4	SyncFence		idle-fence
68717ca54c3Smrg	4	CARD32			options
68817ca54c3Smrg	4				unused
68917ca54c3Smrg	8	CARD64			target-msc
69017ca54c3Smrg	8	CARD64			divisor
69117ca54c3Smrg	8	CARD64			remainder
69217ca54c3Smrg	8n	LISTofPresentNotify	notifies
69317ca54c3Smrg└───
69417ca54c3Smrg
69517ca54c3Smrg┌───
69617ca54c3Smrg    PresentNotifyMSC
69717ca54c3Smrg	1	CARD8			major opcode
69817ca54c3Smrg	1	2			Present opcode
69917ca54c3Smrg	2	10			length
70017ca54c3Smrg	4	Window			window
70117ca54c3Smrg	4	CARD32			serial
70217ca54c3Smrg	4				unused
70317ca54c3Smrg	8	CARD64			target-msc
70417ca54c3Smrg	8	CARD64			divisor
70517ca54c3Smrg	8	CARD64			remainder
70617ca54c3Smrg└───
70717ca54c3Smrg
70817ca54c3Smrg┌───
70917ca54c3Smrg    PresentSelectInput
71017ca54c3Smrg	1	CARD8			major opcode
71117ca54c3Smrg	1	3			Present opcode
71217ca54c3Smrg	2	4			length
71317ca54c3Smrg	4	EventID			event-id
71417ca54c3Smrg	4	Window			window
71517ca54c3Smrg	4	SETofPRESENTEVENTMASK	event-mask
71617ca54c3Smrg└───
71717ca54c3Smrg
71817ca54c3Smrg┌───
71917ca54c3Smrg    PresentQueryCapabilities
72017ca54c3Smrg	1	CARD8			major opcode
72117ca54c3Smrg	1	4			Present opcode
72217ca54c3Smrg	2	2			length
72317ca54c3Smrg	4	CRTC or Window		target
72417ca54c3Smrg72517ca54c3Smrg	1	1			Reply
72617ca54c3Smrg        1				unused
72717ca54c3Smrg	2	CARD16			sequence number
72817ca54c3Smrg	4	0			reply length
72917ca54c3Smrg	4	SETofPRESENTCAPABILITY	capabilities
73017ca54c3Smrg└───
73117ca54c3Smrg
73217ca54c3SmrgA.3 Protocol Events
73317ca54c3Smrg
73417ca54c3Smrg┌───
73517ca54c3Smrg    PresentConfigureNotify
73617ca54c3Smrg	1	35			XGE
73717ca54c3Smrg	1	CARD8			Present extension opcode
73817ca54c3Smrg	2	CARD16			sequence number
73917ca54c3Smrg	4	2			length
74017ca54c3Smrg	2	0			PresentConfigureNotify
74117ca54c3Smrg	2				unused
74217ca54c3Smrg	4	CARD32			event id
74317ca54c3Smrg	4	Window			window
74417ca54c3Smrg	2	INT16			x
74517ca54c3Smrg	2	INT16			y
74617ca54c3Smrg	2	CARD16			width
74717ca54c3Smrg	2	CARD16			height
74817ca54c3Smrg	2	INT16			off x
74917ca54c3Smrg	2	INT16			off y
75017ca54c3Smrg
75117ca54c3Smrg	2	CARD16			pixmap width
75217ca54c3Smrg	2	CARD16			pixmap height
75317ca54c3Smrg	4	CARD32			pixmap flags
75417ca54c3Smrg└───
75517ca54c3Smrg
75617ca54c3Smrg┌───
75717ca54c3Smrg    PresentCompleteNotify
75817ca54c3Smrg	1	35			XGE
75917ca54c3Smrg	1	CARD8			Present extension opcode
76017ca54c3Smrg	2	CARD16			sequence number
76117ca54c3Smrg	4	2			length
76217ca54c3Smrg	2	1			PresentCompleteNotify
76317ca54c3Smrg	1	CARD8			kind
76417ca54c3Smrg	1	CARD8			mode
76517ca54c3Smrg	4	CARD32			event id
76617ca54c3Smrg	4	Window			window
76717ca54c3Smrg	4	CARD32			serial
76817ca54c3Smrg	8	CARD64			ust
76917ca54c3Smrg
77017ca54c3Smrg	8	CARD64			msc
77117ca54c3Smrg└───
77217ca54c3Smrg
77317ca54c3Smrg┌───
77417ca54c3Smrg    PresentIdleNotify
77517ca54c3Smrg	1	35			XGE
77617ca54c3Smrg	1	CARD8			Present extension opcode
77717ca54c3Smrg	2	CARD16			sequence number
77817ca54c3Smrg	4	0			length
77917ca54c3Smrg	2	2			PresentIdleNotify
78017ca54c3Smrg	2				unused
78117ca54c3Smrg	4	CARD32			event id
78217ca54c3Smrg	4	Window			window
78317ca54c3Smrg	4	CARD32			serial
78417ca54c3Smrg	4	Pixmap			pixmap
78517ca54c3Smrg	4	SyncFence		idle-fence
78617ca54c3Smrg└───
78717ca54c3Smrg
78817ca54c3SmrgA.3.1 Protocol Events proposed for later Present extension version
78917ca54c3Smrg
79017ca54c3Smrg┌───
79117ca54c3Smrg    PresentRedirectNotify
79217ca54c3Smrg	1	35			XGE
79317ca54c3Smrg	1	CARD8			Present extension opcode
79417ca54c3Smrg	2	CARD16			sequence number
79517ca54c3Smrg	4	18+2n			length
79617ca54c3Smrg	2	3			PresentRedirectNotify
79717ca54c3Smrg	1	BOOL			update-window
79817ca54c3Smrg	1				unused
79917ca54c3Smrg	4	CARD32			event id
80017ca54c3Smrg	4	Window			event-window
80117ca54c3Smrg	4	Window			window
80217ca54c3Smrg	4	Pixmap			pixmap
80317ca54c3Smrg	4	CARD32			serial
80417ca54c3Smrg
80517ca54c3Smrg	4	Region			valid-area
80617ca54c3Smrg	4	Region			update-area
80717ca54c3Smrg	8	Rectangle		valid-rect
80817ca54c3Smrg	8	Rectangle		update-rect
80917ca54c3Smrg	2	INT16			x-off
81017ca54c3Smrg	2	INT16			y-off
81117ca54c3Smrg	4	CRTC			target-crtc
81217ca54c3Smrg	4	SyncFence		wait-fence
81317ca54c3Smrg	4	SyncFence		idle-fence
81417ca54c3Smrg	4	CARD32			options
81517ca54c3Smrg	4				unused
81617ca54c3Smrg	8	CARD64			target-msc
81717ca54c3Smrg	8	CARD64			divisor
81817ca54c3Smrg	8	CARD64			remainder
81917ca54c3Smrg	8n	LISTofPRESENTNOTIFY	notifies
82017ca54c3Smrg└───
82117ca54c3Smrg
82217ca54c3SmrgA.4 Protocol Errors
82317ca54c3Smrg
82417ca54c3SmrgThe Present extension defines no errors.
82517ca54c3Smrg
82617ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄
827