You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Emscripten's webgpu.h is behind the standard and Dawn implementations #23432
@kainino0x Now that you can write contrib ports in Emscripten, wouldn't it make sense to have a contrib.webgpu (or contrib.dawn_webgpu) to do this? That way you are not breaking Emscripten WebGPU binding. You just upgrade the port version (which might contain breaking changes).
You can also have the port not be a contrib port at all meaning it is a port that anybody can use (simply) without being part of Emscripten. Like I did for ImGui. This port file could live in the Dawn project.
I don't know the internals of Dawn or why it was chosen to have an Emscripten fork which lives in Dawn. I am just pointing out that there is a new mechanism (Emscripten ports) that is available...
I am very familiar with Emscripten contrib/external ports, since I am the one who implemented the feature, so don't hesitate to reach out if you need help/guidance...
I wasn't aware of emscripten-ports! Regardless of that, we actually just started talking to sbc100 about this topic, we might end up maintaining the bindings as a library outside of emscripten instead. The reason we did it in Emscripten to start was that it relied on a lot of internal things. We need a stableish interface between emscripten and js libraries, and a stableish interface for gen_struct_info.py. But it sounds like we may be able to achieve that!
changed the title [-]WebGPU missing functions from webgpu_cpp.h[/-][+]Emscripten's webgpu.h is behind the standard and Dawn implementations[/+]on Feb 27, 2025
At the end of that process should we delete the webgpu support from emscripten? (we can still test it via some kind of vendoring, or add it as a "port")
I am not sure what is the plan (it is hard to follow this thread and a link to the diff of an upcoming README file change is not really helping) but I hope that no matter the solution, there continues to be an easy way to use WebGPU from Emscripten.
I really don't want to have to clone an external project and use CMake to build WebGPU especially that now Emscripten has support for integrating external projects, not maintained in Emscripten (contrib ports).
I am hoping that Dawn/WebGPU can at the very minimum be offered as a contrib port (and I reiterate what I stated in a previous message, that I am more than happy to provide help and guidance...)
I've been working on producing a "packageable" version of emdawnwebgpu that can be easily used by just linking into an emscripten build. Once that's done I should be able to point to updated docs that actually make sense :)
I'll give an update here when that's ready - so I can get help figuring out how this package should be provided to people (I don't know how "ports" work).
Reacted by Fv, TLescoatTFX, Orhun Birsoy, Bugra Barin and Suraj
where CMakeLists.txt includes all of the flags needed to make that work.
For maintenance reasons it seems easier for this to be totally separate from Emscripten, rather than a port. A bunch of these files are generated (not checked into Dawn) so it's not possible to point directly at Dawn's source.
But I'm curious if you think it would be better to add it to the ports. It will be easier to install, but it seems you will only be able to use the version pinned in Emscripten? At least, the contrib ports that exist now seem to pin a version.
@kainino0x I still think that having it as a port would still be very beneficial: the README that you published is quite involved with lots of steps, including complicated instructions to download and build Dawn. Using the port would be as simple as emcc --use-port=contrib.dawn and that's it for the instructions... hard to be simpler...
The fact that the Dawn version is pinned to Emscripten version is not really a problem. This is how SDL, GLFW, (etc...) ports work. Upgrading Emscripten for the new version of Dawn now becomes trivial. If you want to use a different version you can always copy the port file and use it directly since now Emscripten allow non built-in ports.
You mention that there are files that are generated and not checked in into Dawn. I do not know how Dawn gets released (when there is a new version), but if you could automatically publish a zip file containing all the necessary files to build Dawn for Emscripten (both generated and checked in) that would be the best approach. Maybe this is what you are talking about when you say: I'm still working on making pre-packaged releases of emdawnwebgp
I am doing exactly this for the GLFW port:
and then in the port, the downloaded artifact is simply:
We certainly want emscripten users to be able to use WebGPU APIs with as little friction as possible.
There are various ways we could achieve that without having to maintain emdawn directly in the emscirpten tree. I think a "port" is likely the best option. We might also want to consider using a git submodule, but I'm not sure that would be any better. I think having emscripten default to particular pinned version is fine (good even) as long as we document some way to experiment to non-pinned version too.
Reacted by Kai Ninomiya, Code Artworks and Guido Schmidt
Ports do sound extremely convenient. As long as there is some easy way to use a non-pinned version, I'm OK with having a pinned default. The bindings are definitely still buggy so for the near-term future, people will commonly need the latest version, ideally without having to upgrade their whole toolchain.
I do not know how Dawn gets released (when there is a new version), but if you could automatically publish a zip file containing all the necessary files to build Dawn for Emscripten (both generated and checked in) that would be the best approach. Maybe this is what you are talking about when you say: I'm still working on making pre-packaged releases of emdawnwebgpu
Dawn doesn't have any releases (pre-built or otherwise), but since we need to provide pre-built files for emdawnwebgpu, yes, that's my plan - upload packages like the one described above, either as zips on the github releases page, or in some git repository.
Yes, I think this would help for your glfw port maybe? Since it would allow you to keep the glfw3.py logic alongside the upstream code.
If you would to take a crack an implementing what I described above that would be great. I would basically mean two different types of port files:
A) Ones that describe the build actions
B) Ones that describe how to download files of type (A)
(I think using yaml perhaps doesn't actually work since we don't want to take a dependency on pyyaml).
Unfortunately i coudn't make emdawn port working.
A soon as i add this line in cmake:
--use-port=c:/Projects/emsdk/emdawn/emdawnwebgpu.port.py
for both compiler and linker - cmake generator completely stops working, throwing errors on any cpp test step, like:
-- Looking for sys/types.h
-- Looking for sys/types.h - not found
-- Looking for stdint.h
-- Looking for stdint.h - not found
-- Looking for stddef.h
-- Looking for stddef.h - not found
-- Check size of off64_t
-- Check size of off64_t - failed
-- Looking for fseeko
-- Looking for fseeko - not found
-- Looking for unistd.h
-- Looking for unistd.h - not found
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX17
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX17 - Failed
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX20
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX20 - Failed
pycache was created in the port's folder. So it definitely compiled the py file during the build process...
I'm using emsdk 4.0.8.
Dawn release v20250505.211659
Today i updated emsdk to version 4.0.13 and emdawn port stopped working again. It throws the same errors i posted on May 6.
Didn't investigate build errors logs yet. But i updated emsdk several times after May. Everything was ok. I guess 4.0.13 has some breaking changes not compatible with latest emdawn port (emdawn port has version v20250822.104650)
Nevermind. Cmake failed because i used -s TEXTDECODER=0. I disabled it long time ago because it caused some random crashes in past.
I removed TEXDECODER command, and now cmake works.,
Activity
kainino0x commentedon Jan 16, 2025
For the moment we won't be bringing any new changes into Emscripten's WebGPU bindings because we don't want to continuously make breaking changes on every Emscripten release. However we are currently working on an updated fork which lives in Dawn. You can use this fork along with regular Emscripten - it's a big pain right now but it's possible. See:
https://source.chromium.org/chromium/chromium/src/+/main:third_party/dawn/src/emdawnwebgpu/README.md
This sample repo is set up to do this:
https://github.com/kainino0x/webgpu-cross-platform-demo/tree/dawnwasm
You can follow here for updates on the un-forking: https://crbug.com/371024051 (+1 button in the top right)
ypujante commentedon Jan 18, 2025
@kainino0x Now that you can write contrib ports in Emscripten, wouldn't it make sense to have a
contrib.webgpu(orcontrib.dawn_webgpu) to do this? That way you are not breaking Emscripten WebGPU binding. You just upgrade the port version (which might contain breaking changes).You can also have the port not be a contrib port at all meaning it is a port that anybody can use (simply) without being part of Emscripten. Like I did for ImGui. This port file could live in the Dawn project.
I don't know the internals of Dawn or why it was chosen to have an Emscripten fork which lives in Dawn. I am just pointing out that there is a new mechanism (Emscripten ports) that is available...
I am very familiar with Emscripten contrib/external ports, since I am the one who implemented the feature, so don't hesitate to reach out if you need help/guidance...
kainino0x commentedon Jan 30, 2025
I wasn't aware of emscripten-ports! Regardless of that, we actually just started talking to sbc100 about this topic, we might end up maintaining the bindings as a library outside of emscripten instead. The reason we did it in Emscripten to start was that it relied on a lot of internal things. We need a stableish interface between emscripten and js libraries, and a stableish interface for
gen_struct_info.py. But it sounds like we may be able to achieve that!TBA, and thank you for your offer!
kainino0x commentedon Feb 27, 2025
FYI: I'm working on updating the code and documentation in Dawn for how to use emdawnwebgpu (our fork). It's much easier with Emscripten 4.0.3+!
https://dawn-review.googlesource.com/c/dawn/+/227335/4/src/emdawnwebgpu/README.md
[-]WebGPU missing functions from webgpu_cpp.h[/-][+]Emscripten's webgpu.h is behind the standard and Dawn implementations[/+]sbc100 commentedon Feb 27, 2025
At the end of that process should we delete the webgpu support from emscripten? (we can still test it via some kind of vendoring, or add it as a "port")
ypujante commentedon Feb 27, 2025
I am not sure what is the plan (it is hard to follow this thread and a link to the diff of an upcoming README file change is not really helping) but I hope that no matter the solution, there continues to be an easy way to use WebGPU from Emscripten.
I really don't want to have to clone an external project and use CMake to build WebGPU especially that now Emscripten has support for integrating external projects, not maintained in Emscripten (contrib ports).
I am hoping that Dawn/WebGPU can at the very minimum be offered as a contrib port (and I reiterate what I stated in a previous message, that I am more than happy to provide help and guidance...)
kainino0x commentedon Mar 5, 2025
I've been working on producing a "packageable" version of emdawnwebgpu that can be easily used by just linking into an emscripten build. Once that's done I should be able to point to updated docs that actually make sense :)
I'll give an update here when that's ready - so I can get help figuring out how this package should be provided to people (I don't know how "ports" work).
kainino0x commentedon Mar 12, 2025
Those readme changes I linked to have been updated and landed, so there are at least (partial) instructions on how to use emdawnwebgpu:
https://source.chromium.org/chromium/chromium/src/+/main:third_party/dawn/src/emdawnwebgpu/README.md
I'm still working on making pre-packaged releases of emdawnwebgpu. Basically what that's going to look like is something like:
where
CMakeLists.txtincludes all of the flags needed to make that work.For maintenance reasons it seems easier for this to be totally separate from Emscripten, rather than a port. A bunch of these files are generated (not checked into Dawn) so it's not possible to point directly at Dawn's source.
But I'm curious if you think it would be better to add it to the ports. It will be easier to install, but it seems you will only be able to use the version pinned in Emscripten? At least, the contrib ports that exist now seem to pin a version.
ypujante commentedon Mar 12, 2025
@kainino0x I still think that having it as a port would still be very beneficial: the README that you published is quite involved with lots of steps, including complicated instructions to download and build Dawn. Using the port would be as simple as
emcc --use-port=contrib.dawnand that's it for the instructions... hard to be simpler...The fact that the Dawn version is pinned to Emscripten version is not really a problem. This is how SDL, GLFW, (etc...) ports work. Upgrading Emscripten for the new version of Dawn now becomes trivial. If you want to use a different version you can always copy the port file and use it directly since now Emscripten allow non built-in ports.
You mention that there are files that are generated and not checked in into Dawn. I do not know how Dawn gets released (when there is a new version), but if you could automatically publish a zip file containing all the necessary files to build Dawn for Emscripten (both generated and checked in) that would be the best approach. Maybe this is what you are talking about when you say: I'm still working on making pre-packaged releases of emdawnwebgp
I am doing exactly this for the GLFW port:
and then in the port, the downloaded artifact is simply:
I will spend some time looking at a first pass at the Emscripten Dawn port if I can follow your instructions.
sbc100 commentedon Mar 12, 2025
We certainly want emscripten users to be able to use WebGPU APIs with as little friction as possible.
There are various ways we could achieve that without having to maintain emdawn directly in the emscirpten tree. I think a "port" is likely the best option. We might also want to consider using a git submodule, but I'm not sure that would be any better. I think having emscripten default to particular pinned version is fine (good even) as long as we document some way to experiment to non-pinned version too.
kainino0x commentedon Mar 13, 2025
Ports do sound extremely convenient. As long as there is some easy way to use a non-pinned version, I'm OK with having a pinned default. The bindings are definitely still buggy so for the near-term future, people will commonly need the latest version, ideally without having to upgrade their whole toolchain.
kainino0x commentedon Mar 13, 2025
Dawn doesn't have any releases (pre-built or otherwise), but since we need to provide pre-built files for emdawnwebgpu, yes, that's my plan - upload packages like the one described above, either as zips on the github releases page, or in some git repository.
43 remaining items
ypujante commentedon May 5, 2025
@sbc100 I personally like the idea very much. I assume you meant
--use-port=contrib.emdaw(you wrote--use-port=contrib/emdawn)Since I worked on the port system, let me know if you want me to look at a possible way of implementing the changes. Be more than happy to.
sbc100 commentedon May 5, 2025
Yes, I think this would help for your glfw port maybe? Since it would allow you to keep the glfw3.py logic alongside the upstream code.
If you would to take a crack an implementing what I described above that would be great. I would basically mean two different types of port files:
A) Ones that describe the build actions
B) Ones that describe how to download files of type (A)
(I think using yaml perhaps doesn't actually work since we don't want to take a dependency on pyyaml).
sbc100 commentedon May 5, 2025
It looks like we could possibly use
configparser: https://docs.python.org/3/library/configparser.htmlAnd maybe once we depend on python 3.11 we could even use toml!
ypujante commentedon May 5, 2025
I will take a look at it. I created a new ticket (#24260) for it.
Honya2000 commentedon May 6, 2025
Hello,
Unfortunately i coudn't make emdawn port working.
A soon as i add this line in cmake:
--use-port=c:/Projects/emsdk/emdawn/emdawnwebgpu.port.py
for both compiler and linker - cmake generator completely stops working, throwing errors on any cpp test step, like:
-- Looking for sys/types.h
-- Looking for sys/types.h - not found
-- Looking for stdint.h
-- Looking for stdint.h - not found
-- Looking for stddef.h
-- Looking for stddef.h - not found
-- Check size of off64_t
-- Check size of off64_t - failed
-- Looking for fseeko
-- Looking for fseeko - not found
-- Looking for unistd.h
-- Looking for unistd.h - not found
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX17
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX17 - Failed
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX20
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX20 - Failed
pycache was created in the port's folder. So it definitely compiled the py file during the build process...
I'm using emsdk 4.0.8.
Dawn release v20250505.211659
kainino0x commentedon May 6, 2025
It doesn't work on Windows because I totally forgot to test on Windows. Bug is https://crbug.com/415850603, please star it.
kainino0x commentedon May 6, 2025
Never mind, it works fine on Windows. These are two separate issues. Continuing discussion of this one in #24253 for now even though it's closed.
Deprecate -sUSE_WEBGPU in favor of --use-port=emdawnwebgpu (emscripte…
Deprecate -sUSE_WEBGPU in favor of --use-port=emdawnwebgpu (emscripte…
Honya2000 commentedon Aug 23, 2025
Today i updated emsdk to version 4.0.13 and emdawn port stopped working again. It throws the same errors i posted on May 6.
Didn't investigate build errors logs yet. But i updated emsdk several times after May. Everything was ok. I guess 4.0.13 has some breaking changes not compatible with latest emdawn port (emdawn port has version v20250822.104650)
Honya2000 commentedon Aug 24, 2025
Nevermind. Cmake failed because i used -s TEXTDECODER=0. I disabled it long time ago because it caused some random crashes in past.
I removed TEXDECODER command, and now cmake works.,
kainino0x commentedon Aug 25, 2025
Thank you for reporting back!