-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add example renderer for WebGPU #3632
Conversation
Hello @bfierz, Thanks for the PR!
Could you clarify this comment? I suggest rebasing this on latest, as backends were moved to the backends/ folder since 1.79. I'll add some notes now. |
With d20f2bc I have renamed the existing imgui_impl_wgpu feedback:
Examples feedback:
Documentation feedback:
Generally it looks good. I must also say that peeking at |
Hi @ocornut, Thanks for the feedback. I will address the issues you've raised. Two points I'd like to mention already:
|
f88cb06
to
0dbc8ca
Compare
HI @ocornut, I think I cleaned up PR according to your suggestions. A few notes:
|
Updated the initial description to reflect the fact that the GLFW integration is now compatible with Emscripten 2.0.11 |
@ocornut, in this branch in my repository (https://github.com/bfierz/imgui/commits/feature/webgpu-custom-textures - the top 3 commits), I've added support for user-defined textures. If reasonable, I can add these commits to this PR. What do you think? |
Thank you for the update! I'm not sure when I'll be able to tackle this in details but after shipping 1.80.
Do you see a reason not to? Q: Is the reason you started using ( |
Thank you for briefly checking the commits.
Yes, the reason is for using ImPool. However, since it is using I'll also check the changes on the Makefile. |
I have tried this today and could build it (with a simple makefile update) but couldn't figure out how to run it on Firefox or Chrome. May be good in the Readme to link to e.g. With Firefox 84.0.2 with With Firefox Canari 86.0b1 with With Chrome 87.0.4280.141 I get: With Chrome 90.0.4400.0 (Official Build) canary (64-bit) it runs but: I am hosting with: Not sure what I doing wrong? Happy to merge this once you make the change for ImPool and texture support. |
Unfortunately, you didn't do anything wrong. A few days ago @Henauxg reported the same issue and with the latest version of chrome I also have the same problems. We believe that the issue lies with Emscripten not being up to date with chrome canary, but it needs investigation. Never the less I will update the readme to be more specific on this issue. |
Either way since WebGPU is experimental I don't mind merging even as slightly clunky, since I'm hoping the availability of this can help you and others advance work on WebGPU. I just noticed that the work e.g. "Replace ImPool with ImGuiStorage" was already done in your other branch but not in this PR. If you push them to the same PR I'll merge, and I can fix the Makefile bits. |
I will push it as soon as I get to it, thank you for fixing the makefile afterward |
The new run seems to fail due to a missing '-s ERROR_ON_UNDEFINED_SYMBOLS=0' in the makefile. @ocornut would you mind adding this too, while fixing the makefile? |
Just saw this in @ocornut's tweet, it's quite exciting! The use of WebGPU looks good but the implementation could probably be simplified a bit. Is this a good place to make some comments? Also feel free to drop in one of the two Matrix channels listed in Dawn's README.md if you ever have difficulties with WebGPU or the emscripten implementation. |
Hi @Kangz, I am happy to hear any feedback you've got. Feel free to post it here, or send me an email. Thanks for mentioning the Matrix channels. I should join as I experience some weird problems when trying to resize swap chains. |
To second the Kangz, it is exiting. If this works out we could run Imgui application in cloud server, etc and have chrome or Firefox render the UI at client end? As can be expected, my 20 minute quick try to set this up with limited knowledge was not successful. It has been long time dream to be able to write applications with "game like" response, which run on desktop and mobile platforms. ImGui has already made this feasible, although mobile support requires a bit of customization. If the same application can in future be run in browser by remote client, I start to run out of musical wishes:) |
Whoops, this went to the wrong inbox, sorry for the late reply. Again, this is overall pretty good and using the API correctly, which is non-trivial there are not good WebGPU resources (yet). In WGSL is still evolving, but when it stabilizes I think IMGUI should use it instead of hardcoding compiled SPIRV: it will make code more readable / easier to modify, and it will also map better on the Web were only WGSL will be available. (SPIRV will keep being available in native). In the GLSL, the usage of
As nitpicks in
|
@iocafe, I agree. It will be an interesting setup to distribute 3D heavy applications without needing to write a new frontend @Kangz, thank you for the review.
I fully agree it would be a lot cleaner to use it. As I was mainly working with dawn directly, I wasn't sure what the future of the C++ API will be, how it gets from dawn to emscripten. Reuse with e.g. wgpu-native for Firefox was another reason (though it turned out that their API is still very different).
For simplicity, the shader is a direct copy of the Vulkan part. So far I didn't pay much attention to WGSL as it is still in development. But I agree, the shader code should be replaced once WGSL is mature enough. If it already is, I'll give it a try.
Thanks for these hints. Writing data to textures and buffers, was my biggest struggle. I am not sure if I missed what you mentioned, or if at the time of writing things weren't available yet. I've opened the PR rather late; the main development actually dates back to late summer.
Thanks for the hint. I'll try to use |
The C++ API is a pure wrapper over the C API so you can use it in emscripten builds. I think it's even shipped in emscripten today?
I should have thought of that :) Sounds good. Not that WGSL is still not very stable so YMMV with it. It might be best to wait a little bit more.
Gotcha, I think we were in the process of implementing |
Yes, it is. Although it is slightly modified compared to the one shipped with dawn. I am going to give it a try.
In this particular case, I was working with latest emscripten while only 2.0.13 was out. I agree that whoever is using WebGPU now, should be aware that it is not stable yet. The macro is maybe a bit over the top :) While implementing the other proposed changes, two questions came up:
I am afraid I don't quite understand how to work with
This maps to 0xfffff... (at least in my version). However, only when using 0 for both offset and size, I get through the validation. |
Interesting, that might be a missing thing in emscripten. |
Bfierz, when you get to point where testing is needed, I would be interested to take part in that. |
WebGPU example starting failing to build on CI today: https://github.com/ocornut/imgui/runs/2517585708?check_suite_focus=true
|
Ah you update emscripten directly? The following changes are needed: https://hackmd.io/BtRPZXulQICjbcZi4tLCdg Are you able to suppress the failure until this is fixed? |
We get emscripten latest: A bit living on the edge but since we seldomly use it ourselves it is a good way to detect changes. If any of you think you can fix it within a few days I'll leave CI as is, otherwise I'll disable it from CI after that. WebGPU seems so edgy when I google for |
Thanks for notifying, I didn't get to work with emscripten recently. I'll try to update the code base over the weekend. |
I've updated my open branch containing some improvements to the WebGPU API usage that were suggested by @Kangz and added the new render pipeline descriptor: https://github.com/bfierz/imgui/tree/feature/update-wgpu-emsdk-2.0.20 |
WebGPU backend failing on CI today:
|
Should be fixed #4472 This is the first time I use CodeSpaces to do a PR so hopefully it is ok |
Note that more breakage should be incoming, see https://hackmd.io/OxDovqjoTXqC_r_WY-aM1Q |
Thank you Corentin, much appreciated! Merged now. |
Thanks for fixing and providing the link. I am regularly updating the version of dawn that I am using. I will check the deprecations and provide a pull request. |
FYI for anyone interested, WebGPU backend broke again with latest: |
…PassColorAttachment::clearColor to ::clearValue (#3632)
…n as introduced in 83bdfef (#6117, #4116, #3632) The feature was removed from WebGPU (gpuweb/gpuweb#2470)
This change adds a sample implementation of a WebGPU backend for ImGui including an example. The code is compatible with a recent version of Google's Dawn library (1.12.2020), and Emscpripten 2.0.11.
Note that to date WebGPU is a moving target, which will require future adaptations to this sample.
The example uses GLFW as a window toolkit. Support for initializing GLFW in a WebGPU compatible way was added with 2.0.11 (PR: emscripten-core/emscripten#12907).
Here's a screenshot of running the example in chrome canary version with WebGPU enabled: