upload tizen2.0 source
[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
445 9. Extension Events
446
447 ┌───
448     DRI2BufferSwapComplete
449       ▶
450         event_type: CARD16
451         drawable: CARD32
452         ust: CARD64
453         msc: CARD64
454         sbc: CARD64
455 └───
456
457         This event reports the status of the last DRI2SwapBuffers event to
458         the client.  The event type should be one of DRI2_EXCHANGE_COMPLETE,
459         indicating a successful buffer exchange, DRI2_BLIT_COMPLETE, indicating
460         the swap was performed with a blit, and DRI2_FLIP_COMPLETE, indicating
461         a full page flip was completed.
462
463 ┌───
464     DRI2InvalidateBuffers
465       ▶
466         drawable: CARD32
467 └───
468
469         This event is generated when the buffers the client had
470         requested for 'drawable' (with DRI2GetBuffers or
471         DRI2GetBuffersWithFormat) become inappropriate because they
472         don't match the drawable dimensions anymore, or a buffer swap
473         has been performed.
474
475         Note that the server is only required to warn the client once
476         about this condition, until the client takes care of bringing
477         them back up-to-date with another GetBuffers request.
478
479                              ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
480
481 10. Extension Versioning
482
483 The DRI2 extension has undergone a number of revisions before
484
485         1.0: Released, but never used.  Relied on a number of
486                 constructs from the XF86DRI extension, such as a
487                 shared memory area (SAREA) to communicate changes in
488                 cliprects and window sizes, and
489
490         1.99.1: Move the swap buffer functionality into the X server,
491                 introduce SwapBuffer request to copy back buffer
492                 contents to the X drawable.
493
494         1.99.2: Rethink the SwapBuffer request as an asynchronous
495                 request to copy a region between DRI2 buffers.  Drop
496                 CreateDrawable and DestroyDrawable, update Connect to
497                 support different driver types and to send the
498                 authentication group.
499
500         1.99.3: Drop the bitmask argument intended to indicate
501                 presence of optional arguments for CopyRegion.
502
503         2.0: Awesomeness!
504
505         2.1: True excellence.  Added DRI2GetBuffersWithFormat to allow
506              more flexible object creation.
507
508         2.2: Approaching perfection.  Added requests for swapbuffers,
509              MSC and SBC related requests, and events.
510
511         2.3: Added the DRI2InvalidateBuffers event.
512
513         2.6: Enlightenment attained.  Added the DRI2BufferHiz attachment.
514
515 Compatibility up to 2.0 is not preserved, but was also never released.
516
517
518                              ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
519
520
521 11. Relationship with other extensions
522
523 As an extension designed to support other extensions, there is
524 naturally some interactions with other extensions.
525
526
527 11.1 GLX
528
529 The GL auxilary buffers map directly to the DRI2 buffers... eh
530
531
532 11.2 DBE
533
534 The DBE back buffer must correspond to the DRI2_BUFFER_FRONT_LEFT
535 DRI2 buffer for servers that support both DBE and DRI2.
536
537
538 11.3 XvMC / Xv
539
540 We might add a DRI2_BUFFER_YUV to do vsynced colorspace conversion
541 blits.  Maybe... not really sure.
542
543
544                              ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
545
546
547 Appendix A. Protocol Encoding
548
549 Syntactic Conventions
550
551 This document uses the same syntactic conventions as the core X
552 protocol encoding document.
553
554
555 A.1 Common Types
556
557 ┌───
558     DRI2DRIVER
559         0x0     DRI2DriverDRI
560         0x1     DRI2DriverVDPAU
561 └───
562
563 ┌───
564     DRI2ATTACHMENT
565         0x0     DRI2BufferFrontLeft
566         0x1     DRI2BufferBackLeft
567         0x2     DRI2BufferFrontRight
568         0x3     DRI2BufferBackRight
569         0x4     DRI2BufferDepth
570         0x5     DRI2BufferStencil
571         0x6     DRI2BufferAccum
572         0x7     DRI2BufferFakeFrontLeft
573         0x8     DRI2BufferFakeFrontRight
574         0x9     DRI2BufferDepthStencil
575         0xa     DRI2BufferHiz
576 └───
577         Used to encode the possible attachment points.  The attachment
578         DRI2BufferDepthStencil is only available with protocol version 1.1 or
579         later.
580
581 ┌───
582     DRI2BUFFER
583         4       CARD32  attachment
584         4       CARD32  name
585         4       CARD32  pitch
586         4       CARD32  cpp
587         4       CARD32  flags
588 └───
589         A DRI2 buffer specifies the attachment, the kernel memory
590         manager name, the pitch and chars per pixel for a buffer
591         attached to a given drawable.
592
593 ┌───
594     DRI2ATTACH_FORMAT
595         4       CARD32  attachment
596         4       CARD32  format
597 └───
598         Used to describe the attachment and format requested from the server.
599         This data type is only available with protocol version 1.1 or
600         later.
601
602 A.2 Protocol Requests
603
604 ┌───
605     DRI2QueryVersion
606         1       CARD8                   major opcode
607         1       0                       DRI2 opcode
608         2       3                       length
609         4       CARD32                  major version
610         4       CARD32                  minor version
611       ▶
612         1       1                       Reply
613         1                               unused
614         2       CARD16                  sequence number
615         4       0                       reply length
616         4       CARD32                  major version
617         4       CARD32                  minor version
618         16                              unused  
619 └───
620
621 ┌───
622     DRI2Connect
623         1       CARD8                   major opcode
624         1       1                       DRI2 opcode
625         2       3                       length
626         4       WINDOW                  window
627         4       CARD32                  driver type
628       ▶
629         1       1                       Reply
630         1                               unused
631         2       CARD16                  sequence number
632         4       (n+m+p+q)/4             reply length
633         4       n                       driver name length
634         4       m                       device name length
635         16                              unused
636         n       CARD8                   driver name
637         p                               unused, p=pad(n)
638         m       CARD8                   device name
639         q                               unused, q=pad(m)
640 └───
641
642 ┌───
643     DRI2Authenticate
644         1       CARD8                   major opcode
645         1       2                       DRI2 opcode
646         2       3                       length
647         4       WINDOW                  window
648         4       CARD32                  authentication token
649       ▶
650         1       1                       Reply
651         1                               unused
652         2       CARD16                  sequence number
653         4       0                       reply length
654         4       CARD32                  authenticated
655         20                              unused  
656 └───
657
658 ┌───
659     DRI2GetBuffers
660         1       CARD8                   major opcode
661         1       3                       DRI2 opcode
662         2       3                       length
663         4       DRAWABLE                drawable
664         4       n                       number of attachments
665         4n      LISTofDRI2ATTACHMENTS   attachments
666       ▶       
667         1       1                       Reply
668         1                               unused
669         2       CARD16                  sequence number
670         4       0                       reply length
671         4       CARD32                  width of drawable
672         4       CARD32                  height of drawable
673         4       CARD32                  buffer count
674         12                              unused  
675         5n      LISTofDRI2BUFFER        buffers
676 └───
677
678 ┌───
679     DRI2CopyRegion
680         1       CARD8                   major opcode
681         1       4                       DRI2 opcode
682         2       3                       length
683         4       DRAWABLE                drawable
684         4       REGION                  region
685         4       DRI2ATTACHMENT          source
686         4       DRI2ATTACHMENT          destination
687       ▶       
688         1       1                       Reply
689         1                               unused
690         2       CARD16                  sequence number
691         4       0                       reply length
692         24                              unused  
693 └───
694
695 ┌───
696     DRI2GetBuffersWithFormat
697         1       CARD8                   major opcode
698         1       3                       DRI2 opcode
699         2       3                       length
700         4       DRAWABLE                drawable
701         4       n                       number of attachments
702         8n      LISTofDRI2ATTACH_FORMAT attachments and formats
703       ▶
704         1       1                       Reply
705        1                                unused
706         2       CARD16                  sequence number
707         4       0                       reply length
708         4       CARD32                  width of drawable
709         4       CARD32                  height of drawable
710         4       CARD32                  buffer count
711         12                              unused  
712         5n      LISTofDRI2BUFFER        buffers
713 └───
714
715 ┌───
716     DRI2SwapBuffers
717         1       CARD8                   major opcode
718         1       7                       DRI2 opcode
719         2       8                       length
720         4       DRAWABLE                drawable
721       ▶       
722         1       1                       Reply
723         1                               unused
724         2       CARD16                  sequence number
725         4       0                       reply length
726         4       CARD32                  buffer count
727         4       CARD32                  unused
728         4       CARD32                  unused
729         4       CARD32                  unused
730         4       CARD32                  unused
731         4       CARD32                  unused
732         4       CARD32                  unused
733         5n      LISTofDRI2BUFFER        buffers
734 └───
735
736 ┌───
737     DRI2SwapBuffers
738         1       CARD8                   major opcode
739         1       7                       DRI2 opcode
740         2       8                       length
741         4       DRAWABLE                drawable
742         4       CARD32                  target_msc_hi
743         4       CARD32                  target_msc_lo
744         4       CARD32                  divisor_hi
745         4       CARD32                  divisor_lo
746         4       CARD32                  remainder_hi
747         4       CARD32                  remainder_lo
748       ▶       
749         1       1                       Reply
750         1                               unused
751         2       CARD16                  sequence number
752         4       0                       reply length
753         4       CARD32                  swap_hi
754         4       CARD32                  swap_lo
755         5n      LISTofDRI2BUFFER        buffers
756 └───
757
758 ┌───
759     DRI2GetMSC
760         1       CARD8                   major opcode
761         1       7                       DRI2 opcode
762         2       8                       length
763         4       DRAWABLE                drawable
764       ▶
765         1       1                       Reply
766         1                               unused
767         2       CARD16                  sequence number
768         4       0                       reply length
769         4       CARD32                  ust_hi
770         4       CARD32                  ust_lo
771         4       CARD32                  msc_hi
772         4       CARD32                  msc_lo
773         4       CARD32                  sbc_hi
774         4       CARD32                  sbc_lo
775 └───
776
777 ┌───
778     DRI2WaitMSC
779         1       CARD8                   major opcode
780         1       7                       DRI2 opcode
781         2       8                       length
782         4       DRAWABLE                drawable
783         4       CARD32                  target_msc_hi
784         4       CARD32                  target_msc_lo
785         4       CARD32                  divisor_hi
786         4       CARD32                  divisor_lo
787         4       CARD32                  remainder_hi
788         4       CARD32                  remainder_lo
789       ▶
790         1       1                       Reply
791         1                               unused
792         2       CARD16                  sequence number
793         4       0                       reply length
794         4       CARD32                  ust_hi
795         4       CARD32                  ust_lo
796         4       CARD32                  msc_hi
797         4       CARD32                  msc_lo
798         4       CARD32                  sbc_hi
799         4       CARD32                  sbc_lo
800 └───
801
802 ┌───
803     DRI2WaitSBC
804         1       CARD8                   major opcode
805         1       7                       DRI2 opcode
806         2       8                       length
807         4       DRAWABLE                drawable
808         4       CARD32                  swap_hi
809         4       CARD32                  swap_lo
810      ▶
811         1       1                       Reply
812         1                               unused
813         2       CARD16                  sequence number
814         4       0                       reply length
815         4       CARD32                  ust_hi
816         4       CARD32                  ust_lo
817         4       CARD32                  msc_hi
818         4       CARD32                  msc_lo
819         4       CARD32                  sbc_hi
820         4       CARD32                  sbc_lo
821 └───
822
823 ┌───
824     DRI2SwapInterval
825         1       CARD8                   major opcode
826         1       7                       DRI2 opcode
827         2       8                       length
828         4       DRAWABLE                drawable
829         4       CARD32                  interval
830      ▶
831 └───
832
833 A.3 Protocol Events
834
835 The DRI2 extension specifies DRI2_BufferSwapComplete and
836 DRI2_InvalidateBuffers events.
837
838 ┌───
839     DRI2_BufferSwapComplete
840         1       CARD8                   type
841         1       CARD8                   extension
842         2       CARD16                  sequenceNumber
843         2       CARD16                  event_type
844         4       DRAWABLE                drawable
845         4       CARD32                  ust_hi
846         4       CARD32                  ust_lo
847         4       CARD32                  msc_hi
848         4       CARD32                  msc_lo
849         4       CARD32                  sbc_hi
850         4       CARD32                  sbc_lo
851 └───
852
853
854 ┌───
855     DRI2_InvalidateBuffers
856         1       CARD8                   type
857         1       CARD8                   extension
858         2       CARD16                  sequenceNumber
859         4       DRAWABLE                drawable
860         4       CARD32                  unused
861         4       CARD32                  unused
862         4       CARD32                  unused
863         4       CARD32                  unused
864         4       CARD32                  unused
865         4       CARD32                  unused
866 └───
867
868 A.4 Protocol Errors
869
870 The DRI2 extension specifies no errors.
871
872
873                              ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
874
875
876 Appendix B. Implementation on GEM
877
878 Where to begin...