summaryrefslogtreecommitdiff
path: root/dri2proto.txt
blob: 7bde067fbef18f9ace23151f93727f62eb93a4d9 (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
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
			  The DRI2 Extension
			      Version 2.0
			      2008-09-04
      
			  Kristian Høgsberg
			    krh@redhat.com
			     Red Hat, Inc


1. Introduction

The DRI2 extension is designed to associate and access auxillary
rendering buffers with an X drawable.

DRI2 is a essentially a helper extension to support implementation of
direct rendering drivers/libraries/technologies.

The main consumer of this extension will be a direct rendering OpenGL
driver, but the DRI2 extension is not designed to be OpenGL specific.
Direct rendering implementations of OpenVG, Xv, cairo and other
graphics APIs should find the functionality exposed by this extension
helpful and hopefully sufficient.

Relation to XF86DRI


1.1. Acknowledgements

Kevin E. Martin <kem@redhat.com>
Keith Packard <keithp@keithp.com>
Eric Anholt <eric@anholt.net>
Keith Whitwell <keith@tungstengraphics.com>
Jerome Glisse <glisse@freedesktop.org>
Ian Romanick <ian.d.romanick@intel.com>
Michel Dänzer <michel@tungstengraphics.com>
Jesse Barnes <jbarnes@virtuousgeek.org>


			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙


2. DRI2 Concepts


2.1. Attachment points

Stolen from OpenGL FBOs, I guess.


2.2. Kernel rendering manager

This specification assumes a rendering architechture, where an
underlying kernel rendering manager that can provide 32 bit integer
handles to video memory buffers.  These handles can be passed between
processes, which, through a direct rendering driver, submit rendering
to the kernel rendering manager, targeting and/or sourcing from these
buffers.  This extension provides a means to communicate about such
buffers as associated with an X drawable.

The details of how the a direct rendering driver use the buffer names
and submit the rendering requests is outside the scope of this
specification.  However, Appendix B does discuss implementation of
this specification on the Graphics Execution Manager (GEM).


2.3. Request ordering

No ordering between swap buffers and X rendering.  X rendering to src
buffers will block if they have a vblank pending.


2.4 Authentication model

The purpose of the DRM authentication scheme is to grant access to the
kernel rendering manager buffers created by the X server if, and only
if, the client has access to the X server.  This is achieved in a
three-step protocol:

	1) The client gets a token from the kernel rendering manager
	that uniquely identifies it.  The token is a 32 bit integer.

	2) The client passes the token to the X server in the
	DRI2Authenticate request.  This request is a round trip to
	make sure the X server has received and processed the
	authentication before the client starts accessing the DRM.

	3) The X server authorizes the client by passing the token to
	the kernel rendering manager.

A kernel rendering manager can choose not to implement any
authentication and just allow access to all buffers.


2.5 Rendering to the X front buffer

OpenGL allows the client to render to the front buffer, either by
using a single-buffered configuration or but explicitly setting the
draw buffer to GL_FRONT_LEFT.  Not allowed!

The client must ask for a fake front buffer, render to that and then
use DRI2CopyRegion to copy contents back and forth between the fake
front buffer and the real front buffer.  When X and direct rendering
to a front buffer is interleaved, it is the responsibility of the
application to synchronize access using glXWaitGL and glXWaitX.  A
DRI2 implementation of direct rendering GLX, should use these enty
points to copy contents back and forth to as necessary to ensure
consistent rendering.

The client may also use the DRI2SwapBuffers function to request a swap
of the front and back buffers.  If the display server supports it, this
operation may be preferred, since it may be easier and/or more performant
for the server to perform a simple buffer swap rather than a blit.

2.6 Synchronizing rendering

DRI2 provides several methods for synchronizing drawing with various events.
The protocol for these methods is based on the SGI_video_sync and
OML_sync_control GLX extensions.  Using the DRI2WaitMSC request, a client
can wait for a specific frame count or divisor/remainder before continuing
its processing.  With the DRI2WaitSBC request, clients can block until a given
swap count is reached (as incremented by DRI2SwapBuffers).  Finally, using
DRI2SwapBuffers, clients can limit their frame rate by specifying a swap
interval using the swap interval call (currently only available through GLX)
or by using the OML swap buffers routine.

2.7 Events

DRI2 provides an event to indicate when a DRI2SwapBuffers request has
been completed.  This can be used to throttle drawing on the client
side and tie into application main loops.

Another event is generated when the validity of the requested buffers
changes.

			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙


3. Data Types

The server side region support specified in the Xfixes extension
version 2 is used in the CopyRegion request.


			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙


4. Errors

No errors are defined by the DRI2 extension.


			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙

5. Events

The only events provided by DRI2 are DRI2_BufferSwapComplete
and DRI2InvalidateBuffers.


			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙


6. Protocol Types

DRI2DRIVER { DRI2DriverDRI
	     DRI2DriverVDPAU }

	These values describe the type of driver the client will want
	to load.  The server sends back the name of the driver to use
	for the screen in question.

DRI2ATTACHMENT { DRI2BufferFrontLeft
	       	 DRI2BufferBackLeft
	       	 DRI2BufferFrontRight
	       	 DRI2BufferBackRight
	       	 DRI2BufferDepth
	       	 DRI2BufferStencil
	       	 DRI2BufferAccum
		 DRI2BufferFakeFrontLeft
		 DRI2BufferFakeFrontRight
		 DRI2BufferDepthStencil
		 DRI2BufferHiz }

	These values describe various attachment points for DRI2
	buffers.

DRI2BUFFER { attachment: CARD32
    	     name: CARD32
	     pitch: CARD32
    	     cpp: CARD32
	     flags: CARD32 }

	The DRI2BUFFER describes an auxillary rendering buffer
	associated with an X drawable.  'attachment' describes the
	attachment point for the buffer, 'name' is the name of the
	underlying kernel buffer,


DRI2ATTACH_FORMAT { attachment: CARD32
		    format:     CARD32 }

	The DRI2ATTACH_FORMAT describes an attachment and the associated
	format.  'attachment' describes the attachment point for the buffer,
	'format' describes an opaque, device-dependent format for the buffer.

			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙


7. Extension Initialization

The name of this extension is "DRI2".

┌───
    DRI2QueryVersion
	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, but also new value types in the DRI2CopyRegion
	request.  When new values are introduced, the minor version
	will be increased so the client can know which values the X
	server understands from the version number.


			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙


8. Extension Requests

┌───
    DRI2Connect
	window: WINDOW
	driverType: DRI2DRIVER
      ▶
	driver: STRING
	device: STRING
└───

	Returns the driver name and device file to use for the
	specified driver type for the screen associated with 'window'.

	'type' identifies the type of driver to query for.

	'driver' is the name of the driver to load.  The client is
	assumed to know where to look for the drivers and what to do
	with it.

	'device' is the filename of the DRM device file.

	If the client is not local, or the request driver type is
	unknown or not available, 'driver' and 'device' will be empty
	strings.  We are not using an regular X
	error here to indicate failure, which will allow the client
	fall back to other options more easily.

	ISSUE: We could add the list of supported attachments and the
	supported DRI2CopyRegion values here (just the bitmask of all
	supported values).
	
┌───
    DRI2Authenticate
	window: WINDOW
	token: CARD32
      ▶
        authenticated: CARD32
└───
	Errors: Window

	Request that the X server authenticates 'token', allowing the
	client to access the DRM buffers created by the X server on
	the screen associated with 'window'.

	Authentication shouldn't fail at this point, except if an
	invalid token is passed, in which case authenticated is False.

┌───
    DRI2GetBuffers
	drawable: DRAWABLE
	attachments: LISTofDRI2ATTACHMENTS
      ▶	
	width, height: CARD32
	buffers: LISTofDRI2BUFFER
└───
	Errors: Window

	Get buffers for the provided attachment points for the given
	drawable.

	If the DDX driver does not support one or more of the
	specified attachment points, a Value error is generated, with
	the first unsupported attachment point as the error value.

	'width' and 'height' describes the dimensions of the drawable.

	'buffers' is a list of DRI2BUFFER for the given DRI2
	attachment points.

┌───
    DRI2CopyRegion
	drawable: DRAWABLE
	region: REGION
	source: DRI2ATTACHMENT
	destination: DRI2ATTACHMENT
      ▶	
└───
	Errors: Window, Value

	Schedule a copy from one DRI2 buffer to another.

	The DRICopyRegion request has a reply but it is empty.  The
	reply is there to let the direct rendering client wait until
	the server has seen the request before proceeding with
	rendering the next frame.

┌───
    DRI2SwapBuffers
	drawable: DRAWABLE
      ▶	
	count: two CARD32s
└───
	Errors: Window

	Schedule a swap of the front and back buffers with the display
	server.

	Returns the swap count value when the swap will actually occur (e.g.
	the last queued swap count + (pending swap count * swap interval)).

	This request is only available with protocol version 1.2 or
	later.

┌───
    DRI2GetBuffersWithFormat
	drawable: DRAWABLE
	attachments: LISTofDRI2ATTACH_FORMAT
      ▶
	width, height: CARD32
	buffers: LISTofDRI2BUFFER
└───
	Errors: Window

	Get buffers for the provided attachment points with the specified
	formats for the given drawable.

	If the DDX driver does not support one or more of the
	specified attachment points or formats, a Value error is generated,
	with the first unsupported attachment point as the error value.

	'width' and 'height' describes the dimensions of the drawable.

	'buffers' is a list of DRI2BUFFER for the given DRI2
	attachment points.

	This request is only available with protocol version 1.1 or
	later.

┌───
    DRI2GetMSC
	drawable: DRAWABLE
      ▶
	ust, msc, sbc: CARD64
└───
	Errors: Window

	Get the current media stamp counter (MSC) and swap buffer count (SBC)
	along with the unadjusted system time (UST) when the MSC was last
	incremented.

	This request is only available with protocol version 1.2 or
	later.

┌───
    DRI2WaitMSC
	drawable: DRAWABLE
	target_msc: two CARD32s
	divisor: two CARD32s
	remainder: two CARD32s
      ▶
	ust, msc, sbc: CARD64
└───
	Errors: Window

	Blocks the client until either the frame count reaches target_msc or,
	if the frame count is already greater than target_msc when the request
	is received, until the frame count % divisor = remainder.  If divisor
	is 0, the client will be unblocked if the frame count is greater than
	or equal to the target_msc.

	Returns the current media stamp counter (MSC) and swap buffer count
	(SBC) along with the unadjusted system time (UST) when the MSC was last
	incremented.

	This request is only available with protocol version 1.2 or
	later.

┌───
    DRI2WaitSBC
	drawable: DRAWABLE
	target_sbc: two CARD32s
      ▶
	ust, msc, sbc: CARD64
└───
	Errors: Window

	Blocks the client until the swap buffer count reaches target_sbc.  If
	the swap buffer count is already greater than or equal to target_sbc
	when the request is recieved, this request will return immediately.

	If target_sbc is 0, this request will block the client until all
	previous DRI2SwapBuffers requests have completed.

	Returns the current media stamp counter (MSC) and swap buffer count
	(SBC) along with the unadjusted system time (UST) when the MSC was last
	incremented.

	This request is only available with protocol version 1.2 or
	later.

┌───
    DRI2SwapInterval
	drawable: DRAWABLE
	interval: CARD32
      ▶
└───
	Errors: Window

	Sets the swap interval for DRAWABLE.  This will throttle
	DRI2SwapBuffers requests to swap at most once per interval frames,
	which is useful useful for limiting the frame rate.

			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙

9. Extension Events

┌───
    DRI2BufferSwapComplete
      ▶
      	event_type: CARD16
	drawable: CARD32
	ust: CARD64
	msc: CARD64
	sbc: CARD64
└───

	This event reports the status of the last DRI2SwapBuffers event to
	the client.  The event type should be one of DRI2_EXCHANGE_COMPLETE,
	indicating a successful buffer exchange, DRI2_BLIT_COMPLETE, indicating
	the swap was performed with a blit, and DRI2_FLIP_COMPLETE, indicating
	a full page flip was completed.

┌───
    DRI2InvalidateBuffers
      ▶
	drawable: CARD32
└───

	This event is generated when the buffers the client had
	requested for 'drawable' (with DRI2GetBuffers or
	DRI2GetBuffersWithFormat) become inappropriate because they
	don't match the drawable dimensions anymore, or a buffer swap
	has been performed.

	Note that the server is only required to warn the client once
	about this condition, until the client takes care of bringing
	them back up-to-date with another GetBuffers request.

			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙

10. Extension Versioning

The DRI2 extension has undergone a number of revisions before

	1.0: Released, but never used.  Relied on a number of
		constructs from the XF86DRI extension, such as a
		shared memory area (SAREA) to communicate changes in
		cliprects and window sizes, and

	1.99.1: Move the swap buffer functionality into the X server,
		introduce SwapBuffer request to copy back buffer
		contents to the X drawable.

	1.99.2: Rethink the SwapBuffer request as an asynchronous
		request to copy a region between DRI2 buffers.  Drop
		CreateDrawable and DestroyDrawable, update Connect to
		support different driver types and to send the
		authentication group.

	1.99.3: Drop the bitmask argument intended to indicate
		presence of optional arguments for CopyRegion.

	2.0: Awesomeness!

	2.1: True excellence.  Added DRI2GetBuffersWithFormat to allow
             more flexible object creation.

	2.2: Approaching perfection.  Added requests for swapbuffers,
             MSC and SBC related requests, and events.

	2.3: Added the DRI2InvalidateBuffers event.

	2.6: Enlightenment attained.  Added the DRI2BufferHiz attachment.

Compatibility up to 2.0 is not preserved, but was also never released.


			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙


11. Relationship with other extensions

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


11.1 GLX

The GL auxilary buffers map directly to the DRI2 buffers... eh


11.2 DBE

The DBE back buffer must correspond to the DRI2_BUFFER_FRONT_LEFT
DRI2 buffer for servers that support both DBE and DRI2.


11.3 XvMC / Xv

We might add a DRI2_BUFFER_YUV to do vsynced colorspace conversion
blits.  Maybe... not really sure.


			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙


Appendix A. Protocol Encoding

Syntactic Conventions

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


A.1 Common Types

┌───
    DRI2DRIVER
	0x0	DRI2DriverDRI
	0x1	DRI2DriverVDPAU
└───

┌───
    DRI2ATTACHMENT
	0x0	DRI2BufferFrontLeft
	0x1	DRI2BufferBackLeft
	0x2	DRI2BufferFrontRight
	0x3	DRI2BufferBackRight
	0x4	DRI2BufferDepth
	0x5	DRI2BufferStencil
	0x6	DRI2BufferAccum
	0x7	DRI2BufferFakeFrontLeft
	0x8	DRI2BufferFakeFrontRight
	0x9	DRI2BufferDepthStencil
	0xa	DRI2BufferHiz
└───
	Used to encode the possible attachment points.  The attachment
	DRI2BufferDepthStencil is only available with protocol version 1.1 or
	later.

┌───
    DRI2BUFFER
	4	CARD32	attachment
	4	CARD32	name
	4	CARD32	pitch
	4	CARD32	cpp
	4	CARD32	flags
└───
	A DRI2 buffer specifies the attachment, the kernel memory
	manager name, the pitch and chars per pixel for a buffer
	attached to a given drawable.

┌───
    DRI2ATTACH_FORMAT
	4	CARD32	attachment
	4	CARD32	format
└───
	Used to describe the attachment and format requested from the server.
	This data type is only available with protocol version 1.1 or
	later.

A.2 Protocol Requests

┌───
    DRI2QueryVersion
	1	CARD8			major opcode
	1	0			DRI2 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	
└───

┌───
    DRI2Connect
	1	CARD8			major opcode
	1	1			DRI2 opcode
	2	3			length
	4	WINDOW			window
	4	CARD32			driver type
      ▶
	1	1			Reply
        1				unused
	2	CARD16			sequence number
	4	(n+m+p+q)/4		reply length
	4	n			driver name length
	4	m			device name length
	16				unused
	n	CARD8			driver name
	p				unused, p=pad(n)
	m	CARD8			device name
	q				unused, q=pad(m)
└───

┌───
    DRI2Authenticate
	1	CARD8			major opcode
	1	2			DRI2 opcode
	2	3			length
	4	WINDOW			window
	4	CARD32			authentication token
      ▶
	1	1			Reply
        1				unused
	2	CARD16			sequence number
	4	0			reply length
	4	CARD32			authenticated
	20				unused	
└───

┌───
    DRI2GetBuffers
	1	CARD8			major opcode
	1	5			DRI2 opcode
	2	3			length
	4	DRAWABLE		drawable
	4	n			number of attachments
	4n	LISTofDRI2ATTACHMENTS	attachments
      ▶	
	1	1			Reply
        1				unused
	2	CARD16			sequence number
	4	0			reply length
	4	CARD32			width of drawable
	4	CARD32			height of drawable
	4	CARD32			buffer count
	12				unused	
	5n	LISTofDRI2BUFFER	buffers
└───

┌───
    DRI2CopyRegion
	1	CARD8			major opcode
	1	6			DRI2 opcode
	2	3			length
	4	DRAWABLE		drawable
	4	REGION			region
	4	DRI2ATTACHMENT		source
	4	DRI2ATTACHMENT		destination
      ▶	
	1	1			Reply
        1				unused
	2	CARD16			sequence number
	4	0			reply length
	24				unused	
└───

┌───
    DRI2GetBuffersWithFormat
	1	CARD8			major opcode
	1	7			DRI2 opcode
	2	3			length
	4	DRAWABLE		drawable
	4	n			number of attachments
	8n	LISTofDRI2ATTACH_FORMAT	attachments and formats
      ▶
	1	1			Reply
       1				unused
	2	CARD16			sequence number
	4	0			reply length
	4	CARD32			width of drawable
	4	CARD32			height of drawable
	4	CARD32			buffer count
	12				unused	
	5n	LISTofDRI2BUFFER	buffers
└───

┌───
    DRI2SwapBuffers
	1	CARD8			major opcode
	1	8			DRI2 opcode
	2	8			length
	4	DRAWABLE		drawable
      ▶	
	1	1			Reply
        1				unused
	2	CARD16			sequence number
	4	0			reply length
	4	CARD32			buffer count
	4	CARD32			unused
	4	CARD32			unused
	4	CARD32			unused
	4	CARD32			unused
	4	CARD32			unused
	4	CARD32			unused
	5n	LISTofDRI2BUFFER	buffers
└───

┌───
    DRI2SwapBuffers
	1	CARD8			major opcode
	1	8			DRI2 opcode
	2	8			length
	4	DRAWABLE		drawable
	4	CARD32			target_msc_hi
	4	CARD32			target_msc_lo
	4	CARD32			divisor_hi
	4	CARD32			divisor_lo
	4	CARD32			remainder_hi
	4	CARD32			remainder_lo
      ▶	
	1	1			Reply
        1				unused
	2	CARD16			sequence number
	4	0			reply length
	4	CARD32			swap_hi
	4	CARD32			swap_lo
	5n	LISTofDRI2BUFFER	buffers
└───

┌───
    DRI2GetMSC
	1	CARD8			major opcode
	1	9			DRI2 opcode
	2	8			length
	4	DRAWABLE		drawable
      ▶
	1	1			Reply
        1				unused
	2	CARD16			sequence number
	4	0			reply length
	4	CARD32			ust_hi
	4	CARD32			ust_lo
	4	CARD32			msc_hi
	4	CARD32			msc_lo
	4	CARD32			sbc_hi
	4	CARD32			sbc_lo
└───

┌───
    DRI2WaitMSC
	1	CARD8			major opcode
	1	10			DRI2 opcode
	2	8			length
	4	DRAWABLE		drawable
	4	CARD32			target_msc_hi
	4	CARD32			target_msc_lo
	4	CARD32			divisor_hi
	4	CARD32			divisor_lo
	4	CARD32			remainder_hi
	4	CARD32			remainder_lo
      ▶
	1	1			Reply
        1				unused
	2	CARD16			sequence number
	4	0			reply length
	4	CARD32			ust_hi
	4	CARD32			ust_lo
	4	CARD32			msc_hi
	4	CARD32			msc_lo
	4	CARD32			sbc_hi
	4	CARD32			sbc_lo
└───

┌───
    DRI2WaitSBC
	1	CARD8			major opcode
	1	11			DRI2 opcode
	2	8			length
	4	DRAWABLE		drawable
 	4	CARD32			swap_hi
	4	CARD32			swap_lo
     ▶
	1	1			Reply
        1				unused
	2	CARD16			sequence number
	4	0			reply length
	4	CARD32			ust_hi
	4	CARD32			ust_lo
	4	CARD32			msc_hi
	4	CARD32			msc_lo
	4	CARD32			sbc_hi
	4	CARD32			sbc_lo
└───

┌───
    DRI2SwapInterval
	1	CARD8			major opcode
	1	12			DRI2 opcode
	2	8			length
	4	DRAWABLE		drawable
 	4	CARD32			interval
     ▶
└───

A.3 Protocol Events

The DRI2 extension specifies DRI2_BufferSwapComplete and
DRI2_InvalidateBuffers events.

┌───
    DRI2_BufferSwapComplete
	1	CARD8			type
	1	CARD8			extension
	2	CARD16			sequenceNumber
	2	CARD16			event_type
	4	DRAWABLE		drawable
	4	CARD32			ust_hi
	4	CARD32			ust_lo
	4	CARD32			msc_hi
	4	CARD32			msc_lo
	4	CARD32			sbc_hi
	4	CARD32			sbc_lo
└───


┌───
    DRI2_InvalidateBuffers
	1	CARD8			type
	1	CARD8			extension
	2	CARD16			sequenceNumber
	4	DRAWABLE		drawable
	4	CARD32			unused
	4	CARD32			unused
	4	CARD32			unused
	4	CARD32			unused
	4	CARD32			unused
	4	CARD32			unused
└───

A.4 Protocol Errors

The DRI2 extension specifies no errors.


			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙


Appendix B. Implementation on GEM

Where to begin...