@@ -4256,21 +4256,26 @@ def test_pthread_custom_pthread_main_url(self):
4256
4256
delete_file ('test.worker.js' )
4257
4257
self .run_browser ('test2.html' , '/report_result?exit:0' )
4258
4258
4259
- # Test that if the main thread is performing a futex wait while a pthread needs it to do a proxied operation (before that pthread would wake up the main thread), that it's not a deadlock.
4259
+ # Test that if the main thread is performing a futex wait while a pthread
4260
+ # needs it to do a proxied operation (before that pthread would wake up the
4261
+ # main thread), that it's not a deadlock.
4260
4262
@requires_threads
4261
4263
def test_pthread_proxying_in_futex_wait (self ):
4262
4264
self .btest_exit ('pthread/test_pthread_proxying_in_futex_wait.cpp' , args = ['-O3' , '-pthread' , '-sPTHREAD_POOL_SIZE' ])
4263
4265
4264
4266
# Test that sbrk() operates properly in multithreaded conditions
4265
4267
@requires_threads
4266
- def test_pthread_sbrk (self ):
4267
- for aborting_malloc in [0 , 1 ]:
4268
- print ('aborting malloc=' + str (aborting_malloc ))
4269
- # With aborting malloc = 1, test allocating memory in threads
4270
- # With aborting malloc = 0, allocate so much memory in threads that some of the allocations fail.
4271
- self .btest_exit ('pthread/test_pthread_sbrk.cpp' , args = ['-O3' , '-pthread' , '-sPTHREAD_POOL_SIZE=8' , '-sABORTING_MALLOC=' + str (aborting_malloc ), '-DABORTING_MALLOC=' + str (aborting_malloc ), '-sINITIAL_MEMORY=128MB' ])
4268
+ @parameterized ({
4269
+ '' : (['-DABORTING_MALLOC=0' , '-sABORTING_MALLOC=0' ],),
4270
+ 'aborting_malloc' : (['-DABORTING_MALLOC=1' ],),
4271
+ })
4272
+ def test_pthread_sbrk (self , args ):
4273
+ # With aborting malloc = 1, test allocating memory in threads
4274
+ # With aborting malloc = 0, allocate so much memory in threads that some of the allocations fail.
4275
+ self .btest_exit ('pthread/test_pthread_sbrk.cpp' , args = ['-O3' , '-pthread' , '-sPTHREAD_POOL_SIZE=8' , '-sINITIAL_MEMORY=128MB' ] + args )
4272
4276
4273
- # Test that -sABORTING_MALLOC=0 works in both pthreads and non-pthreads builds. (sbrk fails gracefully)
4277
+ # Test that -sABORTING_MALLOC=0 works in both pthreads and non-pthreads
4278
+ # builds. (sbrk fails gracefully)
4274
4279
@parameterized ({
4275
4280
'' : ([],),
4276
4281
'mt' : (['-pthread' ],),
@@ -4280,7 +4285,8 @@ def test_pthread_gauge_available_memory(self, args):
4280
4285
for opts in [[], ['-O2' ]]:
4281
4286
self .btest ('gauge_available_memory.cpp' , expected = '1' , args = ['-sABORTING_MALLOC=0' ] + args + opts )
4282
4287
4283
- # Test that the proxying operations of user code from pthreads to main thread work
4288
+ # Test that the proxying operations of user code from pthreads to main thread
4289
+ # work
4284
4290
@disabled ('https://github.com/emscripten-core/emscripten/issues/18210' )
4285
4291
@requires_threads
4286
4292
def test_pthread_run_on_main_thread (self ):
@@ -4291,27 +4297,31 @@ def test_pthread_run_on_main_thread(self):
4291
4297
def test_pthread_run_on_main_thread_flood (self ):
4292
4298
self .btest_exit ('pthread/test_pthread_run_on_main_thread_flood.cpp' , args = ['-O3' , '-pthread' , '-sPTHREAD_POOL_SIZE' ])
4293
4299
4294
- # Test that it is possible to asynchronously call a JavaScript function on the main thread.
4300
+ # Test that it is possible to asynchronously call a JavaScript function on the
4301
+ # main thread.
4295
4302
@requires_threads
4296
4303
def test_pthread_call_async (self ):
4297
4304
self .btest_exit ('pthread/call_async.c' , args = ['-pthread' ])
4298
4305
4299
- # Test that it is possible to synchronously call a JavaScript function on the main thread and get a return value back.
4306
+ # Test that it is possible to synchronously call a JavaScript function on the
4307
+ # main thread and get a return value back.
4300
4308
@requires_threads
4301
4309
def test_pthread_call_sync_on_main_thread (self ):
4302
4310
self .set_setting ('EXPORTED_FUNCTIONS' , '_main,_malloc' )
4303
4311
self .btest_exit ('pthread/call_sync_on_main_thread.c' , args = ['-O3' , '-pthread' , '-sPROXY_TO_PTHREAD' , '-DPROXY_TO_PTHREAD=1' , '--js-library' , test_file ('pthread/call_sync_on_main_thread.js' )])
4304
4312
self .btest_exit ('pthread/call_sync_on_main_thread.c' , args = ['-O3' , '-pthread' , '-DPROXY_TO_PTHREAD=0' , '--js-library' , test_file ('pthread/call_sync_on_main_thread.js' )])
4305
4313
self .btest_exit ('pthread/call_sync_on_main_thread.c' , args = ['-Oz' , '-DPROXY_TO_PTHREAD=0' , '--js-library' , test_file ('pthread/call_sync_on_main_thread.js' )])
4306
4314
4307
- # Test that it is possible to asynchronously call a JavaScript function on the main thread.
4315
+ # Test that it is possible to asynchronously call a JavaScript function on the
4316
+ # main thread.
4308
4317
@requires_threads
4309
4318
def test_pthread_call_async_on_main_thread (self ):
4310
4319
self .btest ('pthread/call_async_on_main_thread.c' , expected = '7' , args = ['-O3' , '-pthread' , '-sPROXY_TO_PTHREAD' , '-DPROXY_TO_PTHREAD=1' , '--js-library' , test_file ('pthread/call_async_on_main_thread.js' )])
4311
4320
self .btest ('pthread/call_async_on_main_thread.c' , expected = '7' , args = ['-O3' , '-pthread' , '-DPROXY_TO_PTHREAD=0' , '--js-library' , test_file ('pthread/call_async_on_main_thread.js' )])
4312
4321
self .btest ('pthread/call_async_on_main_thread.c' , expected = '7' , args = ['-Oz' , '-DPROXY_TO_PTHREAD=0' , '--js-library' , test_file ('pthread/call_async_on_main_thread.js' )])
4313
4322
4314
- # Tests that spawning a new thread does not cause a reinitialization of the global data section of the application memory area.
4323
+ # Tests that spawning a new thread does not cause a reinitialization of the
4324
+ # global data section of the application memory area.
4315
4325
@requires_threads
4316
4326
def test_pthread_global_data_initialization (self ):
4317
4327
# --memory-init-file mode disabled because WASM=0 does not seem to work with EXPORT_NAME
@@ -4332,7 +4342,9 @@ def test_pthread_global_data_initialization_in_sync_compilation_mode(self):
4332
4342
args = ['-sWASM_ASYNC_COMPILATION=0' ]
4333
4343
self .btest_exit ('pthread/test_pthread_global_data_initialization.c' , args = args + mem_init_mode + ['-pthread' , '-sPROXY_TO_PTHREAD' , '-sPTHREAD_POOL_SIZE' ])
4334
4344
4335
- # Test that emscripten_get_now() reports coherent wallclock times across all pthreads, instead of each pthread independently reporting wallclock times since the launch of that pthread.
4345
+ # Test that emscripten_get_now() reports coherent wallclock times across all
4346
+ # pthreads, instead of each pthread independently reporting wallclock times
4347
+ # since the launch of that pthread.
4336
4348
@requires_threads
4337
4349
def test_pthread_clock_drift (self ):
4338
4350
self .btest_exit ('pthread/test_pthread_clock_drift.cpp' , args = ['-O3' , '-pthread' , '-sPROXY_TO_PTHREAD' ])
@@ -4341,7 +4353,8 @@ def test_pthread_clock_drift(self):
4341
4353
def test_pthread_utf8_funcs (self ):
4342
4354
self .btest_exit ('pthread/test_pthread_utf8_funcs.cpp' , args = ['-pthread' , '-sPTHREAD_POOL_SIZE' ])
4343
4355
4344
- # Test the emscripten_futex_wake(addr, INT_MAX); functionality to wake all waiters
4356
+ # Test the emscripten_futex_wake(addr, INT_MAX); functionality to wake all
4357
+ # waiters
4345
4358
@also_with_wasm2js
4346
4359
@requires_threads
4347
4360
def test_pthread_wake_all (self ):
@@ -4605,8 +4618,10 @@ def test_small_js_flags(self):
4605
4618
if not self .is_wasm64 ():
4606
4619
self .assertLess (abs (size - 4800 ), 100 )
4607
4620
4608
- # Tests that it is possible to initialize and render WebGL content in a pthread by using OffscreenCanvas.
4609
- # -DTEST_CHAINED_WEBGL_CONTEXT_PASSING: Tests that it is possible to transfer WebGL canvas in a chain from main thread -> thread 1 -> thread 2 and then init and render WebGL content there.
4621
+ # Tests that it is possible to initialize and render WebGL content in a
4622
+ # pthread by using OffscreenCanvas. -DTEST_CHAINED_WEBGL_CONTEXT_PASSING:
4623
+ # Tests that it is possible to transfer WebGL canvas in a chain from main
4624
+ # thread -> thread 1 -> thread 2 and then init and render WebGL content there.
4610
4625
@no_chrome ('see https://crbug.com/961765' )
4611
4626
@parameterized ({
4612
4627
'' : ([],),
@@ -4618,8 +4633,11 @@ def test_small_js_flags(self):
4618
4633
def test_webgl_offscreen_canvas_in_pthread (self , args ):
4619
4634
self .btest ('gl_in_pthread.cpp' , expected = '1' , args = args + ['-pthread' , '-sPTHREAD_POOL_SIZE=2' , '-sOFFSCREENCANVAS_SUPPORT' , '-lGL' ])
4620
4635
4621
- # Tests that it is possible to render WebGL content on a <canvas> on the main thread, after it has once been used to render WebGL content in a pthread first
4622
- # -DTEST_MAIN_THREAD_EXPLICIT_COMMIT: Test the same (WebGL on main thread after pthread), but by using explicit .commit() to swap on the main thread instead of implicit "swap when rAF ends" logic
4636
+ # Tests that it is possible to render WebGL content on a <canvas> on the main
4637
+ # thread, after it has once been used to render WebGL content in a pthread
4638
+ # first -DTEST_MAIN_THREAD_EXPLICIT_COMMIT: Test the same (WebGL on main
4639
+ # thread after pthread), but by using explicit .commit() to swap on the main
4640
+ # thread instead of implicit "swap when rAF ends" logic
4623
4641
@parameterized ({
4624
4642
'' : ([],),
4625
4643
'explicit' : (['-DTEST_MAIN_THREAD_EXPLICIT_COMMIT' ],),
@@ -4698,12 +4716,15 @@ def test_webgl_timer_query(self, args):
4698
4716
'' : ([],),
4699
4717
'threads' : (['-pthread' , '-sPROXY_TO_PTHREAD' ],)
4700
4718
})
4701
- def test_webgl_offscreen_framebuffer (self , threads ):
4719
+ @parameterized ({
4720
+ 'v1' : ([],),
4721
+ 'v2' : (['-sFULL_ES2' ],),
4722
+ 'v3' : (['-sFULL_ES3' ],),
4723
+ })
4724
+ def test_webgl_offscreen_framebuffer (self , version , threads ):
4702
4725
# Tests all the different possible versions of libgl
4703
- for version in [[], ['-sFULL_ES3' ], ['-sFULL_ES3' ]]:
4704
- args = ['-lGL' , '-sOFFSCREEN_FRAMEBUFFER' , '-DEXPLICIT_SWAP=1' ] + threads + version
4705
- print ('with args: %s' % str (args ))
4706
- self .btest_exit ('webgl_draw_triangle.c' , args = args )
4726
+ args = ['-lGL' , '-sOFFSCREEN_FRAMEBUFFER' , '-DEXPLICIT_SWAP=1' ] + threads + version
4727
+ self .btest_exit ('webgl_draw_triangle.c' , args = args )
4707
4728
4708
4729
# Tests that VAOs can be used even if WebGL enableExtensionsByDefault is set to 0.
4709
4730
@requires_graphics_hardware
@@ -4739,9 +4760,16 @@ def test_webgl_workaround_webgl_uniform_upload_bug(self):
4739
4760
def test_webgl_array_of_structs_uniform (self ):
4740
4761
self .btest ('webgl_array_of_structs_uniform.c' , args = ['-lGL' , '-sMAX_WEBGL_VERSION=2' ], reference = 'browser/webgl_array_of_structs_uniform.png' )
4741
4762
4742
- # Tests that if a WebGL context is created in a pthread on a canvas that has not been transferred to that pthread, WebGL calls are then proxied to the main thread
4743
- # -DTEST_OFFSCREEN_CANVAS=1: Tests that if a WebGL context is created on a pthread that has the canvas transferred to it via using Emscripten's EMSCRIPTEN_PTHREAD_TRANSFERRED_CANVASES="#canvas", then OffscreenCanvas is used
4744
- # -DTEST_OFFSCREEN_CANVAS=2: Tests that if a WebGL context is created on a pthread that has the canvas transferred to it via automatic transferring of Module.canvas when EMSCRIPTEN_PTHREAD_TRANSFERRED_CANVASES is not defined, then OffscreenCanvas is also used
4763
+ # Tests that if a WebGL context is created in a pthread on a canvas that has
4764
+ # not been transferred to that pthread, WebGL calls are then proxied to the
4765
+ # main thread -DTEST_OFFSCREEN_CANVAS=1: Tests that if a WebGL context is
4766
+ # created on a pthread that has the canvas transferred to it via using
4767
+ # Emscripten's EMSCRIPTEN_PTHREAD_TRANSFERRED_CANVASES="#canvas", then
4768
+ # OffscreenCanvas is used -DTEST_OFFSCREEN_CANVAS=2: Tests that if a WebGL
4769
+ # context is created on a pthread that has the canvas transferred to it via
4770
+ # automatic transferring of Module.canvas when
4771
+ # EMSCRIPTEN_PTHREAD_TRANSFERRED_CANVASES is not defined, then OffscreenCanvas
4772
+ # is also used
4745
4773
@parameterized ({
4746
4774
'' : ([False ],),
4747
4775
'asyncify' : ([True ],),
@@ -4750,38 +4778,49 @@ def test_webgl_array_of_structs_uniform(self):
4750
4778
@requires_offscreen_canvas
4751
4779
@requires_graphics_hardware
4752
4780
def test_webgl_offscreen_canvas_in_proxied_pthread (self , asyncify ):
4753
- cmd = ['-pthread' , '-sOFFSCREENCANVAS_SUPPORT' , '-lGL' , '-sGL_DEBUG' , '-sPROXY_TO_PTHREAD' ]
4781
+ args = ['-pthread' , '-sOFFSCREENCANVAS_SUPPORT' , '-lGL' , '-sGL_DEBUG' , '-sPROXY_TO_PTHREAD' ]
4754
4782
if asyncify :
4755
4783
# given the synchronous render loop here, asyncify is needed to see intermediate frames and
4756
4784
# the gradual color change
4757
- cmd += ['-sASYNCIFY' , '-DASYNCIFY' ]
4758
- print (str (cmd ))
4759
- self .btest_exit ('gl_in_proxy_pthread.cpp' , args = cmd )
4785
+ args += ['-sASYNCIFY' , '-DASYNCIFY' ]
4786
+ self .btest_exit ('gl_in_proxy_pthread.cpp' , args = args )
4760
4787
4761
4788
@parameterized ({
4789
+ '' : ([],),
4762
4790
'proxy' : (['-sPROXY_TO_PTHREAD' ],),
4791
+ })
4792
+ @parameterized ({
4793
+ '' : ([],),
4794
+ 'blocking' : (['-DTEST_SYNC_BLOCKING_LOOP=1' ],),
4795
+ })
4796
+ @parameterized ({
4763
4797
'' : ([],),
4798
+ 'offscreen' : (['-sOFFSCREENCANVAS_SUPPORT' , '-sOFFSCREEN_FRAMEBUFFER' ],),
4764
4799
})
4765
4800
@requires_threads
4766
4801
@requires_graphics_hardware
4767
4802
@requires_offscreen_canvas
4768
- def test_webgl_resize_offscreencanvas_from_main_thread (self , args ):
4769
- for args2 in [[], ['-DTEST_SYNC_BLOCKING_LOOP=1' ]]:
4770
- for args3 in [[], ['-sOFFSCREENCANVAS_SUPPORT' , '-sOFFSCREEN_FRAMEBUFFER' ]]:
4771
- cmd = args + args2 + args3 + ['-pthread' , '-lGL' , '-sGL_DEBUG' ]
4772
- print (str (cmd ))
4773
- self .btest_exit ('resize_offscreencanvas_from_main_thread.cpp' , args = cmd )
4774
-
4775
- @requires_graphics_hardware
4776
- def test_webgl_simple_enable_extensions (self ):
4777
- for webgl_version in [1 , 2 ]:
4778
- for simple_enable_extensions in [0 , 1 ]:
4779
- cmd = ['-DWEBGL_CONTEXT_VERSION=' + str (webgl_version ),
4780
- '-DWEBGL_SIMPLE_ENABLE_EXTENSION=' + str (simple_enable_extensions ),
4781
- '-sMAX_WEBGL_VERSION=2' ,
4782
- '-sGL_SUPPORT_AUTOMATIC_ENABLE_EXTENSIONS=' + str (simple_enable_extensions ),
4783
- '-sGL_SUPPORT_SIMPLE_ENABLE_EXTENSIONS=' + str (simple_enable_extensions )]
4784
- self .btest_exit ('webgl2_simple_enable_extensions.c' , args = cmd )
4803
+ def test_webgl_resize_offscreencanvas_from_main_thread (self , args1 , args2 , args3 ):
4804
+ cmd = args1 + args2 + args3 + ['-pthread' , '-lGL' , '-sGL_DEBUG' ]
4805
+ print (str (cmd ))
4806
+ self .btest_exit ('resize_offscreencanvas_from_main_thread.cpp' , args = cmd )
4807
+
4808
+ @requires_graphics_hardware
4809
+ @parameterized ({
4810
+ 'v1' : (1 ,),
4811
+ 'v2' : (2 ,),
4812
+ })
4813
+ @parameterized ({
4814
+ 'enable' : (1 ,),
4815
+ 'disable' : (0 ,),
4816
+ })
4817
+ def test_webgl_simple_extensions (self , simple_enable_extensions , webgl_version ):
4818
+ cmd = ['-DWEBGL_CONTEXT_VERSION=' + str (webgl_version ),
4819
+ '-DWEBGL_SIMPLE_ENABLE_EXTENSION=' + str (simple_enable_extensions ),
4820
+ '-sMAX_WEBGL_VERSION=2' ,
4821
+ '-sGL_SUPPORT_AUTOMATIC_ENABLE_EXTENSIONS=' + str (simple_enable_extensions ),
4822
+ '-sGL_SUPPORT_SIMPLE_ENABLE_EXTENSIONS=' + str (simple_enable_extensions )]
4823
+ self .btest_exit ('webgl2_simple_enable_extensions.c' , args = cmd )
4785
4824
4786
4825
@parameterized ({
4787
4826
'' : ([],),
0 commit comments