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