Skip to content

Commit

Permalink
Merge branch 'main' into update_libcxx_libcxxabi_19
Browse files Browse the repository at this point in the history
  • Loading branch information
aheejin committed Dec 4, 2024
2 parents b132cff + 58889f9 commit d7aa36b
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 21 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
22 changes: 22 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -15412,3 +15412,25 @@ def test_rust_integration_basics(self):
return 0;
}''')
self.do_runf('main.cpp', 'Hello from rust!', emcc_args=[lib])

@crossplatform
def test_create_cache_directory(self):
if config.FROZEN_CACHE:
self.skipTest("test doesn't work with frozen cache")

# Test that the cache directory (including parent directories) is
# created on demand.
with env_modify({'EM_CACHE': os.path.abspath('foo/bar')}):
self.run_process([EMCC, '-c', test_file('hello_world.c')])
self.assertExists('foo/bar/sysroot_install.stamp')

if not WINDOWS:
# Test that we generate a nice error when we cannot create the cache
# because it is in a read-only location.
# For some reason this doesn't work on windows, at least not in CI.
os.mkdir('rodir')
os.chmod('rodir', 0o444)
self.assertFalse(os.access('rodir', os.W_OK))
with env_modify({'EM_CACHE': os.path.abspath('rodir/foo')}):
err = self.expect_fail([EMCC, '-c', test_file('hello_world.c')])
self.assertContained('emcc: error: unable to create cache directory', err)
8 changes: 4 additions & 4 deletions tools/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ def lock(reason):
def ensure():
ensure_setup()
if not os.path.isdir(cachedir):
parent_dir = os.path.dirname(cachedir)
if not is_writable(parent_dir):
utils.exit_with_error(f'unable to create cache directory "{cachedir}": parent directory not writable (see https://emscripten.org/docs/tools_reference/emcc.html for info on setting the cache directory)')
utils.safe_ensure_dirs(cachedir)
try:
utils.safe_ensure_dirs(cachedir)
except Exception as e:
utils.exit_with_error(f'unable to create cache directory "{cachedir}": {e} (see https://emscripten.org/docs/tools_reference/emcc.html for info on setting the cache directory)')


def erase():
Expand Down

0 comments on commit d7aa36b

Please sign in to comment.