dri2.c revision 4df137691ee29bb812347fa2c5f19095243ede22
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#include <stdio.h>
37#include <X11/Xlibint.h>
38#include <X11/extensions/Xext.h>
39#include <X11/extensions/extutil.h>
40#include <X11/extensions/dri2proto.h>
41#include "xf86drm.h"
42#include "dri2.h"
43#include "glxclient.h"
44#include "GL/glxext.h"
45
46/* Allow the build to work with an older versions of dri2proto.h and
47 * dri2tokens.h.
48 */
49#if DRI2_MINOR < 1
50#undef DRI2_MINOR
51#define DRI2_MINOR 1
52#define X_DRI2GetBuffersWithFormat 7
53#endif
54
55
56static char dri2ExtensionName[] = DRI2_NAME;
57static XExtensionInfo *dri2Info;
58static XEXT_GENERATE_CLOSE_DISPLAY (DRI2CloseDisplay, dri2Info)
59
60static Bool
61DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire);
62static Status
63DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire);
64static int
65DRI2Error(Display *display, xError *err, XExtCodes *codes, int *ret_code);
66
67static /* const */ XExtensionHooks dri2ExtensionHooks = {
68  NULL,                   /* create_gc */
69  NULL,                   /* copy_gc */
70  NULL,                   /* flush_gc */
71  NULL,                   /* free_gc */
72  NULL,                   /* create_font */
73  NULL,                   /* free_font */
74  DRI2CloseDisplay,       /* close_display */
75  DRI2WireToEvent,        /* wire_to_event */
76  DRI2EventToWire,        /* event_to_wire */
77  DRI2Error,              /* error */
78  NULL,                   /* error_string */
79};
80
81static XEXT_GENERATE_FIND_DISPLAY (DRI2FindDisplay,
82                                   dri2Info,
83                                   dri2ExtensionName,
84                                   &dri2ExtensionHooks,
85                                   0, NULL)
86
87static Bool
88DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
89{
90   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
91   struct glx_drawable *glxDraw;
92
93   XextCheckExtension(dpy, info, dri2ExtensionName, False);
94
95   switch ((wire->u.u.type & 0x7f) - info->codes->first_event) {
96
97#ifdef X_DRI2SwapBuffers
98   case DRI2_BufferSwapComplete:
99   {
100      GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event;
101      xDRI2BufferSwapComplete2 *awire = (xDRI2BufferSwapComplete2 *)wire;
102      __GLXDRIdrawable *pdraw;
103
104      pdraw = dri2GetGlxDrawableFromXDrawableId(dpy, awire->drawable);
105
106      /* Ignore swap events if we're not looking for them */
107      aevent->type = dri2GetSwapEventType(dpy, awire->drawable);
108      if(!aevent->type)
109         return False;
110
111      aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire);
112      aevent->send_event = (awire->type & 0x80) != 0;
113      aevent->display = dpy;
114      aevent->drawable = awire->drawable;
115      switch (awire->event_type) {
116      case DRI2_EXCHANGE_COMPLETE:
117	 aevent->event_type = GLX_EXCHANGE_COMPLETE_INTEL;
118	 break;
119      case DRI2_BLIT_COMPLETE:
120	 aevent->event_type = GLX_COPY_COMPLETE_INTEL;
121	 break;
122      case DRI2_FLIP_COMPLETE:
123	 aevent->event_type = GLX_FLIP_COMPLETE_INTEL;
124	 break;
125      default:
126	 /* unknown swap completion type */
127	 return False;
128      }
129      aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo;
130      aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo;
131
132      glxDraw = GetGLXDrawable(dpy, pdraw->drawable);
133      if (awire->sbc < glxDraw->lastEventSbc)
134	 glxDraw->eventSbcWrap += 0x100000000;
135      glxDraw->lastEventSbc = awire->sbc;
136      aevent->sbc = awire->sbc + glxDraw->eventSbcWrap;
137
138      return True;
139   }
140#endif
141#ifdef DRI2_InvalidateBuffers
142   case DRI2_InvalidateBuffers:
143   {
144      xDRI2InvalidateBuffers *awire = (xDRI2InvalidateBuffers *)wire;
145
146      dri2InvalidateBuffers(dpy, awire->drawable);
147      return False;
148   }
149#endif
150   default:
151      /* client doesn't support server event */
152      break;
153   }
154
155   return False;
156}
157
158/* We don't actually support this.  It doesn't make sense for clients to
159 * send each other DRI2 events.
160 */
161static Status
162DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire)
163{
164   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
165
166   XextCheckExtension(dpy, info, dri2ExtensionName, False);
167
168   switch (event->type) {
169   default:
170      /* client doesn't support server event */
171      break;
172   }
173
174   return Success;
175}
176
177static int
178DRI2Error(Display *display, xError *err, XExtCodes *codes, int *ret_code)
179{
180    if (err->majorCode == codes->major_opcode &&
181	err->errorCode == BadDrawable &&
182	err->minorCode == X_DRI2CopyRegion)
183	return True;
184
185    /* If the X drawable was destroyed before the GLX drawable, the
186     * DRI2 drawble will be gone by the time we call
187     * DRI2DestroyDrawable.  So just ignore BadDrawable here. */
188    if (err->majorCode == codes->major_opcode &&
189	err->errorCode == BadDrawable &&
190	err->minorCode == X_DRI2DestroyDrawable)
191	return True;
192
193    return False;
194}
195
196Bool
197DRI2QueryExtension(Display * dpy, int *eventBase, int *errorBase)
198{
199   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
200
201   if (XextHasExtension(info)) {
202      *eventBase = info->codes->first_event;
203      *errorBase = info->codes->first_error;
204      return True;
205   }
206
207   return False;
208}
209
210Bool
211DRI2QueryVersion(Display * dpy, int *major, int *minor)
212{
213   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
214   xDRI2QueryVersionReply rep;
215   xDRI2QueryVersionReq *req;
216   int i, nevents;
217
218   XextCheckExtension(dpy, info, dri2ExtensionName, False);
219
220   LockDisplay(dpy);
221   GetReq(DRI2QueryVersion, req);
222   req->reqType = info->codes->major_opcode;
223   req->dri2ReqType = X_DRI2QueryVersion;
224   req->majorVersion = DRI2_MAJOR;
225   req->minorVersion = DRI2_MINOR;
226   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
227      UnlockDisplay(dpy);
228      SyncHandle();
229      return False;
230   }
231   *major = rep.majorVersion;
232   *minor = rep.minorVersion;
233   UnlockDisplay(dpy);
234   SyncHandle();
235
236   switch (rep.minorVersion) {
237   case 1:
238	   nevents = 0;
239	   break;
240   case 2:
241	   nevents = 1;
242	   break;
243   case 3:
244   default:
245	   nevents = 2;
246	   break;
247   }
248
249   for (i = 0; i < nevents; i++) {
250       XESetWireToEvent (dpy, info->codes->first_event + i, DRI2WireToEvent);
251       XESetEventToWire (dpy, info->codes->first_event + i, DRI2EventToWire);
252   }
253
254   return True;
255}
256
257Bool
258DRI2Connect(Display * dpy, XID window, char **driverName, char **deviceName)
259{
260   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
261   xDRI2ConnectReply rep;
262   xDRI2ConnectReq *req;
263
264   XextCheckExtension(dpy, info, dri2ExtensionName, False);
265
266   LockDisplay(dpy);
267   GetReq(DRI2Connect, req);
268   req->reqType = info->codes->major_opcode;
269   req->dri2ReqType = X_DRI2Connect;
270   req->window = window;
271   req->driverType = DRI2DriverDRI;
272   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
273      UnlockDisplay(dpy);
274      SyncHandle();
275      return False;
276   }
277
278   if (rep.driverNameLength == 0 && rep.deviceNameLength == 0) {
279      UnlockDisplay(dpy);
280      SyncHandle();
281      return False;
282   }
283
284   *driverName = Xmalloc(rep.driverNameLength + 1);
285   if (*driverName == NULL) {
286      _XEatData(dpy,
287                ((rep.driverNameLength + 3) & ~3) +
288                ((rep.deviceNameLength + 3) & ~3));
289      UnlockDisplay(dpy);
290      SyncHandle();
291      return False;
292   }
293   _XReadPad(dpy, *driverName, rep.driverNameLength);
294   (*driverName)[rep.driverNameLength] = '\0';
295
296   *deviceName = Xmalloc(rep.deviceNameLength + 1);
297   if (*deviceName == NULL) {
298      Xfree(*driverName);
299      _XEatData(dpy, ((rep.deviceNameLength + 3) & ~3));
300      UnlockDisplay(dpy);
301      SyncHandle();
302      return False;
303   }
304   _XReadPad(dpy, *deviceName, rep.deviceNameLength);
305   (*deviceName)[rep.deviceNameLength] = '\0';
306
307   UnlockDisplay(dpy);
308   SyncHandle();
309
310   return True;
311}
312
313Bool
314DRI2Authenticate(Display * dpy, XID window, drm_magic_t magic)
315{
316   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
317   xDRI2AuthenticateReq *req;
318   xDRI2AuthenticateReply rep;
319
320   XextCheckExtension(dpy, info, dri2ExtensionName, False);
321
322   LockDisplay(dpy);
323   GetReq(DRI2Authenticate, req);
324   req->reqType = info->codes->major_opcode;
325   req->dri2ReqType = X_DRI2Authenticate;
326   req->window = window;
327   req->magic = magic;
328
329   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
330      UnlockDisplay(dpy);
331      SyncHandle();
332      return False;
333   }
334
335   UnlockDisplay(dpy);
336   SyncHandle();
337
338   return rep.authenticated;
339}
340
341void
342DRI2CreateDrawable(Display * dpy, XID drawable)
343{
344   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
345   xDRI2CreateDrawableReq *req;
346
347   XextSimpleCheckExtension(dpy, info, dri2ExtensionName);
348
349   LockDisplay(dpy);
350   GetReq(DRI2CreateDrawable, req);
351   req->reqType = info->codes->major_opcode;
352   req->dri2ReqType = X_DRI2CreateDrawable;
353   req->drawable = drawable;
354   UnlockDisplay(dpy);
355   SyncHandle();
356}
357
358void
359DRI2DestroyDrawable(Display * dpy, XID drawable)
360{
361   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
362   xDRI2DestroyDrawableReq *req;
363
364   XextSimpleCheckExtension(dpy, info, dri2ExtensionName);
365
366   XSync(dpy, False);
367
368   LockDisplay(dpy);
369   GetReq(DRI2DestroyDrawable, req);
370   req->reqType = info->codes->major_opcode;
371   req->dri2ReqType = X_DRI2DestroyDrawable;
372   req->drawable = drawable;
373   UnlockDisplay(dpy);
374   SyncHandle();
375}
376
377DRI2Buffer *
378DRI2GetBuffers(Display * dpy, XID drawable,
379               int *width, int *height,
380               unsigned int *attachments, int count, int *outCount)
381{
382   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
383   xDRI2GetBuffersReply rep;
384   xDRI2GetBuffersReq *req;
385   DRI2Buffer *buffers;
386   xDRI2Buffer repBuffer;
387   CARD32 *p;
388   int i;
389
390   XextCheckExtension(dpy, info, dri2ExtensionName, False);
391
392   LockDisplay(dpy);
393   GetReqExtra(DRI2GetBuffers, count * 4, req);
394   req->reqType = info->codes->major_opcode;
395   req->dri2ReqType = X_DRI2GetBuffers;
396   req->drawable = drawable;
397   req->count = count;
398   p = (CARD32 *) & req[1];
399   for (i = 0; i < count; i++)
400      p[i] = attachments[i];
401
402   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
403      UnlockDisplay(dpy);
404      SyncHandle();
405      return NULL;
406   }
407
408   *width = rep.width;
409   *height = rep.height;
410   *outCount = rep.count;
411
412   buffers = Xmalloc(rep.count * sizeof buffers[0]);
413   if (buffers == NULL) {
414      _XEatData(dpy, rep.count * sizeof repBuffer);
415      UnlockDisplay(dpy);
416      SyncHandle();
417      return NULL;
418   }
419
420   for (i = 0; i < rep.count; i++) {
421      _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer);
422      buffers[i].attachment = repBuffer.attachment;
423      buffers[i].name = repBuffer.name;
424      buffers[i].pitch = repBuffer.pitch;
425      buffers[i].cpp = repBuffer.cpp;
426      buffers[i].flags = repBuffer.flags;
427   }
428
429   UnlockDisplay(dpy);
430   SyncHandle();
431
432   return buffers;
433}
434
435
436DRI2Buffer *
437DRI2GetBuffersWithFormat(Display * dpy, XID drawable,
438                         int *width, int *height,
439                         unsigned int *attachments, int count, int *outCount)
440{
441   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
442   xDRI2GetBuffersReply rep;
443   xDRI2GetBuffersReq *req;
444   DRI2Buffer *buffers;
445   xDRI2Buffer repBuffer;
446   CARD32 *p;
447   int i;
448
449   XextCheckExtension(dpy, info, dri2ExtensionName, False);
450
451   LockDisplay(dpy);
452   GetReqExtra(DRI2GetBuffers, count * (4 * 2), req);
453   req->reqType = info->codes->major_opcode;
454   req->dri2ReqType = X_DRI2GetBuffersWithFormat;
455   req->drawable = drawable;
456   req->count = count;
457   p = (CARD32 *) & req[1];
458   for (i = 0; i < (count * 2); i++)
459      p[i] = attachments[i];
460
461   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
462      UnlockDisplay(dpy);
463      SyncHandle();
464      return NULL;
465   }
466
467   *width = rep.width;
468   *height = rep.height;
469   *outCount = rep.count;
470
471   buffers = Xmalloc(rep.count * sizeof buffers[0]);
472   if (buffers == NULL) {
473      _XEatData(dpy, rep.count * sizeof repBuffer);
474      UnlockDisplay(dpy);
475      SyncHandle();
476      return NULL;
477   }
478
479   for (i = 0; i < rep.count; i++) {
480      _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer);
481      buffers[i].attachment = repBuffer.attachment;
482      buffers[i].name = repBuffer.name;
483      buffers[i].pitch = repBuffer.pitch;
484      buffers[i].cpp = repBuffer.cpp;
485      buffers[i].flags = repBuffer.flags;
486   }
487
488   UnlockDisplay(dpy);
489   SyncHandle();
490
491   return buffers;
492}
493
494
495void
496DRI2CopyRegion(Display * dpy, XID drawable, XserverRegion region,
497               CARD32 dest, CARD32 src)
498{
499   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
500   xDRI2CopyRegionReq *req;
501   xDRI2CopyRegionReply rep;
502
503   XextSimpleCheckExtension(dpy, info, dri2ExtensionName);
504
505   LockDisplay(dpy);
506   GetReq(DRI2CopyRegion, req);
507   req->reqType = info->codes->major_opcode;
508   req->dri2ReqType = X_DRI2CopyRegion;
509   req->drawable = drawable;
510   req->region = region;
511   req->dest = dest;
512   req->src = src;
513
514   _XReply(dpy, (xReply *) & rep, 0, xFalse);
515
516   UnlockDisplay(dpy);
517   SyncHandle();
518}
519
520#ifdef X_DRI2SwapBuffers
521static void
522load_swap_req(xDRI2SwapBuffersReq *req, CARD64 target, CARD64 divisor,
523	     CARD64 remainder)
524{
525    req->target_msc_hi = target >> 32;
526    req->target_msc_lo = target & 0xffffffff;
527    req->divisor_hi = divisor >> 32;
528    req->divisor_lo = divisor & 0xffffffff;
529    req->remainder_hi = remainder >> 32;
530    req->remainder_lo = remainder & 0xffffffff;
531}
532
533static CARD64
534vals_to_card64(CARD32 lo, CARD32 hi)
535{
536    return (CARD64)hi << 32 | lo;
537}
538
539void DRI2SwapBuffers(Display *dpy, XID drawable, CARD64 target_msc,
540		     CARD64 divisor, CARD64 remainder, CARD64 *count)
541{
542    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
543    xDRI2SwapBuffersReq *req;
544    xDRI2SwapBuffersReply rep;
545
546    XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
547
548    LockDisplay(dpy);
549    GetReq(DRI2SwapBuffers, req);
550    req->reqType = info->codes->major_opcode;
551    req->dri2ReqType = X_DRI2SwapBuffers;
552    req->drawable = drawable;
553    load_swap_req(req, target_msc, divisor, remainder);
554
555    _XReply(dpy, (xReply *)&rep, 0, xFalse);
556
557    *count = vals_to_card64(rep.swap_lo, rep.swap_hi);
558
559    UnlockDisplay(dpy);
560    SyncHandle();
561}
562#endif
563
564#ifdef X_DRI2GetMSC
565Bool DRI2GetMSC(Display *dpy, XID drawable, CARD64 *ust, CARD64 *msc,
566		CARD64 *sbc)
567{
568    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
569    xDRI2GetMSCReq *req;
570    xDRI2MSCReply rep;
571
572    XextCheckExtension (dpy, info, dri2ExtensionName, False);
573
574    LockDisplay(dpy);
575    GetReq(DRI2GetMSC, req);
576    req->reqType = info->codes->major_opcode;
577    req->dri2ReqType = X_DRI2GetMSC;
578    req->drawable = drawable;
579
580    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
581	UnlockDisplay(dpy);
582	SyncHandle();
583	return False;
584    }
585
586    *ust = vals_to_card64(rep.ust_lo, rep.ust_hi);
587    *msc = vals_to_card64(rep.msc_lo, rep.msc_hi);
588    *sbc = vals_to_card64(rep.sbc_lo, rep.sbc_hi);
589
590    UnlockDisplay(dpy);
591    SyncHandle();
592
593    return True;
594}
595#endif
596
597#ifdef X_DRI2WaitMSC
598static void
599load_msc_req(xDRI2WaitMSCReq *req, CARD64 target, CARD64 divisor,
600	     CARD64 remainder)
601{
602    req->target_msc_hi = target >> 32;
603    req->target_msc_lo = target & 0xffffffff;
604    req->divisor_hi = divisor >> 32;
605    req->divisor_lo = divisor & 0xffffffff;
606    req->remainder_hi = remainder >> 32;
607    req->remainder_lo = remainder & 0xffffffff;
608}
609
610Bool DRI2WaitMSC(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor,
611		 CARD64 remainder, CARD64 *ust, CARD64 *msc, CARD64 *sbc)
612{
613    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
614    xDRI2WaitMSCReq *req;
615    xDRI2MSCReply rep;
616
617    XextCheckExtension (dpy, info, dri2ExtensionName, False);
618
619    LockDisplay(dpy);
620    GetReq(DRI2WaitMSC, req);
621    req->reqType = info->codes->major_opcode;
622    req->dri2ReqType = X_DRI2WaitMSC;
623    req->drawable = drawable;
624    load_msc_req(req, target_msc, divisor, remainder);
625
626    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
627	UnlockDisplay(dpy);
628	SyncHandle();
629	return False;
630    }
631
632    *ust = ((CARD64)rep.ust_hi << 32) | (CARD64)rep.ust_lo;
633    *msc = ((CARD64)rep.msc_hi << 32) | (CARD64)rep.msc_lo;
634    *sbc = ((CARD64)rep.sbc_hi << 32) | (CARD64)rep.sbc_lo;
635
636    UnlockDisplay(dpy);
637    SyncHandle();
638
639    return True;
640}
641#endif
642
643#ifdef X_DRI2WaitSBC
644static void
645load_sbc_req(xDRI2WaitSBCReq *req, CARD64 target)
646{
647    req->target_sbc_hi = target >> 32;
648    req->target_sbc_lo = target & 0xffffffff;
649}
650
651Bool DRI2WaitSBC(Display *dpy, XID drawable, CARD64 target_sbc, CARD64 *ust,
652		 CARD64 *msc, CARD64 *sbc)
653{
654    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
655    xDRI2WaitSBCReq *req;
656    xDRI2MSCReply rep;
657
658    XextCheckExtension (dpy, info, dri2ExtensionName, False);
659
660    LockDisplay(dpy);
661    GetReq(DRI2WaitSBC, req);
662    req->reqType = info->codes->major_opcode;
663    req->dri2ReqType = X_DRI2WaitSBC;
664    req->drawable = drawable;
665    load_sbc_req(req, target_sbc);
666
667    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
668	UnlockDisplay(dpy);
669	SyncHandle();
670	return False;
671    }
672
673    *ust = ((CARD64)rep.ust_hi << 32) | rep.ust_lo;
674    *msc = ((CARD64)rep.msc_hi << 32) | rep.msc_lo;
675    *sbc = ((CARD64)rep.sbc_hi << 32) | rep.sbc_lo;
676
677    UnlockDisplay(dpy);
678    SyncHandle();
679
680    return True;
681}
682#endif
683
684#ifdef X_DRI2SwapInterval
685void DRI2SwapInterval(Display *dpy, XID drawable, int interval)
686{
687    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
688    xDRI2SwapIntervalReq *req;
689
690    XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
691
692    LockDisplay(dpy);
693    GetReq(DRI2SwapInterval, req);
694    req->reqType = info->codes->major_opcode;
695    req->dri2ReqType = X_DRI2SwapInterval;
696    req->drawable = drawable;
697    req->interval = interval;
698    UnlockDisplay(dpy);
699    SyncHandle();
700}
701#endif
702
703#endif /* GLX_DIRECT_RENDERING */
704