Skip to content

Commit 943b2b1

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 7edb5c2 commit 943b2b1

File tree

3 files changed

+826
-1
lines changed

3 files changed

+826
-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
@@ -22,7 +23,7 @@
2223

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

2829
try:
@@ -2654,6 +2655,26 @@ def test_webgl2_packed_types(self):
26542655
def test_webgl2_pbo(self):
26552656
self.btest(path_from_root('tests', 'webgl2_pbo.cpp'), args=['-s', 'USE_WEBGL2=1', '-lGL'], expected='0')
26562657

2658+
@requires_graphics_hardware
2659+
def test_webgl2_compute_path_tracing(self):
2660+
if not (is_chrome() and '--enable-webgl2-compute-context' in EMTEST_BROWSER and (WINDOWS or LINUX)):
2661+
self.skipTest('WebGL 2.0 Compute is not enabled/supported')
2662+
# To skip the noisy frames produced at the beginning of path tracing
2663+
create_test_file('pre.js', inspect.cleandoc('''
2664+
(function() {
2665+
var counter = 0;
2666+
var realRequestAnimationFrame = window.requestAnimationFrame;
2667+
window.requestAnimationFrame = function(func) {
2668+
counter++;
2669+
if (counter == 2000) {
2670+
doReftest();
2671+
}
2672+
return realRequestAnimationFrame.call(window, func);
2673+
};
2674+
})();
2675+
'''))
2676+
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'])
2677+
26572678
def test_sdl_touch(self):
26582679
for opts in [[], ['-O2', '-g1', '--closure', '1']]:
26592680
print(opts)

0 commit comments

Comments
 (0)