diff --git a/src/lib/libhtml5_webgl.js b/src/lib/libhtml5_webgl.js index ecc1c8e8cc160..b3958e482b002 100644 --- a/src/lib/libhtml5_webgl.js +++ b/src/lib/libhtml5_webgl.js @@ -28,27 +28,27 @@ var LibraryHtml5WebGL = { #if PTHREADS && OFFSCREEN_FRAMEBUFFER // In offscreen framebuffer mode, we implement a proxied version of the // emscripten_webgl_create_context() function in JS. - emscripten_webgl_create_context_proxied__proxy: 'sync', - emscripten_webgl_create_context_proxied__deps: ['emscripten_webgl_do_create_context'], - emscripten_webgl_create_context_proxied: (target, attributes) => - _emscripten_webgl_do_create_context(target, attributes), + _emscripten_webgl_create_context_proxied__proxy: 'sync', + _emscripten_webgl_create_context_proxied__deps: ['_emscripten_webgl_do_create_context'], + _emscripten_webgl_create_context_proxied: (target, attributes) => + __emscripten_webgl_do_create_context(target, attributes), // The other proxied GL commands are defined in C (guarded by the // __EMSCRIPTEN_OFFSCREEN_FRAMEBUFFER__ definition). #else // When not in offscreen framebuffer mode, these functions are implemented // in JS and forwarded without any proxying. - emscripten_webgl_create_context: 'emscripten_webgl_do_create_context', + emscripten_webgl_create_context: '_emscripten_webgl_do_create_context', - emscripten_webgl_get_current_context: 'emscripten_webgl_do_get_current_context', + emscripten_webgl_get_current_context: '_emscripten_webgl_do_get_current_context', - emscripten_webgl_commit_frame: 'emscripten_webgl_do_commit_frame', + emscripten_webgl_commit_frame: '_emscripten_webgl_do_commit_frame', - emscripten_webgl_destroy_context: 'emscripten_webgl_do_destroy_context', + emscripten_webgl_destroy_context: '_emscripten_webgl_do_destroy_context', #endif #if OFFSCREENCANVAS_SUPPORT - emscripten_webgl_do_create_context__postset: ` + _emscripten_webgl_do_create_context__postset: ` registerPreMainLoop(() => { // If the current GL context is an OffscreenCanvas, but it was initialized // with implicit swap mode, perform the swap on behalf of the user. @@ -58,18 +58,18 @@ var LibraryHtml5WebGL = { });`, #endif - emscripten_webgl_do_create_context__deps: [ + _emscripten_webgl_do_create_context__deps: [ #if OFFSCREENCANVAS_SUPPORT '$registerPreMainLoop', 'malloc', 'emscripten_supports_offscreencanvas', #endif #if PTHREADS && OFFSCREEN_FRAMEBUFFER - 'emscripten_webgl_create_context_proxied', + '_emscripten_webgl_create_context_proxied', #endif '$webglPowerPreferences', '$findCanvasEventTarget'], // This function performs proxying manually, depending on the style of context that is to be created. - emscripten_webgl_do_create_context: (target, attributes) => { + _emscripten_webgl_do_create_context: (target, attributes) => { #if ASSERTIONS assert(attributes); #endif @@ -138,7 +138,7 @@ var LibraryHtml5WebGL = { {{{ makeSetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.renderViaOffscreenBackBuffer, '1', 'i8') }}}; {{{ makeSetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.preserveDrawingBuffer, '1', 'i8') }}}; } - return _emscripten_webgl_create_context_proxied(target, attributes); + return __emscripten_webgl_create_context_proxied(target, attributes); } } #endif @@ -222,8 +222,8 @@ var LibraryHtml5WebGL = { #if PTHREADS && OFFSCREEN_FRAMEBUFFER // Runs on the calling thread, proxies if needed. - emscripten_webgl_make_context_current_calling_thread__sig: 'ip', - emscripten_webgl_make_context_current_calling_thread: (contextHandle) => { + _emscripten_webgl_make_context_current_calling_thread__sig: 'ip', + _emscripten_webgl_make_context_current_calling_thread: (contextHandle) => { var success = GL.makeContextCurrent(contextHandle); if (success) GL.currentContextIsProxied = false; // If succeeded above, we will have a local GL context from this thread (worker or main). return success ? {{{ cDefs.EMSCRIPTEN_RESULT_SUCCESS }}} : {{{ cDefs.EMSCRIPTEN_RESULT_INVALID_PARAM }}}; @@ -256,7 +256,7 @@ var LibraryHtml5WebGL = { }, #endif - emscripten_webgl_do_get_current_context: () => GL.currentContext ? GL.currentContext.handle : 0, + _emscripten_webgl_do_get_current_context: () => GL.currentContext ? GL.currentContext.handle : 0, emscripten_webgl_get_drawing_buffer_size__proxy: 'sync_on_webgl_context_handle_thread', emscripten_webgl_get_drawing_buffer_size: (contextHandle, width, height) => { @@ -270,10 +270,10 @@ var LibraryHtml5WebGL = { return {{{ cDefs.EMSCRIPTEN_RESULT_SUCCESS }}}; }, - emscripten_webgl_do_commit_frame: () => { + _emscripten_webgl_do_commit_frame: () => { #if TRACE_WEBGL_CALLS var threadId = (typeof _pthread_self !== 'undefined') ? _pthread_self : () => 1; - err(`[Thread ${threadId()}, GL ctx: ${GL.currentContext.handle}]: emscripten_webgl_do_commit_frame()`); + err(`[Thread ${threadId()}, GL ctx: ${GL.currentContext.handle}]: _emscripten_webgl_do_commit_frame()`); #endif if (!GL.currentContext || !GL.currentContext.GLctx) { #if GL_DEBUG @@ -333,8 +333,8 @@ var LibraryHtml5WebGL = { return {{{ cDefs.EMSCRIPTEN_RESULT_SUCCESS }}}; }, - emscripten_webgl_do_destroy_context__proxy: 'sync_on_webgl_context_handle_thread', - emscripten_webgl_do_destroy_context: (contextHandle) => { + _emscripten_webgl_do_destroy_context__proxy: 'sync_on_webgl_context_handle_thread', + _emscripten_webgl_do_destroy_context: (contextHandle) => { if (GL.currentContext == contextHandle) GL.currentContext = 0; GL.deleteContext(contextHandle); }, diff --git a/src/lib/libsigs.js b/src/lib/libsigs.js index 0e46e5cded485..f73ba4919dbd8 100644 --- a/src/lib/libsigs.js +++ b/src/lib/libsigs.js @@ -352,6 +352,10 @@ sigs = { _emscripten_thread_mailbox_await__sig: 'vp', _emscripten_thread_set_strongref__sig: 'vp', _emscripten_throw_longjmp__sig: 'v', + _emscripten_webgl_do_commit_frame__sig: 'i', + _emscripten_webgl_do_create_context__sig: 'ppp', + _emscripten_webgl_do_destroy_context__sig: 'ip', + _emscripten_webgl_do_get_current_context__sig: 'p', _emval_array_to_memory_view__sig: 'vpp', _emval_await__sig: 'pp', _emval_coro_make_promise__sig: 'ppp', @@ -873,10 +877,6 @@ sigs = { emscripten_webgl_commit_frame__sig: 'i', emscripten_webgl_create_context__sig: 'ppp', emscripten_webgl_destroy_context__sig: 'ip', - emscripten_webgl_do_commit_frame__sig: 'i', - emscripten_webgl_do_create_context__sig: 'ppp', - emscripten_webgl_do_destroy_context__sig: 'ip', - emscripten_webgl_do_get_current_context__sig: 'p', emscripten_webgl_enable_ANGLE_instanced_arrays__sig: 'ip', emscripten_webgl_enable_EXT_clip_control__sig: 'ip', emscripten_webgl_enable_EXT_polygon_offset_clamp__sig: 'ip', diff --git a/system/lib/gl/webgl1.c b/system/lib/gl/webgl1.c index 2ed29519ef124..8a3ed7b247854 100644 --- a/system/lib/gl/webgl1.c +++ b/system/lib/gl/webgl1.c @@ -78,9 +78,9 @@ EMSCRIPTEN_WEBGL_CONTEXT_HANDLE emscripten_webgl_create_context(const char *targ (attributes->proxyContextToMainThread == EMSCRIPTEN_WEBGL_CONTEXT_PROXY_FALLBACK && !emscripten_supports_offscreencanvas())) { EmscriptenWebGLContextAttributes attrs = *attributes; attrs.renderViaOffscreenBackBuffer = true; - return (EMSCRIPTEN_WEBGL_CONTEXT_HANDLE)emscripten_sync_run_in_main_runtime_thread_ptr(EM_FUNC_SIG_PPP, &emscripten_webgl_do_create_context, target, &attrs); + return (EMSCRIPTEN_WEBGL_CONTEXT_HANDLE)emscripten_sync_run_in_main_runtime_thread_ptr(EM_FUNC_SIG_PPP, &_emscripten_webgl_do_create_context, target, &attrs); } else { - return emscripten_webgl_do_create_context(target, attributes); + return _emscripten_webgl_do_create_context(target, attributes); } } @@ -90,14 +90,14 @@ EMSCRIPTEN_RESULT emscripten_webgl_make_context_current(EMSCRIPTEN_WEBGL_CONTEXT return EMSCRIPTEN_RESULT_SUCCESS; if (context && GetOwningThread(context) == pthread_self()) { - EMSCRIPTEN_RESULT r = emscripten_webgl_make_context_current_calling_thread(context); + EMSCRIPTEN_RESULT r = _emscripten_webgl_make_context_current_calling_thread(context); if (r == EMSCRIPTEN_RESULT_SUCCESS) { pthread_setspecific(currentActiveWebGLContext, (void*)context); pthread_setspecific(currentThreadOwnsItsWebGLContext, (void*)1); } return r; } else { - EMSCRIPTEN_RESULT r = emscripten_sync_run_in_main_runtime_thread(EM_FUNC_SIG_IP, &emscripten_webgl_make_context_current_calling_thread, context); + EMSCRIPTEN_RESULT r = emscripten_sync_run_in_main_runtime_thread(EM_FUNC_SIG_IP, &_emscripten_webgl_make_context_current_calling_thread, context); if (r == EMSCRIPTEN_RESULT_SUCCESS) { pthread_setspecific(currentActiveWebGLContext, (void*)context); pthread_setspecific(currentThreadOwnsItsWebGLContext, (void*)0); @@ -114,16 +114,16 @@ EMSCRIPTEN_WEBGL_CONTEXT_HANDLE emscripten_webgl_get_current_context(void) { EMSCRIPTEN_RESULT emscripten_webgl_commit_frame(void) { GL_FUNCTION_TRACE(); if (pthread_getspecific(currentThreadOwnsItsWebGLContext)) - return emscripten_webgl_do_commit_frame(); + return _emscripten_webgl_do_commit_frame(); else - return (EMSCRIPTEN_RESULT)emscripten_sync_run_in_main_runtime_thread(EM_FUNC_SIG_I, &emscripten_webgl_do_commit_frame); + return (EMSCRIPTEN_RESULT)emscripten_sync_run_in_main_runtime_thread(EM_FUNC_SIG_I, &_emscripten_webgl_do_commit_frame); } EMSCRIPTEN_RESULT emscripten_webgl_destroy_context(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context) { GL_FUNCTION_TRACE(); if (emscripten_webgl_get_current_context() == context) emscripten_webgl_make_context_current(0); - return emscripten_webgl_do_destroy_context(context); + return _emscripten_webgl_do_destroy_context(context); } static void *memdup(const void *ptr, size_t sz) { diff --git a/system/lib/gl/webgl_internal.h b/system/lib/gl/webgl_internal.h index 6a42056a00edc..98a62c9770c7d 100644 --- a/system/lib/gl/webgl_internal.h +++ b/system/lib/gl/webgl_internal.h @@ -6,11 +6,11 @@ */ #pragma once -EMSCRIPTEN_WEBGL_CONTEXT_HANDLE emscripten_webgl_do_get_current_context(void); -EMSCRIPTEN_WEBGL_CONTEXT_HANDLE emscripten_webgl_do_create_context(const char *target, const EmscriptenWebGLContextAttributes *attributes); -EMSCRIPTEN_RESULT emscripten_webgl_make_context_current_calling_thread(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); -EMSCRIPTEN_RESULT emscripten_webgl_do_commit_frame(void); -EMSCRIPTEN_RESULT emscripten_webgl_do_destroy_context(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); +EMSCRIPTEN_WEBGL_CONTEXT_HANDLE _emscripten_webgl_do_get_current_context(void); +EMSCRIPTEN_WEBGL_CONTEXT_HANDLE _emscripten_webgl_do_create_context(const char *target, const EmscriptenWebGLContextAttributes *attributes); +EMSCRIPTEN_RESULT _emscripten_webgl_make_context_current_calling_thread(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); +EMSCRIPTEN_RESULT _emscripten_webgl_do_commit_frame(void); +EMSCRIPTEN_RESULT _emscripten_webgl_do_destroy_context(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); bool emscripten_supports_offscreencanvas(void); void _emscripten_proxied_gl_context_activated_from_main_browser_thread(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); diff --git a/test/codesize/test_codesize_hello_dylink_all.json b/test/codesize/test_codesize_hello_dylink_all.json index 51aabd0b2d2b7..080c561717270 100644 --- a/test/codesize/test_codesize_hello_dylink_all.json +++ b/test/codesize/test_codesize_hello_dylink_all.json @@ -1,7 +1,7 @@ { - "a.out.js": 272709, + "a.out.js": 272713, "a.out.nodebug.wasm": 588152, - "total": 860861, + "total": 860865, "sent": [ "IMG_Init", "IMG_Load", @@ -300,6 +300,10 @@ "_emscripten_runtime_keepalive_clear", "_emscripten_system", "_emscripten_throw_longjmp", + "_emscripten_webgl_do_commit_frame", + "_emscripten_webgl_do_create_context", + "_emscripten_webgl_do_destroy_context", + "_emscripten_webgl_do_get_current_context", "_glGetActiveAttribOrUniform", "_gmtime_js", "_localtime_js", @@ -957,10 +961,6 @@ "emscripten_webgl_commit_frame", "emscripten_webgl_create_context", "emscripten_webgl_destroy_context", - "emscripten_webgl_do_commit_frame", - "emscripten_webgl_do_create_context", - "emscripten_webgl_do_destroy_context", - "emscripten_webgl_do_get_current_context", "emscripten_webgl_enable_ANGLE_instanced_arrays", "emscripten_webgl_enable_EXT_clip_control", "emscripten_webgl_enable_EXT_polygon_offset_clamp",