dri2.c revision 7a0bcba9f9d7a4dcba11d06f207a5d494a330d5f
1/*
2 * Copyright © 2008 Red Hat, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Soft-
6 * ware"), to deal in the Software without restriction, including without
7 * limitation the rights to use, copy, modify, merge, publish, distribute,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, provided that the above copyright
10 * notice(s) and this permission notice appear in all copies of the Soft-
11 * ware and that both the above copyright notice(s) and this permission
12 * notice appear in supporting documentation.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
16 * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
17 * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
18 * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
19 * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
22 * MANCE OF THIS SOFTWARE.
23 *
24 * Except as contained in this notice, the name of a copyright holder shall
25 * not be used in advertising or otherwise to promote the sale, use or
26 * other dealings in this Software without prior written authorization of
27 * the copyright holder.
28 *
29 * Authors:
30 *   Kristian Høgsberg (krh@redhat.com)
31 */
32
33
34#ifdef GLX_DIRECT_RENDERING
35
36#define NEED_REPLIES
37#include <stdio.h>
38#include <X11/Xlibint.h>
39#include <X11/extensions/Xext.h>
40#include <X11/extensions/extutil.h>
41#include <X11/extensions/dri2proto.h>
42#include "xf86drm.h"
43#include "dri2.h"
44#include "glxclient.h"
45#include "GL/glxext.h"
46
47/* Allow the build to work with an older versions of dri2proto.h and
48 * dri2tokens.h.
49 */
50#if DRI2_MINOR < 1
51#undef DRI2_MINOR
52#define DRI2_MINOR 1
53#define X_DRI2GetBuffersWithFormat 7
54#endif
55
56
57static char dri2ExtensionName[] = DRI2_NAME;
58static XExtensionInfo *dri2Info;
59static XEXT_GENERATE_CLOSE_DISPLAY (DRI2CloseDisplay, dri2Info)
60
61static Bool
62DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire);
63static Status
64DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire);
65static int
66DRI2Error(Display *display, xError *err, XExtCodes *codes, int *ret_code);
67
68static /* const */ XExtensionHooks dri2ExtensionHooks = {
69  NULL,                   /* create_gc */
70  NULL,                   /* copy_gc */
71  NULL,                   /* flush_gc */
72  NULL,                   /* free_gc */
73  NULL,                   /* create_font */
74  NULL,                   /* free_font */
75  DRI2CloseDisplay,       /* close_display */
76  DRI2WireToEvent,        /* wire_to_event */
77  DRI2EventToWire,        /* event_to_wire */
78  DRI2Error,              /* error */
79  NULL,                   /* error_string */
80};
81
82static XEXT_GENERATE_FIND_DISPLAY (DRI2FindDisplay,
83                                   dri2Info,
84                                   dri2ExtensionName,
85                                   &dri2ExtensionHooks,
86                                   0, NULL)
87
88static Bool
89DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
90{
91   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
92   XExtDisplayInfo *glx_info = __glXFindDisplay(dpy);
93
94   XextCheckExtension(dpy, info, dri2ExtensionName, False);
95
96   switch ((wire->u.u.type & 0x7f) - info->codes->first_event) {
97
98#ifdef X_DRI2SwapBuffers
99   case DRI2_BufferSwapComplete:
100   {
101      GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event;
102      xDRI2BufferSwapComplete *awire = (xDRI2BufferSwapComplete *)wire;
103      aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire);
104      aevent->type =
105	  (glx_info->codes->first_event + GLX_BufferSwapComplete) & 0x75;
106      aevent->send_event = (awire->type & 0x80) != 0;
107      aevent->display = dpy;
108      aevent->drawable = awire->drawable;
109      switch (awire->event_type) {
110      case DRI2_EXCHANGE_COMPLETE:
111	 aevent->event_type = GLX_EXCHANGE_COMPLETE_INTEL;
112	 break;
113      case DRI2_BLIT_COMPLETE:
114	 aevent->event_type = GLX_BLIT_COMPLETE_INTEL;
115	 break;
116      case DRI2_FLIP_COMPLETE:
117	 aevent->event_type = GLX_FLIP_COMPLETE_INTEL;
118	 break;
119      default:
120	 /* unknown swap completion type */
121	 return False;
122      }
123      aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo;
124      aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo;
125      aevent->sbc = ((CARD64)awire->sbc_hi << 32) | awire->sbc_lo;
126      return True;
127   }
128#endif
129#ifdef DRI2_InvalidateBuffers
130   case DRI2_InvalidateBuffers:
131   {
132      xDRI2InvalidateBuffers *awire = (xDRI2InvalidateBuffers *)wire;
133
134      dri2InvalidateBuffers(dpy, awire->drawable);
135      return False;
136   }
137#endif
138   default:
139      /* client doesn't support server event */
140      break;
141   }
142
143   return False;
144}
145
146/* We don't actually support this.  It doesn't make sense for clients to
147 * send each other DRI2 events.
148 */
149static Status
150DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire)
151{
152   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
153
154   XextCheckExtension(dpy, info, dri2ExtensionName, False);
155
156   switch (event->type) {
157   default:
158      /* client doesn't support server event */
159      break;
160   }
161
162   return Success;
163}
164
165static int
166DRI2Error(Display *display, xError *err, XExtCodes *codes, int *ret_code)
167{
168    if (err->majorCode == codes->major_opcode &&
169	err->errorCode == BadDrawable &&
170	err->minorCode == X_DRI2CopyRegion)
171	return True;
172
173    return False;
174}
175
176Bool
177DRI2QueryExtension(Display * dpy, int *eventBase, int *errorBase)
178{
179   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
180
181   if (XextHasExtension(info)) {
182      *eventBase = info->codes->first_event;
183      *errorBase = info->codes->first_error;
184      return True;
185   }
186
187   return False;
188}
189
190Bool
191DRI2QueryVersion(Display * dpy, int *major, int *minor)
192{
193   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
194   xDRI2QueryVersionReply rep;
195   xDRI2QueryVersionReq *req;
196   int i, nevents;
197
198   XextCheckExtension(dpy, info, dri2ExtensionName, False);
199
200   LockDisplay(dpy);
201   GetReq(DRI2QueryVersion, req);
202   req->reqType = info->codes->major_opcode;
203   req->dri2ReqType = X_DRI2QueryVersion;
204   req->majorVersion = DRI2_MAJOR;
205   req->minorVersion = DRI2_MINOR;
206   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
207      UnlockDisplay(dpy);
208      SyncHandle();
209      return False;
210   }
211   *major = rep.majorVersion;
212   *minor = rep.minorVersion;
213   UnlockDisplay(dpy);
214   SyncHandle();
215
216   switch (rep.minorVersion) {
217   case 1:
218	   nevents = 0;
219	   break;
220   case 2:
221	   nevents = 1;
222	   break;
223   case 3:
224   default:
225	   nevents = 2;
226	   break;
227   }
228
229   for (i = 0; i < nevents; i++) {
230       XESetWireToEvent (dpy, info->codes->first_event + i, DRI2WireToEvent);
231       XESetEventToWire (dpy, info->codes->first_event + i, DRI2EventToWire);
232   }
233
234   return True;
235}
236
237Bool
238DRI2Connect(Display * dpy, XID window, char **driverName, char **deviceName)
239{
240   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
241   xDRI2ConnectReply rep;
242   xDRI2ConnectReq *req;
243
244   XextCheckExtension(dpy, info, dri2ExtensionName, False);
245
246   LockDisplay(dpy);
247   GetReq(DRI2Connect, req);
248   req->reqType = info->codes->major_opcode;
249   req->dri2ReqType = X_DRI2Connect;
250   req->window = window;
251   req->driverType = DRI2DriverDRI;
252   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
253      UnlockDisplay(dpy);
254      SyncHandle();
255      return False;
256   }
257
258   if (rep.driverNameLength == 0 && rep.deviceNameLength == 0) {
259      UnlockDisplay(dpy);
260      SyncHandle();
261      return False;
262   }
263
264   *driverName = Xmalloc(rep.driverNameLength + 1);
265   if (*driverName == NULL) {
266      _XEatData(dpy,
267                ((rep.driverNameLength + 3) & ~3) +
268                ((rep.deviceNameLength + 3) & ~3));
269      UnlockDisplay(dpy);
270      SyncHandle();
271      return False;
272   }
273   _XReadPad(dpy, *driverName, rep.driverNameLength);
274   (*driverName)[rep.driverNameLength] = '\0';
275
276   *deviceName = Xmalloc(rep.deviceNameLength + 1);
277   if (*deviceName == NULL) {
278      Xfree(*driverName);
279      _XEatData(dpy, ((rep.deviceNameLength + 3) & ~3));
280      UnlockDisplay(dpy);
281      SyncHandle();
282      return False;
283   }
284   _XReadPad(dpy, *deviceName, rep.deviceNameLength);
285   (*deviceName)[rep.deviceNameLength] = '\0';
286
287   UnlockDisplay(dpy);
288   SyncHandle();
289
290   return True;
291}
292
293Bool
294DRI2Authenticate(Display * dpy, XID window, drm_magic_t magic)
295{
296   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
297   xDRI2AuthenticateReq *req;
298   xDRI2AuthenticateReply rep;
299
300   XextCheckExtension(dpy, info, dri2ExtensionName, False);
301
302   LockDisplay(dpy);
303   GetReq(DRI2Authenticate, req);
304   req->reqType = info->codes->major_opcode;
305   req->dri2ReqType = X_DRI2Authenticate;
306   req->window = window;
307   req->magic = magic;
308
309   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
310      UnlockDisplay(dpy);
311      SyncHandle();
312      return False;
313   }
314
315   UnlockDisplay(dpy);
316   SyncHandle();
317
318   return rep.authenticated;
319}
320
321void
322DRI2CreateDrawable(Display * dpy, XID drawable)
323{
324   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
325   xDRI2CreateDrawableReq *req;
326
327   XextSimpleCheckExtension(dpy, info, dri2ExtensionName);
328
329   LockDisplay(dpy);
330   GetReq(DRI2CreateDrawable, req);
331   req->reqType = info->codes->major_opcode;
332   req->dri2ReqType = X_DRI2CreateDrawable;
333   req->drawable = drawable;
334   UnlockDisplay(dpy);
335   SyncHandle();
336}
337
338void
339DRI2DestroyDrawable(Display * dpy, XID drawable)
340{
341   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
342   xDRI2DestroyDrawableReq *req;
343
344   XextSimpleCheckExtension(dpy, info, dri2ExtensionName);
345
346   XSync(dpy, False);
347
348   LockDisplay(dpy);
349   GetReq(DRI2DestroyDrawable, req);
350   req->reqType = info->codes->major_opcode;
351   req->dri2ReqType = X_DRI2DestroyDrawable;
352   req->drawable = drawable;
353   UnlockDisplay(dpy);
354   SyncHandle();
355}
356
357DRI2Buffer *
358DRI2GetBuffers(Display * dpy, XID drawable,
359               int *width, int *height,
360               unsigned int *attachments, int count, int *outCount)
361{
362   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
363   xDRI2GetBuffersReply rep;
364   xDRI2GetBuffersReq *req;
365   DRI2Buffer *buffers;
366   xDRI2Buffer repBuffer;
367   CARD32 *p;
368   int i;
369
370   XextCheckExtension(dpy, info, dri2ExtensionName, False);
371
372   LockDisplay(dpy);
373   GetReqExtra(DRI2GetBuffers, count * 4, req);
374   req->reqType = info->codes->major_opcode;
375   req->dri2ReqType = X_DRI2GetBuffers;
376   req->drawable = drawable;
377   req->count = count;
378   p = (CARD32 *) & req[1];
379   for (i = 0; i < count; i++)
380      p[i] = attachments[i];
381
382   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
383      UnlockDisplay(dpy);
384      SyncHandle();
385      return NULL;
386   }
387
388   *width = rep.width;
389   *height = rep.height;
390   *outCount = rep.count;
391
392   buffers = Xmalloc(rep.count * sizeof buffers[0]);
393   if (buffers == NULL) {
394      _XEatData(dpy, rep.count * sizeof repBuffer);
395      UnlockDisplay(dpy);
396      SyncHandle();
397      return NULL;
398   }
399
400   for (i = 0; i < rep.count; i++) {
401      _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer);
402      buffers[i].attachment = repBuffer.attachment;
403      buffers[i].name = repBuffer.name;
404      buffers[i].pitch = repBuffer.pitch;
405      buffers[i].cpp = repBuffer.cpp;
406      buffers[i].flags = repBuffer.flags;
407   }
408
409   UnlockDisplay(dpy);
410   SyncHandle();
411
412   return buffers;
413}
414
415
416DRI2Buffer *
417DRI2GetBuffersWithFormat(Display * dpy, XID drawable,
418                         int *width, int *height,
419                         unsigned int *attachments, int count, int *outCount)
420{
421   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
422   xDRI2GetBuffersReply rep;
423   xDRI2GetBuffersReq *req;
424   DRI2Buffer *buffers;
425   xDRI2Buffer repBuffer;
426   CARD32 *p;
427   int i;
428
429   XextCheckExtension(dpy, info, dri2ExtensionName, False);
430
431   LockDisplay(dpy);
432   GetReqExtra(DRI2GetBuffers, count * (4 * 2), req);
433   req->reqType = info->codes->major_opcode;
434   req->dri2ReqType = X_DRI2GetBuffersWithFormat;
435   req->drawable = drawable;
436   req->count = count;
437   p = (CARD32 *) & req[1];
438   for (i = 0; i < (count * 2); i++)
439      p[i] = attachments[i];
440
441   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
442      UnlockDisplay(dpy);
443      SyncHandle();
444      return NULL;
445   }
446
447   *width = rep.width;
448   *height = rep.height;
449   *outCount = rep.count;
450
451   buffers = Xmalloc(rep.count * sizeof buffers[0]);
452   if (buffers == NULL) {
453      _XEatData(dpy, rep.count * sizeof repBuffer);
454      UnlockDisplay(dpy);
455      SyncHandle();
456      return NULL;
457   }
458
459   for (i = 0; i < rep.count; i++) {
460      _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer);
461      buffers[i].attachment = repBuffer.attachment;
462      buffers[i].name = repBuffer.name;
463      buffers[i].pitch = repBuffer.pitch;
464      buffers[i].cpp = repBuffer.cpp;
465      buffers[i].flags = repBuffer.flags;
466   }
467
468   UnlockDisplay(dpy);
469   SyncHandle();
470
471   return buffers;
472}
473
474
475void
476DRI2CopyRegion(Display * dpy, XID drawable, XserverRegion region,
477               CARD32 dest, CARD32 src)
478{
479   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
480   xDRI2CopyRegionReq *req;
481   xDRI2CopyRegionReply rep;
482
483   XextSimpleCheckExtension(dpy, info, dri2ExtensionName);
484
485   LockDisplay(dpy);
486   GetReq(DRI2CopyRegion, req);
487   req->reqType = info->codes->major_opcode;
488   req->dri2ReqType = X_DRI2CopyRegion;
489   req->drawable = drawable;
490   req->region = region;
491   req->dest = dest;
492   req->src = src;
493
494   _XReply(dpy, (xReply *) & rep, 0, xFalse);
495
496   UnlockDisplay(dpy);
497   SyncHandle();
498}
499
500#ifdef X_DRI2SwapBuffers
501static void
502load_swap_req(xDRI2SwapBuffersReq *req, CARD64 target, CARD64 divisor,
503	     CARD64 remainder)
504{
505    req->target_msc_hi = target >> 32;
506    req->target_msc_lo = target & 0xffffffff;
507    req->divisor_hi = divisor >> 32;
508    req->divisor_lo = divisor & 0xffffffff;
509    req->remainder_hi = remainder >> 32;
510    req->remainder_lo = remainder & 0xffffffff;
511}
512
513static CARD64
514vals_to_card64(CARD32 lo, CARD32 hi)
515{
516    return (CARD64)hi << 32 | lo;
517}
518
519void DRI2SwapBuffers(Display *dpy, XID drawable, CARD64 target_msc,
520		     CARD64 divisor, CARD64 remainder, CARD64 *count)
521{
522    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
523    xDRI2SwapBuffersReq *req;
524    xDRI2SwapBuffersReply rep;
525
526    XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
527
528    LockDisplay(dpy);
529    GetReq(DRI2SwapBuffers, req);
530    req->reqType = info->codes->major_opcode;
531    req->dri2ReqType = X_DRI2SwapBuffers;
532    req->drawable = drawable;
533    load_swap_req(req, target_msc, divisor, remainder);
534
535    _XReply(dpy, (xReply *)&rep, 0, xFalse);
536
537    *count = vals_to_card64(rep.swap_lo, rep.swap_hi);
538
539    UnlockDisplay(dpy);
540    SyncHandle();
541}
542#endif
543
544#ifdef X_DRI2GetMSC
545Bool DRI2GetMSC(Display *dpy, XID drawable, CARD64 *ust, CARD64 *msc,
546		CARD64 *sbc)
547{
548    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
549    xDRI2GetMSCReq *req;
550    xDRI2MSCReply rep;
551
552    XextCheckExtension (dpy, info, dri2ExtensionName, False);
553
554    LockDisplay(dpy);
555    GetReq(DRI2GetMSC, req);
556    req->reqType = info->codes->major_opcode;
557    req->dri2ReqType = X_DRI2GetMSC;
558    req->drawable = drawable;
559
560    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
561	UnlockDisplay(dpy);
562	SyncHandle();
563	return False;
564    }
565
566    *ust = vals_to_card64(rep.ust_lo, rep.ust_hi);
567    *msc = vals_to_card64(rep.msc_lo, rep.msc_hi);
568    *sbc = vals_to_card64(rep.sbc_lo, rep.sbc_hi);
569
570    UnlockDisplay(dpy);
571    SyncHandle();
572
573    return True;
574}
575#endif
576
577#ifdef X_DRI2WaitMSC
578static void
579load_msc_req(xDRI2WaitMSCReq *req, CARD64 target, CARD64 divisor,
580	     CARD64 remainder)
581{
582    req->target_msc_hi = target >> 32;
583    req->target_msc_lo = target & 0xffffffff;
584    req->divisor_hi = divisor >> 32;
585    req->divisor_lo = divisor & 0xffffffff;
586    req->remainder_hi = remainder >> 32;
587    req->remainder_lo = remainder & 0xffffffff;
588}
589
590Bool DRI2WaitMSC(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor,
591		 CARD64 remainder, CARD64 *ust, CARD64 *msc, CARD64 *sbc)
592{
593    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
594    xDRI2WaitMSCReq *req;
595    xDRI2MSCReply rep;
596
597    XextCheckExtension (dpy, info, dri2ExtensionName, False);
598
599    LockDisplay(dpy);
600    GetReq(DRI2WaitMSC, req);
601    req->reqType = info->codes->major_opcode;
602    req->dri2ReqType = X_DRI2WaitMSC;
603    req->drawable = drawable;
604    load_msc_req(req, target_msc, divisor, remainder);
605
606    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
607	UnlockDisplay(dpy);
608	SyncHandle();
609	return False;
610    }
611
612    *ust = ((CARD64)rep.ust_hi << 32) | (CARD64)rep.ust_lo;
613    *msc = ((CARD64)rep.msc_hi << 32) | (CARD64)rep.msc_lo;
614    *sbc = ((CARD64)rep.sbc_hi << 32) | (CARD64)rep.sbc_lo;
615
616    UnlockDisplay(dpy);
617    SyncHandle();
618
619    return True;
620}
621#endif
622
623#ifdef X_DRI2WaitSBC
624static void
625load_sbc_req(xDRI2WaitSBCReq *req, CARD64 target)
626{
627    req->target_sbc_hi = target >> 32;
628    req->target_sbc_lo = target & 0xffffffff;
629}
630
631Bool DRI2WaitSBC(Display *dpy, XID drawable, CARD64 target_sbc, CARD64 *ust,
632		 CARD64 *msc, CARD64 *sbc)
633{
634    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
635    xDRI2WaitSBCReq *req;
636    xDRI2MSCReply rep;
637
638    XextCheckExtension (dpy, info, dri2ExtensionName, False);
639
640    LockDisplay(dpy);
641    GetReq(DRI2WaitSBC, req);
642    req->reqType = info->codes->major_opcode;
643    req->dri2ReqType = X_DRI2WaitSBC;
644    req->drawable = drawable;
645    load_sbc_req(req, target_sbc);
646
647    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
648	UnlockDisplay(dpy);
649	SyncHandle();
650	return False;
651    }
652
653    *ust = ((CARD64)rep.ust_hi << 32) | rep.ust_lo;
654    *msc = ((CARD64)rep.msc_hi << 32) | rep.msc_lo;
655    *sbc = ((CARD64)rep.sbc_hi << 32) | rep.sbc_lo;
656
657    UnlockDisplay(dpy);
658    SyncHandle();
659
660    return True;
661}
662#endif
663
664#ifdef X_DRI2SwapInterval
665void DRI2SwapInterval(Display *dpy, XID drawable, int interval)
666{
667    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
668    xDRI2SwapIntervalReq *req;
669
670    XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
671
672    LockDisplay(dpy);
673    GetReq(DRI2SwapInterval, req);
674    req->reqType = info->codes->major_opcode;
675    req->dri2ReqType = X_DRI2SwapInterval;
676    req->drawable = drawable;
677    req->interval = interval;
678    UnlockDisplay(dpy);
679    SyncHandle();
680}
681#endif
682
683#endif /* GLX_DIRECT_RENDERING */
684