v0.7.0: SDL-free wasm worker backend (WebGPU + WebGL2) with on-demand assets

The engine now runs on a plain Web Worker (no SDL, no PROXY_TO_PTHREAD: in a pthread Emscripten proxies every filesystem syscall to the main browser thread, where synchronous XHR - and thus FS.createLazyFile - is forbidden). A page/worker pair transfers an OffscreenCanvas and forwards DOM input; assets load lazily from an embedded manifest, so entering a map fetches only that map and its tiles.

Presentation: ra3.webgpu (WebGPU via Emscripten's emdawnwebgpu port, WGSL shaders, the default on wasm) and ra3.wasmgl (WebGL2, GLSL ES). The legacy SDL ra3.webgl backend is removed.
This commit is contained in:
EnderTheCoder
2026-09-29 12:08:07 +08:00
parent 70d4beca4f
commit 889ce945f2
27 changed files with 2161 additions and 639 deletions
+12 -3
View File
@@ -12,8 +12,17 @@
# libc++ `std` module must be built with the same setting as its consumers,
# or clang rejects the prebuilt module ("configuration mismatch"). The engine
# throws, so exceptions are enabled everywhere.
# * The SDL3 web port (`-sUSE_SDL=3`) is attached by CMake to the SDL interface
# target, not here, so only the targets that use SDL pay for it.
# * Asyncify turns `emscripten_sleep` (used by display::sleep_frame on
# Emscripten) into a yield: the engine's frame loops are blocking, and without
# yielding the worker freezes and never paints.
#
# No pthreads: the runtime's main thread runs inside a plain Web Worker started
# by `apps/web/openra3.worker.js`, so its virtual filesystem is local to that
# worker and `FS.createLazyFile` (synchronous XHR) is legal. Under
# `PROXY_TO_PTHREAD` Emscripten proxies every filesystem syscall to the main
# browser thread, where synchronous XHR is forbidden, so lazy assets cannot work
# there - hence the plain worker. The SDL3 web port is only pulled in by the
# legacy main-thread backend (OPENRA3_WASM_SDL).
# `import std` support: the gate and the module switch must be in place before
# Emscripten.cmake runs and before the compiler is probed.
@@ -37,7 +46,7 @@ include("${OPENRA3_EMSCRIPTEN_CMAKE}")
#
# Asyncify turns `emscripten_sleep` (used by display::sleep_frame on Emscripten)
# into a yield to the browser: the engine's frame loops are blocking, and
# without yielding the page freezes and never paints.
# without yielding the worker freezes and never paints.
set(CMAKE_CXX_FLAGS_INIT "-fexceptions -sASYNCIFY=1")
set(CMAKE_C_FLAGS_INIT "-sASYNCIFY=1")
set(CMAKE_EXE_LINKER_FLAGS_INIT