Skip to content

Commit fd630c1

Browse files
authored
Merge pull request #1283 from floooh/emdawnwebgpu
Switch WebGPU backends to emdawnwebgpu
2 parents ac8abed + 8a715f1 commit fd630c1

File tree

4 files changed

+387
-253
lines changed

4 files changed

+387
-253
lines changed

CHANGELOG.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,46 @@
11
## Updates
22

3+
### 15-Jun-2025
4+
5+
The sokol_app.h and sokol_gfx.h WebGPU backends have been updated for the new
6+
`emdawnwebgpu` Emscripten Port. The directly integrated WebGPU support in the
7+
Emscripten SDK has been outdated for quite a while now and the Emscripten SDK
8+
now prints a deprecation warning for the old WebGPU shim.
9+
10+
**NOTE:** this change requires to change your Emscripten build process:
11+
12+
- remove the linker option `-s USE_WEBGPU=1`
13+
- instead add `--use-port=emdawnwebgpu` both to compile and link steps
14+
15+
You'll also need to be on the most recent Emscripten SDK (>= 4.0.10).
16+
17+
The WebGPU specific code in sokol_app.h has been moved out of the Emscripten
18+
`#ifdef/#endif` blocks to prepare for using the WebGPU backend in native
19+
scenarios outside web browsers (which requires much more work in the various
20+
sokol_app.h platform backends though).
21+
22+
I'm not entirely happy with how the new `emdawnwebgpu` JS shim turned out since it
23+
adds its own event loop for async operations, and quite a bit of bloat (10..20
24+
KBytes uncompressed) over the older and simpler WebGPU shim, but currently
25+
that's the price to pay for source code compatibility with the native WebGPU
26+
implementation in Google's Dawn library. The latest `webgpu/webgpu.h` API
27+
also made some questionable design choices which don't quite fit the C language
28+
(`WGPUStringView` and `WGPUFuture`), these may be useful when using the C API
29+
from other languages but are overkill both for usage from C and WASM.
30+
31+
At a later point I might implement my own WebGPU JS shim as alternative to
32+
`emdawnwebgpu` which would do some things more efficiently and with less code,
33+
but the cost of `<webgpu/webgpu.h>` compatibility, but currently that's not a
34+
high priority.
35+
36+
PR: https://github.com/floooh/sokol/pull/1283
37+
38+
Also note this bug report which currently prevents using the Emscripten Closure
39+
pass (this isn't a new thing though, the old WebGPU JS shim also didn't work
40+
with Closure):
41+
42+
https://issues.chromium.org/issues/424836759
43+
344
### 08-Jun-2025
445

546
A code cleanup in sokol_gfx.h for internal object references. No change in behaviour

0 commit comments

Comments
 (0)