Skip to content

Commit

Permalink
Parameterize test_webgl_offscreen_framebuffer_state_restoration. NFC (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 authored Dec 4, 2024
1 parent c35d60a commit da54ee3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ int main() {
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_create_context("#canvas", &attr);
emscripten_webgl_make_context_current(ctx);

#if !TEST_WEBGL2 && TEST_VAO
#if !TEST_WEBGL2 && TEST_VERIFY_WEBGL1_VAO_SUPPORT
// This test cannot run without browser support for OES_vertex_array_object.
// This check is just to verify that the browser has support; otherwise, we
// will end up testing the non-VAO path. Enabling it here does not actually do
// anything, because offscreen framebuffer has already been initialized. Note
// that if GL_SUPPORT_AUTOMATIC_ENABLE_EXTENSIONS=0, then offscreen
// framebuffer will _never_ use VAOs on WebGL 1 (unless something enables
// OES_vertex_array_object before createOffscreenFramebuffer runs).
if (!emscripten_webgl_enable_extension(ctx, "OES_vertex_array_object")) {
return 1;
}
Expand Down
32 changes: 16 additions & 16 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4322,22 +4322,22 @@ def test_webgl_vao_without_automatic_extensions(self):

# Tests that offscreen framebuffer state restoration works
@requires_graphics_hardware
def test_webgl_offscreen_framebuffer_state_restoration(self):
for args in [
# full state restoration path on WebGL 1.0
['-sMAX_WEBGL_VERSION', '-sOFFSCREEN_FRAMEBUFFER_FORBID_VAO_PATH'],
# VAO path on WebGL 1.0
['-sMAX_WEBGL_VERSION'],
['-sMAX_WEBGL_VERSION=2', '-DTEST_WEBGL2=0'],
# VAO path on WebGL 2.0
['-sMAX_WEBGL_VERSION=2', '-DTEST_WEBGL2=1', '-DTEST_ANTIALIAS=1', '-DTEST_REQUIRE_VAO=1'],
# full state restoration path on WebGL 2.0
['-sMAX_WEBGL_VERSION=2', '-DTEST_WEBGL2=1', '-DTEST_ANTIALIAS=1', '-sOFFSCREEN_FRAMEBUFFER_FORBID_VAO_PATH'],
# blitFramebuffer path on WebGL 2.0 (falls back to VAO on Firefox < 67)
['-sMAX_WEBGL_VERSION=2', '-DTEST_WEBGL2=1', '-DTEST_ANTIALIAS=0'],
]:
cmd = args + ['-lGL', '-sOFFSCREEN_FRAMEBUFFER', '-DEXPLICIT_SWAP=1']
self.btest_exit('webgl_offscreen_framebuffer_swap_with_bad_state.c', args=cmd)
@parameterized({
# full state restoration path on WebGL 1.0
'gl1_no_vao': (['-sMAX_WEBGL_VERSION=1', '-sOFFSCREEN_FRAMEBUFFER_FORBID_VAO_PATH'],),
# VAO path on WebGL 1.0
'gl1': (['-sMAX_WEBGL_VERSION=1', '-DTEST_VERIFY_WEBGL1_VAO_SUPPORT=1'],),
'gl1_max_gl2': (['-sMAX_WEBGL_VERSION=2'],),
# VAO path on WebGL 2.0
'gl2': (['-sMAX_WEBGL_VERSION=2', '-DTEST_WEBGL2=1', '-DTEST_ANTIALIAS=1'],),
# full state restoration path on WebGL 2.0
'gl2_no_vao': (['-sMAX_WEBGL_VERSION=2', '-DTEST_WEBGL2=1', '-DTEST_ANTIALIAS=1', '-sOFFSCREEN_FRAMEBUFFER_FORBID_VAO_PATH'],),
# blitFramebuffer path on WebGL 2.0 (falls back to VAO on Firefox < 67)
'gl2_no_aa': (['-sMAX_WEBGL_VERSION=2', '-DTEST_WEBGL2=1', '-DTEST_ANTIALIAS=0'],),
})
def test_webgl_offscreen_framebuffer_state_restoration(self, args, skip_vao=False):
cmd = args + ['-lGL', '-sOFFSCREEN_FRAMEBUFFER', '-DEXPLICIT_SWAP=1']
self.btest_exit('webgl_offscreen_framebuffer_swap_with_bad_state.c', args=cmd)

@parameterized({
'': ([],),
Expand Down

0 comments on commit da54ee3

Please sign in to comment.