summaryrefslogtreecommitdiff
path: root/presentproto.txt
blob: 79bffb8ae6c95e3738f6af967e1d7cc38a2647d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
			The Present Extension
			     Version 1.0
			       2013-6-6
      
			    Keith Packard
			  keithp@keithp.com
			  Intel Corporation

1. Introduction

The Present extension provides a way for applications to update their
window contents from a pixmap in a well defined fashion, synchronizing
with the display refresh and potentially using a more efficient
mechanism than copying the contents of the source pixmap.

1.1. Acknowledgments

Eric Anholt <eric@anholt.net>
Owen Taylor <otaylor@redhat.com>
James Jones <janomes@nvidia.com>

			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 

2. Data Types

PRESENTEVENTID { XID }

	Defines a unique event delivery target for Present
	events. Multiple event IDs can be allocated to provide
	multiple distinct event delivery contexts.

PRESENTNOTIFY {
	window: WINDOW
	serial: CARD32
	}

	A list of these is passed to PresentPixmap; when the indicated
	PresentPixmap completes, PresentCompletNotify events will be
	delivered both to the PresentPixmap window/serial parameter as
	well as each of the entries in the list of PRESENTNOTIFY parameter.

PRESENTEVENTTYPE { PresentConfigureNotify,
		   PresentCompleteNotify,
		   PresentIdleNotify,
		   PresentRedirectNotify }

PRESENTEVENTMASK { PresentConfigureNotifyMask,
		   PresentCompleteNotifyMask,
		   PresentSubredirectNotifyMask }

PRESENTOPTION { PresentOptionAsync,
                PresentOptionCopy,
		PresentOptionUST }

PRESENTCAPABILITY { PresentCapabilityAsync,
		    PresentCapabilityFence,
		    PresentCapabilityUST }

PRESENTCOMPLETEKIND { PresentCompleteKindPixmap,
		      PresentCompleteKindMSCNotify }

PRESENTCOMPLETEMODE { PresentCompleteModeCopy,
		      PresentCompleteModeFlip,
		      PresentCompleteModeSkip }

The Present extension also uses the Sync extension Fence data type to
provide synchronization for pixmaps.

			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 

3. Errors

EventID
	A value for an EventID argument does not name a defined EventID

			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 

5. Events

ConfigureNotify events inform clients about window configuration
changes which can affect the allocation of window-related buffers.

CompleteNotify events inform clients about the completion of a pending
PresentPixmap request.

IdleNotify events inform clients when pixmaps are available for re-use.

RedirectNotify events inform clients about other clients PresentPixmap
requests.

			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 

6. Extension Initialization

The name of this extension is "Present"

┌───
    PresentQueryVersion
	client-major-version:	CARD32
	client-minor-version:	CARD32
      ▶
	major-version:		CARD32
	minor-version:		CARD32
└───

	The client sends the highest supported version to the server
	and the server sends the highest version it supports, but no
	higher than the requested version. Major versions changes can
	introduce incompatibilities in existing functionality, minor
	version changes introduce only backward compatible changes.
	It is the clients responsibility to ensure that the server
	supports a version which is compatible with its expectations.

	Backwards compatible changes included addition of new
	requests.

			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 

7. Extension Requests

┌───
    PresentPixmap
	window: WINDOW
	pixmap: PIXMAP
	serial: CARD32
	valid-area: REGION or None
	update-area: REGION or None
	x-off, y-off: INT16
	target-crtc: CRTC or None
	wait-fence: FENCE
	idle-fence: FENCE
	options: SETofPRESENTOPTION
	target-msc: CARD64
	divisor: CARD64
	remainder: CARD64
	notifies: LISTofPRESENTNOTIFY
└───
	Errors: Window, Pixmap, Match

	Provides new content for the specified window, to be made
	visible at the specified time (defined by 'target-msc', 'divisor'
	and 'remainder'). If the depth of 'pixmap' and 'window' do not
	match, a Match error will be generated.

	'serial' is an arbitrary client-specified value which will
	be returned in the associated PresentCompleteNotify event so
	that the client can associate the event and request.

	'valid-area' defines the portion of 'pixmap' which contains
	valid window contents, or None if the pixmap contains valid
	contents for the whole window.

	'update-area' defines the subset of the window to be updated,
	or None if the whole window is to be updated.

	PresentPixmap may use any region of 'pixmap' which contains
	'update-area' and which is contained by 'valid-area'. In other
	words, areas inside 'update-area' will be presented from
	'pixmap', areas outside 'valid-area' will not be presented
	from 'pixmap' and areas inside 'valid-area' but outside
	'update-area' may or may not be presented at the discretion of
	the X server.

	'x-off' and 'y-off' define the location in the window where
	the 0,0 location of the pixmap will be presented. valid-area
	and update-area are relative to the pixmap.

	PresentPixmap will block until 'wait-fence' is triggered.
	
	When the X server has finished using 'pixmap' for this
	operation, it will send a PresentIdleNotify event and arrange
	for any 'idle-fence' to be triggered. This may be at any time
	following the PresentPixmap request -- the contents may be
	immediately copied to another buffer, copied just in time for
	the vblank interrupt or the pixmap may be used directly for
	display (in which case it will be busy until some future
	PresentPixmap operation).

	If 'idle-fence' is not None, then the client guarantees to the
	X server that it will wait for that fence to be signalled
	before it uses the pixmap again. If 'idle-fence' is None, then
	the X server must arrange for the pixmap to be re-usable by
	the client as soon as the PresentIdleNotify event has been
	received. Note that if PresentCapabilityFence is set for the
	associated CRTC, then clients should use fences to improve
	overall systme performance. If PresentCapabilityFence is not
	set, then using fences offers no benefit, but also no cost.

	If 'target-msc' is greater than the current msc for 'window',
	the presentation will occur at (or after) the 'target-msc'
	field. Otherwise, the presentation will occur after the next
	field where msc % 'divisor' == 'remainder'.
	
	If 'target-crtc' is None, then the X server will choose a
	suitable CRTC for synchronization.
	
	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.

	If 'options' contains PresentOptionCopy, then 'pixmap' will be
	idle, and 'idle-fence' triggered as soon as the operation occurs.

	If 'options' contains PresentOptionUST, then target-msc,
	divisor and remainder will all be interpreted as UST values
	instead of MSC values and the frame update will be scheduled
	for the specified UST time, If the target-crtc supports
	PresentCapabilityUST, then the swap time will be as close to
	the target time as the driver can manage. Otherwise, the
	server will take the target UST time and convert it to a
	suitable target MSC value.

	After the presentation occurs, a PresentCompleteNotify event
	with kind PresentCompleteKindPixmap will be generated, both to
	'window' as well as all members of 'notifies'.

	If 'window' is destroyed before the presentation occurs, then
	the presentation action will not be completed.

	PresentPixmap holds a reference to 'pixmap' until the
	presentation occurs, so 'pixmap' may be immediately freed
	after the request executes, even if that is before the
	presentation occurs.

	If 'idle-fence' is destroyed before the presentation occurs,
	then idle-fence will not be signaled but the presentation will
	occur normally.

	If 'wait-fence' is destroyed before it becomes triggered, then
	the presentation operation will no longer wait for it and will
	occur when the other conditions are satisfied.

┌───
    PresentNotifyMSC
	window: WINDOW
	serial: CARD32
	target-msc: CARD64
	divisor: CARD64
	remainder: CARD64
└───
	Errors: Window

	Delivers a PresentCompleteNotifyEvent with kind
	PresentCompleteKindNotifyMSC after the time specified by
	'target-msc', 'divisor' and 'remainder').

	'serial' is an arbitrary client-specified value which will be
	returned in the event so that the client can associate the
	event and request.

	If 'target-msc' is greater than the current msc for 'window',
	the event will be delivered at (or after) the 'target-msc'
	field. Otherwise, the event delivery will occur after the next
	field where msc % 'divisor' == 'remainder'.
	
	If 'window' is destroyed before the event is delivered, then
	the event delivery will not be completed.

┌───
    PresentSelectInput
	event-id: PRESENTEVENTID
	window: WINDOW
	eventMask: SETofPRESENTEVENT
└───
	Errors: Window, Value, Match, IDchoice, Access

	Selects the set of Present events to be delivered for the
	specified window and event context. PresentSelectInput can
	create, modifiy or delete event contexts. An event context is
	associated with a specific window; using an existing event
	context with a different window generates a Match error.

	If eventContext specifies an existing event context, then if
	eventMask is empty, PresentSelectInput deletes the specified
	context, otherwise the specified event context is changed to
	select a different set of events.

	If eventContext is an unused XID, then if eventMask is empty
	no operation is performed. Otherwise, a new event context is
	created selecting the specified events.

	Specifying PresentSubredirectNotify Mask causes PresentPixmap
	requests on any child of 'window' from other clients to
	generate PresentRedirectNotify events to 'window' instead of
	actually performing the operation. However, only one client at
	a time can select for PresentRedirect on a window. An attempt
	to violate this restriction results in an Access error.

┌───
    PresentQueryCapabilities
	target:			CRTC or WINDOW
      ▶
	capabilities:		SETofPRESENTCAPABILITY
└───
	Errors: Window, CRTC

	Returns the supported capabilities for the target CRTC.  If
	'target' is a CRTC, then it is used as the target CRTC.  If
	'target' is a WINDOW, then the target CRTC is selected by the
	X server from among the CRTCs on the screen specified by the window.

	PresentCapabilityAsync means that the target device can flip
	the scanout buffer mid-frame instead of waiting for a vertical
	blank interval. The precise latency between the flip request
	and the actual scanout transition is not defined by this
	specification, but is intended to be no more than a few
	scanlines.

	PresentCapabilityFence means that the target device can take
	advantage of SyncFences in the Present operations to improve
	GPU throughput. The driver must operate correctly in the
	absense of fences, but may have reduced performance. Using
	fences for drivers not advertising this capability should have
	no performance impact.

	PresentCapabilityUST means that the target device can scanout
	the image at an arbitrary UST time value, and is not driven by
	a periodic scanout timer. Applications specifying UST times
	for PresentPixmap can expect that their image will appear to
	the user within a short amount of time from that specified in
	the request. The precise accuracy of the scanout time is not
	defined by the extension, but is expected to be on the order
	of milliseconds or less.

			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 

8. Extension Events

┌───
    PresentConfigureNotify
	type: CARD8			XGE event type (35)
	extension: CARD8		Present extension request number
	sequence-number: CARD16
	length: CARD32			2
	length: CARD16			2
	evtype: CARD16			Present_ConfigureNotify
	eventID: PRESENTEVENTID
	window: WINDOW
	x: INT16
	y: INT16
	width: CARD16
	height: CARD16
	off_x: INT16
	off_y: INT16
	pixmap_width: CARD16
	pixmap_height: CARD16
	pixmap_flags: CARD32
└───

	PresentConfigureNotify events are sent when the window
	configuration changes if PresentSelectInput has requested
	it. PresentConfigureNotify events are XGE events and so do not
	have a unique event type.

	'x' and 'y' are the parent-relative location of 'window'. 

┌───
    PresentCompleteNotify
	type: CARD8			XGE event type (35)
	extension: CARD8		Present extension request number
	sequence-number: CARD16
	length: CARD32			2
	evtype: PRESENTEVENTTYPE	PresentCompleteNotify
	eventID: PRESENTEVENTID
	window: WINDOW
	kind: PRESENTCOMPLETEKIND
	mode: PRESENTCOMPLETEMODE
	serial: CARD32
	ust: CARD64
	msc: CARD64
└───

	CompleteNotify events are delivered when a PresentPixmap or
	PresentNotifyMSC operation has completed.

	'kind' is PresentCompleteKindPixmap when generated by a
	PresentPixmap operation completion or
	PresentCompleteKindNotifyMsc when generated by a
	PresentNotifyMSC operation completion.

	'mode' is PresentCompleteModeCopy when the source pixmap
	contents are taken from the pixmap and the pixmap is idle
	immediately after the presentation completes. 'mode' is
	PresentCompleteModeFlip when the pixmap remains in-use even
	after the presentation completes. It will become idle no
	later than when the next PresentPixmap operation targeting the
	same window is performed by any client. If the presentation
	operation was skipped because some later operation made it
	irrelevant, then 'mode' will be PresentCompleteModeSkip.

	'serial' is the value provided in the generating PresentPixmap
	request.

	'msc' and 'ust' indicate the frame count and system time when
	the presentation actually occurred.

┌───
    PresentIdleNotify
	type: CARD8			XGE event type (35)
	extension: CARD8		Present extension request number
	sequence-number: CARD16
	length: CARD32			0
	evtype: PRESENTEVENTTYPE	PresentIdleNotify
	eventID: PRESENTEVENTID
	window: WINDOW
	serial: CARD32
	pixmap: PIXMAP
	idle-fence: FENCE
└───

	IdleNotify events are delivered when a pixmap used in a
	PresentPixmap operation may be re-used by the client.

	'window' is the window from the PresentPixmap to which this
	event is delivered.

	'serial' is the value provided in the associated PresentPixmap
	request.

	'pixmap' is the pixmap which is ready for re-use.

	'idle-fence' is the fence which was provided in the
	originating PresentPixmap request and is used to synchronize
	rendering between the client and the X server's use of the
	buffer. If not None, then the client must wait for the fence
	to be signaled before using the pixmap.

┌───
    PresentRedirectNotify
	type: CARD8			XGE event type (35)
	extension: CARD8		Present extension request number
	sequence-number: CARD16
	length: CARD32			16
	evtype: CARD16			Present_RedirectNotify
	update-window: CARD8

	eventID: PRESENTEVENTID
	event-window: WINDOW
	window: WINDOW
	pixmap: PIXMAP
	serial: CARD32

	valid-area: REGION
	update-area: REGION
	valid-rect: RECTANGLE
	update-rect: RECTANGLE
	x-off, y-off: INT16
	target-crtc: CRTC
	wait-fence: FENCE
	idle-fence: FENCE
	options: SETofPRESENTOPTION
	target_msc: CARD64
	divisor: CARD64
	remainder: CARD64
└───

	RedirectNotify events are delivered when the client has
	selected for SubredirectNotify the parent of the target
	window. All of the values provided to the PresentPixmap
	request are provided. If the client simply passes these
	parameters back to the X server, the effect will be as if the
	original client executed the request.


			     ❄ ❄ ❄  ❄  ❄ ❄ ❄

9. Extension Versioning

	1.0: First published version

			     ❄ ❄ ❄  ❄  ❄ ❄ ❄


10. Relationship with other extensions

As an extension designed to support other extensions, there is
naturally some interactions with other extensions.

10.1 GLX

GLX is both an application interface and an X extension. OpenGL
applications using the GLX API will use the GLX extension and may use
the Present extension to display application contents.

10.2 DRI3

The DRI3 extension provides a way to share direct rendered pixel data
with the X server as X pixmaps. When used in conjunction with Present,
they provide a complete direct rendering solution for OpenGL or other
APIs.

10.3 DRI2

Present provides similar functionality to the DRI2SwapBuffers and
requests, however Present uses X pixmaps to refer to the new window
contents instead of the DRI2 buffer attachments.

Present and DRI3 are designed in conjunction to replace DRI2

10.4 XvMC / Xv

It might be nice to be able to use YUV formatted objects as Present
sources.

			     ❄ ❄ ❄  ❄  ❄ ❄ ❄

Appendix A. Protocol Encoding

Syntactic Conventions

This document uses the same syntactic conventions as the core X
protocol encoding document.


A.1 Common Types

A.2 Protocol Requests

┌───
    PresentQueryVersion
	1	CARD8			major opcode
	1	0			Present opcode
	2	3			length
	4	CARD32			major version
	4	CARD32			minor version
      ▶
	1	1			Reply
        1				unused
	2	CARD16			sequence number
	4	0			reply length
	4	CARD32			major version
        4	CARD32			minor version
	16				unused	
└───


A.3 Protocol Events

┌───
    PresentConfigureNotify
	1	35			XGE
	1	CARD8			Present extension opcode
	2	CARD16			sequence number
	4	2			length
	2	0			PresentConfigureNotify
	2				unused
	4	CARD32			event id
	4	Window			window
	2	INT16			x
	2	INT16			y
	2	CARD16			width
	2	CARD16			height
	2	INT16			off x
	2	INT16			off y
	2	CARD16			pixmap width
	2	CARD16			pixmap height
	4	CARD32			pixmap flags
└───

┌───
    PresentCompleteNotify
	1	35			XGE
	1	CARD8			Present extension opcode
	2	CARD16			sequence number
	4	2			length
	2	1			PresentCompleteNotify
	2	CARD16			kind
	4	CARD32			event id
	4	Window			window
	4	CARD32			serial
	8	CARD64			ust
	8	CARD64			msc
└───

A.4 Protocol Errors

The DRI3 extension defines no errors.

			     ❄ ❄ ❄  ❄  ❄ ❄ ❄