mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-27 16:49:42 +01:00
Add a WebGPU variant of the web demo using Emscripten's emdawnwebgpu port. Uses the WGSL shaders from the library API, a storage buffer for the atlas (i16→i32 expansion on upload), and Emscripten HTML5 APIs for input (no GLFW). Also moves demo_shader_add_glyph_vertices to demo-shader.h as static inline so demo-buffer.cc can be compiled without GL. Build: bash util/gpu/web/build-webgpu.sh → out/webgpu.html The existing WebGL build continues to work unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
36 lines
972 B
Bash
Executable File
36 lines
972 B
Bash
Executable File
#!/bin/sh
|
|
|
|
# Build the hb-gpu web demo with Emscripten + WebGPU.
|
|
# Prerequisites: source emsdk/emsdk_env.sh
|
|
|
|
set -e
|
|
|
|
SRCDIR="$(cd "$(dirname "$0")/../../.." && pwd)"
|
|
OUTDIR="$(dirname "$0")/out"
|
|
|
|
mkdir -p "$OUTDIR"
|
|
|
|
em++ \
|
|
-std=c++17 \
|
|
-Oz -flto \
|
|
-I"$SRCDIR/src" \
|
|
-I"$SRCDIR/util/gpu/web" \
|
|
-DHB_NO_MT \
|
|
-DHAVE_ROUND \
|
|
-DHB_HAS_GPU \
|
|
-include gl-stub.h \
|
|
"$SRCDIR/src/harfbuzz-world.cc" \
|
|
"$SRCDIR/util/gpu/demo-atlas.cc" \
|
|
"$SRCDIR/util/gpu/demo-buffer.cc" \
|
|
"$SRCDIR/util/gpu/demo-font.cc" \
|
|
"$SRCDIR/util/gpu/web/hb-gpu-web-webgpu.cc" \
|
|
--use-port=emdawnwebgpu \
|
|
-sALLOW_MEMORY_GROWTH=1 \
|
|
-sEXPORTED_FUNCTIONS='["_main","_web_load_font","_web_set_text","_web_get_text","_malloc","_free"]' \
|
|
-sEXPORTED_RUNTIME_METHODS='["UTF8ToString","lengthBytesUTF8","stringToUTF8"]' \
|
|
--shell-file "$SRCDIR/util/gpu/web/shell.html" \
|
|
-o "$OUTDIR/webgpu.html"
|
|
|
|
echo "Built: $OUTDIR/webgpu.html"
|
|
echo "Serve: python3 -m http.server -d $OUTDIR"
|