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