@@ -135,6 +135,56 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
135
135
emscripten_webgl_enable_WEBGL_multi_draw__deps : [ '$webgl_enable_WEBGL_multi_draw' ] ,
136
136
emscripten_webgl_enable_WEBGL_multi_draw : ( ctx ) => webgl_enable_WEBGL_multi_draw ( GL . contexts [ ctx ] . GLctx ) ,
137
137
138
+ $getEmscriptenSupportedExtensions__internal : true ,
139
+ $getEmscriptenSupportedExtensions : function ( ctx ) {
140
+ // Restrict the list of advertised extensions to those that we actually
141
+ // support.
142
+ var supportedExtensions = [
143
+ #if MIN_WEBGL_VERSION == 1
144
+ // WebGL 1 extensions
145
+ 'ANGLE_instanced_arrays' ,
146
+ 'EXT_blend_minmax' ,
147
+ 'EXT_disjoint_timer_query' ,
148
+ 'EXT_frag_depth' ,
149
+ 'EXT_shader_texture_lod' ,
150
+ 'EXT_sRGB' ,
151
+ 'OES_element_index_uint' ,
152
+ 'OES_fbo_render_mipmap' ,
153
+ 'OES_standard_derivatives' ,
154
+ 'OES_texture_float' ,
155
+ 'OES_texture_half_float' ,
156
+ 'OES_texture_half_float_linear' ,
157
+ 'OES_vertex_array_object' ,
158
+ 'WEBGL_color_buffer_float' ,
159
+ 'WEBGL_depth_texture' ,
160
+ 'WEBGL_draw_buffers' ,
161
+ #endif
162
+ #if MAX_WEBGL_VERSION >= 2
163
+ // WebGL 2 extensions
164
+ 'EXT_color_buffer_float' ,
165
+ 'EXT_disjoint_timer_query_webgl2' ,
166
+ 'EXT_texture_norm16' ,
167
+ 'WEBGL_clip_cull_distance' ,
168
+ #endif
169
+ // WebGL 1 and WebGL 2 extensions
170
+ 'EXT_color_buffer_half_float' ,
171
+ 'EXT_float_blend' ,
172
+ 'EXT_texture_compression_bptc' ,
173
+ 'EXT_texture_compression_rgtc' ,
174
+ 'EXT_texture_filter_anisotropic' ,
175
+ 'KHR_parallel_shader_compile' ,
176
+ 'OES_texture_float_linear' ,
177
+ 'WEBGL_compressed_texture_s3tc' ,
178
+ 'WEBGL_compressed_texture_s3tc_srgb' ,
179
+ 'WEBGL_debug_renderer_info' ,
180
+ 'WEBGL_debug_shaders' ,
181
+ 'WEBGL_lose_context' ,
182
+ 'WEBGL_multi_draw' ,
183
+ ] ;
184
+ // .getSupportedExtensions() can return null if context is lost, so coerce to empty array.
185
+ return ( ctx . getSupportedExtensions ( ) || [ ] ) . filter ( ext => supportedExtensions . includes ( ext ) ) ;
186
+ } ,
187
+
138
188
$GL__postset : 'var GLctx;' ,
139
189
#if GL_SUPPORT_AUTOMATIC_ENABLE_EXTENSIONS
140
190
// If GL_SUPPORT_AUTOMATIC_ENABLE_EXTENSIONS is enabled, GL.initExtensions() will call to initialize these.
@@ -153,8 +203,9 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
153
203
'$webgl_enable_WEBGL_multi_draw_instanced_base_vertex_base_instance' ,
154
204
#endif
155
205
'$webgl_enable_WEBGL_multi_draw' ,
206
+ '$getEmscriptenSupportedExtensions' ,
156
207
] ,
157
- #endif
208
+ #endif // GL_SUPPORT_AUTOMATIC_ENABLE_EXTENSIONS
158
209
$GL : {
159
210
#if GL_DEBUG
160
211
debug : true ,
@@ -738,60 +789,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
738
789
}
739
790
disableHalfFloatExtensionIfBroken ( ctx ) ;
740
791
#endif
741
-
742
- // If end user enables *glGetProcAddress() functionality or
743
- // GL_SUPPORT_AUTOMATIC_ENABLE_EXTENSIONS, then we must filter out
744
- // all future WebGL extensions from being passed to the user, and only restrict to advertising
745
- // extensions that the *glGetProcAddress() function knows to handle.
746
- #if GL_ENABLE_GET_PROC_ADDRESS || GL_SUPPORT_AUTOMATIC_ENABLE_EXTENSIONS
747
- var _allSupportedExtensions = ctx . getSupportedExtensions ;
748
- var supportedExtensionsForGetProcAddress = [
749
- #if MIN_WEBGL_VERSION == 1
750
- // WebGL 1 extensions
751
- 'ANGLE_instanced_arrays' ,
752
- 'EXT_blend_minmax' ,
753
- 'EXT_disjoint_timer_query' ,
754
- 'EXT_frag_depth' ,
755
- 'EXT_shader_texture_lod' ,
756
- 'EXT_sRGB' ,
757
- 'OES_element_index_uint' ,
758
- 'OES_fbo_render_mipmap' ,
759
- 'OES_standard_derivatives' ,
760
- 'OES_texture_float' ,
761
- 'OES_texture_half_float' ,
762
- 'OES_texture_half_float_linear' ,
763
- 'OES_vertex_array_object' ,
764
- 'WEBGL_color_buffer_float' ,
765
- 'WEBGL_depth_texture' ,
766
- 'WEBGL_draw_buffers' ,
767
- #endif
768
- #if MAX_WEBGL_VERSION >= 2
769
- // WebGL 2 extensions
770
- 'EXT_color_buffer_float' ,
771
- 'EXT_disjoint_timer_query_webgl2' ,
772
- 'EXT_texture_norm16' ,
773
- 'WEBGL_clip_cull_distance' ,
774
- #endif
775
- // WebGL 1 and WebGL 2 extensions
776
- 'EXT_color_buffer_half_float' ,
777
- 'EXT_float_blend' ,
778
- 'EXT_texture_compression_bptc' ,
779
- 'EXT_texture_compression_rgtc' ,
780
- 'EXT_texture_filter_anisotropic' ,
781
- 'KHR_parallel_shader_compile' ,
782
- 'OES_texture_float_linear' ,
783
- 'WEBGL_compressed_texture_s3tc' ,
784
- 'WEBGL_compressed_texture_s3tc_srgb' ,
785
- 'WEBGL_debug_renderer_info' ,
786
- 'WEBGL_debug_shaders' ,
787
- 'WEBGL_lose_context' ,
788
- 'WEBGL_multi_draw' ,
789
- ] ;
790
- ctx . getSupportedExtensions = function ( ) {
791
- return ( _allSupportedExtensions . apply ( this ) || [ ] ) . filter ( ext => supportedExtensionsForGetProcAddress . includes ( ext ) ) ;
792
- }
793
- #endif
794
-
795
792
return handle ;
796
793
} ,
797
794
@@ -1206,10 +1203,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1206
1203
1207
1204
webgl_enable_WEBGL_multi_draw ( GLctx ) ;
1208
1205
1209
- // .getSupportedExtensions() can return null if context is lost, so coerce
1210
- // to empty array.
1211
- var exts = GLctx . getSupportedExtensions ( ) || [ ] ;
1212
- exts . forEach ( ( ext ) => {
1206
+ getEmscriptenSupportedExtensions ( GLctx ) . forEach ( ( ext ) => {
1213
1207
// WEBGL_lose_context, WEBGL_debug_renderer_info and WEBGL_debug_shaders
1214
1208
// are not enabled by default.
1215
1209
if ( ! ext . includes ( 'lose_context' ) && ! ext . includes ( 'debug' ) ) {
@@ -1220,14 +1214,16 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1220
1214
} ,
1221
1215
#endif
1222
1216
1223
- getExtensions ( ) {
1224
- // .getSupportedExtensions() can return null if context is lost, so coerce to empty array.
1225
- var exts = GLctx . getSupportedExtensions ( ) || [ ] ;
1217
+ } ,
1218
+
1219
+ $webglGetExtensions__internal : true ,
1220
+ $webglGetExtensions__deps : [ '$getEmscriptenSupportedExtensions' ] ,
1221
+ $webglGetExtensions ( ) {
1222
+ var exts = getEmscriptenSupportedExtensions ( GLctx ) ;
1226
1223
#if GL_EXTENSIONS_IN_PREFIXED_FORMAT
1227
- exts = exts . concat ( exts . map ( ( e ) => "GL_" + e ) ) ;
1224
+ exts = exts . concat ( exts . map ( ( e ) => "GL_" + e ) ) ;
1228
1225
#endif
1229
- return exts ;
1230
- } ,
1226
+ return exts ;
1231
1227
} ,
1232
1228
1233
1229
glPixelStorei : ( pname , param ) => {
@@ -1237,13 +1233,13 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1237
1233
GLctx . pixelStorei ( pname , param ) ;
1238
1234
} ,
1239
1235
1240
- glGetString__deps : [ '$stringToNewUTF8' ] ,
1236
+ glGetString__deps : [ '$stringToNewUTF8' , '$webglGetExtensions' ] ,
1241
1237
glGetString : ( name_ ) => {
1242
1238
var ret = GL . stringCache [ name_ ] ;
1243
1239
if ( ! ret ) {
1244
1240
switch ( name_ ) {
1245
1241
case 0x1F03 /* GL_EXTENSIONS */ :
1246
- ret = stringToNewUTF8 ( GL . getExtensions ( ) . join ( ' ' ) ) ;
1242
+ ret = stringToNewUTF8 ( webglGetExtensions ( ) . join ( ' ' ) ) ;
1247
1243
break ;
1248
1244
case 0x1F00 /* GL_VENDOR */ :
1249
1245
case 0x1F01 /* GL_RENDERER */ :
@@ -1305,7 +1301,11 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1305
1301
return ret ;
1306
1302
} ,
1307
1303
1308
- $emscriptenWebGLGet__deps : [ '$writeI53ToI64' ] ,
1304
+ $emscriptenWebGLGet__deps : [ '$writeI53ToI64' ,
1305
+ #if MAX_WEBGL_VERSION >= 2
1306
+ '$webglGetExtensions' , // For GL_NUM_EXTENSIONS
1307
+ #endif
1308
+ ] ,
1309
1309
$emscriptenWebGLGet : ( name_ , p , type ) = > {
1310
1310
// Guard against user passing a null pointer.
1311
1311
// Note that GLES2 spec does not say anything about how passing a null
@@ -1368,15 +1368,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1368
1368
return ;
1369
1369
}
1370
1370
#endif
1371
- // .getSupportedExtensions() can return null if context is lost, so coerce to empty array.
1372
- var exts = GLctx . getSupportedExtensions ( ) || [ ] ;
1373
- #if GL_EXTENSIONS_IN_PREFIXED_FORMAT
1374
- // each extension is duplicated, first in unprefixed WebGL form, and
1375
- // then a second time with "GL_" prefix.
1376
- ret = 2 * exts . length ;
1377
- #else
1378
- ret = exts . length ;
1379
- #endif
1371
+ ret = webglGetExtensions ( ) . length ;
1380
1372
break ;
1381
1373
case 0x821B : // GL_MAJOR_VERSION
1382
1374
case 0x821C : // GL_MINOR_VERSION
0 commit comments