Skip to content

Commit

Permalink
add a test for WebGL 2.0 Compute
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hujiajie committed Jul 22, 2019
1 parent 8025c85 commit 003df2f
Show file tree
Hide file tree
Showing 3 changed files with 818 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from __future__ import print_function
import argparse
import inspect
import json
import multiprocessing
import os
Expand All @@ -21,7 +22,7 @@

from runner import BrowserCore, path_from_root, has_browser, EMTEST_BROWSER, no_wasm_backend, flaky, create_test_file
from tools import system_libs
from tools.shared import PYTHON, EMCC, WINDOWS, FILE_PACKAGER, PIPE, SPIDERMONKEY_ENGINE, JS_ENGINES
from tools.shared import PYTHON, EMCC, WINDOWS, LINUX, FILE_PACKAGER, PIPE, SPIDERMONKEY_ENGINE, JS_ENGINES
from tools.shared import try_delete, Building, run_process, run_js

try:
Expand Down Expand Up @@ -2626,6 +2627,26 @@ def test_webgl2_packed_types(self):
def test_webgl2_pbo(self):
self.btest(path_from_root('tests', 'webgl2_pbo.cpp'), args=['-s', 'USE_WEBGL2=1', '-lGL'], expected='0')

@requires_graphics_hardware
def test_webgl2_compute_path_tracing(self):
if not (is_chrome() and '--enable-webgl2-compute-context' in EMTEST_BROWSER and (WINDOWS or LINUX)):
self.skipTest('WebGL 2.0 Compute is not enabled/supported')
# To skip the noisy frames produced at the beginning of path tracing
create_test_file('pre.js', inspect.cleandoc('''
(function() {
var counter = 0;
var realRequestAnimationFrame = window.requestAnimationFrame;
window.requestAnimationFrame = function(func) {
counter++;
if (counter == 2000) {
doReftest();
}
realRequestAnimationFrame.call(window, func);
};
})();
'''))
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'])

def test_sdl_touch(self):
for opts in [[], ['-O2', '-g1', '--closure', '1']]:
print(opts)
Expand Down
Loading

0 comments on commit 003df2f

Please sign in to comment.