glx: Implement GLX_EXT_no_config_context
[mesa.git] / src / glx / g_glxglvnddispatchfuncs.c
1 #include <stdlib.h>
2
3 #include "glxclient.h"
4 #include "glxglvnd.h"
5 #include "glxglvnddispatchfuncs.h"
6 #include "g_glxglvnddispatchindices.h"
7
8 const int DI_FUNCTION_COUNT = DI_LAST_INDEX;
9 /* Allocate an extra 'dummy' to ease lookup. See FindGLXFunction() */
10 int __glXDispatchTableIndices[DI_LAST_INDEX + 1];
11 const __GLXapiExports *__glXGLVNDAPIExports;
12
13 const char * const __glXDispatchTableStrings[DI_LAST_INDEX] = {
14 #define __ATTRIB(field) \
15 [DI_##field] = "glX"#field
16
17 __ATTRIB(BindSwapBarrierSGIX),
18 __ATTRIB(BindTexImageEXT),
19 // glXChooseFBConfig implemented by libglvnd
20 __ATTRIB(ChooseFBConfigSGIX),
21 // glXChooseVisual implemented by libglvnd
22 // glXCopyContext implemented by libglvnd
23 __ATTRIB(CopySubBufferMESA),
24 // glXCreateContext implemented by libglvnd
25 __ATTRIB(CreateContextAttribsARB),
26 __ATTRIB(CreateContextWithConfigSGIX),
27 __ATTRIB(CreateGLXPbufferSGIX),
28 // glXCreateGLXPixmap implemented by libglvnd
29 __ATTRIB(CreateGLXPixmapMESA),
30 __ATTRIB(CreateGLXPixmapWithConfigSGIX),
31 // glXCreateNewContext implemented by libglvnd
32 // glXCreatePbuffer implemented by libglvnd
33 // glXCreatePixmap implemented by libglvnd
34 // glXCreateWindow implemented by libglvnd
35 // glXDestroyContext implemented by libglvnd
36 __ATTRIB(DestroyGLXPbufferSGIX),
37 // glXDestroyGLXPixmap implemented by libglvnd
38 // glXDestroyPbuffer implemented by libglvnd
39 // glXDestroyPixmap implemented by libglvnd
40 // glXDestroyWindow implemented by libglvnd
41 // glXFreeContextEXT implemented by libglvnd
42 // glXGetClientString implemented by libglvnd
43 // glXGetConfig implemented by libglvnd
44 __ATTRIB(GetContextIDEXT),
45 // glXGetCurrentContext implemented by libglvnd
46 // glXGetCurrentDisplay implemented by libglvnd
47 __ATTRIB(GetCurrentDisplayEXT),
48 // glXGetCurrentDrawable implemented by libglvnd
49 // glXGetCurrentReadDrawable implemented by libglvnd
50 __ATTRIB(GetDriverConfig),
51 // glXGetFBConfigAttrib implemented by libglvnd
52 __ATTRIB(GetFBConfigAttribSGIX),
53 __ATTRIB(GetFBConfigFromVisualSGIX),
54 // glXGetFBConfigs implemented by libglvnd
55 __ATTRIB(GetMscRateOML),
56 // glXGetProcAddress implemented by libglvnd
57 // glXGetProcAddressARB implemented by libglvnd
58 __ATTRIB(GetScreenDriver),
59 // glXGetSelectedEvent implemented by libglvnd
60 __ATTRIB(GetSelectedEventSGIX),
61 __ATTRIB(GetSwapIntervalMESA),
62 __ATTRIB(GetSyncValuesOML),
63 __ATTRIB(GetVideoSyncSGI),
64 // glXGetVisualFromFBConfig implemented by libglvnd
65 __ATTRIB(GetVisualFromFBConfigSGIX),
66 // glXImportContextEXT implemented by libglvnd
67 // glXIsDirect implemented by libglvnd
68 __ATTRIB(JoinSwapGroupSGIX),
69 // glXMakeContextCurrent implemented by libglvnd
70 // glXMakeCurrent implemented by libglvnd
71 // glXQueryContext implemented by libglvnd
72 __ATTRIB(QueryContextInfoEXT),
73 __ATTRIB(QueryCurrentRendererIntegerMESA),
74 __ATTRIB(QueryCurrentRendererStringMESA),
75 // glXQueryDrawable implemented by libglvnd
76 // glXQueryExtension implemented by libglvnd
77 // glXQueryExtensionsString implemented by libglvnd
78 __ATTRIB(QueryGLXPbufferSGIX),
79 __ATTRIB(QueryMaxSwapBarriersSGIX),
80 __ATTRIB(QueryRendererIntegerMESA),
81 __ATTRIB(QueryRendererStringMESA),
82 // glXQueryServerString implemented by libglvnd
83 // glXQueryVersion implemented by libglvnd
84 __ATTRIB(ReleaseBuffersMESA),
85 __ATTRIB(ReleaseTexImageEXT),
86 // glXSelectEvent implemented by libglvnd
87 __ATTRIB(SelectEventSGIX),
88 // glXSwapBuffers implemented by libglvnd
89 __ATTRIB(SwapBuffersMscOML),
90 __ATTRIB(SwapIntervalMESA),
91 __ATTRIB(SwapIntervalSGI),
92 // glXUseXFont implemented by libglvnd
93 __ATTRIB(WaitForMscOML),
94 __ATTRIB(WaitForSbcOML),
95 // glXWaitGL implemented by libglvnd
96 __ATTRIB(WaitVideoSyncSGI),
97 // glXWaitX implemented by libglvnd
98
99 #undef __ATTRIB
100 };
101
102 #define __FETCH_FUNCTION_PTR(func_name) \
103 p##func_name = (void *) \
104 __VND->fetchDispatchEntry(dd, __glXDispatchTableIndices[DI_##func_name])
105
106
107 static void dispatch_BindTexImageEXT(Display *dpy, GLXDrawable drawable,
108 int buffer, const int *attrib_list)
109 {
110 PFNGLXBINDTEXIMAGEEXTPROC pBindTexImageEXT;
111 __GLXvendorInfo *dd;
112
113 dd = GetDispatchFromDrawable(dpy, drawable);
114 if (dd == NULL)
115 return;
116
117 __FETCH_FUNCTION_PTR(BindTexImageEXT);
118 if (pBindTexImageEXT == NULL)
119 return;
120
121 pBindTexImageEXT(dpy, drawable, buffer, attrib_list);
122 }
123
124
125
126 static GLXFBConfigSGIX *dispatch_ChooseFBConfigSGIX(Display *dpy, int screen,
127 int *attrib_list,
128 int *nelements)
129 {
130 PFNGLXCHOOSEFBCONFIGSGIXPROC pChooseFBConfigSGIX;
131 __GLXvendorInfo *dd;
132 GLXFBConfigSGIX *ret;
133
134 dd = __VND->getDynDispatch(dpy, screen);
135 if (dd == NULL)
136 return NULL;
137
138 __FETCH_FUNCTION_PTR(ChooseFBConfigSGIX);
139 if (pChooseFBConfigSGIX == NULL)
140 return NULL;
141
142 ret = pChooseFBConfigSGIX(dpy, screen, attrib_list, nelements);
143 if (AddFBConfigsMapping(dpy, ret, nelements, dd)) {
144 free(ret);
145 return NULL;
146 }
147
148 return ret;
149 }
150
151
152
153 static GLXContext dispatch_CreateContextAttribsARB(Display *dpy,
154 GLXFBConfig config,
155 GLXContext share_list,
156 Bool direct,
157 const int *attrib_list)
158 {
159 PFNGLXCREATECONTEXTATTRIBSARBPROC pCreateContextAttribsARB;
160 __GLXvendorInfo *dd;
161 GLXContext ret;
162
163 if (config) {
164 dd = GetDispatchFromFBConfig(dpy, config);
165 } else if (attrib_list) {
166 int i, screen;
167
168 for (i = 0; attrib_list[i * 2] != None; i++) {
169 if (attrib_list[i * 2] == GLX_SCREEN) {
170 screen = attrib_list[i * 2 + 1];
171 dd = GetDispatchFromDrawable(dpy, RootWindow(dpy, screen));
172 break;
173 }
174 }
175 }
176 if (dd == NULL)
177 return None;
178
179 __FETCH_FUNCTION_PTR(CreateContextAttribsARB);
180 if (pCreateContextAttribsARB == NULL)
181 return None;
182
183 ret = pCreateContextAttribsARB(dpy, config, share_list, direct, attrib_list);
184 if (AddContextMapping(dpy, ret, dd)) {
185 /* XXX: Call glXDestroyContext which lives in libglvnd. If we're not
186 * allowed to call it from here, should we extend __glXDispatchTableIndices ?
187 */
188 return None;
189 }
190
191 return ret;
192 }
193
194
195
196 static GLXContext dispatch_CreateContextWithConfigSGIX(Display *dpy,
197 GLXFBConfigSGIX config,
198 int render_type,
199 GLXContext share_list,
200 Bool direct)
201 {
202 PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC pCreateContextWithConfigSGIX;
203 __GLXvendorInfo *dd;
204 GLXContext ret;
205
206 dd = GetDispatchFromFBConfig(dpy, config);
207 if (dd == NULL)
208 return None;
209
210 __FETCH_FUNCTION_PTR(CreateContextWithConfigSGIX);
211 if (pCreateContextWithConfigSGIX == NULL)
212 return None;
213
214 ret = pCreateContextWithConfigSGIX(dpy, config, render_type, share_list, direct);
215 if (AddContextMapping(dpy, ret, dd)) {
216 /* XXX: Call glXDestroyContext which lives in libglvnd. If we're not
217 * allowed to call it from here, should we extend __glXDispatchTableIndices ?
218 */
219 return None;
220 }
221
222 return ret;
223 }
224
225
226
227 static GLXPbuffer dispatch_CreateGLXPbufferSGIX(Display *dpy,
228 GLXFBConfig config,
229 unsigned int width,
230 unsigned int height,
231 int *attrib_list)
232 {
233 PFNGLXCREATEGLXPBUFFERSGIXPROC pCreateGLXPbufferSGIX;
234 __GLXvendorInfo *dd;
235 GLXPbuffer ret;
236
237 dd = GetDispatchFromFBConfig(dpy, config);
238 if (dd == NULL)
239 return None;
240
241 __FETCH_FUNCTION_PTR(CreateGLXPbufferSGIX);
242 if (pCreateGLXPbufferSGIX == NULL)
243 return None;
244
245 ret = pCreateGLXPbufferSGIX(dpy, config, width, height, attrib_list);
246 if (AddDrawableMapping(dpy, ret, dd)) {
247 PFNGLXDESTROYGLXPBUFFERSGIXPROC pDestroyGLXPbufferSGIX;
248
249 __FETCH_FUNCTION_PTR(DestroyGLXPbufferSGIX);
250 if (pDestroyGLXPbufferSGIX)
251 pDestroyGLXPbufferSGIX(dpy, ret);
252
253 return None;
254 }
255
256 return ret;
257 }
258
259
260
261 static GLXPixmap dispatch_CreateGLXPixmapWithConfigSGIX(Display *dpy,
262 GLXFBConfigSGIX config,
263 Pixmap pixmap)
264 {
265 PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC pCreateGLXPixmapWithConfigSGIX;
266 __GLXvendorInfo *dd;
267 GLXPixmap ret;
268
269 dd = GetDispatchFromFBConfig(dpy, config);
270 if (dd == NULL)
271 return None;
272
273 __FETCH_FUNCTION_PTR(CreateGLXPixmapWithConfigSGIX);
274 if (pCreateGLXPixmapWithConfigSGIX == NULL)
275 return None;
276
277 ret = pCreateGLXPixmapWithConfigSGIX(dpy, config, pixmap);
278 if (AddDrawableMapping(dpy, ret, dd)) {
279 /* XXX: Call glXDestroyGLXPixmap which lives in libglvnd. If we're not
280 * allowed to call it from here, should we extend __glXDispatchTableIndices ?
281 */
282 return None;
283 }
284
285 return ret;
286 }
287
288
289
290 static void dispatch_DestroyGLXPbufferSGIX(Display *dpy, GLXPbuffer pbuf)
291 {
292 PFNGLXDESTROYGLXPBUFFERSGIXPROC pDestroyGLXPbufferSGIX;
293 __GLXvendorInfo *dd;
294
295 dd = GetDispatchFromDrawable(dpy, pbuf);
296 if (dd == NULL)
297 return;
298
299 __FETCH_FUNCTION_PTR(DestroyGLXPbufferSGIX);
300 if (pDestroyGLXPbufferSGIX == NULL)
301 return;
302
303 pDestroyGLXPbufferSGIX(dpy, pbuf);
304 }
305
306
307
308 static GLXContextID dispatch_GetContextIDEXT(const GLXContext ctx)
309 {
310 PFNGLXGETCONTEXTIDEXTPROC pGetContextIDEXT;
311 __GLXvendorInfo *dd;
312
313 dd = GetDispatchFromContext(ctx);
314 if (dd == NULL)
315 return None;
316
317 __FETCH_FUNCTION_PTR(GetContextIDEXT);
318 if (pGetContextIDEXT == NULL)
319 return None;
320
321 return pGetContextIDEXT(ctx);
322 }
323
324
325
326 static Display *dispatch_GetCurrentDisplayEXT(void)
327 {
328 PFNGLXGETCURRENTDISPLAYEXTPROC pGetCurrentDisplayEXT;
329 __GLXvendorInfo *dd;
330
331 if (!__VND->getCurrentContext())
332 return NULL;
333
334 dd = __VND->getCurrentDynDispatch();
335 if (dd == NULL)
336 return NULL;
337
338 __FETCH_FUNCTION_PTR(GetCurrentDisplayEXT);
339 if (pGetCurrentDisplayEXT == NULL)
340 return NULL;
341
342 return pGetCurrentDisplayEXT();
343 }
344
345
346
347 static const char *dispatch_GetDriverConfig(const char *driverName)
348 {
349 #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
350 /*
351 * The options are constant for a given driverName, so we do not need
352 * a context (and apps expect to be able to call this without one).
353 */
354 return glXGetDriverConfig(driverName);
355 #else
356 return NULL;
357 #endif
358 }
359
360
361
362 static int dispatch_GetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config,
363 int attribute, int *value_return)
364 {
365 PFNGLXGETFBCONFIGATTRIBSGIXPROC pGetFBConfigAttribSGIX;
366 __GLXvendorInfo *dd;
367
368 dd = GetDispatchFromFBConfig(dpy, config);
369 if (dd == NULL)
370 return GLX_NO_EXTENSION;
371
372 __FETCH_FUNCTION_PTR(GetFBConfigAttribSGIX);
373 if (pGetFBConfigAttribSGIX == NULL)
374 return GLX_NO_EXTENSION;
375
376 return pGetFBConfigAttribSGIX(dpy, config, attribute, value_return);
377 }
378
379
380
381 static GLXFBConfigSGIX dispatch_GetFBConfigFromVisualSGIX(Display *dpy,
382 XVisualInfo *vis)
383 {
384 PFNGLXGETFBCONFIGFROMVISUALSGIXPROC pGetFBConfigFromVisualSGIX;
385 __GLXvendorInfo *dd;
386 GLXFBConfigSGIX ret = NULL;
387
388 dd = GetDispatchFromVisual(dpy, vis);
389 if (dd == NULL)
390 return NULL;
391
392 __FETCH_FUNCTION_PTR(GetFBConfigFromVisualSGIX);
393 if (pGetFBConfigFromVisualSGIX == NULL)
394 return NULL;
395
396 ret = pGetFBConfigFromVisualSGIX(dpy, vis);
397 if (AddFBConfigMapping(dpy, ret, dd))
398 /* XXX: dealloc ret ? */
399 return NULL;
400
401 return ret;
402 }
403
404
405
406 static void dispatch_GetSelectedEventSGIX(Display *dpy, GLXDrawable drawable,
407 unsigned long *mask)
408 {
409 PFNGLXGETSELECTEDEVENTSGIXPROC pGetSelectedEventSGIX;
410 __GLXvendorInfo *dd;
411
412 dd = GetDispatchFromDrawable(dpy, drawable);
413 if (dd == NULL)
414 return;
415
416 __FETCH_FUNCTION_PTR(GetSelectedEventSGIX);
417 if (pGetSelectedEventSGIX == NULL)
418 return;
419
420 pGetSelectedEventSGIX(dpy, drawable, mask);
421 }
422
423
424
425 static int dispatch_GetVideoSyncSGI(unsigned int *count)
426 {
427 PFNGLXGETVIDEOSYNCSGIPROC pGetVideoSyncSGI;
428 __GLXvendorInfo *dd;
429
430 if (!__VND->getCurrentContext())
431 return GLX_BAD_CONTEXT;
432
433 dd = __VND->getCurrentDynDispatch();
434 if (dd == NULL)
435 return GLX_NO_EXTENSION;
436
437 __FETCH_FUNCTION_PTR(GetVideoSyncSGI);
438 if (pGetVideoSyncSGI == NULL)
439 return GLX_NO_EXTENSION;
440
441 return pGetVideoSyncSGI(count);
442 }
443
444
445
446 static XVisualInfo *dispatch_GetVisualFromFBConfigSGIX(Display *dpy,
447 GLXFBConfigSGIX config)
448 {
449 PFNGLXGETVISUALFROMFBCONFIGSGIXPROC pGetVisualFromFBConfigSGIX;
450 __GLXvendorInfo *dd;
451
452 dd = GetDispatchFromFBConfig(dpy, config);
453 if (dd == NULL)
454 return NULL;
455
456 __FETCH_FUNCTION_PTR(GetVisualFromFBConfigSGIX);
457 if (pGetVisualFromFBConfigSGIX == NULL)
458 return NULL;
459
460 return pGetVisualFromFBConfigSGIX(dpy, config);
461 }
462
463
464
465 static int dispatch_QueryContextInfoEXT(Display *dpy, GLXContext ctx,
466 int attribute, int *value)
467 {
468 PFNGLXQUERYCONTEXTINFOEXTPROC pQueryContextInfoEXT;
469 __GLXvendorInfo *dd;
470
471 dd = GetDispatchFromContext(ctx);
472 if (dd == NULL)
473 return GLX_NO_EXTENSION;
474
475 __FETCH_FUNCTION_PTR(QueryContextInfoEXT);
476 if (pQueryContextInfoEXT == NULL)
477 return GLX_NO_EXTENSION;
478
479 return pQueryContextInfoEXT(dpy, ctx, attribute, value);
480 }
481
482
483
484 static void dispatch_QueryGLXPbufferSGIX(Display *dpy, GLXPbuffer pbuf,
485 int attribute, unsigned int *value)
486 {
487 PFNGLXQUERYGLXPBUFFERSGIXPROC pQueryGLXPbufferSGIX;
488 __GLXvendorInfo *dd;
489
490 dd = GetDispatchFromDrawable(dpy, pbuf);
491 if (dd == NULL)
492 return;
493
494 __FETCH_FUNCTION_PTR(QueryGLXPbufferSGIX);
495 if (pQueryGLXPbufferSGIX == NULL)
496 return;
497
498 pQueryGLXPbufferSGIX(dpy, pbuf, attribute, value);
499 }
500
501
502
503 static void dispatch_ReleaseTexImageEXT(Display *dpy, GLXDrawable drawable,
504 int buffer)
505 {
506 PFNGLXRELEASETEXIMAGEEXTPROC pReleaseTexImageEXT;
507 __GLXvendorInfo *dd;
508
509 dd = GetDispatchFromDrawable(dpy, drawable);
510 if (dd == NULL)
511 return;
512
513 __FETCH_FUNCTION_PTR(ReleaseTexImageEXT);
514 if (pReleaseTexImageEXT == NULL)
515 return;
516
517 pReleaseTexImageEXT(dpy, drawable, buffer);
518 }
519
520
521
522 static void dispatch_SelectEventSGIX(Display *dpy, GLXDrawable drawable,
523 unsigned long mask)
524 {
525 PFNGLXSELECTEVENTSGIXPROC pSelectEventSGIX;
526 __GLXvendorInfo *dd;
527
528 dd = GetDispatchFromDrawable(dpy, drawable);
529 if (dd == NULL)
530 return;
531
532 __FETCH_FUNCTION_PTR(SelectEventSGIX);
533 if (pSelectEventSGIX == NULL)
534 return;
535
536 pSelectEventSGIX(dpy, drawable, mask);
537 }
538
539
540
541 static int dispatch_SwapIntervalSGI(int interval)
542 {
543 PFNGLXSWAPINTERVALSGIPROC pSwapIntervalSGI;
544 __GLXvendorInfo *dd;
545
546 if (!__VND->getCurrentContext())
547 return GLX_BAD_CONTEXT;
548
549 dd = __VND->getCurrentDynDispatch();
550 if (dd == NULL)
551 return GLX_NO_EXTENSION;
552
553 __FETCH_FUNCTION_PTR(SwapIntervalSGI);
554 if (pSwapIntervalSGI == NULL)
555 return GLX_NO_EXTENSION;
556
557 return pSwapIntervalSGI(interval);
558 }
559
560
561
562 static int dispatch_WaitVideoSyncSGI(int divisor, int remainder,
563 unsigned int *count)
564 {
565 PFNGLXWAITVIDEOSYNCSGIPROC pWaitVideoSyncSGI;
566 __GLXvendorInfo *dd;
567
568 if (!__VND->getCurrentContext())
569 return GLX_BAD_CONTEXT;
570
571 dd = __VND->getCurrentDynDispatch();
572 if (dd == NULL)
573 return GLX_NO_EXTENSION;
574
575 __FETCH_FUNCTION_PTR(WaitVideoSyncSGI);
576 if (pWaitVideoSyncSGI == NULL)
577 return GLX_NO_EXTENSION;
578
579 return pWaitVideoSyncSGI(divisor, remainder, count);
580 }
581
582
583
584 static void dispatch_BindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable,
585 int barrier)
586 {
587 PFNGLXBINDSWAPBARRIERSGIXPROC pBindSwapBarrierSGIX;
588 __GLXvendorInfo *dd;
589
590 dd = GetDispatchFromDrawable(dpy, drawable);
591 if (dd == NULL)
592 return;
593
594 __FETCH_FUNCTION_PTR(BindSwapBarrierSGIX);
595 if (pBindSwapBarrierSGIX == NULL)
596 return;
597
598 pBindSwapBarrierSGIX(dpy, drawable, barrier);
599 }
600
601
602
603 static void dispatch_CopySubBufferMESA(Display *dpy, GLXDrawable drawable,
604 int x, int y, int width, int height)
605 {
606 PFNGLXCOPYSUBBUFFERMESAPROC pCopySubBufferMESA;
607 __GLXvendorInfo *dd;
608
609 dd = GetDispatchFromDrawable(dpy, drawable);
610 if (dd == NULL)
611 return;
612
613 __FETCH_FUNCTION_PTR(CopySubBufferMESA);
614 if (pCopySubBufferMESA == NULL)
615 return;
616
617 pCopySubBufferMESA(dpy, drawable, x, y, width, height);
618 }
619
620
621
622 static GLXPixmap dispatch_CreateGLXPixmapMESA(Display *dpy,
623 XVisualInfo *visinfo,
624 Pixmap pixmap, Colormap cmap)
625 {
626 PFNGLXCREATEGLXPIXMAPMESAPROC pCreateGLXPixmapMESA;
627 __GLXvendorInfo *dd;
628 GLXPixmap ret;
629
630 dd = GetDispatchFromVisual(dpy, visinfo);
631 if (dd == NULL)
632 return None;
633
634 __FETCH_FUNCTION_PTR(CreateGLXPixmapMESA);
635 if (pCreateGLXPixmapMESA == NULL)
636 return None;
637
638 ret = pCreateGLXPixmapMESA(dpy, visinfo, pixmap, cmap);
639 if (AddDrawableMapping(dpy, ret, dd)) {
640 /* XXX: Call glXDestroyGLXPixmap which lives in libglvnd. If we're not
641 * allowed to call it from here, should we extend __glXDispatchTableIndices ?
642 */
643 return None;
644 }
645
646 return ret;
647 }
648
649
650
651 static GLboolean dispatch_GetMscRateOML(Display *dpy, GLXDrawable drawable,
652 int32_t *numerator, int32_t *denominator)
653 {
654 PFNGLXGETMSCRATEOMLPROC pGetMscRateOML;
655 __GLXvendorInfo *dd;
656
657 dd = GetDispatchFromDrawable(dpy, drawable);
658 if (dd == NULL)
659 return GL_FALSE;
660
661 __FETCH_FUNCTION_PTR(GetMscRateOML);
662 if (pGetMscRateOML == NULL)
663 return GL_FALSE;
664
665 return pGetMscRateOML(dpy, drawable, numerator, denominator);
666 }
667
668
669
670 static const char *dispatch_GetScreenDriver(Display *dpy, int scrNum)
671 {
672 typedef const char *(*fn_glXGetScreenDriver_ptr)(Display *dpy, int scrNum);
673 fn_glXGetScreenDriver_ptr pGetScreenDriver;
674 __GLXvendorInfo *dd;
675
676 dd = __VND->getDynDispatch(dpy, scrNum);
677 if (dd == NULL)
678 return NULL;
679
680 __FETCH_FUNCTION_PTR(GetScreenDriver);
681 if (pGetScreenDriver == NULL)
682 return NULL;
683
684 return pGetScreenDriver(dpy, scrNum);
685 }
686
687
688
689 static int dispatch_GetSwapIntervalMESA(void)
690 {
691 PFNGLXGETSWAPINTERVALMESAPROC pGetSwapIntervalMESA;
692 __GLXvendorInfo *dd;
693
694 if (!__VND->getCurrentContext())
695 return GLX_BAD_CONTEXT;
696
697 dd = __VND->getCurrentDynDispatch();
698 if (dd == NULL)
699 return 0;
700
701 __FETCH_FUNCTION_PTR(GetSwapIntervalMESA);
702 if (pGetSwapIntervalMESA == NULL)
703 return 0;
704
705 return pGetSwapIntervalMESA();
706 }
707
708
709
710 static Bool dispatch_GetSyncValuesOML(Display *dpy, GLXDrawable drawable,
711 int64_t *ust, int64_t *msc, int64_t *sbc)
712 {
713 PFNGLXGETSYNCVALUESOMLPROC pGetSyncValuesOML;
714 __GLXvendorInfo *dd;
715
716 dd = GetDispatchFromDrawable(dpy, drawable);
717 if (dd == NULL)
718 return False;
719
720 __FETCH_FUNCTION_PTR(GetSyncValuesOML);
721 if (pGetSyncValuesOML == NULL)
722 return False;
723
724 return pGetSyncValuesOML(dpy, drawable, ust, msc, sbc);
725 }
726
727
728
729 static void dispatch_JoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable,
730 GLXDrawable member)
731 {
732 PFNGLXJOINSWAPGROUPSGIXPROC pJoinSwapGroupSGIX;
733 __GLXvendorInfo *dd;
734
735 dd = GetDispatchFromDrawable(dpy, drawable);
736 if (dd == NULL)
737 return;
738
739 __FETCH_FUNCTION_PTR(JoinSwapGroupSGIX);
740 if (pJoinSwapGroupSGIX == NULL)
741 return;
742
743 pJoinSwapGroupSGIX(dpy, drawable, member);
744 }
745
746
747
748 static Bool dispatch_QueryCurrentRendererIntegerMESA(int attribute,
749 unsigned int *value)
750 {
751 PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC pQueryCurrentRendererIntegerMESA;
752 __GLXvendorInfo *dd;
753
754 if (!__VND->getCurrentContext())
755 return False;
756
757 dd = __VND->getCurrentDynDispatch();
758 if (dd == NULL)
759 return False;
760
761 __FETCH_FUNCTION_PTR(QueryCurrentRendererIntegerMESA);
762 if (pQueryCurrentRendererIntegerMESA == NULL)
763 return False;
764
765 return pQueryCurrentRendererIntegerMESA(attribute, value);
766 }
767
768
769
770 static const char *dispatch_QueryCurrentRendererStringMESA(int attribute)
771 {
772 PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC pQueryCurrentRendererStringMESA;
773 __GLXvendorInfo *dd;
774
775 if (!__VND->getCurrentContext())
776 return NULL;
777
778 dd = __VND->getCurrentDynDispatch();
779 if (dd == NULL)
780 return NULL;
781
782 __FETCH_FUNCTION_PTR(QueryCurrentRendererStringMESA);
783 if (pQueryCurrentRendererStringMESA == NULL)
784 return NULL;
785
786 return pQueryCurrentRendererStringMESA(attribute);
787 }
788
789
790
791 static Bool dispatch_QueryMaxSwapBarriersSGIX(Display *dpy, int screen,
792 int *max)
793 {
794 PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC pQueryMaxSwapBarriersSGIX;
795 __GLXvendorInfo *dd;
796
797 dd = __VND->getDynDispatch(dpy, screen);
798 if (dd == NULL)
799 return False;
800
801 __FETCH_FUNCTION_PTR(QueryMaxSwapBarriersSGIX);
802 if (pQueryMaxSwapBarriersSGIX == NULL)
803 return False;
804
805 return pQueryMaxSwapBarriersSGIX(dpy, screen, max);
806 }
807
808
809
810 static Bool dispatch_QueryRendererIntegerMESA(Display *dpy, int screen,
811 int renderer, int attribute,
812 unsigned int *value)
813 {
814 PFNGLXQUERYRENDERERINTEGERMESAPROC pQueryRendererIntegerMESA;
815 __GLXvendorInfo *dd;
816
817 dd = __VND->getDynDispatch(dpy, screen);
818 if (dd == NULL)
819 return False;
820
821 __FETCH_FUNCTION_PTR(QueryRendererIntegerMESA);
822 if (pQueryRendererIntegerMESA == NULL)
823 return False;
824
825 return pQueryRendererIntegerMESA(dpy, screen, renderer, attribute, value);
826 }
827
828
829
830 static const char *dispatch_QueryRendererStringMESA(Display *dpy, int screen,
831 int renderer, int attribute)
832 {
833 PFNGLXQUERYRENDERERSTRINGMESAPROC pQueryRendererStringMESA;
834 __GLXvendorInfo *dd = NULL;
835
836 dd = __VND->getDynDispatch(dpy, screen);
837 if (dd == NULL)
838 return NULL;
839
840 __FETCH_FUNCTION_PTR(QueryRendererStringMESA);
841 if (pQueryRendererStringMESA == NULL)
842 return NULL;
843
844 return pQueryRendererStringMESA(dpy, screen, renderer, attribute);
845 }
846
847
848
849 static Bool dispatch_ReleaseBuffersMESA(Display *dpy, GLXDrawable d)
850 {
851 PFNGLXRELEASEBUFFERSMESAPROC pReleaseBuffersMESA;
852 __GLXvendorInfo *dd;
853
854 dd = GetDispatchFromDrawable(dpy, d);
855 if (dd == NULL)
856 return False;
857
858 __FETCH_FUNCTION_PTR(ReleaseBuffersMESA);
859 if (pReleaseBuffersMESA == NULL)
860 return False;
861
862 return pReleaseBuffersMESA(dpy, d);
863 }
864
865
866
867 static int64_t dispatch_SwapBuffersMscOML(Display *dpy, GLXDrawable drawable,
868 int64_t target_msc, int64_t divisor,
869 int64_t remainder)
870 {
871 PFNGLXSWAPBUFFERSMSCOMLPROC pSwapBuffersMscOML;
872 __GLXvendorInfo *dd;
873
874 dd = GetDispatchFromDrawable(dpy, drawable);
875 if (dd == NULL)
876 return 0;
877
878 __FETCH_FUNCTION_PTR(SwapBuffersMscOML);
879 if (pSwapBuffersMscOML == NULL)
880 return 0;
881
882 return pSwapBuffersMscOML(dpy, drawable, target_msc, divisor, remainder);
883 }
884
885
886
887 static int dispatch_SwapIntervalMESA(unsigned int interval)
888 {
889 PFNGLXSWAPINTERVALMESAPROC pSwapIntervalMESA;
890 __GLXvendorInfo *dd;
891
892 if (!__VND->getCurrentContext())
893 return GLX_BAD_CONTEXT;
894
895 dd = __VND->getCurrentDynDispatch();
896 if (dd == NULL)
897 return 0;
898
899 __FETCH_FUNCTION_PTR(SwapIntervalMESA);
900 if (pSwapIntervalMESA == NULL)
901 return 0;
902
903 return pSwapIntervalMESA(interval);
904 }
905
906
907
908 static Bool dispatch_WaitForMscOML(Display *dpy, GLXDrawable drawable,
909 int64_t target_msc, int64_t divisor,
910 int64_t remainder, int64_t *ust,
911 int64_t *msc, int64_t *sbc)
912 {
913 PFNGLXWAITFORMSCOMLPROC pWaitForMscOML;
914 __GLXvendorInfo *dd;
915
916 dd = GetDispatchFromDrawable(dpy, drawable);
917 if (dd == NULL)
918 return False;
919
920 __FETCH_FUNCTION_PTR(WaitForMscOML);
921 if (pWaitForMscOML == NULL)
922 return False;
923
924 return pWaitForMscOML(dpy, drawable, target_msc, divisor, remainder, ust, msc, sbc);
925 }
926
927
928
929 static Bool dispatch_WaitForSbcOML(Display *dpy, GLXDrawable drawable,
930 int64_t target_sbc, int64_t *ust,
931 int64_t *msc, int64_t *sbc)
932 {
933 PFNGLXWAITFORSBCOMLPROC pWaitForSbcOML;
934 __GLXvendorInfo *dd;
935
936 dd = GetDispatchFromDrawable(dpy, drawable);
937 if (dd == NULL)
938 return False;
939
940 __FETCH_FUNCTION_PTR(WaitForSbcOML);
941 if (pWaitForSbcOML == NULL)
942 return False;
943
944 return pWaitForSbcOML(dpy, drawable, target_sbc, ust, msc, sbc);
945 }
946
947 #undef __FETCH_FUNCTION_PTR
948
949
950 /* Allocate an extra 'dummy' to ease lookup. See FindGLXFunction() */
951 const void * const __glXDispatchFunctions[DI_LAST_INDEX + 1] = {
952 #define __ATTRIB(field) \
953 [DI_##field] = (void *)dispatch_##field
954
955 __ATTRIB(BindSwapBarrierSGIX),
956 __ATTRIB(BindTexImageEXT),
957 __ATTRIB(ChooseFBConfigSGIX),
958 __ATTRIB(CopySubBufferMESA),
959 __ATTRIB(CreateContextAttribsARB),
960 __ATTRIB(CreateContextWithConfigSGIX),
961 __ATTRIB(CreateGLXPbufferSGIX),
962 __ATTRIB(CreateGLXPixmapMESA),
963 __ATTRIB(CreateGLXPixmapWithConfigSGIX),
964 __ATTRIB(DestroyGLXPbufferSGIX),
965 __ATTRIB(GetContextIDEXT),
966 __ATTRIB(GetCurrentDisplayEXT),
967 __ATTRIB(GetDriverConfig),
968 __ATTRIB(GetFBConfigAttribSGIX),
969 __ATTRIB(GetFBConfigFromVisualSGIX),
970 __ATTRIB(GetMscRateOML),
971 __ATTRIB(GetScreenDriver),
972 __ATTRIB(GetSelectedEventSGIX),
973 __ATTRIB(GetSwapIntervalMESA),
974 __ATTRIB(GetSyncValuesOML),
975 __ATTRIB(GetVideoSyncSGI),
976 __ATTRIB(GetVisualFromFBConfigSGIX),
977 __ATTRIB(JoinSwapGroupSGIX),
978 __ATTRIB(QueryContextInfoEXT),
979 __ATTRIB(QueryCurrentRendererIntegerMESA),
980 __ATTRIB(QueryCurrentRendererStringMESA),
981 __ATTRIB(QueryGLXPbufferSGIX),
982 __ATTRIB(QueryMaxSwapBarriersSGIX),
983 __ATTRIB(QueryRendererIntegerMESA),
984 __ATTRIB(QueryRendererStringMESA),
985 __ATTRIB(ReleaseBuffersMESA),
986 __ATTRIB(ReleaseTexImageEXT),
987 __ATTRIB(SelectEventSGIX),
988 __ATTRIB(SwapBuffersMscOML),
989 __ATTRIB(SwapIntervalMESA),
990 __ATTRIB(SwapIntervalSGI),
991 __ATTRIB(WaitForMscOML),
992 __ATTRIB(WaitForSbcOML),
993 __ATTRIB(WaitVideoSyncSGI),
994
995 [DI_LAST_INDEX] = NULL,
996 #undef __ATTRIB
997 };