Skip to content

Commit 954cd01

Browse files
committed
add a test for WebGL 2.0 Compute
The test is expected to work on Windows and Linux with EMTEST_BROWSER="chrome --use-gl=angle --use-angle=gl --use-cmd-decoder=passthrough --enable-webgl2-compute-context". Sadly, the Mesa software renderer is too slow and lacks certain OpenGL extensions for WebGL 2.0 Compute to work, so the test is not enabled in CI.
1 parent 020f2f2 commit 954cd01

File tree

3 files changed

+818
-1
lines changed

3 files changed

+818
-1
lines changed

tests/test_browser.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from __future__ import print_function
88
import argparse
9+
import inspect
910
import json
1011
import multiprocessing
1112
import os
@@ -21,7 +22,7 @@
2122

2223
from runner import BrowserCore, path_from_root, has_browser, EMTEST_BROWSER, no_fastcomp, no_wasm_backend, flaky, create_test_file, parameterized
2324
from tools import system_libs
24-
from tools.shared import PYTHON, EMCC, WINDOWS, FILE_PACKAGER, PIPE, SPIDERMONKEY_ENGINE, JS_ENGINES
25+
from tools.shared import PYTHON, EMCC, WINDOWS, LINUX, FILE_PACKAGER, PIPE, SPIDERMONKEY_ENGINE, JS_ENGINES
2526
from tools.shared import try_delete, Building, run_process, run_js
2627

2728
try:
@@ -2628,6 +2629,26 @@ def test_webgl2_packed_types(self):
26282629
def test_webgl2_pbo(self):
26292630
self.btest(path_from_root('tests', 'webgl2_pbo.cpp'), args=['-s', 'USE_WEBGL2=1', '-lGL'], expected='0')
26302631

2632+
@requires_graphics_hardware
2633+
def test_webgl2_compute_path_tracing(self):
2634+
if not (is_chrome() and '--enable-webgl2-compute-context' in EMTEST_BROWSER and (WINDOWS or LINUX)):
2635+
self.skipTest('WebGL 2.0 Compute is not enabled/supported')
2636+
# To skip the noisy frames produced at the beginning of path tracing
2637+
create_test_file('pre.js', inspect.cleandoc('''
2638+
(function() {
2639+
var counter = 0;
2640+
var realRequestAnimationFrame = window.requestAnimationFrame;
2641+
window.requestAnimationFrame = function(func) {
2642+
counter++;
2643+
if (counter == 2000) {
2644+
doReftest();
2645+
}
2646+
return realRequestAnimationFrame.call(window, func);
2647+
};
2648+
})();
2649+
'''))
2650+
self.btest('webgl2_compute_path_tracing.cpp', reference='webgl2_compute_path_tracing.png', manually_trigger_reftest=True, timeout=120, args=['-std=c++11', '-lglfw', '-lGLESv2', '-s', 'USE_GLFW=3', '-s', 'USE_WEBGL2_COMPUTE=1', '-s', 'EXIT_RUNTIME=1', '--pre-js', 'pre.js'])
2651+
26312652
def test_sdl_touch(self):
26322653
for opts in [[], ['-O2', '-g1', '--closure', '1']]:
26332654
print(opts)

0 commit comments

Comments
 (0)