Hacker News new | ask | show | jobs
by Buttons840 738 days ago
WGPU is an implementation of WebGPU. This is more accurate than saying it uses WebGPU; WebGPU is not software, you can't use it.

WGPU goes beyond WebGPU in many ways already, and could also support threads.

1 comments

> WGPU is an implementation of WebGPU

No.

    wgpu is a safe and portable graphics library for Rust based on the WebGPU API. 
    ...
    and browsers via WebAssembly on WebGPU and WebGL2.
https://wgpu.rs/

> WebGPU is not software, you can't use it

It's an API that you can use, like OpenGL, Vulkan, Metal, .... Here you can see the current Browser support: https://caniuse.com/webgpu

And what do you call when you call that API? wgpu in Firefox and Dawn in Chrome.

wgpu is an implementation of webgpu with the raw rust bindings rather than the C-API it also provides called by Firefox.

Unless you want to dig into the implementation details of the various subcrates.

> wgpu in Firefox

Ah, sorry, I didn't know that, thanks. On Chrome it uses either WebGL2 or WebGPU.

    When running in a web browser (by compilation to WebAssembly) without the "webgl" feature enabled, wgpu relies on the browser's own WebGPU implementation. 
https://github.com/gfx-rs/wgpu?tab=readme-ov-file#tracking-t...
The wgpu crate in rust can do two things. The first is that it is an implementation of the webgpu spec built upon OpenGL/Vulkan/DirectX/WebGL/Metal. This is what firefox uses. The other is that it can just generate calls to the webgpu api. This is what it does when targetting wasm.

So if you're writing rust with wgpu and you target wasm and run it in firefox you will have a wasm program that calls the browser's implementation of webgpu which is the same wgpu crate you used just built in the other way.

If you run it in Chrome instead it will use Dawn.

And in native land wgpu and dawn are incompatible and have different C-apis. One uses uint32_t everywhere and the other size_t. So they're the same on 32bit platforms like WASM but not on modern native platforms