emscripten-core / emscripten-core/emscripten

Has anyone ever gotten WebGPU working with PROXY_TO_PTHREAD ?

Open
#22,484 2 comments 0 reactions 0 assignees View on GitHub
webgpu
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

**Version of emscripten/emsdk:**
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.65 (7f8a05dd4e37cbd7ffde6d624f91fd545f7b52e3)
clang version 20.0.0git (https:/github.com/llvm/llvm-project 547917aebd1e79a8929b53f0ddf3b5185ee4df74)
Target: wasm32-unknown-emscripten
Thread model: posix

I am using this sample to figure out how to get started with porting an engine to Emscripten + WebGPU:
https://developer.chrome.com/docs/web-platform/webgpu/build-app

The sample works, as is. But I also want `PROXY_TO_PTHREAD` because I need to wait for threads on the main thread.

The sample uses GLFW for window creation and surface setup. This already doesn't seem to work well. `glfwInit()` already fails, if I run it on my apps main thread.

I can proxy it to the browser thread with this:

```cpp
proxy_queue = em_proxying_queue_create();
emscripten_proxy_sync(proxy_queue, emscripten_main_runtime_thread_id(), InitBrowser, nullptr);
emscripten_proxy_execute_queue(proxy_queue);
```

That seems to get around the first issue. However, quickly I run into various other issues. For example the "device" is not accessible on all threads, I found `OFFSCREENCANVAS_SUPPORT` and tried that, that seems to make some stuff work and break others.

And so on and so forth. It would be very tedious to write down all the ways that this endeavor failed.

So my question is, is it generally possible to use WebGPU today (with emsdk 3.1.65) using `PROXY_TO_PTHREAD` ? Does anyone have a sample that shows which hoops one has to jump through to make it work?

I'm also wondering whether the issues are mainly in GLFW (which seems to assume that it always runs on the browser thread). Maybe rolling my own for window setup could make this work? Again, if someone has a working example somewhere, that would be very helpful.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.