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