diff --git a/.github/workflows/npm-deploy.yml b/.github/workflows/npm-deploy.yml index 44ef2dbbee..7dc2ed248f 100644 --- a/.github/workflows/npm-deploy.yml +++ b/.github/workflows/npm-deploy.yml @@ -26,7 +26,7 @@ jobs: cd build/web && printf "y" | ./build.sh release - name: Deploy to npm run: | - cd out/cmake-webgl-release/web/filament-js + cd out/cmake-wasm-release/web/filament-js npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 875827da55..5e0c79117d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -177,7 +177,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # ================================================================================================== # OS specific # ================================================================================================== -if (UNIX AND NOT APPLE AND NOT ANDROID AND NOT WEBGL) +if (UNIX AND NOT APPLE AND NOT ANDROID AND NOT WASM) set(LINUX TRUE) else() # since cmake 3.25 LINUX is automatically set based on CMAKE_SYSTEM_NAME, which the android @@ -218,7 +218,7 @@ if (LINUX) endif() endif() -if (ANDROID OR WEBGL OR IOS OR FILAMENT_LINUX_IS_MOBILE) +if (ANDROID OR WASM OR IOS OR FILAMENT_LINUX_IS_MOBILE) set(IS_MOBILE_TARGET TRUE) endif() @@ -226,7 +226,7 @@ if (ANDROID) add_definitions(-D__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__) endif() -if (NOT ANDROID AND NOT WEBGL AND NOT IOS AND NOT FILAMENT_LINUX_IS_MOBILE) +if (NOT ANDROID AND NOT WASM AND NOT IOS AND NOT FILAMENT_LINUX_IS_MOBILE) set(IS_HOST_PLATFORM TRUE) endif() @@ -473,7 +473,7 @@ if (NOT MSVC) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffunction-sections -fdata-sections") endif() -if (ANDROID OR WEBGL) +if (ANDROID OR WASM) # On Android and WebGL RELEASE builds, we omit unwind info to save space. # (We keep unwind info on iOS to allow readable stack traces in crash reports.) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-unwind-tables -fno-asynchronous-unwind-tables") @@ -482,11 +482,11 @@ endif() # With WebGL, we disable RTTI because we pass emscripten::val back and forth # between C++ and JavaScript in order to efficiently access typed arrays, which are unbound. # NOTE: This is not documented in emscripten so we should consider a different approach. -if (WEBGL) +if (WASM) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") endif() -if (WEBGL_PTHREADS) +if (WASM_PTHREADS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") endif() @@ -503,7 +503,7 @@ if (ANDROID) # keep STL debug infos (mimics what the NDK does) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-limit-debug-info") endif() -if (NOT MSVC AND NOT WEBGL) +if (NOT MSVC AND NOT WASM) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector") endif() set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${EXTRA_SANITIZE_OPTIONS}") @@ -522,7 +522,7 @@ endif() # Linker flags # ================================================================================================== # Strip unused sections -if (NOT WEBGL) +if (NOT WASM) set(GC_SECTIONS "-Wl,--gc-sections") endif() @@ -556,7 +556,7 @@ endif() set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GC_SECTIONS} ${NO_EXEC_STACK}") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GC_SECTIONS} ${B_SYMBOLIC_FUNCTIONS} ${BINARY_ALIGNMENT}") -if (WEBGL_PTHREADS) +if (WASM_PTHREADS) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pthread") endif() @@ -586,7 +586,7 @@ endif() # By default, build with Vulkan support on desktop platforms, although clients must request to use # it at run time. -if (WIN32 OR WEBGL OR IOS) +if (WIN32 OR WASM OR IOS) option(FILAMENT_SUPPORTS_VULKAN "Include the Vulkan backend" OFF) else() option(FILAMENT_SUPPORTS_VULKAN "Include the Vulkan backend" ON) @@ -604,7 +604,7 @@ if (FILAMENT_SUPPORTS_WEBP_TEXTURES) endif() # Build with Metal support on non-WebGL Apple platforms. -if (APPLE AND NOT WEBGL) +if (APPLE AND NOT WASM) option(FILAMENT_SUPPORTS_METAL "Include the Metal backend" ON) else() option(FILAMENT_SUPPORTS_METAL "Include the Metal backend" OFF) @@ -614,7 +614,7 @@ if (FILAMENT_SUPPORTS_METAL) endif() # Building filamat increases build times and isn't required for web, so turn it off by default. -if (NOT WEBGL) +if (NOT WASM) option(FILAMENT_BUILD_FILAMAT "Build filamat and JNI buildings" ON) else() option(FILAMENT_BUILD_FILAMAT "Build filamat and JNI buildings" OFF) @@ -840,7 +840,7 @@ if (FILAMENT_IMPORT_PREBUILT_EXECUTABLES_DIR) set(IMPORT_EXECUTABLES_DIR ${FILAMENT_IMPORT_PREBUILT_EXECUTABLES_DIR}) endif() -if (WEBGL) +if (WASM) set(IMPORT_EXECUTABLES ${FILAMENT}/${IMPORT_EXECUTABLES_DIR}/ImportExecutables-Release.cmake) else() if (FILAMENT_EXPORT_PREBUILT_EXECUTABLES OR FILAMENT_IMPORT_PREBUILT_EXECUTABLES) @@ -875,7 +875,7 @@ function(get_resgen_vars ARCHIVE_DIR ARCHIVE_NAME) set(RESGEN_HEADER "${ARCHIVE_DIR}/${ARCHIVE_NAME}.h" PARENT_SCOPE) # Visual Studio makes it difficult to use assembly without using MASM. MASM doesn't support # the equivalent of .incbin, so on Windows we'll just tell resgen to output a C file. - if (WEBGL OR WIN32 OR ANDROID_ON_WINDOWS) + if (WASM OR WIN32 OR ANDROID_ON_WINDOWS) set(RESGEN_OUTPUTS "${OUTPUTS};${ARCHIVE_DIR}/${ARCHIVE_NAME}.c" PARENT_SCOPE) set(RESGEN_FLAGS -qcx ${ARCHIVE_DIR} -p ${ARCHIVE_NAME} PARENT_SCOPE) set(RESGEN_SOURCE "${ARCHIVE_DIR}/${ARCHIVE_NAME}.c" PARENT_SCOPE) @@ -980,7 +980,7 @@ add_subdirectory(${FILAMENT}/filament) set(FILAMENT_SAMPLES_BINARY_DIR ${PROJECT_BINARY_DIR}/samples) -if (WEBGL) +if (WASM) add_subdirectory(web/filament-js) add_subdirectory(web/examples) endif() diff --git a/NEW_RELEASE_NOTES.md b/NEW_RELEASE_NOTES.md index f408ba3462..5f0a5b8fd5 100644 --- a/NEW_RELEASE_NOTES.md +++ b/NEW_RELEASE_NOTES.md @@ -6,3 +6,5 @@ appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md). ## Release notes for next branch cut + +- WEBGL_PTHREADS renamed to WASM_PTHREADS in CMakeLists.txt diff --git a/README.md b/README.md index 5375d6b91e..bee80cbf05 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [](https://github.com/google/filament/actions/workflows/status-web.yml) Filament is a real-time physically based rendering engine for Android, iOS, Linux, macOS, Windows, -and WebGL. It is designed to be as small as possible and as efficient as possible on Android. +and WASM. It is designed to be as small as possible and as efficient as possible on Android. ## Download diff --git a/build.sh b/build.sh index f2ca4ced96..3fb90f4b10 100755 --- a/build.sh +++ b/build.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -# Host tools required by Android, WebGL, and iOS builds +# Host tools required by Android, WASM, and iOS builds MOBILE_HOST_TOOLS="matc resgen cmgen filamesh uberz" WEB_HOST_TOOLS="${MOBILE_HOST_TOOLS} mipgen filamesh" @@ -34,7 +34,7 @@ function print_help { echo " -m" echo " Compile with make instead of ninja." echo " -p platform1,platform2,..." - echo " Where platformN is [desktop|android|ios|webgl|all]." + echo " Where platformN is [desktop|android|ios|wasm|all]." echo " Platform(s) to build, defaults to desktop." echo " Building for iOS will automatically perform a partial desktop build." echo " -q abi1,abi2,..." @@ -173,7 +173,7 @@ ISSUE_RELEASE_BUILD=false ISSUE_ANDROID_BUILD=false ISSUE_IOS_BUILD=false ISSUE_DESKTOP_BUILD=true -ISSUE_WEBGL_BUILD=false +ISSUE_WASM_BUILD=false # Default: all ABI_ARMEABI_V7A=true @@ -356,12 +356,12 @@ function build_desktop { fi } -function build_webgl_with_target { +function build_wasm_with_target { local lc_target=$(echo "$1" | tr '[:upper:]' '[:lower:]') - echo "Building WebGL ${lc_target}..." - mkdir -p "out/cmake-webgl-${lc_target}" - pushd "out/cmake-webgl-${lc_target}" > /dev/null + echo "Building WASM ${lc_target}..." + mkdir -p "out/cmake-wasm-${lc_target}" + pushd "out/cmake-wasm-${lc_target}" > /dev/null if [[ ! "${BUILD_TARGETS}" ]]; then BUILD_TARGETS=${BUILD_CUSTOM_TARGETS} @@ -378,13 +378,13 @@ function build_webgl_with_target { ${IMPORT_EXECUTABLES_DIR_OPTION} \ -DCMAKE_TOOLCHAIN_FILE="${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" \ -DCMAKE_BUILD_TYPE="$1" \ - -DCMAKE_INSTALL_PREFIX="../webgl-${lc_target}/filament" \ - -DWEBGL=1 \ + -DCMAKE_INSTALL_PREFIX="../wasm-${lc_target}/filament" \ + -DWASM=1 \ ${WEBGPU_OPTION} \ ${BACKEND_DEBUG_FLAG_OPTION} \ ${EXCEPTIONS_OPTION} \ ../.. - ln -sf "out/cmake-webgl-${lc_target}/compile_commands.json" \ + ln -sf "out/cmake-wasm-${lc_target}/compile_commands.json" \ ../../compile_commands.json ${BUILD_COMMAND} ${BUILD_TARGETS} ) @@ -416,7 +416,7 @@ function build_webgl_with_target { popd > /dev/null } -function build_webgl { +function build_wasm { # For the host tools, suppress install and always use Release. local old_install_command=${INSTALL_COMMAND}; INSTALL_COMMAND= local old_issue_debug_build=${ISSUE_DEBUG_BUILD}; ISSUE_DEBUG_BUILD=false @@ -429,11 +429,11 @@ function build_webgl { ISSUE_RELEASE_BUILD=${old_issue_release_build} if [[ "${ISSUE_DEBUG_BUILD}" == "true" ]]; then - build_webgl_with_target "Debug" + build_wasm_with_target "Debug" fi if [[ "${ISSUE_RELEASE_BUILD}" == "true" ]]; then - build_webgl_with_target "Release" + build_wasm_with_target "Release" fi } @@ -809,7 +809,7 @@ function validate_build_command { fi fi # If building a WebAssembly module, ensure we know where Emscripten lives. - if [[ "${EMSDK}" == "" ]] && [[ "${ISSUE_WEBGL_BUILD}" == "true" ]]; then + if [[ "${EMSDK}" == "" ]] && [[ "${ISSUE_WASM_BUILD}" == "true" ]]; then echo "Error: EMSDK is not set, exiting" exit 1 fi @@ -835,7 +835,7 @@ function run_test { } function run_tests { - if [[ "${ISSUE_WEBGL_BUILD}" == "true" ]]; then + if [[ "${ISSUE_WASM_BUILD}" == "true" ]]; then if ! echo "TypeScript $(tsc --version)" ; then tsc --noEmit \ third_party/gl-matrix/gl-matrix.d.ts \ @@ -920,18 +920,18 @@ while getopts ":hacCfgimp:q:uvWslwedtk:bVx:S:X:Py:E" opt; do ios) ISSUE_IOS_BUILD=true ;; - webgl) - ISSUE_WEBGL_BUILD=true + wasm) + ISSUE_WASM_BUILD=true ;; all) ISSUE_ANDROID_BUILD=true ISSUE_IOS_BUILD=true ISSUE_DESKTOP_BUILD=true - ISSUE_WEBGL_BUILD=false + ISSUE_WASM_BUILD=false ;; *) echo "Unknown platform ${platform}" - echo "Platform must be one of [desktop|android|ios|webgl|all]" + echo "Platform must be one of [desktop|android|ios|wasm|all]" echo "" exit 1 ;; @@ -1112,8 +1112,8 @@ if [[ "${ISSUE_IOS_BUILD}" == "true" ]]; then check_debug_release_build build_ios fi -if [[ "${ISSUE_WEBGL_BUILD}" == "true" ]]; then - check_debug_release_build build_webgl +if [[ "${ISSUE_WASM_BUILD}" == "true" ]]; then + check_debug_release_build build_wasm fi if [[ "${RUN_TESTS}" == "true" ]]; then diff --git a/build/web/build.sh b/build/web/build.sh index dc038b7581..1cebc86e30 100755 --- a/build/web/build.sh +++ b/build/web/build.sh @@ -8,4 +8,4 @@ set -x source `dirname $0`/../common/build-common.sh pushd `dirname $0`/../.. > /dev/null -./build.sh -p webgl -c $RUN_TESTS $GENERATE_ARCHIVES $BUILD_DEBUG $BUILD_RELEASE +./build.sh -p wasm -c $RUN_TESTS $GENERATE_ARCHIVES $BUILD_DEBUG $BUILD_RELEASE diff --git a/docs_src/README.md b/docs_src/README.md index aff61ca5f5..4155c0fbc6 100644 --- a/docs_src/README.md +++ b/docs_src/README.md @@ -81,10 +81,10 @@ The process for copying and processing these READMEs is outlined in [Introductory docs](#introductory-doc). ### Web Examples and Tutorials -Filament provides a number of WebGL tutorials and examples in the `web/` directory. These are -compiled during the WebGL CMake build and are integrated into the documentation via +Filament provides a number of web tutorials and examples in the `web/` directory. These are +compiled during the web CMake build and are integrated into the documentation via `duplicates.json`. The process is entirely automated: -1. `run.py` maps the `.html` and `.md` WebGL outputs from the `out/cmake-webgl-release/...` +1. `run.py` maps the `.html` and `.md` web outputs from the `out/cmake-wasm-release/...` directory into `docs_src/src_mdbook/src/samples/web/` using the instructions in `duplicates.json`. 2. While transferring `.html` to `.md`, `run.py` strips away the ``, `
`, and `` tags. By retaining only the `