Skip to content

Commit 67603e9

Browse files
authored
Add env. var. EMTEST_LACKS_WEBGL2. (#25266)
Add env. var. EMTEST_LACKS_WEBGL2. EMTEST_LACKS_WEBGL2 and EMTEST_LACKS_WEBGPU imply EMTEST_LACKS_GRAPHICS_HARDWARE. Annotate use of WebGL2 in test_browser suite.
1 parent 23ddf3b commit 67603e9

File tree

1 file changed

+37
-14
lines changed

1 file changed

+37
-14
lines changed

test/test_browser.py

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,17 @@ def decorated(self, *args, **kwargs):
190190
return decorator
191191

192192

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+
193201
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")
195204
requires_sound_hardware = skipExecIf(os.getenv('EMTEST_LACKS_SOUND_HARDWARE'), 'This test requires sound hardware')
196205
requires_offscreen_canvas = skipExecIf(os.getenv('EMTEST_LACKS_OFFSCREEN_CANVAS'), 'This test requires a browser with OffscreenCanvas')
197206

@@ -1251,15 +1260,15 @@ def test_webgl_no_double_error(self):
12511260
def test_webgl_parallel_shader_compile(self):
12521261
self.btest_exit('webgl_parallel_shader_compile.cpp')
12531262

1254-
@requires_graphics_hardware
1263+
@requires_webgl2
12551264
def test_webgl_explicit_uniform_location(self):
12561265
self.btest_exit('webgl_explicit_uniform_location.c', cflags=['-sGL_EXPLICIT_UNIFORM_LOCATION', '-sMIN_WEBGL_VERSION=2'])
12571266

12581267
@requires_graphics_hardware
12591268
def test_webgl_sampler_layout_binding(self):
12601269
self.btest_exit('webgl_sampler_layout_binding.c', cflags=['-sGL_EXPLICIT_UNIFORM_BINDING'])
12611270

1262-
@requires_graphics_hardware
1271+
@requires_webgl2
12631272
def test_webgl2_ubo_layout_binding(self):
12641273
self.btest_exit('webgl2_ubo_layout_binding.c', cflags=['-sGL_EXPLICIT_UNIFORM_BINDING', '-sMIN_WEBGL_VERSION=2'])
12651274

@@ -1799,7 +1808,7 @@ def test_gles2_emulation(self, args):
17991808
'-lGL', '-lEGL', '-lX11', '-Wno-int-conversion', '-Wno-pointer-sign',
18001809
'--preload-file', 'basemap.tga', '--preload-file', 'lightmap.tga', '--preload-file', 'smoke.tga'] + args)
18011810

1802-
@requires_graphics_hardware
1811+
@requires_webgl2
18031812
def test_clientside_vertex_arrays_es3(self):
18041813
self.reftest('clientside_vertex_arrays_es3.c', 'gl_triangle.png', cflags=['-sFULL_ES3', '-sUSE_GLFW=3', '-lglfw', '-lGLESv2'])
18051814

@@ -2133,7 +2142,7 @@ def test_cubegeom_pre2_vao2(self):
21332142
def test_cubegeom_pre_vao_es(self):
21342143
self.reftest('third_party/cubegeom/cubegeom_pre_vao_es.c', 'third_party/cubegeom/cubegeom_pre_vao.png', cflags=['-sFULL_ES2', '-lGL', '-lSDL'])
21352144

2136-
@requires_graphics_hardware
2145+
@requires_webgl2
21372146
@no_swiftshader
21382147
def test_cubegeom_row_length(self):
21392148
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):
22512260
'es2_tracing': (['-sMIN_WEBGL_VERSION=2', '-sFULL_ES2', '-sWEBGL2_BACKWARDS_COMPATIBILITY_EMULATION', '-sTRACE_WEBGL_CALLS'],),
22522261
})
22532262
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')
22542265
if self.is_4gb() and '-sMIN_WEBGL_VERSION=2' in args:
22552266
self.skipTest('texSubImage2D fails: https://crbug.com/325090165')
22562267
self.reftest('gl_subdata.c', 'float_tex.png', cflags=['-lGL', '-lglut'] + args)
@@ -2681,7 +2692,7 @@ def test_webgl2(self, args):
26812692
self.btest_exit('webgl2.c', cflags=['-sMAX_WEBGL_VERSION=2', '-lGL'] + args)
26822693

26832694
# Tests the WebGL 2 glGetBufferSubData() functionality.
2684-
@requires_graphics_hardware
2695+
@requires_webgl2
26852696
@no_4gb('getBufferSubData fails: https://crbug.com/325090165')
26862697
def test_webgl2_get_buffer_sub_data(self):
26872698
self.btest_exit('webgl2_get_buffer_sub_data.c', cflags=['-sMAX_WEBGL_VERSION=2', '-lGL'])
@@ -2696,11 +2707,11 @@ def test_webgl2_pthreads(self):
26962707
def test_webgl2_objects(self):
26972708
self.btest_exit('webgl2_objects.c', cflags=['-sMAX_WEBGL_VERSION=2', '-lGL'])
26982709

2699-
@requires_graphics_hardware
2710+
@requires_webgl2
27002711
@parameterized({
27012712
'': ([],),
27022713
'offscreencanvas': (['-sOFFSCREENCANVAS_SUPPORT', '-pthread', '-sPROXY_TO_PTHREAD'],),
2703-
'offscreenframbuffer': (['-sOFFSCREEN_FRAMEBUFFER', '-pthread', '-sPROXY_TO_PTHREAD'],),
2714+
'offscreenframebuffer': (['-sOFFSCREEN_FRAMEBUFFER', '-pthread', '-sPROXY_TO_PTHREAD'],),
27042715
})
27052716
def test_html5_webgl_api(self, args):
27062717
if '-sOFFSCREENCANVAS_SUPPORT' in args and os.getenv('EMTEST_LACKS_OFFSCREEN_CANVAS'):
@@ -2715,6 +2726,8 @@ def test_html5_webgl_api(self, args):
27152726
})
27162727
@requires_graphics_hardware
27172728
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')
27182731
self.btest_exit('webgl_preprocessor_variables.c', cflags=['-lGL'] + opts)
27192732

27202733
@requires_graphics_hardware
@@ -2727,11 +2740,13 @@ def test_webgl2_ubos(self):
27272740
'webgl2': (['-sMAX_WEBGL_VERSION=2', '-DTEST_WEBGL2=1'],),
27282741
})
27292742
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')
27302745
if args and self.is_4gb():
27312746
self.skipTest('readPixels fails: https://crbug.com/324992397')
27322747
self.btest_exit('webgl2_garbage_free_entrypoints.c', cflags=args)
27332748

2734-
@requires_graphics_hardware
2749+
@requires_webgl2
27352750
def test_webgl2_backwards_compatibility_emulation(self):
27362751
self.btest_exit('webgl2_backwards_compatibility_emulation.c', cflags=['-sMAX_WEBGL_VERSION=2', '-sWEBGL2_BACKWARDS_COMPATIBILITY_EMULATION'])
27372752

@@ -2754,13 +2769,16 @@ def test_webgl_context_major_version(self):
27542769

27552770
# -sMIN_WEBGL_VERSION=2 => only 2 allowed
27562771
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):
27572775
self.btest_exit('test_webgl_context_major_version.c', cflags=['-lGL', '-sMIN_WEBGL_VERSION=2', '-DWEBGL_CONTEXT_MAJOR_VERSION=2'])
27582776

27592777
# -sMAX_WEBGL_VERSION=2 => 1 and 2 are ok
27602778
self.btest_exit('test_webgl_context_major_version.c', cflags=['-lGL', '-sMAX_WEBGL_VERSION=2', '-DWEBGL_CONTEXT_MAJOR_VERSION=1'])
27612779
self.btest_exit('test_webgl_context_major_version.c', cflags=['-lGL', '-sMAX_WEBGL_VERSION=2', '-DWEBGL_CONTEXT_MAJOR_VERSION=2'])
27622780

2763-
@requires_graphics_hardware
2781+
@requires_webgl2
27642782
def test_webgl2_invalid_teximage2d_type(self):
27652783
self.btest_exit('webgl2_invalid_teximage2d_type.c', cflags=['-sMAX_WEBGL_VERSION=2'])
27662784

@@ -2769,7 +2787,7 @@ def test_webgl_with_closure(self):
27692787
self.btest_exit('webgl_with_closure.c', cflags=['-O2', '-sMAX_WEBGL_VERSION=2', '--closure=1', '-lGL'])
27702788

27712789
# Tests that -sGL_ASSERTIONS and glVertexAttribPointer with packed types works
2772-
@requires_graphics_hardware
2790+
@requires_webgl2
27732791
def test_webgl2_packed_types(self):
27742792
self.btest_exit('webgl2_draw_packed_triangle.c', cflags=['-lGL', '-sMAX_WEBGL_VERSION=2', '-sGL_ASSERTIONS'])
27752793

@@ -2791,7 +2809,7 @@ def test_webgl2_sokol_mrt(self):
27912809
self.reftest('third_party/sokol/mrt-emcc.c', 'third_party/sokol/mrt-emcc.png',
27922810
cflags=['-sMAX_WEBGL_VERSION=2', '-lGL'])
27932811

2794-
@requires_graphics_hardware
2812+
@requires_webgl2
27952813
@no_4gb('fails to render')
27962814
def test_webgl2_sokol_arraytex(self):
27972815
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):
42824300
# We might want to append the --enable-webgl-draft-extensions to the EMTEST_BROWSER env arg.
42834301
# If testing on Mac, you also need --use-cmd-decoder=passthrough to get this extension.
42844302
# 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
42864304
@parameterized({
42874305
'': (0,),
42884306
'multidraw': (1,),
@@ -4354,6 +4372,8 @@ def test_webgl_vao_without_automatic_extensions(self):
43544372
'gl2_no_aa': (['-sMAX_WEBGL_VERSION=2', '-DTEST_WEBGL2=1', '-DTEST_ANTIALIAS=0'],),
43554373
})
43564374
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')
43574377
base_args = ['-lGL', '-sOFFSCREEN_FRAMEBUFFER', '-DEXPLICIT_SWAP=1']
43584378
self.btest_exit('webgl_offscreen_framebuffer_swap_with_bad_state.c', cflags=base_args + args)
43594379

@@ -4367,7 +4387,7 @@ def test_webgl_draw_triangle_with_uniform_color(self, args):
43674387
self.btest_exit('webgl_draw_triangle_with_uniform_color.c', cflags=args)
43684388

43694389
# Tests that using an array of structs in GL uniforms works.
4370-
@requires_graphics_hardware
4390+
@requires_webgl2
43714391
def test_webgl_array_of_structs_uniform(self):
43724392
self.reftest('webgl_array_of_structs_uniform.c', 'webgl_array_of_structs_uniform.png', cflags=['-lGL', '-sMAX_WEBGL_VERSION=2'])
43734393

@@ -4424,6 +4444,9 @@ def test_webgl_resize_offscreencanvas_from_main_thread(self, args1, args2, args3
44244444
'disable': (0,),
44254445
})
44264446
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+
44274450
cmd = ['-DWEBGL_CONTEXT_VERSION=' + str(webgl_version),
44284451
'-DWEBGL_SIMPLE_ENABLE_EXTENSION=' + str(simple_enable_extensions),
44294452
'-sMAX_WEBGL_VERSION=2',

0 commit comments

Comments
 (0)