mirror of
https://github.com/ocornut/imgui.git
synced 2026-04-01 21:17:42 -05:00
Backends, Examples: removed Emscripten < 4.0.10 support. Removed IMGUI_IMPL_WEBGPU_BACKEND_WGPU. (#9281, #8381)
- This commit removes the option of using -sUSE_WEBGPU=1 from CMake and make - Compiling with a version of Emscripten >= 4.0.10 will work the same way as it was before - Compiling with a version of Emscripten < 4.0.10 will print an error message and abort the build (in the case of CMake) - Since there can only be 1 implementation for the backend in the case of Emscripten, this commit cleans the code accordingly
This commit is contained in:
@@ -52,17 +52,10 @@ set(IMGUI_EXAMPLE_SOURCE_FILES
|
||||
)
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
if(NOT IMGUI_EMSCRIPTEN_WEBGPU_FLAG) # if IMGUI_EMSCRIPTEN_WEBGPU_FLAG not used, set by current EMSCRIPTEN version
|
||||
if(EMSCRIPTEN_VERSION VERSION_GREATER_EQUAL "4.0.10")
|
||||
set(IMGUI_EMSCRIPTEN_WEBGPU_FLAG "--use-port=emdawnwebgpu" CACHE STRING "Choose between --use-port=emdawnwebgpu (Dawn implementation of EMSCRIPTEN) and -sUSE_WEBGPU=1 (WGPU implementation of EMSCRIPTEN, deprecated in 4.0.10): default to --use-port=emdawnwebgpu for EMSCRIPTEN >= 4.0.10")
|
||||
else()
|
||||
set(IMGUI_EMSCRIPTEN_WEBGPU_FLAG "-sUSE_WEBGPU=1" CACHE STRING "Use -sUSE_WEBGPU=1 for EMSCRIPTEN WGPU implementation")
|
||||
endif()
|
||||
else() # if IMGUI_EMSCRIPTEN_WEBGPU_FLAG used, check correct version
|
||||
if(EMSCRIPTEN_VERSION VERSION_LESS "4.0.10" AND "${IMGUI_EMSCRIPTEN_WEBGPU_FLAG}" MATCHES "emdawnwebgpu")
|
||||
# it's necessary EMSCRIPTEN >= v4.0.10 (although "--use-port=path/to/emdawnwebgpu.port.py" is supported/tested from v4.0.8)
|
||||
message(FATAL_ERROR "emdawnwebgpu needs EMSCRIPTEN version >= 4.0.10")
|
||||
endif()
|
||||
if(EMSCRIPTEN_VERSION VERSION_GREATER_EQUAL "4.0.10")
|
||||
set(IMGUI_EMSCRIPTEN_WEBGPU_FLAG "--use-port=emdawnwebgpu" CACHE STRING "Default to --use-port=emdawnwebgpu. You can override to provide your own local port.")
|
||||
else()
|
||||
message(FATAL_ERROR "emdawnwebgpu needs EMSCRIPTEN version >= 4.0.10")
|
||||
endif()
|
||||
|
||||
add_compile_options(-sDISABLE_EXCEPTION_CATCHING=1 -DIMGUI_DISABLE_FILE_FUNCTIONS=1)
|
||||
@@ -160,7 +153,6 @@ endif()
|
||||
# IMGUI_IMPL_WEBGPU_BACKEND_DAWN/WGPU internal define is set according to:
|
||||
# EMSCRIPTEN: by used FLAG
|
||||
# --use-port=emdawnwebgpu --> IMGUI_IMPL_WEBGPU_BACKEND_DAWN enabled (+EMSCRIPTEN)
|
||||
# -sUSE_WEBGPU=1 --> IMGUI_IMPL_WEBGPU_BACKEND_WGPU enabled (+EMSCRIPTEN)
|
||||
# NATIVE: by used SDK installation directory
|
||||
# if IMGUI_DAWN_DIR is valid --> IMGUI_IMPL_WEBGPU_BACKEND_DAWN enabled
|
||||
# if IMGUI_WGPU_DIR is valid --> IMGUI_IMPL_WEBGPU_BACKEND_WGPU enabled
|
||||
@@ -180,12 +172,8 @@ if(NOT EMSCRIPTEN) # WegGPU-Native settings
|
||||
else() # Emscripten settings
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||
|
||||
if("${IMGUI_EMSCRIPTEN_WEBGPU_FLAG}" MATCHES "emdawnwebgpu")
|
||||
target_compile_options(${IMGUI_EXECUTABLE} PUBLIC "${IMGUI_EMSCRIPTEN_WEBGPU_FLAG}")
|
||||
target_compile_definitions(${IMGUI_EXECUTABLE} PUBLIC "IMGUI_IMPL_WEBGPU_BACKEND_DAWN")
|
||||
else()
|
||||
target_compile_definitions(${IMGUI_EXECUTABLE} PUBLIC "IMGUI_IMPL_WEBGPU_BACKEND_WGPU")
|
||||
endif()
|
||||
target_compile_options(${IMGUI_EXECUTABLE} PUBLIC "${IMGUI_EMSCRIPTEN_WEBGPU_FLAG}")
|
||||
target_compile_definitions(${IMGUI_EXECUTABLE} PUBLIC "IMGUI_IMPL_WEBGPU_BACKEND_DAWN")
|
||||
message(STATUS "Using ${IMGUI_EMSCRIPTEN_WEBGPU_FLAG} WebGPU implementation")
|
||||
|
||||
target_compile_options(${IMGUI_EXECUTABLE} PUBLIC "-sUSE_SDL=2")
|
||||
|
||||
@@ -40,11 +40,7 @@ LDFLAGS += -s ASYNCIFY=1
|
||||
LDFLAGS += -s NO_EXIT_RUNTIME=0
|
||||
LDFLAGS += -s ASSERTIONS=1
|
||||
|
||||
# (1) Using legacy WebGPU implementation (Emscripten < 4.0.10)
|
||||
#EMS += -DIMGUI_IMPL_WEBGPU_BACKEND_WGPU
|
||||
#LDFLAGS += -s USE_WEBGPU=1
|
||||
|
||||
# or (2) Using newer Dawn-based WebGPU port (Emscripten >= 4.0.10)
|
||||
# Using Dawn-based WebGPU port (requires Emscripten >= 4.0.10)
|
||||
EMS += --use-port=emdawnwebgpu
|
||||
LDFLAGS += --use-port=emdawnwebgpu
|
||||
|
||||
|
||||
@@ -60,12 +60,7 @@ For the WASM code produced by Emscripten to work correctly, it will also be nece
|
||||
CMake checks the EMSCRIPEN version then:
|
||||
- if EMS >= 4.0.10 uses `--use-port=emdawnwebgpu` flag to build
|
||||
- it set `IMGUI_IMPL_WEBGPU_BACKEND_DAWN` compiler define
|
||||
- if EMS < 4.0.10 uses `-sUSE_WEBGPU=1` flag to build
|
||||
- it set `IMGUI_IMPL_WEBGPU_BACKEND_WGPU` compiler define
|
||||
|
||||
#### Generate Emscripten forcing `-sUSE_WEBGPU=1` deprecated flag even with EMS >= 4.0.10
|
||||
- `emcmake cmake -G Ninja -DIMGUI_EMSCRIPTEN_WEBGPU_FLAG="-sUSE_WEBGPU=1" -B where_to_build_dir`
|
||||
- it set `IMGUI_IMPL_WEBGPU_BACKEND_WGPU` compiler define
|
||||
- if EMS < 4.0.10 the build aborts (`-sUSE_WEBGPU=1` is no longer supported in ImGui)
|
||||
|
||||
#### Generate Emscripten using external WebGPU library (emdawnwebgpu_pkg)
|
||||
- `emcmake cmake -G Ninja -DIMGUI_EMSCRIPTEN_WEBGPU_FLAG="--use-port=path_to_emdawnwebgpu_pkg" -B where_to_build_dir`
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#include <emscripten/html5.h>
|
||||
#if defined(IMGUI_IMPL_WEBGPU_BACKEND_WGPU)
|
||||
#include <emscripten/html5_webgpu.h>
|
||||
#endif
|
||||
#include "../libs/emscripten/emscripten_mainloop_stub.h"
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user