471 points · by billconan · 2y ago · 73 comments
However, I'm feeling burnt out and ready to call it finished, even though it may not feel completely done. Avoiding another abandoned side project has been my primary motivation in reaching this point.
The problem is that people are reaching out to it, as means to avoid the Vulkan mess, when the real alternative is middleware engines.
Documentation will keep improving with time. There have already been a number of high-quality tutorials and references created over the past few years, for example:
https://webgpufundamentals.org/ for JavaScript/the web API
https://sotrh.github.io/learn-wgpu/ for Rust (web or native)
Is there even a good Middleware engine that can also target web? My impressions are that both Unity and Unreal expressed interest in WebGPU support, but what's publicly available is pretty barebones.
Also, I imagine the people working with WebGPU to begin with are either hobbyists, looking to learn and work in a professional role with WebGPU, or are in fact making that future Middleware (be it proprietary or open source).
On the plus side, it makes me appreciate how wonderful it is to have modern dev tooling when I’m working on literally anything else.
> However, I'm feeling burnt out and ready to call it finished, even though it may not feel completely done. Avoiding another abandoned side project has been my primary motivation in reaching this point.
Thank you for spending your time to produce this excellent resource and releasing it to us. Don’t feel too bad about it not being all the way where you’d like it to be. You can always improve it later, or even allow the community to help you improve it.
In case it's interesting to anyone, I did just go on a big bug-filing spree for Firefox. There are a handful of issues (that were already on the Firefox team's radar) to resolve before all of these playgrounds work as-is: https://bugzilla.mozilla.org/show_bug.cgi?id=webgpu-unleashe...
1. The playground code does not seem to fully work on Safari. The code is there and selectable but the glyphs are invisible.
EDIT: My Safari was just bugged, had to restart it and it works
2. Is the cover of the book on the right of the playground supposed to change depending on which example you are looking at? I think it could be nice if the book contents were rendered alongside the code if the user wanted instead of the cover which does not change.
I have WebGPU enabled in Safari through a preview flag, and running the playground examples worked fine.
WebGPU is super slow on GPU and all the official benchmarks only care about CPU performance.
omg I thought I was the only one that found that. I tried webgpu (On a native context) and it was slowwwww. Only 10k non-overlapping triangles can bring my RTX GPU to its knees. It's not the shader because it was only a color. It's not the overlapping (And I tried a depth prepass as well). It's not the draw calls. The API is slow, straight up.
In fact, you can try to open a WebGPU demo in your browser and check the GPU usage in the Task Manager. Close it, open a random webgl Unity game and you'll see how much a single WebGPU triangle takes compared to a full-fledged game.
On my computer, the average Unity game with shadows, shaders 'n stuff takes 5% GPU and a simple WebGPU demo takes 7%.
Your benchmark doesn't match the experience of people building games and applications on top of WebGPU, so something else is probably going on there. If your benchmark is set up well, you should be limited by the fill rate of your GPU, at which point you should see roughly the same performance across all APIs.
> On my computer, the average Unity game with shadows, shaders 'n stuff takes 5% GPU and a simple WebGPU demo takes 7%.
GPU usage isn't a great metric for performance comparisons in general because it can actually imply the inverse depending on the test case. For example, if the scenes were exactly the same, a lower GPU usage could actually suggest that you're bottlenecked by the CPU, so you can't submit commands fast enough to the GPU and the GPU is sitting idle for longer while it waits.
Here's an example of Bevy WebGL vs Bevy WebGPU:
I get 50 fps on 78k birds with WebGPU: https://bevyengine.org/examples-webgpu/stress-tests/bevymark...
I get 50 fps on 90k birds with WebGL: https://bevyengine.org/examples/stress-tests/bevymark/
So you test the difference between them with technically the same code.
(They can get 78k birds, which is way better than my triangles, because they batch 'em. I know 10k drawcalls doesn't seem good, but any 2024 computer can handle that load with ease.)
Older frameworks will get x10 better results , such as Kha (https://lemon07r.github.io/kha-html5-bunnymark/) or OpenFL (https://lemon07r.github.io/openfl-bunnymark/), but they run at lower res and this is a very CPU based benchmark, so I'm not gonna count them.
> be limited by the fill rate of your GPU
They're 10k triangles and they're not overlapping... There are no textures per se. No passes except the main one, with a 1080p render texture. No microtriangles. And I bet the shader is less than 0.25 ALU.
> at which point you should see roughly the same performance across all APIs.
Nah, ANGLE (OpenGL) does just fine. Unity as well.
> a lower GPU usage could actually suggest that you're bottlenecked by the CPU
No. I have yet to see a game on my computer that uses more than 0.5% of my CPU. Games are usually GPU bound.
I know a young person who was quite interested in this and looking for a resource like this.
I love the focus you've place on video, and actually making it engaging. Subject Matter Experts who undertake this are my favourite audience to be around and help.
If you might be interested in exploring this content of yours into aligned educational content and delivery including videos that could support your work financially, I'd be happy to chat an share what I do as I like magnifying subject matter experts doing things like this. All knowledge is yours, strictly to add value.
Just the notion of a hyperlinked code-playground is fantastic. Not to mention the content of the book.
And a side project at that? Wow. Congratulations and thanks for sharing.
There is a _lot_ of work to do still to make sure we comply with the spec. in a way that's acceptable to ship in a browser. We're 90% of the way there in terms of functionality, but the last 10% of fixing up spec. changes in the last few years + being significantly more resourced-constrained (we have 3 full-time folks, Chrome has/had an order of magnitude more humans working on WebGPU) means we've got our work cut out for us.
If you're interested if your use cases work already a consumer of WebGPU in JS on Firefox, you can:
- Follow the `Platform Graphics: WebGPU` component in Bugzilla ([0]).
- CC yourself on the `webgpu-v1`[0] bug and its dependent meta bugs (which aggregate yet more work). These get updated every so often to recognize the (ahem) ever-growing list of things we have to do in Firefox.
- Try things out in Nightly, and file issues to help us prioritize things!
[0]: https://bugzilla.mozilla.org/buglist.cgi?component=Graphics%...
Can't wait to see WebGL / WebGL2 / WebGPU performance benchmark tables comparing all the browser and platforms when it ships everywhere.
The whole sandbox HID scope capture issue is a core problem that needs resolved.
Best of luck =3
https://github.com/BabylonJS/Babylon.js/
1. It works just fine for basic 3D functionality, but has limited support for tricks like fog FX etc. WebGL is actually quite capable when combined with simplified physics engines, and animated mesh packing formats.
2. In a business context it fails to check all the boxes, as people are not going to invest in a platform with near zero IP protection.
3. Steam + Unreal has all the advantages, and none of the problems/overhead of a Browser. i.e. peoples game pads, spacial audio, and shader cache buffers will work properly.
WebGL is just hitting the same VRML market that failed decades ago for the same reasons. =3
as for ip protection. Which platforms do that?
My questions: are there good, native implementations of WebGPU where learning it can replace learning CUDA or ROC for good, GPU utilization? If not, would a book like this teach us enough to easily pick up CUDA etc? Or are they very different to the point we’re better off learning the GPU-specific libraries?
That said, you can do machine learning in WebGPU, and, if your goal is to ship in a browser, it is viable.
I personally think the performance gap can be closed with some engineering effort, and that WebGPU has the potential to become a real contender, but it's too early to say for sure. Certainly CUDA has a major head-start.
Just a low hanging issue. The rendering on mobile viewport especially on Firefox is not ideal. Navigation is broke and content does not scroll well.
Question: I see the that the code for the examples can be pulled from github, but I don't see anywhere to download the text of the book for offline reading??
I'd like to get excited about WebGPU as well, but I am lacking enough imagination here. Games? 3D animations? What else beyond these obvious applications?
Those who are excited about it: why? what are you planning to build with it?
A slideshow program with custom font rendering & line wrapping and nice shader based transitions between slides for instance.
Even something like a terminal/tty is much nicer when it renders at > 60fps with smooth scrolling. Very hard to do with DOM nodes.
Because of the web a generation of programmers has forgotten how fast and responsive applications can be. Webgpu can make the web feel fast again.
I'm going to start by rampaging through this book.
Formatting nitpick for the site: when viewed on mobile, the text width is set to screen width minus 1 margin, but the page is fixed at text width plus both margins, so the scrolling has a lot of sloppy side-to-side play and it's irritating to get the content lined up in the middle.