@@ -190,8 +190,17 @@ def decorated(self, *args, **kwargs):
190
190
return decorator
191
191
192
192
193
+ def webgl2_disabled ():
194
+ return os .getenv ('EMTEST_LACKS_WEBGL2' ) or os .getenv ('EMTEST_LACKS_GRAPHICS_HARDWARE' )
195
+
196
+
197
+ def webgpu_disabled ():
198
+ return os .getenv ('EMTEST_LACKS_WEBGPU' ) or os .getenv ('EMTEST_LACKS_GRAPHICS_HARDWARE' )
199
+
200
+
193
201
requires_graphics_hardware = skipExecIf (os .getenv ('EMTEST_LACKS_GRAPHICS_HARDWARE' ), 'This test requires graphics hardware' )
194
- requires_webgpu = unittest .skipIf (os .getenv ('EMTEST_LACKS_WEBGPU' ), "This test requires WebGPU to be available" )
202
+ requires_webgl2 = unittest .skipIf (webgl2_disabled (), "This test requires WebGL2 to be available" )
203
+ requires_webgpu = unittest .skipIf (webgpu_disabled (), "This test requires WebGPU to be available" )
195
204
requires_sound_hardware = skipExecIf (os .getenv ('EMTEST_LACKS_SOUND_HARDWARE' ), 'This test requires sound hardware' )
196
205
requires_offscreen_canvas = skipExecIf (os .getenv ('EMTEST_LACKS_OFFSCREEN_CANVAS' ), 'This test requires a browser with OffscreenCanvas' )
197
206
@@ -1251,15 +1260,15 @@ def test_webgl_no_double_error(self):
1251
1260
def test_webgl_parallel_shader_compile (self ):
1252
1261
self .btest_exit ('webgl_parallel_shader_compile.cpp' )
1253
1262
1254
- @requires_graphics_hardware
1263
+ @requires_webgl2
1255
1264
def test_webgl_explicit_uniform_location (self ):
1256
1265
self .btest_exit ('webgl_explicit_uniform_location.c' , cflags = ['-sGL_EXPLICIT_UNIFORM_LOCATION' , '-sMIN_WEBGL_VERSION=2' ])
1257
1266
1258
1267
@requires_graphics_hardware
1259
1268
def test_webgl_sampler_layout_binding (self ):
1260
1269
self .btest_exit ('webgl_sampler_layout_binding.c' , cflags = ['-sGL_EXPLICIT_UNIFORM_BINDING' ])
1261
1270
1262
- @requires_graphics_hardware
1271
+ @requires_webgl2
1263
1272
def test_webgl2_ubo_layout_binding (self ):
1264
1273
self .btest_exit ('webgl2_ubo_layout_binding.c' , cflags = ['-sGL_EXPLICIT_UNIFORM_BINDING' , '-sMIN_WEBGL_VERSION=2' ])
1265
1274
@@ -1799,7 +1808,7 @@ def test_gles2_emulation(self, args):
1799
1808
'-lGL' , '-lEGL' , '-lX11' , '-Wno-int-conversion' , '-Wno-pointer-sign' ,
1800
1809
'--preload-file' , 'basemap.tga' , '--preload-file' , 'lightmap.tga' , '--preload-file' , 'smoke.tga' ] + args )
1801
1810
1802
- @requires_graphics_hardware
1811
+ @requires_webgl2
1803
1812
def test_clientside_vertex_arrays_es3 (self ):
1804
1813
self .reftest ('clientside_vertex_arrays_es3.c' , 'gl_triangle.png' , cflags = ['-sFULL_ES3' , '-sUSE_GLFW=3' , '-lglfw' , '-lGLESv2' ])
1805
1814
@@ -2133,7 +2142,7 @@ def test_cubegeom_pre2_vao2(self):
2133
2142
def test_cubegeom_pre_vao_es (self ):
2134
2143
self .reftest ('third_party/cubegeom/cubegeom_pre_vao_es.c' , 'third_party/cubegeom/cubegeom_pre_vao.png' , cflags = ['-sFULL_ES2' , '-lGL' , '-lSDL' ])
2135
2144
2136
- @requires_graphics_hardware
2145
+ @requires_webgl2
2137
2146
@no_swiftshader
2138
2147
def test_cubegeom_row_length (self ):
2139
2148
self .reftest ('third_party/cubegeom/cubegeom_pre_vao_es.c' , 'third_party/cubegeom/cubegeom_pre_vao.png' , cflags = ['-sFULL_ES2' , '-lGL' , '-lSDL' , '-DUSE_UNPACK_ROW_LENGTH' , '-sMIN_WEBGL_VERSION=2' ])
@@ -2251,6 +2260,8 @@ def test_float_tex(self):
2251
2260
'es2_tracing' : (['-sMIN_WEBGL_VERSION=2' , '-sFULL_ES2' , '-sWEBGL2_BACKWARDS_COMPATIBILITY_EMULATION' , '-sTRACE_WEBGL_CALLS' ],),
2252
2261
})
2253
2262
def test_subdata (self , args ):
2263
+ if '-sMIN_WEBGL_VERSION=2' in args and webgl2_disabled ():
2264
+ self .skipTest ('This test requires WebGL2 to be available' )
2254
2265
if self .is_4gb () and '-sMIN_WEBGL_VERSION=2' in args :
2255
2266
self .skipTest ('texSubImage2D fails: https://crbug.com/325090165' )
2256
2267
self .reftest ('gl_subdata.c' , 'float_tex.png' , cflags = ['-lGL' , '-lglut' ] + args )
@@ -2681,7 +2692,7 @@ def test_webgl2(self, args):
2681
2692
self .btest_exit ('webgl2.c' , cflags = ['-sMAX_WEBGL_VERSION=2' , '-lGL' ] + args )
2682
2693
2683
2694
# Tests the WebGL 2 glGetBufferSubData() functionality.
2684
- @requires_graphics_hardware
2695
+ @requires_webgl2
2685
2696
@no_4gb ('getBufferSubData fails: https://crbug.com/325090165' )
2686
2697
def test_webgl2_get_buffer_sub_data (self ):
2687
2698
self .btest_exit ('webgl2_get_buffer_sub_data.c' , cflags = ['-sMAX_WEBGL_VERSION=2' , '-lGL' ])
@@ -2696,11 +2707,11 @@ def test_webgl2_pthreads(self):
2696
2707
def test_webgl2_objects (self ):
2697
2708
self .btest_exit ('webgl2_objects.c' , cflags = ['-sMAX_WEBGL_VERSION=2' , '-lGL' ])
2698
2709
2699
- @requires_graphics_hardware
2710
+ @requires_webgl2
2700
2711
@parameterized ({
2701
2712
'' : ([],),
2702
2713
'offscreencanvas' : (['-sOFFSCREENCANVAS_SUPPORT' , '-pthread' , '-sPROXY_TO_PTHREAD' ],),
2703
- 'offscreenframbuffer ' : (['-sOFFSCREEN_FRAMEBUFFER' , '-pthread' , '-sPROXY_TO_PTHREAD' ],),
2714
+ 'offscreenframebuffer ' : (['-sOFFSCREEN_FRAMEBUFFER' , '-pthread' , '-sPROXY_TO_PTHREAD' ],),
2704
2715
})
2705
2716
def test_html5_webgl_api (self , args ):
2706
2717
if '-sOFFSCREENCANVAS_SUPPORT' in args and os .getenv ('EMTEST_LACKS_OFFSCREEN_CANVAS' ):
@@ -2715,6 +2726,8 @@ def test_html5_webgl_api(self, args):
2715
2726
})
2716
2727
@requires_graphics_hardware
2717
2728
def test_webgl_preprocessor_variables (self , opts ):
2729
+ if '-DWEBGL_VERSION=2' in opts and webgl2_disabled ():
2730
+ self .skipTest ('This test requires WebGL2 to be available' )
2718
2731
self .btest_exit ('webgl_preprocessor_variables.c' , cflags = ['-lGL' ] + opts )
2719
2732
2720
2733
@requires_graphics_hardware
@@ -2727,11 +2740,13 @@ def test_webgl2_ubos(self):
2727
2740
'webgl2' : (['-sMAX_WEBGL_VERSION=2' , '-DTEST_WEBGL2=1' ],),
2728
2741
})
2729
2742
def test_webgl2_garbage_free_entrypoints (self , args ):
2743
+ if '-DTEST_WEBGL2=1' in args and webgl2_disabled ():
2744
+ self .skipTest ('This test requires WebGL2 to be available' )
2730
2745
if args and self .is_4gb ():
2731
2746
self .skipTest ('readPixels fails: https://crbug.com/324992397' )
2732
2747
self .btest_exit ('webgl2_garbage_free_entrypoints.c' , cflags = args )
2733
2748
2734
- @requires_graphics_hardware
2749
+ @requires_webgl2
2735
2750
def test_webgl2_backwards_compatibility_emulation (self ):
2736
2751
self .btest_exit ('webgl2_backwards_compatibility_emulation.c' , cflags = ['-sMAX_WEBGL_VERSION=2' , '-sWEBGL2_BACKWARDS_COMPATIBILITY_EMULATION' ])
2737
2752
@@ -2754,13 +2769,16 @@ def test_webgl_context_major_version(self):
2754
2769
2755
2770
# -sMIN_WEBGL_VERSION=2 => only 2 allowed
2756
2771
self .btest ('test_webgl_context_major_version.c' , expected = 'abort:Expected Error: WebGL 1 requested but only WebGL 2 is supported (MIN_WEBGL_VERSION is 2)' , cflags = ['-lGL' , '-sMIN_WEBGL_VERSION=2' , '-DWEBGL_CONTEXT_MAJOR_VERSION=1' ])
2772
+
2773
+ @requires_webgl2
2774
+ def test_webgl_context_major_version_webgl2 (self ):
2757
2775
self .btest_exit ('test_webgl_context_major_version.c' , cflags = ['-lGL' , '-sMIN_WEBGL_VERSION=2' , '-DWEBGL_CONTEXT_MAJOR_VERSION=2' ])
2758
2776
2759
2777
# -sMAX_WEBGL_VERSION=2 => 1 and 2 are ok
2760
2778
self .btest_exit ('test_webgl_context_major_version.c' , cflags = ['-lGL' , '-sMAX_WEBGL_VERSION=2' , '-DWEBGL_CONTEXT_MAJOR_VERSION=1' ])
2761
2779
self .btest_exit ('test_webgl_context_major_version.c' , cflags = ['-lGL' , '-sMAX_WEBGL_VERSION=2' , '-DWEBGL_CONTEXT_MAJOR_VERSION=2' ])
2762
2780
2763
- @requires_graphics_hardware
2781
+ @requires_webgl2
2764
2782
def test_webgl2_invalid_teximage2d_type (self ):
2765
2783
self .btest_exit ('webgl2_invalid_teximage2d_type.c' , cflags = ['-sMAX_WEBGL_VERSION=2' ])
2766
2784
@@ -2769,7 +2787,7 @@ def test_webgl_with_closure(self):
2769
2787
self .btest_exit ('webgl_with_closure.c' , cflags = ['-O2' , '-sMAX_WEBGL_VERSION=2' , '--closure=1' , '-lGL' ])
2770
2788
2771
2789
# Tests that -sGL_ASSERTIONS and glVertexAttribPointer with packed types works
2772
- @requires_graphics_hardware
2790
+ @requires_webgl2
2773
2791
def test_webgl2_packed_types (self ):
2774
2792
self .btest_exit ('webgl2_draw_packed_triangle.c' , cflags = ['-lGL' , '-sMAX_WEBGL_VERSION=2' , '-sGL_ASSERTIONS' ])
2775
2793
@@ -2791,7 +2809,7 @@ def test_webgl2_sokol_mrt(self):
2791
2809
self .reftest ('third_party/sokol/mrt-emcc.c' , 'third_party/sokol/mrt-emcc.png' ,
2792
2810
cflags = ['-sMAX_WEBGL_VERSION=2' , '-lGL' ])
2793
2811
2794
- @requires_graphics_hardware
2812
+ @requires_webgl2
2795
2813
@no_4gb ('fails to render' )
2796
2814
def test_webgl2_sokol_arraytex (self ):
2797
2815
self .reftest ('third_party/sokol/arraytex-emsc.c' , 'third_party/sokol/arraytex-emsc.png' ,
@@ -4282,7 +4300,7 @@ def test_webgl_multi_draw(self, args):
4282
4300
# We might want to append the --enable-webgl-draft-extensions to the EMTEST_BROWSER env arg.
4283
4301
# If testing on Mac, you also need --use-cmd-decoder=passthrough to get this extension.
4284
4302
# Also there is a known bug with Mac Intel baseInstance which can fail producing the expected image result.
4285
- @requires_graphics_hardware
4303
+ @requires_webgl2
4286
4304
@parameterized ({
4287
4305
'' : (0 ,),
4288
4306
'multidraw' : (1 ,),
@@ -4354,6 +4372,8 @@ def test_webgl_vao_without_automatic_extensions(self):
4354
4372
'gl2_no_aa' : (['-sMAX_WEBGL_VERSION=2' , '-DTEST_WEBGL2=1' , '-DTEST_ANTIALIAS=0' ],),
4355
4373
})
4356
4374
def test_webgl_offscreen_framebuffer_state_restoration (self , args ):
4375
+ if '-DTEST_WEBGL2=1' in args and webgl2_disabled ():
4376
+ self .skipTest ('This test requires WebGL2 to be available' )
4357
4377
base_args = ['-lGL' , '-sOFFSCREEN_FRAMEBUFFER' , '-DEXPLICIT_SWAP=1' ]
4358
4378
self .btest_exit ('webgl_offscreen_framebuffer_swap_with_bad_state.c' , cflags = base_args + args )
4359
4379
@@ -4367,7 +4387,7 @@ def test_webgl_draw_triangle_with_uniform_color(self, args):
4367
4387
self .btest_exit ('webgl_draw_triangle_with_uniform_color.c' , cflags = args )
4368
4388
4369
4389
# Tests that using an array of structs in GL uniforms works.
4370
- @requires_graphics_hardware
4390
+ @requires_webgl2
4371
4391
def test_webgl_array_of_structs_uniform (self ):
4372
4392
self .reftest ('webgl_array_of_structs_uniform.c' , 'webgl_array_of_structs_uniform.png' , cflags = ['-lGL' , '-sMAX_WEBGL_VERSION=2' ])
4373
4393
@@ -4424,6 +4444,9 @@ def test_webgl_resize_offscreencanvas_from_main_thread(self, args1, args2, args3
4424
4444
'disable' : (0 ,),
4425
4445
})
4426
4446
def test_webgl_simple_extensions (self , webgl_version , simple_enable_extensions ):
4447
+ if webgl_version == 2 and webgl2_disabled ():
4448
+ self .skipTest ('This test requires WebGL2 to be available' )
4449
+
4427
4450
cmd = ['-DWEBGL_CONTEXT_VERSION=' + str (webgl_version ),
4428
4451
'-DWEBGL_SIMPLE_ENABLE_EXTENSION=' + str (simple_enable_extensions ),
4429
4452
'-sMAX_WEBGL_VERSION=2' ,
0 commit comments