211 points · by mariuz · 2y ago · 198 comments
I'm really looking forward to getting bindless later down the road, although I expect it to take quite a while.
By the same token, I'm quite surprised that effort is being put into a compatibility mode, when WebGPU is already too old and limiting for a lot of people, and when WebGL(2) is going to have to be maintained by browsers anyways.
Yes.
This has had a devastating effect on Rust 3D graphics. The main crate for doing 3D graphics in Rust is WGPU. WGPU supports not just WebGPU, but Android, Vulkan, Metal, Direct-X 12, and OpenGL. It makes them all look much like Vulkan. Bevy, Rend3, and Renderling, the next level up, all use WGPU. It's so convenient.
WGPU has lowest common denominator support. If WebGPU can't do something inside a browser, then WGPU probably can't do it on other platforms which could handle it. So WGPU makes your gamer PC perform like a browser or a phone. No bindless, no multiple queues, and somewhat inefficient binding and allocation.
This is one reason we don't see high-performance games written in Rust.
After four years of development, WGPU performance has gone down, not up. When it dropped 21% recently and I pointed that out, some people were very annoyed.[1]
Google pushing bindless forward might help get this unstuck. Although notice that the target date on their whiteboard is December 2026. I'm not sure that game dev in Rust has that much runway left. Three major projects have been cancelled and the main site for Rust game dev stopped updating in June 2024.[2]
Rendering is _hard_, and Rust is an uncommon toolchain in the gamedev industry. I don't think wgpu has much to do with it. Vulkan via ash and DirectX12 via windows-rs are both great options in Rust.
> After four years of development, WGPU performance has gone down, not up. When it dropped 21% recently and I pointed that out, some people were very annoyed.[1]
Performance isn't most of the wgpu maintainer's (who are paid by Mozilla) priority at the moment. Fixing bugs and implementing missing features so that they can ship WebGPU support in Firefox is more important. The other maintainers are volunteers with no obligation besides finding it enjoyable to work on. Performance can always be improved later, but getting working WebGPU support to users so that websites can start targeting it is crucial. The annoyance is that you were rude about it.
> Google pushing bindless forward might help get this unstuck. Although notice that the target date on their whiteboard is December 2026.
The bindless stuff is basically "developers requested it a ton when we asked for feedback on features they wanted (I was one of those people who gave them feedback), and we had some draft proposals from (iirc) 1-2 different people". It's wanted, but there are still major questions to answer. It's not like this is a set thing they've been developing and are preparing to release. All the features listed are just feedback from users and discussion that took place at the WebGPU face to face recently.
My team at Mozilla are active contributors to WGPU. For the moment, when we Mozilla engineers are prioritizing our own work, we are focused on compatibility and safety, because that's what we need most urgently for our use case. Once we have shipped WebGPU in Firefox, we will start putting our efforts into other things like performance, developer experience, and so on.
But WGPU has other contributors with other priorities. For example, WGPU just merged some additions to its nascent ray tracing support. That's not a Mozilla priority, but WGPU took the PR. Similarly for some recent extensions to 64-bit atomics (which I think is used by Bevy for Nanite-like techniques?), and other areas.
WGPU is an open source project. We at Mozilla contribute to the features we need; other people contribute to what they care about; and the overall direction of the project is determined by what capable contributors put in the time to make happen.
Yes. I think I'm beginning to see what's gone wrong with the Rust crates. It's an architectural problem. Vulcano and WGPU try to create a Rust safety perimeter at an API that's basically a wrapper around Vulkan. This may be the wrong boundary for that safety perimeter.
Moving buffer allocation inside the safety perimeter may eliminate a level of locking and checking. Bindless really brings this out, because somebody has to keep the descriptor table and buffer allocation in sync. The GPU depends on that. So that has safety implications.
If this problem is partitioned differently, the locking problems for concurrent GPU content updating may become simpler. Right now, both Vulcano and WGPU force more serialization than Vulkan itself requires. The rendering thread is too often stalled on a lock waiting for some content updating operation that should not interfere with rendering.
Too much detail for this forum. I'll continue this elsewhere. This has been useful.
Sounds like WGPU, the project, should be detached from Firefox?
To me the priority of shipping WGPU on FF is kind of mind-boggling, as I consider the browser irrelevant at this point in time.
* Before the major rework called "arcanization", `wgpu_core` used a locking design that caused huge amounts of contention in any multi-threaded program. It took write locks so often I doubt you could get much parallelism at all out of it. That's all been ripped out, and we've been evolving steadily towards a more limited and reasonable locking discipline.
* `wgpu_core` used to have a complex system of "suspected resources" and deferred cleanup, apparently to try to reduce the amount of work that needed to be done when a command buffer finished executing on the GPU. This turned out not to actually save any work at all: it did exactly the same amount of bookkeeping, just at a different time. We ripped out this complexity and got big speedups on some test cases.
* `wgpu_core` used to use Rust generics to generate, essentially, a separate copy of its entire code for each backend (Vulkan, Metal, D3D12) that it used. The idea was that the code generator would be able to see exactly what backend types and functions `wgpu_core` was using, inline stuff, optimize, etc. It also put our build times through the roof. So, to see if we could do something about the build times, Wumpf experimented with making the `wgpu_hal` API use dynamic dispatch instead. For reasons that are not clear to me, switching from generics to dynamic dispatch made WGPU faster --- substantially so on some benchmarks.
Animats posts frequently about performance problems they're running into, but when they do it's always this huge pile of unanalyzed data. It's almost as if, they run into a performance problem with their code, and then rather than figuring out what's going on themselves, they throw their whole app over the wall and ask WGPU to debug the problem. That is just not a service we offer.
I honestly don't get your annoyed response; any OSS project wishes they had such detailed bug reports, and such a performance regression would concern me very much if it happened in a project I maintain.
Someone was seemingly "annoyed" by an impatient end-user asking for an status update ("It's now next week. Waiting.") and nothing more. They didn't seem to be annoyed about that you pointed out a performance issue, and instead explained that their current focus is elsewhere.
Bindless lets you reduce the amount of book keeping you have to do per-object on the CPU, but much more importantly opens the door for GPU driven rendering.
The problem with WebGPU is there's no bindless and the 'bindful' path is quite expensive to meet the safety requirements of a browser API. There's no way around the slow path, and the slow path is quite slow. In this case the workaround is cut features because the API simply imposes too much overhead.
[1] https://discussions.unity.com/t/gpu-bindless-resources-suppo...
The industry has moved beyond that, with teams where programmers only have a minor role (quite important nontheless), on the whole game design, with plenty of tooling for designers and other non-programmer folks to do their tasks.
Eventually with more graphical tooling, or scripting systems, it will start to gain more steam.
Note that TinyGlade also created most of their tooling in-house, they only partially depend on Bevy.
Most of the gamedev in my opinion is extremely exploratory and demands constant experimentation with design. C/C++ offer fluidity, a very good and mature debug toolchain, solid performance ceiling and support from other people.
It will be really hard to replace C++ in performance/simulation contexts. Security takes a backseat there.
Bindless is a game changer - pun intended. It can’t happen soon enough.
Just curious, what are the three major projects that were cancelled?
I also want to mention that folks are shipping high performance games in Rust - the first title that comes to mind is “Tiny Glade” which is breathtakingly gorgeous, though it is a casual game. It does not run on wgpu though, to my knowledge. I may have a different definition of high performance, with lower expectations.
Here are some:
- LogLog Games [1]. Not happy with Bevy. Not too unhappy about performance, although it's mentioned.
- Moonlight Coffee [2]. Not a major project, but he got as far as loading glTF and displaying the results, then quit. That's a common place to give up.
- Hexops. [3] Found Rust "too hard", switched to Zig.
Tiny Glade is very well done. But, of course, it's a tiny glade. This avoids the scaling problems.
[1] https://news.ycombinator.com/item?id=40172033
[2] https://www.gamedev.net/blogs/entry/2294178-abandoning-the-r...
[3] https://devlog.hexops.com/2021/increasing-my-contribution-to...
Does it directly, internally, support Vulkan instead of on-the-fly translation from WebGPU to VK?
The main purpose of WebGPU is to specify a 3D API over the common subset of Metal/D3D12/Vulkan features (e.g. doing an 'on-the-fly translation' of WebGPU API calls to Metal/D3D12/Vulkan API calls, very similar to how (a part of) Proton does an on-the-fly translation of the various D3D API versions to Vulkan.
I'm not disagreeing that bindless is needed but it's a bit of hyperbole to claim the texture limits are too small for serious applications given the large list of serious graphics applications that shipped before bindless existed and the large number of serious graphics applications and games still shipping that don't use them.
For an idea of bevy's default view and PBR material bindings, see:
* https://github.com/bevyengine/bevy/blob/main/crates/bevy_pbr...
* https://github.com/bevyengine/bevy/blob/main/crates/bevy_pbr...
I agree that compat mode takes up more of the WebGPU standard committee's time than bindless. I'm not sure that's how I would prioritize things. (As a Mozilla engineer, we have more than enough implementation work to do already, so what the committee discusses is sort of beside the point for us...)
What would be really helpful is if, once the bindless proposal <https://hackmd.io/PCwnjLyVSqmLfTRSqH0viA?view> gets merged into the spec repo <https://github.com/gpuweb/gpuweb/tree/main/proposals>, a contributor could start adapting what WGPU has now to match the proposal. Implementation experience would be incredibly valuable feedback for the committee.
I never personally ran into the issue, but I know it's a problem our users have had.
The default limits are like the lowest common denominator and typically way lower than what the device actually supports.
Part of the challenge of making a general purpose engine is that we can't make choices that specialize to a use case like that. We need to support all the backends, all the rendering features, all the tradeoffs, so that our users don't have to. It's a hard challenge.
WebGPU demos never work for me, so I personally consider the tech dead until that gets fixed. WebGL is barely stable enough to use as well, so I guess I'll just have to keep doing GPU stuff outside of the browser.
But bth, Google doesn't seem to care about Android either. Chrome supports it on Snapdragons and that's it. Do you have Xclipse GPU? Like, I don't know, Samsung's current flagship line Galaxy S24 does? Too bad, not good enough.
Lots of people use MacOS and Windows though, so Google has incentive to support these platforms.
To me, one of the greatest things about the web is that the DOM is malleable in that you can right click -> view source -> change things. This is dead in an era where the server just sends you a compiled WASM dll.
It seems to me that the inevitable result of things like WASM and WebGPU will be "rich media web 4.0 applications" that are just DRM, crypto miners, and spyware compiled so that they're more difficult to circumvent, and delivered via the browser. An excuse to write web apps with poor performance because "well the user just needs a stronger GPU". It seems like an express train back to the bad old days of every website being written in flash.
I honestly cannot see the upsides of these technologies. Is it gaming? Why would I want to play a 3D game in my fucking browser of all places? That's a strict downgrade in almost every way I can think of. Why would anyone want that? Is it "AI"? Why would I want to run an LLM in the browser, I could just run it natively for better performance?
All I can see and have seen over the last several years is a steady parade of new technologies that will make the internet (and in some cases the lives of every day people) objectively worse while enriching a handful of big tech douchebags.
Why are we going down this path? Who is asking for this stuff? Why the fuck would I want to expose my GPU to a website?
To provide users a way to instantly play a game without having to download all assets at once. Give developers a potential way to avoid app store royalties of up to 30% on desktop or mobile. With wgpu in rust, you can also target WebGPU as a shared 3d runtime that will run across OS's natively rather than having to target Vulkan, Metal, and DirectX.
> Why would I want to run an LLM in the browser, I could just run it natively for better performance?
What about users who don't know how to download a model and run it locally? I would argue this is the vast majority of users in the world. Also, this specific use case is probably not going to be generalized with WebGPU yet due to model sizes, but rather other APIs like the Prompt API in Chrome which will use Gemini Nano embedded into the browser (assume it will eventually get standardized). https://developer.chrome.com/docs/ai/built-in-apis
I agree with you that WASM and WebGPU will be used for adware, targeting, and spyware - but if you don't want to use them, you should disable them in your browser settings - there's definitely value add for other users even if you can't see any benefits.
You end up having to re-implement steam to keep a local copy of the assets on the client device yourself, expect browsers to do the same to manage caching the gigabytes of data transparently, or design your game around a very slow storage device or use tiny assets.
Flash games worked because they fit very nicely into the 'tiny assets' category.
There's a reason QuakeLive didn't catch on and it's because streaming resources to the player makes for awful UX.
>What about users who don't know how to download a model and run it locally?
Those users also don't know how to compile MS Word from source but they have been getting along just fine with installers.
That’s what made flash games so big back in the day.
No need for the web in that case, which is inefficient. You can do with like those 1MB installers and stream those assets.
> but if you don't want to use them, you should disable them in your browser settings
Which the majority won't. People don't even go in their phone settings, apart from connecting to WiFi and changing their wallpaper.
WebAssembly brings all languages to the browser. Why shouldn't I be able to use C#, Rust, Go, Dart, Python, or whatever else in browser?
WebAssembly brings better performance. That's what Webamp found: https://jordaneldredge.com/blog/speeding-up-winamps-music-vi...
And what Amazon found: https://www.amazon.science/blog/how-prime-video-updates-its-...
And what Google found: https://web.dev/case-studies/google-sheets-wasmgc
Why make things perform worse when they can perform better?
Why shouldn't I be able to make an application that compiles to the Windows, macOS, and Linux desktops and also to the browser? This one does: https://bandysc.github.io/AvaloniaVisualBasic6/
This has zero end-user benefit. While having the end-user drawbacks gp mentioned (reduced ability to inspect and modify content).
> WebAssembly brings better performance.
Wirth's law says "hold my beer".
Maybe you are not be aware of the number of good web apps that use some WebGL under the hood? You might be using office applications in your browser already that use WebGL when it’s available, and the reason is it makes things faster, more responsive, more scalable, and more efficient. Same would go for WebGPU.
There’s no reason to imagine that the web will do bad things with your resources that you didn’t ask for and don’t have control over. There have been hiccups in the past, but they got fixed. Awareness is higher now, and if there are hiccups, they’ll get fixed.
The web is like this right now. Why would things magically become a utopia?
Read some security update news from browser vendors and vulnerability researcher posts. There's some weak signals about vendors acknowledging the difficulty of securing the enormous attack surface of browsers built on unsafe foundations, eg MS "enhanced security mode" and Apple "lockdown mode".
Runescape! I grew up playing Runescape! How could anyone not want games like Runescape to exist?!?
I mean, I wouldn't say I don't want it to exist. But Runescape is one of the shittiest, most boring games I've ever played. It's not exactly a strong argument for why we should run stuff in the browser
Native operating systems are garbage at maintaining user privacy and become maintenance burdens when too many applications have been installed and even uninstalled on the machine.
While not perfect, a browser tab is a stronger sandbox than you can easily get in any other context.
> Why would I want to run an LLM in the browser, I could just run it natively for better performance?
Why would you try out a new app in a sandboxed browser, when instead you could give it complete access to your entire computer?
Yes, running LLMs on the web may not have significant advantages due to the speed limitations, but other models, such as those for bg removal, speech-to-subtitles, and translation, could become practical and efficient thanks to WebGPU.
HTML documents were sort-of like an app sandbox.
Evolution is now adding an app sandbox to HTML.
There is little we can do to resist it. I don't like it either - I hate HTML.
"This is the next step in the standardization process, and it comes with stronger guarantees of stability and intellectual property protection."
I understand stability, and in the general sense I see that people feel they need to protect their IP, but in this specific case what is meant by "intellectual property protection"?
[0] https://www.w3.org/policies/patent-policy/#sec-Requirements
Right now I feel like the only way to write efficient WebGPU code is to deeply understand specific GPU architectures. I hope some day there's a dev tools tab that shows me I'm spending too much time sampling a texture or there's a lot of contention on my atomic add.
> Right now I feel like the only way to write efficient WebGPU code is to deeply understand specific GPU architectures. I hope some day there's a dev tools tab that shows me I'm spending too much time sampling a texture or there's a lot of contention on my atomic add.
It's kind of the nature of the beast. Something that's cheap on one GPU might be more expensive on another, or might be fine because you can hide the latency even if it's slow, or the CPU overhead negates any GPU wins, etc. The APIs that give you the data for what you're asking are also vendor-specific.
I know that the reason is a lot of technical complexity (plus little standardization between vendors), but I think the end goal should be to make GPU programming more accessible.
Developer tooling for debugging 3D Web APIs has been a continuous request since WebGL 1.0, from 2011.
Until now the only thing that ever came out of it was SpectorJS and it shows its age.
For a while Firefox did have a debugger, that they eventually removed from developer tools.
You are left with writing the application twice, so that can make use of modern native debugging tools for graphics programming.
I do research and develop ANN's for data analysis within chemistry. Making it possible for less tech literate people to visit a site, select a model, load their dataset, and get answers, is quite handy. The best part is because I can use their hardware to do it all, it all stays private, no one has to upload any sensitive research data etc. and I don't have to ship to various devices etc. I know if they have a mainstream updated browser they can likely use the tool. No endless requests for help, no mystery issues to solve, things just work.
Such permissions requests have been associated I think exclusively with input and output, not computation.
The 3D API is just meant to be a minimal portable abstraction over common low-level hardware features, composing those features into higher level constructs is intentionally left as an exercise for the user.
Web APIs need more standardized functionality built in, including high-level ones, and not rely on additional libraries, because they have to download across a network.
It's like having to install an app every time you visit a site.
https://github.com/linebender/vello
and (shameless plug):
The last time I tried with pixi.js the problem was smoothly zooming polygons with a constant width border thicker than hairline. Doing that was basically just generating new textures on every frame.
WebGPU is going to usher in a new era of web games, the biggest benefit being compute shaders which have never before been possible inside the browser.
DISCLAIMER - Will only work on a Windows device running Chrome or a Chromium browser. Mac and iOS isn't well supported yet.
Space demo - https://play.spacelancers.com/
Forest demo - https://play-dev.simplystream.com/?token=bd4ca6db-522a-4a73-...
It loaded, but "work" is a stretch. It was a multiple second lag to react to input. Very choppy.
So basically Webgpu is just another graphics API for targeting Windows. Yay.
Once we mobile optimize, they should work well.
> whom is WebGPU for? […] it’s a huge rigamarole.
Where is this comment coming from? WebGPU enables compute shaders, and there are applications in anything that uses a GPU, from ML to physics to audio to … you name it. What is making you think game engines would be the only users? I bet a lot of companies are looking forward to being able to use compute shaders in JS apps and web pages.
> Godot has had zero development for WebGPU support.
Why would Godot be an indicator? I love Godot and their efforts, but it’s less than 1% of game engine market share, and a much smaller less well funded team. Of course they’re not on the bleeding edge. Unity is closer to 30% market share and is actively engaging with WebGPU, so it seems like you’re downplaying and contradicting a strong indicator.
> WebGPU enables compute shaders, and there are applications in anything that uses a GPU, from ML to physics to audio to … you name it.
I know.
If you have to go through a giant product like Unity for example to use WebGPU because Apple will essentially have its own flavor of WebGPU just like it has its own flavor of everything, is it really cross platform?
Does Apple support Vulkan? No. It was invented for middlewares!
Apple has a flag to toggle on WebGPU on iOS today. I know dude. What does that really mean?
They have such a poor record of support for gamey things on Mobile Safari. No immersive WebXR, a long history of breaking WASM, a long history of poor WebGL 2 and texture compression support. Why is this going to be any different?
Apple's WebGPU implementation in Safari is entirely spec compliant, and this time they've actually been faster than Firefox.
https://www.youtube.com/watch?v=HrLyZ24UcRE
Apple maps and others also use it
https://www.construct.net/en/free-online-games/ultra-pixel-s...
Which Construct 3 game should I try on Mobile Safari?
I know there are other game engines. Supporting Mobile Safari is very very hard. It has its own flavor of everything. I would never speak in absolutes about some web standard and how it will work on Mobile Safari.