54 points · by mariuz · 3y ago · 59 comments
https://machengine.org/pkg/mach-gpu-dawn/
It's also possible to use wgpu-native in C/C++ projects as prebuilt library, see:
And currently some high-frequency WebGPU calls have an even higher CPU overhead than similar WebGL2 calls (I wrote about that here a bit: https://floooh.github.io/2023/10/16/sokol-webgpu.html).
WebGPU allows more flexibility of course, compute shaders and storage buffers are more flexible and cleaner than trying to shoehorn the same stuff into vertex/fragment shaders and using textures as "poor man's storage buffer", but that doesn't mean that one approach is slower or faster than the other.
The "max number of sampled texture per shader stage" is a runtime device limit, and the minimal value for that seems to be 16. So texture atlasses are still a thing in WebGPU.
WebGPU has render bundles, which allow to pre-record command sequences, but even with that you don't want to change resource bindings thousands of times per frame (or even hundreds of times).
It might make sense though to build texture atlases dynamically (basically use one very big texture as "tile cache") and update that via writeTexture() calls (just don't rebuild the entire atlas each frame).
Most people are better served by using GL 4.6, DX 11 and such, or a middleware engine.
Even console vendors have multiple APIs because of that, not everyone needs all little details of the GPU.
Unity is supposed to have good DirectX 12 coming up, by the way.
"Achieving Real Time Ray Tracing on Xbox with Unity and DirectX12"
The only thing good about it, is moving the Web 3D beyond GL ES 3.0 subset.
Don't expect nanite or Fortnite on the browser anytime soon.
I have a PR that does a lot of the same things (meshlets, visbuffer, material depth, two pass occlusion culling) open for Bevy https://github.com/bevyengine/bevy/pull/10164 that I've been working on, which uses WebGPU.
WebGPU is actually a pretty good API imo. It's missing some advanced features like raytracing, mesh shaders, and subgroup operations (coming soon!), but it can still do a lot.
The much bigger missing feature is "bindless" support (non-uniform arrays of bound resources). BindGroup overhead (and ergonomics) is a significant downside.
If you're ever looking to join a team to advance Unreal Engine 5 and graphics in the browser, please reach out. We're tackling Nanite and Lumen in the browser, and contributing to the WebGPU spec in collaboration with Google.
You can reach me on Discord - my username is astlouis44
I'm also on LinkedIn: https://www.linkedin.com/in/alex-st-louis-3986a5102/
WebGPU still has a nice balance between convenience and a somewhat modern feature set, but going down to the native platform 3D APIs (Metal, D3D12 and Vulkan) will always offer a much bigger feature set and less CPU overhead (mainly because WebGPU also needs to support mobile GPUs, and some of those are indeed 10 years behind the curve).
[1] https://registry.khronos.org/vulkan/specs/1.3-extensions/man...
[2] https://registry.khronos.org/vulkan/specs/1.3-extensions/man...
[3] https://registry.khronos.org/vulkan/specs/1.3-extensions/man...
[4] https://registry.khronos.org/vulkan/specs/1.3-extensions/man...
WebGPU outside of the browser doesn't really matter, middleware engines already cover that, and with much better tooling.
Besides WebGPU outside of the browser cannot deviate from the WebGPU on the browser, otherwise it is exactly the same pain as porting between OpenGL ES, OpenGL and WebGL, API that are only compatible in name.
In my opinion, the main strength of WebGPU is it removes the cost of re-implementing something when targeting a different platform. If that was present in 2015, maybe we'd have more games, more interesting applications, and less pressure on people who feel locked into one vendor's ecosystem.
[1] https://forum.babylonjs.com/t/why-havent-3d-web-games-reache...
As a non game developer, though, I am wondering if migrating existing renderers would allow me to create UIs, or parts of them, using graphics that is not just html+CSS without the massive overhead that we currently have. I mean, I can draw the frames just fine but these extra cycles suck power and produce heat
https://felt.com/blog/svg-to-canvas-part-2-building-interact... and https://github.com/servo/pathfinder/ might be of interest.
Not excited, and very few of those will materialise. Next gen games require next gen graphics. You can check for yourself how much those graphics weigh.
Wouldn't that make Chrome unusable if you don't have a recent GPU?
https://github.com/gpuweb/gpuweb/issues/4266
Also I guess Chrome could just fall back to a "legacy rendering backend" if WebGPU isn't supported.
IMO that's only really necessary if you are targeting hardware >5 years old, or embedded hardware, though.
I feel like this would only really get used for simple mobile games and not for actual titles with gameplay... even if the API is there, most people don't have powerful enough devices to drive modern console or PC quality games. And if they did, they'd be looking on Steam or an app store, not the Web.
What's the use case?
It also gets more interesting when you consider that the world is increasingly moving to ARM. Take Qualcomm's new ARM chips for example; they're competitive with Apple Silicon already. WASM/WebGPU represents a straightforward way to convert x86 games to run on these new chips.
Below is a blog post about our platform-as-a-service and tools, and our current development focus to support Unreal Engine 5 in WebGPU/WASM:
I enjoyed your Western Town demo. I always wished they would make virtual tours, Assassin's Creed-style, of old ghost towns like https://www.parks.ca.gov/?page_id=509
I wish we could agree on something slightly more ergonomic than a C FFI. The largest common denominator has to be slightly more advanced than C (if we decide to not accommodate C).
Thanks.
If you want to use WebGPU from as many languages as possible, a C API is pretty much the only option.
There's also a C++ API, but just as with the JS API, this is limited to a single language.
For usage from Rust you can also use gfx-rs/wgpu, which has a Rust-idiomatic API (e.g. see: https://github.com/gfx-rs/wgpu/blob/trunk/examples/hello-tri... - which to be honest doesn't look more "ergonomic" than the C API to me).
Also, it's not like the C API is "unergonomic", it works with C99 designated initialization which makes it quite nice to use. The only downside is COM-style manual lifetime management via ref/release calls, but if you are used to Direct3D that's a no-brainer (it works exactly the same), and the C++ API has RAII wrappers for this stuff.
Was the title a freudian slip or something?
As much as we all distrust Google, this kind of tangential comment is pretty tiresome when it has no relevance to what's being posted.
I’m surprised there isn’t much support for even a bytecode representation…