-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
renderer_gl.cpp
8837 lines (7703 loc) · 269 KB
/
renderer_gl.cpp
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
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright 2011-2022 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/
#include "bgfx_p.h"
#if (BGFX_CONFIG_RENDERER_OPENGLES || BGFX_CONFIG_RENDERER_OPENGL)
# include "renderer_gl.h"
# include <bx/timer.h>
# include <bx/uint32_t.h>
# include "emscripten.h"
namespace bgfx { namespace gl
{
static char s_viewName[BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME];
inline void setViewType(ViewId _view, const bx::StringView _str)
{
if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION || BGFX_CONFIG_PROFILER) )
{
bx::memCopy(&s_viewName[_view][3], _str.getPtr(), _str.getLength() );
}
}
struct PrimInfo
{
GLenum m_type;
uint32_t m_min;
uint32_t m_div;
uint32_t m_sub;
};
static const PrimInfo s_primInfo[] =
{
{ GL_TRIANGLES, 3, 3, 0 },
{ GL_TRIANGLE_STRIP, 3, 1, 2 },
{ GL_LINES, 2, 2, 0 },
{ GL_LINE_STRIP, 2, 1, 1 },
{ GL_POINTS, 1, 1, 0 },
{ GL_ZERO, 0, 0, 0 },
};
BX_STATIC_ASSERT(Topology::Count == BX_COUNTOF(s_primInfo)-1);
static const char* s_attribName[] =
{
"a_position",
"a_normal",
"a_tangent",
"a_bitangent",
"a_color0",
"a_color1",
"a_color2",
"a_color3",
"a_indices",
"a_weight",
"a_texcoord0",
"a_texcoord1",
"a_texcoord2",
"a_texcoord3",
"a_texcoord4",
"a_texcoord5",
"a_texcoord6",
"a_texcoord7",
};
BX_STATIC_ASSERT(Attrib::Count == BX_COUNTOF(s_attribName) );
static const char* s_instanceDataName[] =
{
"i_data0",
"i_data1",
"i_data2",
"i_data3",
"i_data4",
};
BX_STATIC_ASSERT(BGFX_CONFIG_MAX_INSTANCE_DATA_COUNT == BX_COUNTOF(s_instanceDataName) );
static const GLenum s_access[] =
{
GL_READ_ONLY,
GL_WRITE_ONLY,
GL_READ_WRITE,
};
BX_STATIC_ASSERT(Access::Count == BX_COUNTOF(s_access) );
static const GLenum s_attribType[] =
{
GL_UNSIGNED_BYTE, // Uint8
GL_UNSIGNED_INT_10_10_10_2, // Uint10
GL_SHORT, // Int16
GL_HALF_FLOAT, // Half
GL_FLOAT, // Float
};
BX_STATIC_ASSERT(AttribType::Count == BX_COUNTOF(s_attribType) );
struct Blend
{
GLenum m_src;
GLenum m_dst;
bool m_factor;
};
static const Blend s_blendFactor[] =
{
{ 0, 0, false }, // ignored
{ GL_ZERO, GL_ZERO, false }, // ZERO
{ GL_ONE, GL_ONE, false }, // ONE
{ GL_SRC_COLOR, GL_SRC_COLOR, false }, // SRC_COLOR
{ GL_ONE_MINUS_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, false }, // INV_SRC_COLOR
{ GL_SRC_ALPHA, GL_SRC_ALPHA, false }, // SRC_ALPHA
{ GL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, false }, // INV_SRC_ALPHA
{ GL_DST_ALPHA, GL_DST_ALPHA, false }, // DST_ALPHA
{ GL_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA, false }, // INV_DST_ALPHA
{ GL_DST_COLOR, GL_DST_COLOR, false }, // DST_COLOR
{ GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_DST_COLOR, false }, // INV_DST_COLOR
{ GL_SRC_ALPHA_SATURATE, GL_ONE, false }, // SRC_ALPHA_SAT
{ GL_CONSTANT_COLOR, GL_CONSTANT_COLOR, true }, // FACTOR
{ GL_ONE_MINUS_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR, true }, // INV_FACTOR
};
static const GLenum s_blendEquation[] =
{
GL_FUNC_ADD,
GL_FUNC_SUBTRACT,
GL_FUNC_REVERSE_SUBTRACT,
GL_MIN,
GL_MAX,
};
static const GLenum s_cmpFunc[] =
{
0, // ignored
GL_LESS,
GL_LEQUAL,
GL_EQUAL,
GL_GEQUAL,
GL_GREATER,
GL_NOTEQUAL,
GL_NEVER,
GL_ALWAYS,
};
static const GLenum s_stencilOp[] =
{
GL_ZERO,
GL_KEEP,
GL_REPLACE,
GL_INCR_WRAP,
GL_INCR,
GL_DECR_WRAP,
GL_DECR,
GL_INVERT,
};
static const GLenum s_stencilFace[] =
{
GL_FRONT_AND_BACK,
GL_FRONT,
GL_BACK,
};
static GLenum s_textureAddress[] =
{
GL_REPEAT,
GL_MIRRORED_REPEAT,
GL_CLAMP_TO_EDGE,
GL_CLAMP_TO_BORDER,
};
static const GLenum s_textureFilterMag[] =
{
GL_LINEAR,
GL_NEAREST,
GL_LINEAR,
};
static const GLenum s_textureFilterMin[][3] =
{
{ GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_NEAREST },
{ GL_NEAREST, GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_NEAREST },
{ GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_NEAREST },
};
struct TextureFormatInfo
{
GLenum m_internalFmt;
GLenum m_internalFmtSrgb;
GLenum m_fmt;
GLenum m_fmtSrgb;
GLenum m_type;
bool m_supported;
GLint m_mapping[4];
};
// In desktop OpenGL 4+ and OpenGL ES 3.0+, specific GL formats GL_x_INTEGER are used for integer textures.
// For older desktop OpenGL contexts, GL names without _INTEGER suffix were used.
// See http://docs.gl/gl4/glTexImage2D, http://docs.gl/gl3/glTexImage2D, http://docs.gl/es3/glTexImage2D
#if BGFX_CONFIG_RENDERER_OPENGL >= 40 || BGFX_CONFIG_RENDERER_OPENGLES
# define RED_INTEGER GL_RED_INTEGER
# define RG_INTEGER GL_RG_INTEGER
# define RGB_INTEGER GL_RGB_INTEGER
# define RGBA_INTEGER GL_RGBA_INTEGER
#else
# define RED_INTEGER GL_RED
# define RG_INTEGER GL_RG
# define RGB_INTEGER GL_RGB
# define RGBA_INTEGER GL_RGBA
#endif
static TextureFormatInfo s_textureFormat[] =
{
#define $_ -1
#define $0 GL_ZERO
#define $1 GL_ONE
#define $R GL_RED
#define $G GL_GREEN
#define $B GL_BLUE
#define $A GL_ALPHA
{ GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_ZERO, false, { $_, $_, $_, $_ } }, // BC1
{ GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_ZERO, false, { $_, $_, $_, $_ } }, // BC2
{ GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_ZERO, false, { $_, $_, $_, $_ } }, // BC3
{ GL_COMPRESSED_LUMINANCE_LATC1_EXT, GL_ZERO, GL_COMPRESSED_LUMINANCE_LATC1_EXT, GL_COMPRESSED_LUMINANCE_LATC1_EXT, GL_ZERO, false, { $_, $_, $_, $_ } }, // BC4
{ GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT, GL_ZERO, GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT, GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT, GL_ZERO, false, { $_, $_, $_, $_ } }, // BC5
{ GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, GL_ZERO, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, GL_ZERO, false, { $_, $_, $_, $_ } }, // BC6H
{ GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB, GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_ZERO, false, { $_, $_, $_, $_ } }, // BC7
{ GL_ETC1_RGB8_OES, GL_ZERO, GL_ETC1_RGB8_OES, GL_ETC1_RGB8_OES, GL_ZERO, false, { $_, $_, $_, $_ } }, // ETC1
{ GL_COMPRESSED_RGB8_ETC2, GL_ZERO, GL_COMPRESSED_RGB8_ETC2, GL_COMPRESSED_RGB8_ETC2, GL_ZERO, false, { $_, $_, $_, $_ } }, // ETC2
{ GL_COMPRESSED_RGBA8_ETC2_EAC, GL_COMPRESSED_SRGB8_ETC2, GL_COMPRESSED_RGBA8_ETC2_EAC, GL_COMPRESSED_RGBA8_ETC2_EAC, GL_ZERO, false, { $_, $_, $_, $_ } }, // ETC2A
{ GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_ZERO, false, { $_, $_, $_, $_ } }, // ETC2A1
{ GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT, GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, GL_ZERO, false, { $_, $_, $_, $_ } }, // PTC12
{ GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT, GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, GL_ZERO, false, { $_, $_, $_, $_ } }, // PTC14
{ GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, GL_ZERO, false, { $_, $_, $_, $_ } }, // PTC12A
{ GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, GL_ZERO, false, { $_, $_, $_, $_ } }, // PTC14A
{ GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG, GL_ZERO, GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG, GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG, GL_ZERO, false, { $_, $_, $_, $_ } }, // PTC22
{ GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG, GL_ZERO, GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG, GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG, GL_ZERO, false, { $_, $_, $_, $_ } }, // PTC24
{ GL_ATC_RGB_AMD, GL_ZERO, GL_ATC_RGB_AMD, GL_ATC_RGB_AMD, GL_ZERO, false, { $_, $_, $_, $_ } }, // ATC
{ GL_ATC_RGBA_EXPLICIT_ALPHA_AMD, GL_ZERO, GL_ATC_RGBA_EXPLICIT_ALPHA_AMD, GL_ATC_RGBA_EXPLICIT_ALPHA_AMD, GL_ZERO, false, { $_, $_, $_, $_ } }, // ATCE
{ GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD, GL_ZERO, GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD, GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD, GL_ZERO, false, { $_, $_, $_, $_ } }, // ATCI
{ GL_COMPRESSED_RGBA_ASTC_4x4_KHR, GL_COMPRESSED_SRGB8_ASTC_4x4_KHR, GL_COMPRESSED_RGBA_ASTC_4x4_KHR, GL_COMPRESSED_RGBA_ASTC_4x4_KHR, GL_ZERO, false, { $_, $_, $_, $_ } }, // ASTC4x4
{ GL_COMPRESSED_RGBA_ASTC_5x5_KHR, GL_COMPRESSED_SRGB8_ASTC_5x5_KHR, GL_COMPRESSED_RGBA_ASTC_5x5_KHR, GL_COMPRESSED_RGBA_ASTC_5x5_KHR, GL_ZERO, false, { $_, $_, $_, $_ } }, // ASTC5x5
{ GL_COMPRESSED_RGBA_ASTC_6x6_KHR, GL_COMPRESSED_SRGB8_ASTC_6x6_KHR, GL_COMPRESSED_RGBA_ASTC_6x6_KHR, GL_COMPRESSED_RGBA_ASTC_6x6_KHR, GL_ZERO, false, { $_, $_, $_, $_ } }, // ASTC6x6
{ GL_COMPRESSED_RGBA_ASTC_8x5_KHR, GL_COMPRESSED_SRGB8_ASTC_8x5_KHR, GL_COMPRESSED_RGBA_ASTC_8x5_KHR, GL_COMPRESSED_RGBA_ASTC_8x5_KHR, GL_ZERO, false, { $_, $_, $_, $_ } }, // ASTC8x5
{ GL_COMPRESSED_RGBA_ASTC_8x6_KHR, GL_COMPRESSED_SRGB8_ASTC_8x6_KHR, GL_COMPRESSED_RGBA_ASTC_8x6_KHR, GL_COMPRESSED_RGBA_ASTC_8x6_KHR, GL_ZERO, false, { $_, $_, $_, $_ } }, // ASTC8x6
{ GL_COMPRESSED_RGBA_ASTC_10x5_KHR, GL_COMPRESSED_SRGB8_ASTC_10x5_KHR, GL_COMPRESSED_RGBA_ASTC_10x5_KHR, GL_COMPRESSED_RGBA_ASTC_10x5_KHR, GL_ZERO, false, { $_, $_, $_, $_ } }, // ASTC10x5
{ GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO, false, { $_, $_, $_, $_ } }, // Unknown
{ GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO, false, { $_, $_, $_, $_ } }, // R1
{ GL_ALPHA, GL_ZERO, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, false, { $_, $_, $_, $_ } }, // A8
{ GL_R8, GL_ZERO, GL_RED, GL_RED, GL_UNSIGNED_BYTE, false, { $_, $_, $_, $_ } }, // R8
{ GL_R8I, GL_ZERO, RED_INTEGER, GL_RED_INTEGER, GL_BYTE, false, { $_, $_, $_, $_ } }, // R8I
{ GL_R8UI, GL_ZERO, RED_INTEGER, GL_RED_INTEGER, GL_UNSIGNED_BYTE, false, { $_, $_, $_, $_ } }, // R8U
{ GL_R8_SNORM, GL_ZERO, GL_RED, GL_RED, GL_BYTE, false, { $_, $_, $_, $_ } }, // R8S
{ GL_R16, GL_ZERO, GL_RED, GL_RED, GL_UNSIGNED_SHORT, false, { $_, $_, $_, $_ } }, // R16
{ GL_R16I, GL_ZERO, RED_INTEGER, GL_RED_INTEGER, GL_SHORT, false, { $_, $_, $_, $_ } }, // R16I
{ GL_R16UI, GL_ZERO, RED_INTEGER, GL_RED_INTEGER, GL_UNSIGNED_SHORT, false, { $_, $_, $_, $_ } }, // R16U
{ GL_R16F, GL_ZERO, GL_RED, GL_RED, GL_HALF_FLOAT, false, { $_, $_, $_, $_ } }, // R16F
{ GL_R16_SNORM, GL_ZERO, GL_RED, GL_RED, GL_SHORT, false, { $_, $_, $_, $_ } }, // R16S
{ GL_R32I, GL_ZERO, RED_INTEGER, GL_RED_INTEGER, GL_INT, false, { $_, $_, $_, $_ } }, // R32I
{ GL_R32UI, GL_ZERO, RED_INTEGER, GL_RED_INTEGER, GL_UNSIGNED_INT, false, { $_, $_, $_, $_ } }, // R32U
{ GL_R32F, GL_ZERO, GL_RED, GL_RED, GL_FLOAT, false, { $_, $_, $_, $_ } }, // R32F
{ GL_RG8, GL_ZERO, GL_RG, GL_RG, GL_UNSIGNED_BYTE, false, { $_, $_, $_, $_ } }, // RG8
{ GL_RG8I, GL_ZERO, RG_INTEGER, GL_RG_INTEGER, GL_BYTE, false, { $_, $_, $_, $_ } }, // RG8I
{ GL_RG8UI, GL_ZERO, RG_INTEGER, GL_RG_INTEGER, GL_UNSIGNED_BYTE, false, { $_, $_, $_, $_ } }, // RG8U
{ GL_RG8_SNORM, GL_ZERO, GL_RG, GL_RG, GL_BYTE, false, { $_, $_, $_, $_ } }, // RG8S
{ GL_RG16, GL_ZERO, GL_RG, GL_RG, GL_UNSIGNED_SHORT, false, { $_, $_, $_, $_ } }, // RG16
{ GL_RG16I, GL_ZERO, RG_INTEGER, GL_RG_INTEGER, GL_SHORT, false, { $_, $_, $_, $_ } }, // RG16I
{ GL_RG16UI, GL_ZERO, RG_INTEGER, GL_RG_INTEGER, GL_UNSIGNED_SHORT, false, { $_, $_, $_, $_ } }, // RG16U
{ GL_RG16F, GL_ZERO, GL_RG, GL_RG, GL_HALF_FLOAT, false, { $_, $_, $_, $_ } }, // RG16F
{ GL_RG16_SNORM, GL_ZERO, GL_RG, GL_RG, GL_SHORT, false, { $_, $_, $_, $_ } }, // RG16S
{ GL_RG32I, GL_ZERO, RG_INTEGER, GL_RG_INTEGER, GL_INT, false, { $_, $_, $_, $_ } }, // RG32I
{ GL_RG32UI, GL_ZERO, RG_INTEGER, GL_RG_INTEGER, GL_UNSIGNED_INT, false, { $_, $_, $_, $_ } }, // RG32U
{ GL_RG32F, GL_ZERO, GL_RG, GL_RG, GL_FLOAT, false, { $_, $_, $_, $_ } }, // RG32F
{ GL_RGB8, GL_SRGB8, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, false, { $_, $_, $_, $_ } }, // RGB8
{ GL_RGB8I, GL_ZERO, RGB_INTEGER, GL_RGB_INTEGER, GL_BYTE, false, { $_, $_, $_, $_ } }, // RGB8I
{ GL_RGB8UI, GL_ZERO, RGB_INTEGER, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, false, { $_, $_, $_, $_ } }, // RGB8U
{ GL_RGB8_SNORM, GL_ZERO, GL_RGB, GL_RGB, GL_BYTE, false, { $_, $_, $_, $_ } }, // RGB8S
{ GL_RGB9_E5, GL_ZERO, GL_RGB, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, false, { $_, $_, $_, $_ } }, // RGB9E5F
{ GL_RGBA8, GL_SRGB8_ALPHA8, GL_BGRA, GL_BGRA, GL_UNSIGNED_BYTE, false, { $_, $_, $_, $_ } }, // BGRA8
{ GL_RGBA8, GL_SRGB8_ALPHA8, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, false, { $_, $_, $_, $_ } }, // RGBA8
{ GL_RGBA8I, GL_ZERO, RGBA_INTEGER, GL_RGBA_INTEGER, GL_BYTE, false, { $_, $_, $_, $_ } }, // RGBA8I
{ GL_RGBA8UI, GL_ZERO, RGBA_INTEGER, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, false, { $_, $_, $_, $_ } }, // RGBA8U
{ GL_RGBA8_SNORM, GL_ZERO, GL_RGBA, GL_RGBA, GL_BYTE, false, { $_, $_, $_, $_ } }, // RGBA8S
{ GL_RGBA16, GL_ZERO, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT, false, { $_, $_, $_, $_ } }, // RGBA16
{ GL_RGBA16I, GL_ZERO, RGBA_INTEGER, GL_RGBA_INTEGER, GL_SHORT, false, { $_, $_, $_, $_ } }, // RGBA16I
{ GL_RGBA16UI, GL_ZERO, RGBA_INTEGER, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, false, { $_, $_, $_, $_ } }, // RGBA16U
{ GL_RGBA16F, GL_ZERO, GL_RGBA, GL_RGBA, GL_HALF_FLOAT, false, { $_, $_, $_, $_ } }, // RGBA16F
{ GL_RGBA16_SNORM, GL_ZERO, GL_RGBA, GL_RGBA, GL_SHORT, false, { $_, $_, $_, $_ } }, // RGBA16S
{ GL_RGBA32I, GL_ZERO, RGBA_INTEGER, GL_RGBA_INTEGER, GL_INT, false, { $_, $_, $_, $_ } }, // RGBA32I
{ GL_RGBA32UI, GL_ZERO, RGBA_INTEGER, GL_RGBA_INTEGER, GL_UNSIGNED_INT, false, { $_, $_, $_, $_ } }, // RGBA32U
{ GL_RGBA32F, GL_ZERO, GL_RGBA, GL_RGBA, GL_FLOAT, false, { $_, $_, $_, $_ } }, // RGBA32F
{ GL_RGB565, GL_ZERO, GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, false, { $_, $_, $_, $_ } }, // B5G6R5
{ GL_RGB565, GL_ZERO, GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, false, { $_, $_, $_, $_ } }, // R5G6B5
{ GL_RGBA4, GL_ZERO, GL_BGRA, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, false, { $_, $_, $_, $_ } }, // BGRA4
{ GL_RGBA4, GL_ZERO, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4_REV, false, { $_, $_, $_, $_ } }, // RGBA4
{ GL_RGB5_A1, GL_ZERO, GL_BGRA, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, false, { $_, $_, $_, $_ } }, // BGR5A1
{ GL_RGB5_A1, GL_ZERO, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, false, { $_, $_, $_, $_ } }, // RGB5A1
{ GL_RGB10_A2, GL_ZERO, GL_RGBA, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, false, { $_, $_, $_, $_ } }, // RGB10A2
{ GL_R11F_G11F_B10F, GL_ZERO, GL_RGB, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, false, { $_, $_, $_, $_ } }, // RG11B10F
{ GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO, false, { $_, $_, $_, $_ } }, // UnknownDepth
{ GL_DEPTH_COMPONENT16, GL_ZERO, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, false, { $_, $_, $_, $_ } }, // D16
{ GL_DEPTH_COMPONENT24, GL_ZERO, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, false, { $_, $_, $_, $_ } }, // D24
{ GL_DEPTH24_STENCIL8, GL_ZERO, GL_DEPTH_STENCIL, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, false, { $_, $_, $_, $_ } }, // D24S8
{ GL_DEPTH_COMPONENT32, GL_ZERO, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, false, { $_, $_, $_, $_ } }, // D32
{ GL_DEPTH_COMPONENT32F, GL_ZERO, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT, false, { $_, $_, $_, $_ } }, // D16F
{ GL_DEPTH_COMPONENT32F, GL_ZERO, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT, false, { $_, $_, $_, $_ } }, // D24F
{ GL_DEPTH_COMPONENT32F, GL_ZERO, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT, false, { $_, $_, $_, $_ } }, // D32F
{ GL_STENCIL_INDEX8, GL_ZERO, GL_STENCIL_INDEX, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, false, { $_, $_, $_, $_ } }, // D0S8
#undef $_
#undef $0
#undef $1
#undef $R
#undef $G
#undef $B
#undef $A
};
BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_textureFormat) );
static bool s_textureFilter[TextureFormat::Count+1];
static GLenum s_rboFormat[] =
{
GL_ZERO, // BC1
GL_ZERO, // BC2
GL_ZERO, // BC3
GL_ZERO, // BC4
GL_ZERO, // BC5
GL_ZERO, // BC6H
GL_ZERO, // BC7
GL_ZERO, // ETC1
GL_ZERO, // ETC2
GL_ZERO, // ETC2A
GL_ZERO, // ETC2A1
GL_ZERO, // PTC12
GL_ZERO, // PTC14
GL_ZERO, // PTC12A
GL_ZERO, // PTC14A
GL_ZERO, // PTC22
GL_ZERO, // PTC24
GL_ZERO, // ATC
GL_ZERO, // ATCE
GL_ZERO, // ATCI
GL_ZERO, // ASTC4x4
GL_ZERO, // ASTC5x5
GL_ZERO, // ASTC6x6
GL_ZERO, // ASTC8x5
GL_ZERO, // ASTC8x6
GL_ZERO, // ASTC10x5
GL_ZERO, // Unknown
GL_ZERO, // R1
GL_ALPHA, // A8
GL_R8, // R8
GL_R8I, // R8I
GL_R8UI, // R8U
GL_R8_SNORM, // R8S
GL_R16, // R16
GL_R16I, // R16I
GL_R16UI, // R16U
GL_R16F, // R16F
GL_R16_SNORM, // R16S
GL_R32I, // R32I
GL_R32UI, // R32U
GL_R32F, // R32F
GL_RG8, // RG8
GL_RG8I, // RG8I
GL_RG8UI, // RG8U
GL_RG8_SNORM, // RG8S
GL_RG16, // RG16
GL_RG16I, // RG16I
GL_RG16UI, // RG16U
GL_RG16F, // RG16F
GL_RG16_SNORM, // RG16S
GL_RG32I, // RG32I
GL_RG32UI, // RG32U
GL_RG32F, // RG32F
GL_RGB8, // RGB8
GL_RGB8I, // RGB8I
GL_RGB8UI, // RGB8UI
GL_RGB8_SNORM, // RGB8S
GL_RGB9_E5, // RGB9E5F
GL_RGBA8, // BGRA8
GL_RGBA8, // RGBA8
GL_RGBA8I, // RGBA8I
GL_RGBA8UI, // RGBA8UI
GL_RGBA8_SNORM, // RGBA8S
GL_RGBA16, // RGBA16
GL_RGBA16I, // RGBA16I
GL_RGBA16UI, // RGBA16U
GL_RGBA16F, // RGBA16F
GL_RGBA16_SNORM, // RGBA16S
GL_RGBA32I, // RGBA32I
GL_RGBA32UI, // RGBA32U
GL_RGBA32F, // RGBA32F
GL_RGB565, // B5G6R5
GL_RGB565, // R5G6B5
GL_RGBA4, // BGRA4
GL_RGBA4, // RGBA4
GL_RGB5_A1, // BGR5A1
GL_RGB5_A1, // RGB5A1
GL_RGB10_A2, // RGB10A2
GL_R11F_G11F_B10F, // RG11B10F
GL_ZERO, // UnknownDepth
GL_DEPTH_COMPONENT16, // D16
GL_DEPTH_COMPONENT24, // D24
GL_DEPTH24_STENCIL8, // D24S8
GL_DEPTH_COMPONENT32, // D32
GL_DEPTH_COMPONENT32F, // D16F
GL_DEPTH_COMPONENT32F, // D24F
GL_DEPTH_COMPONENT32F, // D32F
GL_STENCIL_INDEX8, // D0S8
};
BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_rboFormat) );
static GLenum s_imageFormat[] =
{
GL_ZERO, // BC1
GL_ZERO, // BC2
GL_ZERO, // BC3
GL_ZERO, // BC4
GL_ZERO, // BC5
GL_ZERO, // BC6H
GL_ZERO, // BC7
GL_ZERO, // ETC1
GL_ZERO, // ETC2
GL_ZERO, // ETC2A
GL_ZERO, // ETC2A1
GL_ZERO, // PTC12
GL_ZERO, // PTC14
GL_ZERO, // PTC12A
GL_ZERO, // PTC14A
GL_ZERO, // PTC22
GL_ZERO, // PTC24
GL_ZERO, // ATC
GL_ZERO, // ATCE
GL_ZERO, // ATCI
GL_ZERO, // ASTC4x4
GL_ZERO, // ASTC5x5
GL_ZERO, // ASTC6x6
GL_ZERO, // ASTC8x5
GL_ZERO, // ASTC8x6
GL_ZERO, // ASTC10x5
GL_ZERO, // Unknown
GL_ZERO, // R1
GL_ALPHA, // A8
GL_R8, // R8
GL_R8I, // R8I
GL_R8UI, // R8UI
GL_R8_SNORM, // R8S
GL_R16, // R16
GL_R16I, // R16I
GL_R16UI, // R16U
GL_R16F, // R16F
GL_R16_SNORM, // R16S
GL_R32I, // R32I
GL_R32UI, // R32U
GL_R32F, // R32F
GL_RG8, // RG8
GL_RG8I, // RG8I
GL_RG8UI, // RG8U
GL_RG8_SNORM, // RG8S
GL_RG16, // RG16
GL_RG16I, // RG16I
GL_RG16UI, // RG16U
GL_RG16F, // RG16F
GL_RG16_SNORM, // RG16S
GL_RG32I, // RG32I
GL_RG32UI, // RG32U
GL_RG32F, // RG32F
GL_RGB8, // RGB8
GL_RGB8I, // RGB8I
GL_RGB8UI, // RGB8UI
GL_RGB8_SNORM, // RGB8S
GL_RGB9_E5, // RGB9E5F
GL_RGBA8, // BGRA8
GL_RGBA8, // RGBA8
GL_RGBA8I, // RGBA8I
GL_RGBA8UI, // RGBA8UI
GL_RGBA8_SNORM, // RGBA8S
GL_RGBA16, // RGBA16
GL_RGBA16I, // RGBA16I
GL_RGBA16UI, // RGBA16U
GL_RGBA16F, // RGBA16F
GL_RGBA16_SNORM, // RGBA16S
GL_RGBA32I, // RGBA32I
GL_RGBA32UI, // RGBA32U
GL_RGBA32F, // RGBA32F
GL_RGB565, // B5G6R5
GL_RGB565, // R5G6B5
GL_RGBA4, // BGRA4
GL_RGBA4, // RGBA4
GL_RGB5_A1, // BGR5A1
GL_RGB5_A1, // RGB5A1
GL_RGB10_A2, // RGB10A2
GL_R11F_G11F_B10F, // RG11B10F
GL_ZERO, // UnknownDepth
GL_ZERO, // D16
GL_ZERO, // D24
GL_ZERO, // D24S8
GL_ZERO, // D32
GL_ZERO, // D16F
GL_ZERO, // D24F
GL_ZERO, // D32F
GL_ZERO, // D0S8
};
BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_imageFormat) );
struct Extension
{
enum Enum
{
AMD_conservative_depth,
AMD_multi_draw_indirect,
ANGLE_depth_texture,
ANGLE_framebuffer_blit,
ANGLE_framebuffer_multisample,
ANGLE_instanced_arrays,
ANGLE_texture_compression_dxt1,
ANGLE_texture_compression_dxt3,
ANGLE_texture_compression_dxt5,
ANGLE_timer_query,
ANGLE_translated_shader_source,
APPLE_texture_format_BGRA8888,
APPLE_texture_max_level,
ARB_clip_control,
ARB_compute_shader,
ARB_conservative_depth,
ARB_copy_image,
ARB_debug_label,
ARB_debug_output,
ARB_depth_buffer_float,
ARB_depth_clamp,
ARB_draw_buffers_blend,
ARB_draw_indirect,
ARB_draw_instanced,
ARB_ES3_compatibility,
ARB_framebuffer_object,
ARB_framebuffer_sRGB,
ARB_get_program_binary,
ARB_half_float_pixel,
ARB_half_float_vertex,
ARB_indirect_parameters,
ARB_instanced_arrays,
ARB_internalformat_query,
ARB_internalformat_query2,
ARB_invalidate_subdata,
ARB_map_buffer_range,
ARB_multi_draw_indirect,
ARB_multisample,
ARB_occlusion_query,
ARB_occlusion_query2,
ARB_program_interface_query,
ARB_provoking_vertex,
ARB_sampler_objects,
ARB_seamless_cube_map,
ARB_shader_bit_encoding,
ARB_shader_image_load_store,
ARB_shader_storage_buffer_object,
ARB_shader_texture_lod,
ARB_shader_viewport_layer_array,
ARB_texture_compression_bptc,
ARB_texture_compression_rgtc,
ARB_texture_cube_map_array,
ARB_texture_float,
ARB_texture_multisample,
ARB_texture_rg,
ARB_texture_rgb10_a2ui,
ARB_texture_stencil8,
ARB_texture_storage,
ARB_texture_swizzle,
ARB_timer_query,
ARB_uniform_buffer_object,
ARB_vertex_array_object,
ARB_vertex_type_2_10_10_10_rev,
ATI_meminfo,
CHROMIUM_color_buffer_float_rgb,
CHROMIUM_color_buffer_float_rgba,
CHROMIUM_depth_texture,
CHROMIUM_framebuffer_multisample,
CHROMIUM_texture_compression_dxt3,
CHROMIUM_texture_compression_dxt5,
EXT_bgra,
EXT_blend_color,
EXT_blend_minmax,
EXT_blend_subtract,
EXT_color_buffer_half_float,
EXT_color_buffer_float,
EXT_copy_image,
EXT_compressed_ETC1_RGB8_sub_texture,
EXT_debug_label,
EXT_debug_marker,
EXT_debug_tool,
EXT_discard_framebuffer,
EXT_disjoint_timer_query,
EXT_draw_buffers,
EXT_draw_instanced,
EXT_instanced_arrays,
EXT_frag_depth,
EXT_framebuffer_blit,
EXT_framebuffer_object,
EXT_framebuffer_sRGB,
EXT_gpu_shader4,
EXT_multi_draw_indirect,
EXT_occlusion_query_boolean,
EXT_packed_float,
EXT_read_format_bgra,
EXT_shader_image_load_store,
EXT_shader_texture_lod,
EXT_shadow_samplers,
EXT_sRGB_write_control,
EXT_texture_array,
EXT_texture_compression_dxt1,
EXT_texture_compression_latc,
EXT_texture_compression_rgtc,
EXT_texture_compression_s3tc,
EXT_texture_cube_map_array,
EXT_texture_filter_anisotropic,
EXT_texture_format_BGRA8888,
EXT_texture_rg,
EXT_texture_shared_exponent,
EXT_texture_snorm,
EXT_texture_sRGB,
EXT_texture_storage,
EXT_texture_swizzle,
EXT_texture_type_2_10_10_10_REV,
EXT_timer_query,
EXT_unpack_subimage,
EXT_sRGB,
EXT_multisampled_render_to_texture,
GOOGLE_depth_texture,
IMG_multisampled_render_to_texture,
IMG_read_format,
IMG_shader_binary,
IMG_texture_compression_pvrtc,
IMG_texture_compression_pvrtc2,
IMG_texture_format_BGRA8888,
INTEL_fragment_shader_ordering,
KHR_debug,
KHR_no_error,
MOZ_WEBGL_compressed_texture_s3tc,
MOZ_WEBGL_depth_texture,
NV_conservative_raster,
NV_copy_image,
NV_draw_buffers,
NV_draw_instanced,
NV_instanced_arrays,
NV_occlusion_query,
NV_texture_border_clamp,
NVX_gpu_memory_info,
OES_copy_image,
OES_compressed_ETC1_RGB8_texture,
OES_depth24,
OES_depth32,
OES_depth_texture,
OES_element_index_uint,
OES_fragment_precision_high,
OES_fbo_render_mipmap,
OES_get_program_binary,
OES_required_internalformat,
OES_packed_depth_stencil,
OES_read_format,
OES_rgb8_rgba8,
OES_standard_derivatives,
OES_texture_3D,
OES_texture_float,
OES_texture_float_linear,
OES_texture_npot,
OES_texture_half_float,
OES_texture_half_float_linear,
OES_texture_stencil8,
OES_texture_storage_multisample_2d_array,
OES_vertex_array_object,
OES_vertex_half_float,
OES_vertex_type_10_10_10_2,
WEBGL_color_buffer_float,
WEBGL_compressed_texture_etc1,
WEBGL_compressed_texture_s3tc,
WEBGL_compressed_texture_pvrtc,
WEBGL_depth_texture,
WEBGL_draw_buffers,
WEBKIT_EXT_texture_filter_anisotropic,
WEBKIT_WEBGL_compressed_texture_s3tc,
WEBKIT_WEBGL_depth_texture,
Count
};
const char* m_name;
bool m_supported;
bool m_initialize;
};
// Extension registry
//
// ANGLE:
// https://github.com/google/angle/tree/master/extensions
//
// CHROMIUM:
// https://chromium.googlesource.com/chromium/src.git/+/refs/heads/git-svn/gpu/GLES2/extensions/CHROMIUM
//
// EGL:
// https://www.khronos.org/registry/egl/extensions/
//
// GL:
// https://www.opengl.org/registry/
//
// GLES:
// https://www.khronos.org/registry/gles/extensions/
//
// WEBGL:
// https://www.khronos.org/registry/webgl/extensions/
//
static Extension s_extension[] =
{
{ "AMD_conservative_depth", false, true },
{ "AMD_multi_draw_indirect", false, true },
{ "ANGLE_depth_texture", false, true },
{ "ANGLE_framebuffer_blit", false, true },
{ "ANGLE_framebuffer_multisample", false, false },
{ "ANGLE_instanced_arrays", false, true },
{ "ANGLE_texture_compression_dxt1", false, true },
{ "ANGLE_texture_compression_dxt3", false, true },
{ "ANGLE_texture_compression_dxt5", false, true },
{ "ANGLE_timer_query", false, true },
{ "ANGLE_translated_shader_source", false, true },
{ "APPLE_texture_format_BGRA8888", false, true },
{ "APPLE_texture_max_level", false, true },
{ "ARB_clip_control", BGFX_CONFIG_RENDERER_OPENGL >= 43, true },
{ "ARB_compute_shader", BGFX_CONFIG_RENDERER_OPENGL >= 43, true },
{ "ARB_conservative_depth", BGFX_CONFIG_RENDERER_OPENGL >= 42, true },
{ "ARB_copy_image", BGFX_CONFIG_RENDERER_OPENGL >= 42, true },
{ "ARB_debug_label", false, true },
{ "ARB_debug_output", BGFX_CONFIG_RENDERER_OPENGL >= 43, true },
{ "ARB_depth_buffer_float", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
{ "ARB_depth_clamp", BGFX_CONFIG_RENDERER_OPENGL >= 32, true },
{ "ARB_draw_buffers_blend", BGFX_CONFIG_RENDERER_OPENGL >= 40, true },
{ "ARB_draw_indirect", BGFX_CONFIG_RENDERER_OPENGL >= 40, true },
{ "ARB_draw_instanced", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
{ "ARB_ES3_compatibility", BGFX_CONFIG_RENDERER_OPENGL >= 43, true },
{ "ARB_framebuffer_object", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
{ "ARB_framebuffer_sRGB", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
{ "ARB_get_program_binary", BGFX_CONFIG_RENDERER_OPENGL >= 41, true },
{ "ARB_half_float_pixel", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
{ "ARB_half_float_vertex", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
{ "ARB_indirect_parameters", BGFX_CONFIG_RENDERER_OPENGL >= 46, true },
{ "ARB_instanced_arrays", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
{ "ARB_internalformat_query", BGFX_CONFIG_RENDERER_OPENGL >= 42, true },
{ "ARB_internalformat_query2", BGFX_CONFIG_RENDERER_OPENGL >= 43, true },
{ "ARB_invalidate_subdata", BGFX_CONFIG_RENDERER_OPENGL >= 43, true },
{ "ARB_map_buffer_range", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
{ "ARB_multi_draw_indirect", BGFX_CONFIG_RENDERER_OPENGL >= 43, true },
{ "ARB_multisample", false, true },
{ "ARB_occlusion_query", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
{ "ARB_occlusion_query2", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
{ "ARB_program_interface_query", BGFX_CONFIG_RENDERER_OPENGL >= 43, true },
{ "ARB_provoking_vertex", BGFX_CONFIG_RENDERER_OPENGL >= 32, true },
{ "ARB_sampler_objects", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
{ "ARB_seamless_cube_map", BGFX_CONFIG_RENDERER_OPENGL >= 32, true },
{ "ARB_shader_bit_encoding", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
{ "ARB_shader_image_load_store", BGFX_CONFIG_RENDERER_OPENGL >= 42, true },
{ "ARB_shader_storage_buffer_object", BGFX_CONFIG_RENDERER_OPENGL >= 43, true },
{ "ARB_shader_texture_lod", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
{ "ARB_shader_viewport_layer_array", false, true },
{ "ARB_texture_compression_bptc", BGFX_CONFIG_RENDERER_OPENGL >= 44, true },
{ "ARB_texture_compression_rgtc", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
{ "ARB_texture_cube_map_array", BGFX_CONFIG_RENDERER_OPENGL >= 40, true },
{ "ARB_texture_float", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
{ "ARB_texture_multisample", BGFX_CONFIG_RENDERER_OPENGL >= 32, true },
{ "ARB_texture_rg", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
{ "ARB_texture_rgb10_a2ui", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
{ "ARB_texture_stencil8", false, true },
{ "ARB_texture_storage", BGFX_CONFIG_RENDERER_OPENGL >= 42, true },
{ "ARB_texture_swizzle", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
{ "ARB_timer_query", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
{ "ARB_uniform_buffer_object", BGFX_CONFIG_RENDERER_OPENGL >= 31, true },
{ "ARB_vertex_array_object", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
{ "ARB_vertex_type_2_10_10_10_rev", false, true },
{ "ATI_meminfo", false, true },
{ "CHROMIUM_color_buffer_float_rgb", false, true },
{ "CHROMIUM_color_buffer_float_rgba", false, true },
{ "CHROMIUM_depth_texture", false, true },
{ "CHROMIUM_framebuffer_multisample", false, true },
{ "CHROMIUM_texture_compression_dxt3", false, true },
{ "CHROMIUM_texture_compression_dxt5", false, true },
{ "EXT_bgra", false, true },
{ "EXT_blend_color", BGFX_CONFIG_RENDERER_OPENGL >= 31, true },
{ "EXT_blend_minmax", BGFX_CONFIG_RENDERER_OPENGL >= 14, true },
{ "EXT_blend_subtract", BGFX_CONFIG_RENDERER_OPENGL >= 14, true },
{ "EXT_color_buffer_half_float", false, true }, // GLES2 extension.
{ "EXT_color_buffer_float", false, true }, // GLES2 extension.
{ "EXT_copy_image", false, true }, // GLES2 extension.
{ "EXT_compressed_ETC1_RGB8_sub_texture", false, true }, // GLES2 extension.
{ "EXT_debug_label", false, true },
{ "EXT_debug_marker", false, true },
{ "EXT_debug_tool", false, true }, // RenderDoc extension.
{ "EXT_discard_framebuffer", false, true }, // GLES2 extension.
{ "EXT_disjoint_timer_query", false, true }, // GLES2 extension.
{ "EXT_draw_buffers", false, true }, // GLES2 extension.
{ "EXT_draw_instanced", false, true }, // GLES2 extension.
{ "EXT_instanced_arrays", false, true }, // GLES2 extension.
{ "EXT_frag_depth", false, true }, // GLES2 extension.
{ "EXT_framebuffer_blit", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
{ "EXT_framebuffer_object", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
{ "EXT_framebuffer_sRGB", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
{ "EXT_gpu_shader4", BGFX_CONFIG_RENDERER_OPENGL >= 31, true },
{ "EXT_multi_draw_indirect", false, true }, // GLES3.1 extension.
{ "EXT_occlusion_query_boolean", false, true }, // GLES2 extension.
{ "EXT_packed_float", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
{ "EXT_read_format_bgra", false, true },
{ "EXT_shader_image_load_store", false, true },
{ "EXT_shader_texture_lod", false, true }, // GLES2 extension.
{ "EXT_shadow_samplers", false, true },
{ "EXT_sRGB_write_control", false, true }, // GLES2 extension.
{ "EXT_texture_array", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
{ "EXT_texture_compression_dxt1", false, true },
{ "EXT_texture_compression_latc", false, true },
{ "EXT_texture_compression_rgtc", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
{ "EXT_texture_compression_s3tc", false, true },
{ "EXT_texture_cube_map_array", false, true }, // GLES3.1 extension.
{ "EXT_texture_filter_anisotropic", false, true },
{ "EXT_texture_format_BGRA8888", false, true },
{ "EXT_texture_rg", false, true }, // GLES2 extension.
{ "EXT_texture_shared_exponent", false, true },
{ "EXT_texture_snorm", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
{ "EXT_texture_sRGB", false, true },
{ "EXT_texture_storage", false, true },
{ "EXT_texture_swizzle", false, true },
{ "EXT_texture_type_2_10_10_10_REV", false, true },
{ "EXT_timer_query", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
{ "EXT_unpack_subimage", false, true },
{ "EXT_sRGB", false, true }, // GLES2 extension.
{ "EXT_multisampled_render_to_texture", false, true }, // GLES2 extension.
{ "GOOGLE_depth_texture", false, true },
{ "IMG_multisampled_render_to_texture", false, true },
{ "IMG_read_format", false, true },
{ "IMG_shader_binary", false, true },
{ "IMG_texture_compression_pvrtc", false, true },
{ "IMG_texture_compression_pvrtc2", false, true },
{ "IMG_texture_format_BGRA8888", false, true },
{ "INTEL_fragment_shader_ordering", false, true },
{ "KHR_debug", BGFX_CONFIG_RENDERER_OPENGL >= 43, true },
{ "KHR_no_error", false, true },
{ "MOZ_WEBGL_compressed_texture_s3tc", false, true },
{ "MOZ_WEBGL_depth_texture", false, true },
{ "NV_conservative_raster", false, true },
{ "NV_copy_image", false, true },
{ "NV_draw_buffers", false, true }, // GLES2 extension.
{ "NV_draw_instanced", false, true }, // GLES2 extension.
{ "NV_instanced_arrays", false, true }, // GLES2 extension.
{ "NV_occlusion_query", false, true },
{ "NV_texture_border_clamp", false, true }, // GLES2 extension.
{ "NVX_gpu_memory_info", false, true },
{ "OES_copy_image", false, true },
{ "OES_compressed_ETC1_RGB8_texture", false, true },
{ "OES_depth24", false, true },
{ "OES_depth32", false, true },
{ "OES_depth_texture", false, true },
{ "OES_element_index_uint", false, true },
{ "OES_fragment_precision_high", false, true },
{ "OES_fbo_render_mipmap", false, true },
{ "OES_get_program_binary", false, true },
{ "OES_required_internalformat", false, true },
{ "OES_packed_depth_stencil", false, true },
{ "OES_read_format", false, true },
{ "OES_rgb8_rgba8", false, true },
{ "OES_standard_derivatives", false, true },
{ "OES_texture_3D", false, true },
{ "OES_texture_float", false, true },
{ "OES_texture_float_linear", false, true },
{ "OES_texture_npot", false, true },
{ "OES_texture_half_float", false, true },
{ "OES_texture_half_float_linear", false, true },
{ "OES_texture_stencil8", false, true },
{ "OES_texture_storage_multisample_2d_array", false, true },
{ "OES_vertex_array_object", false, !BX_PLATFORM_IOS },
{ "OES_vertex_half_float", false, true },
{ "OES_vertex_type_10_10_10_2", false, true },
{ "WEBGL_color_buffer_float", false, true },
{ "WEBGL_compressed_texture_etc1", false, true },
{ "WEBGL_compressed_texture_s3tc", false, true },
{ "WEBGL_compressed_texture_pvrtc", false, true },
{ "WEBGL_depth_texture", false, true },
{ "WEBGL_draw_buffers", false, true },
{ "WEBKIT_EXT_texture_filter_anisotropic", false, true },
{ "WEBKIT_WEBGL_compressed_texture_s3tc", false, true },
{ "WEBKIT_WEBGL_depth_texture", false, true },
};
BX_STATIC_ASSERT(Extension::Count == BX_COUNTOF(s_extension) );
static const char* s_ARB_shader_texture_lod[] =
{
"texture2DLod",
"texture2DArrayLod", // BK - interacts with ARB_texture_array.
"texture2DProjLod",
"texture2DGrad",
"texture2DProjGrad",
"texture3DLod",
"texture3DProjLod",
"texture3DGrad",
"texture3DProjGrad",
"textureCubeLod",
"textureCubeGrad",
"shadow2DLod",
"shadow2DProjLod",
NULL
// "texture1DLod",
// "texture1DProjLod",
// "shadow1DLod",
// "shadow1DProjLod",
};
static const char* s_EXT_shader_texture_lod[] =
{
"texture2DLod",
"texture2DProjLod",
"textureCubeLod",
"texture2DGrad",
"texture2DProjGrad",
"textureCubeGrad",
NULL
};
static const char* s_ARB_shader_viewport_layer_array[] =
{
"gl_ViewportIndex",
"gl_Layer",
NULL
};
static const char* s_EXT_shadow_samplers[] =
{
"shadow2D",
"shadow2DProj",
NULL
};
static const char* s_OES_standard_derivatives[] =
{
"dFdx",
"dFdy",
"fwidth",
NULL
};
static const char* s_uisamplers[] =
{
"isampler2D",
"usampler2D",
"isampler3D",
"usampler3D",
"isamplerCube",
"usamplerCube",
NULL
};
static const char* s_uint[] =
{
"uint",
"uvec2",
"uvec3",
"uvec4",
NULL
};
static const char* s_texelFetch[] =
{
"texture",
"textureLod",
"textureGrad",
"textureProj",
"textureProjLod",
"texelFetch",
"texelFetchOffset",