upgrade for xorg-server 1.12.99.905 (for 1.13 RC)
[framework/uifw/xorg/proto/x11proto-dri2.git] / dri2proto.txt
1                           The DRI2 Extension
2                               Version 2.0
3                               2008-09-04
4       
5                           Kristian Høgsberg
6                             krh@redhat.com
7                              Red Hat, Inc
8
9
10 1. Introduction
11
12 The DRI2 extension is designed to associate and access auxillary
13 rendering buffers with an X drawable.
14
15 DRI2 is a essentially a helper extension to support implementation of
16 direct rendering drivers/libraries/technologies.
17
18 The main consumer of this extension will be a direct rendering OpenGL
19 driver, but the DRI2 extension is not designed to be OpenGL specific.
20 Direct rendering implementations of OpenVG, Xv, cairo and other
21 graphics APIs should find the functionality exposed by this extension
22 helpful and hopefully sufficient.
23
24 Relation to XF86DRI
25
26
27 1.1. Acknowledgements
28
29 Kevin E. Martin <kem@redhat.com>
30 Keith Packard <keithp@keithp.com>
31 Eric Anholt <eric@anholt.net>
32 Keith Whitwell <keith@tungstengraphics.com>
33 Jerome Glisse <glisse@freedesktop.org>
34 Ian Romanick <ian.d.romanick@intel.com>
35 Michel Dänzer <michel@tungstengraphics.com>
36 Jesse Barnes <jbarnes@virtuousgeek.org>
37
38
39                              ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
40
41
42 2. DRI2 Concepts
43
44
45 2.1. Attachment points
46
47 Stolen from OpenGL FBOs, I guess.
48
49
50 2.2. Kernel rendering manager
51
52 This specification assumes a rendering architechture, where an
53 underlying kernel rendering manager that can provide 32 bit integer
54 handles to video memory buffers.  These handles can be passed between
55 processes, which, through a direct rendering driver, submit rendering
56 to the kernel rendering manager, targeting and/or sourcing from these
57 buffers.  This extension provides a means to communicate about such
58 buffers as associated with an X drawable.
59
60 The details of how the a direct rendering driver use the buffer names
61 and submit the rendering requests is outside the scope of this
62 specification.  However, Appendix B does discuss implementation of
63 this specification on the Graphics Execution Manager (GEM).
64
65
66 2.3. Request ordering
67
68 No ordering between swap buffers and X rendering.  X rendering to src
69 buffers will block if they have a vblank pending.
70
71
72 2.4 Authentication model
73
74 The purpose of the DRM authentication scheme is to grant access to the
75 kernel rendering manager buffers created by the X server if, and only
76 if, the client has access to the X server.  This is achieved in a
77 three-step protocol:
78
79         1) The client gets a token from the kernel rendering manager
80         that uniquely identifies it.  The token is a 32 bit integer.
81
82         2) The client passes the token to the X server in the
83         DRI2Authenticate request.  This request is a round trip to
84         make sure the X server has received and processed the
85         authentication before the client starts accessing the DRM.
86
87         3) The X server authorizes the client by passing the token to
88         the kernel rendering manager.
89
90 A kernel rendering manager can choose not to implement any
91 authentication and just allow access to all buffers.
92
93
94 2.5 Rendering to the X front buffer
95
96 OpenGL allows the client to render to the front buffer, either by
97 using a single-buffered configuration or but explicitly setting the
98 draw buffer to GL_FRONT_LEFT.  Not allowed!
99
100 The client must ask for a fake front buffer, render to that and then
101 use DRI2CopyRegion to copy contents back and forth between the fake
102 front buffer and the real front buffer.  When X and direct rendering
103 to a front buffer is interleaved, it is the responsibility of the
104 application to synchronize access using glXWaitGL and glXWaitX.  A
105 DRI2 implementation of direct rendering GLX, should use these enty
106 points to copy contents back and forth to as necessary to ensure
107 consistent rendering.
108
109 The client may also use the DRI2SwapBuffers function to request a swap
110 of the front and back buffers.  If the display server supports it, this
111 operation may be preferred, since it may be easier and/or more performant
112 for the server to perform a simple buffer swap rather than a blit.
113
114 2.6 Synchronizing rendering
115
116 DRI2 provides several methods for synchronizing drawing with various events.
117 The protocol for these methods is based on the SGI_video_sync and
118 OML_sync_control GLX extensions.  Using the DRI2WaitMSC request, a client
119 can wait for a specific frame count or divisor/remainder before continuing
120 its processing.  With the DRI2WaitSBC request, clients can block until a given
121 swap count is reached (as incremented by DRI2SwapBuffers).  Finally, using
122 DRI2SwapBuffers, clients can limit their frame rate by specifying a swap
123 interval using the swap interval call (currently only available through GLX)
124 or by using the OML swap buffers routine.
125
126 2.7 Events
127
128 DRI2 provides an event to indicate when a DRI2SwapBuffers request has
129 been completed.  This can be used to throttle drawing on the client
130 side and tie into application main loops.
131
132 Another event is generated when the validity of the requested buffers
133 changes.
134
135                              ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
136
137
138 3. Data Types
139
140 The server side region support specified in the Xfixes extension
141 version 2 is used in the CopyRegion request.
142
143
144                              ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
145
146
147 4. Errors
148
149 No errors are defined by the DRI2 extension.
150
151
152                              ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
153
154 5. Events
155
156 The only events provided by DRI2 are DRI2_BufferSwapComplete
157 and DRI2InvalidateBuffers.
158
159
160                              ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
161
162
163 6. Protocol Types
164
165 DRI2DRIVER { DRI2DriverDRI
166              DRI2DriverVDPAU }
167
168         These values describe the type of driver the client will want
169         to load.  The server sends back the name of the driver to use
170         for the screen in question.
171
172 DRI2ATTACHMENT { DRI2BufferFrontLeft
173                  DRI2BufferBackLeft
174                  DRI2BufferFrontRight
175                  DRI2BufferBackRight
176                  DRI2BufferDepth
177                  DRI2BufferStencil
178                  DRI2BufferAccum
179                  DRI2BufferFakeFrontLeft
180                  DRI2BufferFakeFrontRight
181                  DRI2BufferDepthStencil
182                  DRI2BufferHiz }
183
184         These values describe various attachment points for DRI2
185         buffers.
186
187 DRI2BUFFER { attachment: CARD32
188              name: CARD32
189              pitch: CARD32
190              cpp: CARD32
191              flags: CARD32 }
192
193         The DRI2BUFFER describes an auxillary rendering buffer
194         associated with an X drawable.  'attachment' describes the
195         attachment point for the buffer, 'name' is the name of the
196         underlying kernel buffer,
197
198
199 DRI2ATTACH_FORMAT { attachment: CARD32
200                     format:     CARD32 }
201
202         The DRI2ATTACH_FORMAT describes an attachment and the associated
203         format.  'attachment' describes the attachment point for the buffer,
204         'format' describes an opaque, device-dependent format for the buffer.
205
206                              ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
207
208
209 7. Extension Initialization
210
211 The name of this extension is "DRI2".
212
213 ┌───
214     DRI2QueryVersion
215         client-major-version:   CARD32
216         client-minor-version:   CARD32
217       ▶
218         major-version:          CARD32
219         minor-version:          CARD32
220 └───
221
222         The client sends the highest supported version to the server
223         and the server sends the highest version it supports, but no
224         higher than the requested version. Major versions changes can
225         introduce incompatibilities in existing functionality, minor
226         version changes introduce only backward compatible changes.
227         It is the clients responsibility to ensure that the server
228         supports a version which is compatible with its expectations.
229
230         Backwards compatible changes included addition of new
231         requests, but also new value types in the DRI2CopyRegion
232         request.  When new values are introduced, the minor version
233         will be increased so the client can know which values the X
234         server understands from the version number.
235
236
237                              ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
238
239
240 8. Extension Requests
241
242 ┌───
243     DRI2Connect
244         window: WINDOW
245         driverType: DRI2DRIVER
246       ▶
247         driver: STRING
248         device: STRING
249 └───
250
251         Returns the driver name and device file to use for the
252         specified driver type for the screen associated with 'window'.
253
254         'type' identifies the type of driver to query for.
255
256         'driver' is the name of the driver to load.  The client is
257         assumed to know where to look for the drivers and what to do
258         with it.
259
260         'device' is the filename of the DRM device file.
261
262         If the client is not local, or the request driver type is
263         unknown or not available, 'driver' and 'device' will be empty
264         strings.  We are not using an regular X
265         error here to indicate failure, which will allow the client
266         fall back to other options more easily.
267
268         ISSUE: We could add the list of supported attachments and the
269         supported DRI2CopyRegion values here (just the bitmask of all
270         supported values).
271         
272 ┌───
273     DRI2Authenticate
274         window: WINDOW
275         token: CARD32
276       ▶
277         authenticated: CARD32
278 └───
279         Errors: Window
280
281         Request that the X server authenticates 'token', allowing the
282         client to access the DRM buffers created by the X server on
283         the screen associated with 'window'.
284
285         Authentication shouldn't fail at this point, except if an
286         invalid token is passed, in which case authenticated is False.
287
288 ┌───
289     DRI2GetBuffers
290         drawable: DRAWABLE
291         attachments: LISTofDRI2ATTACHMENTS
292       ▶       
293         width, height: CARD32
294         buffers: LISTofDRI2BUFFER
295 └───
296         Errors: Window
297
298         Get buffers for the provided attachment points for the given
299         drawable.
300
301         If the DDX driver does not support one or more of the
302         specified attachment points, a Value error is generated, with
303         the first unsupported attachment point as the error value.
304
305         'width' and 'height' describes the dimensions of the drawable.
306
307         'buffers' is a list of DRI2BUFFER for the given DRI2
308         attachment points.
309
310 ┌───
311     DRI2CopyRegion
312         drawable: DRAWABLE
313         region: REGION
314         source: DRI2ATTACHMENT
315         destination: DRI2ATTACHMENT
316       ▶       
317 └───
318         Errors: Window, Value
319
320         Schedule a copy from one DRI2 buffer to another.
321
322         The DRICopyRegion request has a reply but it is empty.  The
323         reply is there to let the direct rendering client wait until
324         the server has seen the request before proceeding with
325         rendering the next frame.
326
327 ┌───
328     DRI2SwapBuffers
329         drawable: DRAWABLE
330       ▶       
331         count: two CARD32s
332 └───
333         Errors: Window
334
335         Schedule a swap of the front and back buffers with the display
336         server.
337
338         Returns the swap count value when the swap will actually occur (e.g.
339         the last queued swap count + (pending swap count * swap interval)).
340
341         This request is only available with protocol version 1.2 or
342         later.
343
344 ┌───
345     DRI2GetBuffersWithFormat
346         drawable: DRAWABLE
347         attachments: LISTofDRI2ATTACH_FORMAT
348       ▶
349         width, height: CARD32
350         buffers: LISTofDRI2BUFFER
351 └───
352         Errors: Window
353
354         Get buffers for the provided attachment points with the specified
355         formats for the given drawable.
356
357         If the DDX driver does not support one or more of the
358         specified attachment points or formats, a Value error is generated,
359         with the first unsupported attachment point as the error value.
360
361         'width' and 'height' describes the dimensions of the drawable.
362
363         'buffers' is a list of DRI2BUFFER for the given DRI2
364         attachment points.
365
366         This request is only available with protocol version 1.1 or
367         later.
368
369 ┌───
370     DRI2GetMSC
371         drawable: DRAWABLE
372       ▶
373         ust, msc, sbc: CARD64
374 └───
375         Errors: Window
376
377         Get the current media stamp counter (MSC) and swap buffer count (SBC)
378         along with the unadjusted system time (UST) when the MSC was last
379         incremented.
380
381         This request is only available with protocol version 1.2 or
382         later.
383
384 ┌───
385     DRI2WaitMSC
386         drawable: DRAWABLE
387         target_msc: two CARD32s
388         divisor: two CARD32s
389         remainder: two CARD32s
390       ▶
391         ust, msc, sbc: CARD64
392 └───
393         Errors: Window
394
395         Blocks the client until either the frame count reaches target_msc or,
396         if the frame count is already greater than target_msc when the request
397         is received, until the frame count % divisor = remainder.  If divisor
398         is 0, the client will be unblocked if the frame count is greater than
399         or equal to the target_msc.
400
401         Returns the current media stamp counter (MSC) and swap buffer count
402         (SBC) along with the unadjusted system time (UST) when the MSC was last
403         incremented.
404
405         This request is only available with protocol version 1.2 or
406         later.
407
408 ┌───
409     DRI2WaitSBC
410         drawable: DRAWABLE
411         target_sbc: two CARD32s
412       ▶
413         ust, msc, sbc: CARD64
414 └───
415         Errors: Window
416
417         Blocks the client until the swap buffer count reaches target_sbc.  If
418         the swap buffer count is already greater than or equal to target_sbc
419         when the request is recieved, this request will return immediately.
420
421         If target_sbc is 0, this request will block the client until all
422         previous DRI2SwapBuffers requests have completed.
423
424         Returns the current media stamp counter (MSC) and swap buffer count
425         (SBC) along with the unadjusted system time (UST) when the MSC was last
426         incremented.
427
428         This request is only available with protocol version 1.2 or
429         later.
430
431 ┌───
432     DRI2SwapInterval
433         drawable: DRAWABLE
434         interval: CARD32
435       ▶
436 └───
437         Errors: Window
438
439         Sets the swap interval for DRAWABLE.  This will throttle
440         DRI2SwapBuffers requests to swap at most once per interval frames,
441         which is useful useful for limiting the frame rate.
442
443 ┌───
444     DRI2GetParam
445         drawable: DRAWABLE
446         param: CARD32
447       ▶
448         is_param_recognized: BOOL
449         value: CARD64
450 └───
451         Errors: Drawable
452
453         Get the value of a parameter.  The parameter's value is looked up on
454         the screen associated with 'drawable'.
455
456         Parameter names in which the value of the most significant byte is
457         0 are reserved for the X server. Currently, no such parameter names
458         are defined. (When any such names are defined, they will be defined in
459         this extension specification and its associated headers).
460
461         Parameter names in which the byte's value is 1 are reserved for the
462         DDX. Such names are private to each driver and shall be defined in the
463         respective driver's headers.
464
465         Parameter names in which the byte's value is neither 0 nor 1 are
466         reserved for future use.
467
468         Possible values of 'is_param_recognized' are true (1) and false (0).
469         If false, then 'value' is undefined.
470
471         This request is only available with protocol version 1.4 or later.
472
473                              ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
474
475 9. Extension Events
476
477 ┌───
478     DRI2BufferSwapComplete
479       ▶
480         event_type: CARD16
481         drawable: CARD32
482         ust: CARD64
483         msc: CARD64
484         sbc: CARD64
485 └───
486
487         This event reports the status of the last DRI2SwapBuffers event to
488         the client.  The event type should be one of DRI2_EXCHANGE_COMPLETE,
489         indicating a successful buffer exchange, DRI2_BLIT_COMPLETE, indicating
490         the swap was performed with a blit, and DRI2_FLIP_COMPLETE, indicating
491         a full page flip was completed.
492
493 ┌───
494     DRI2InvalidateBuffers
495       ▶
496         drawable: CARD32
497 └───
498
499         This event is generated when the buffers the client had
500         requested for 'drawable' (with DRI2GetBuffers or
501         DRI2GetBuffersWithFormat) become inappropriate because they
502         don't match the drawable dimensions anymore, or a buffer swap
503         has been performed.
504
505         Note that the server is only required to warn the client once
506         about this condition, until the client takes care of bringing
507         them back up-to-date with another GetBuffers request.
508
509                              ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
510
511 10. Extension Versioning
512
513 The DRI2 extension has undergone a number of revisions before
514
515         1.0: Released, but never used.  Relied on a number of
516                 constructs from the XF86DRI extension, such as a
517                 shared memory area (SAREA) to communicate changes in
518                 cliprects and window sizes, and
519
520         1.99.1: Move the swap buffer functionality into the X server,
521                 introduce SwapBuffer request to copy back buffer
522                 contents to the X drawable.
523
524         1.99.2: Rethink the SwapBuffer request as an asynchronous
525                 request to copy a region between DRI2 buffers.  Drop
526                 CreateDrawable and DestroyDrawable, update Connect to
527                 support different driver types and to send the
528                 authentication group.
529
530         1.99.3: Drop the bitmask argument intended to indicate
531                 presence of optional arguments for CopyRegion.
532
533         2.0: Awesomeness!
534
535         2.1: True excellence.  Added DRI2GetBuffersWithFormat to allow
536              more flexible object creation.
537
538         2.2: Approaching perfection.  Added requests for swapbuffers,
539              MSC and SBC related requests, and events.
540
541         2.3: Added the DRI2InvalidateBuffers event.
542
543         2.6: Enlightenment attained.  Added the DRI2BufferHiz attachment.
544
545         2.7: Added the DRI2GetParam request.
546
547 Compatibility up to 2.0 is not preserved, but was also never released.
548
549
550                              ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
551
552
553 11. Relationship with other extensions
554
555 As an extension designed to support other extensions, there is
556 naturally some interactions with other extensions.
557
558
559 11.1 GLX
560
561 The GL auxilary buffers map directly to the DRI2 buffers... eh
562
563
564 11.2 DBE
565
566 The DBE back buffer must correspond to the DRI2_BUFFER_FRONT_LEFT
567 DRI2 buffer for servers that support both DBE and DRI2.
568
569
570 11.3 XvMC / Xv
571
572 We might add a DRI2_BUFFER_YUV to do vsynced colorspace conversion
573 blits.  Maybe... not really sure.
574
575
576                              ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
577
578
579 Appendix A. Protocol Encoding
580
581 Syntactic Conventions
582
583 This document uses the same syntactic conventions as the core X
584 protocol encoding document.
585
586
587 A.1 Common Types
588
589 ┌───
590     DRI2DRIVER
591         0x0     DRI2DriverDRI
592         0x1     DRI2DriverVDPAU
593 └───
594
595 ┌───
596     DRI2ATTACHMENT
597         0x0     DRI2BufferFrontLeft
598         0x1     DRI2BufferBackLeft
599         0x2     DRI2BufferFrontRight
600         0x3     DRI2BufferBackRight
601         0x4     DRI2BufferDepth
602         0x5     DRI2BufferStencil
603         0x6     DRI2BufferAccum
604         0x7     DRI2BufferFakeFrontLeft
605         0x8     DRI2BufferFakeFrontRight
606         0x9     DRI2BufferDepthStencil
607         0xa     DRI2BufferHiz
608 └───
609         Used to encode the possible attachment points.  The attachment
610         DRI2BufferDepthStencil is only available with protocol version 1.1 or
611         later.
612
613 ┌───
614     DRI2BUFFER
615         4       CARD32  attachment
616         4       CARD32  name
617         4       CARD32  pitch
618         4       CARD32  cpp
619         4       CARD32  flags
620 └───
621         A DRI2 buffer specifies the attachment, the kernel memory
622         manager name, the pitch and chars per pixel for a buffer
623         attached to a given drawable.
624
625 ┌───
626     DRI2ATTACH_FORMAT
627         4       CARD32  attachment
628         4       CARD32  format
629 └───
630         Used to describe the attachment and format requested from the server.
631         This data type is only available with protocol version 1.1 or
632         later.
633
634 A.2 Protocol Requests
635
636 ┌───
637     DRI2QueryVersion
638         1       CARD8                   major opcode
639         1       0                       DRI2 opcode
640         2       3                       length
641         4       CARD32                  major version
642         4       CARD32                  minor version
643       ▶
644         1       1                       Reply
645         1                               unused
646         2       CARD16                  sequence number
647         4       0                       reply length
648         4       CARD32                  major version
649         4       CARD32                  minor version
650         16                              unused  
651 └───
652
653 ┌───
654     DRI2Connect
655         1       CARD8                   major opcode
656         1       1                       DRI2 opcode
657         2       3                       length
658         4       WINDOW                  window
659         4       CARD32                  driver type
660       ▶
661         1       1                       Reply
662         1                               unused
663         2       CARD16                  sequence number
664         4       (n+m+p+q)/4             reply length
665         4       n                       driver name length
666         4       m                       device name length
667         16                              unused
668         n       CARD8                   driver name
669         p                               unused, p=pad(n)
670         m       CARD8                   device name
671         q                               unused, q=pad(m)
672 └───
673
674 ┌───
675     DRI2Authenticate
676         1       CARD8                   major opcode
677         1       2                       DRI2 opcode
678         2       3                       length
679         4       WINDOW                  window
680         4       CARD32                  authentication token
681       ▶
682         1       1                       Reply
683         1                               unused
684         2       CARD16                  sequence number
685         4       0                       reply length
686         4       CARD32                  authenticated
687         20                              unused  
688 └───
689
690 ┌───
691     DRI2GetBuffers
692         1       CARD8                   major opcode
693         1       5                       DRI2 opcode
694         2       3                       length
695         4       DRAWABLE                drawable
696         4       n                       number of attachments
697         4n      LISTofDRI2ATTACHMENTS   attachments
698       ▶       
699         1       1                       Reply
700         1                               unused
701         2       CARD16                  sequence number
702         4       0                       reply length
703         4       CARD32                  width of drawable
704         4       CARD32                  height of drawable
705         4       CARD32                  buffer count
706         12                              unused  
707         5n      LISTofDRI2BUFFER        buffers
708 └───
709
710 ┌───
711     DRI2CopyRegion
712         1       CARD8                   major opcode
713         1       6                       DRI2 opcode
714         2       3                       length
715         4       DRAWABLE                drawable
716         4       REGION                  region
717         4       DRI2ATTACHMENT          source
718         4       DRI2ATTACHMENT          destination
719       ▶       
720         1       1                       Reply
721         1                               unused
722         2       CARD16                  sequence number
723         4       0                       reply length
724         24                              unused  
725 └───
726
727 ┌───
728     DRI2GetBuffersWithFormat
729         1       CARD8                   major opcode
730         1       7                       DRI2 opcode
731         2       3                       length
732         4       DRAWABLE                drawable
733         4       n                       number of attachments
734         8n      LISTofDRI2ATTACH_FORMAT attachments and formats
735       ▶
736         1       1                       Reply
737        1                                unused
738         2       CARD16                  sequence number
739         4       0                       reply length
740         4       CARD32                  width of drawable
741         4       CARD32                  height of drawable
742         4       CARD32                  buffer count
743         12                              unused  
744         5n      LISTofDRI2BUFFER        buffers
745 └───
746
747 ┌───
748     DRI2SwapBuffers
749         1       CARD8                   major opcode
750         1       8                       DRI2 opcode
751         2       8                       length
752         4       DRAWABLE                drawable
753       ▶       
754         1       1                       Reply
755         1                               unused
756         2       CARD16                  sequence number
757         4       0                       reply length
758         4       CARD32                  buffer count
759         4       CARD32                  unused
760         4       CARD32                  unused
761         4       CARD32                  unused
762         4       CARD32                  unused
763         4       CARD32                  unused
764         4       CARD32                  unused
765         5n      LISTofDRI2BUFFER        buffers
766 └───
767
768 ┌───
769     DRI2SwapBuffers
770         1       CARD8                   major opcode
771         1       8                       DRI2 opcode
772         2       8                       length
773         4       DRAWABLE                drawable
774         4       CARD32                  target_msc_hi
775         4       CARD32                  target_msc_lo
776         4       CARD32                  divisor_hi
777         4       CARD32                  divisor_lo
778         4       CARD32                  remainder_hi
779         4       CARD32                  remainder_lo
780       ▶       
781         1       1                       Reply
782         1                               unused
783         2       CARD16                  sequence number
784         4       0                       reply length
785         4       CARD32                  swap_hi
786         4       CARD32                  swap_lo
787         5n      LISTofDRI2BUFFER        buffers
788 └───
789
790 ┌───
791     DRI2GetMSC
792         1       CARD8                   major opcode
793         1       9                       DRI2 opcode
794         2       8                       length
795         4       DRAWABLE                drawable
796       ▶
797         1       1                       Reply
798         1                               unused
799         2       CARD16                  sequence number
800         4       0                       reply length
801         4       CARD32                  ust_hi
802         4       CARD32                  ust_lo
803         4       CARD32                  msc_hi
804         4       CARD32                  msc_lo
805         4       CARD32                  sbc_hi
806         4       CARD32                  sbc_lo
807 └───
808
809 ┌───
810     DRI2WaitMSC
811         1       CARD8                   major opcode
812         1       10                      DRI2 opcode
813         2       8                       length
814         4       DRAWABLE                drawable
815         4       CARD32                  target_msc_hi
816         4       CARD32                  target_msc_lo
817         4       CARD32                  divisor_hi
818         4       CARD32                  divisor_lo
819         4       CARD32                  remainder_hi
820         4       CARD32                  remainder_lo
821       ▶
822         1       1                       Reply
823         1                               unused
824         2       CARD16                  sequence number
825         4       0                       reply length
826         4       CARD32                  ust_hi
827         4       CARD32                  ust_lo
828         4       CARD32                  msc_hi
829         4       CARD32                  msc_lo
830         4       CARD32                  sbc_hi
831         4       CARD32                  sbc_lo
832 └───
833
834 ┌───
835     DRI2WaitSBC
836         1       CARD8                   major opcode
837         1       11                      DRI2 opcode
838         2       8                       length
839         4       DRAWABLE                drawable
840         4       CARD32                  swap_hi
841         4       CARD32                  swap_lo
842      ▶
843         1       1                       Reply
844         1                               unused
845         2       CARD16                  sequence number
846         4       0                       reply length
847         4       CARD32                  ust_hi
848         4       CARD32                  ust_lo
849         4       CARD32                  msc_hi
850         4       CARD32                  msc_lo
851         4       CARD32                  sbc_hi
852         4       CARD32                  sbc_lo
853 └───
854
855 ┌───
856     DRI2SwapInterval
857         1       CARD8                   major opcode
858         1       12                      DRI2 opcode
859         2       8                       length
860         4       DRAWABLE                drawable
861         4       CARD32                  interval
862      ▶
863 └───
864
865 ┌───
866     DRI2GetParam
867         1       CARD8                   major opcode
868         1       13                      DRI2 opcode
869         2       8                       length
870         4       DRAWABLE                drawable
871         4       CARD32                  param
872      ▶
873         1       1                       Reply
874         1       BOOL                    is_param_recognized
875         2       CARD16                  sequence number
876         4       0                       reply length
877         4       CARD32                  value_hi
878         4       CARD32                  value_lo
879         16                              unused
880 └───
881
882 A.3 Protocol Events
883
884 The DRI2 extension specifies DRI2_BufferSwapComplete and
885 DRI2_InvalidateBuffers events.
886
887 ┌───
888     DRI2_BufferSwapComplete
889         1       CARD8                   type
890         1       CARD8                   extension
891         2       CARD16                  sequenceNumber
892         2       CARD16                  event_type
893         4       DRAWABLE                drawable
894         4       CARD32                  ust_hi
895         4       CARD32                  ust_lo
896         4       CARD32                  msc_hi
897         4       CARD32                  msc_lo
898         4       CARD32                  sbc_hi
899         4       CARD32                  sbc_lo
900 └───
901
902
903 ┌───
904     DRI2_InvalidateBuffers
905         1       CARD8                   type
906         1       CARD8                   extension
907         2       CARD16                  sequenceNumber
908         4       DRAWABLE                drawable
909         4       CARD32                  unused
910         4       CARD32                  unused
911         4       CARD32                  unused
912         4       CARD32                  unused
913         4       CARD32                  unused
914         4       CARD32                  unused
915 └───
916
917 A.4 Protocol Errors
918
919 The DRI2 extension specifies no errors.
920
921
922                              ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
923
924
925 Appendix B. Implementation on GEM
926
927 Where to begin...