Wgpu-rs: Target the Web directly

Created on 25 Oct 2019  Â·  6Comments  Â·  Source: gfx-rs/wgpu-rs

We need to make wgpu-rs do the actual Web calls and run in the browser supporting WebGPU API. The API itself is still evolving, but we should start exploring what our side would look like, and maybe we'll already get something running.

enhancement help wanted

Most helpful comment

Let's consider this fixed by #193
Amazing work of @grovesNL and everyone involved, thank you all!

All 6 comments

Steps to get this working:

  1. Ensure mozilla-central has up-to-date WebGPU WebIDL

    • This step can probably be omitted, but technically this is the upstream for many of the existing web-sys WebIDL files

    • Done (we use the complete WebIDL from gpuweb instead)!

  2. Update the existing WebGPU WebIDL in web-sys so we can generate Rust bindings
  3. Split calls in wgpu-rs to use #[cfg(target_arch = "wasm32")] to target web-sys, and #[cfg(not(target_arch = "wasm32"))] to target wgpu-native

    • We might want to consider splitting wgpu-rs into two backends (wgpu-native and web-sys), or use a trait like we do in glow, or something else

  4. Now we can build for wasm32-unknown-unknown and use wasm-bindgen-cli or wasm-pack as usual

Thank you for describing the steps! They look very actionable, and make me believe we can get a prototype running (at least device creation) by the end of the year.

FYI, (1) was mostly updated to latest WebIDL by https://phabricator.services.mozilla.com/D46166, which took more of my blood and tears than I'd hope or expect.

Edit: actually, we settled on not exporting any WebGPU logic that isn't implemented yet, other than the bare interfaces... which means that at least my https://phabricator.services.mozilla.com/D49458 needs to be merged before we proceed here.

Gecko PR has landed, and now one can at least create a device on WebGPU (in Nightly!). I think the work can be started here, according to @grovesNL plan.

I also already have some branches for web-sys changes and wgpu-rs changes for this – just need to update them based on the recent changes and then we can start making some progress here.

Small update: https://github.com/rustwasm/wasm-bindgen/pull/1997 has been merged which allows us to use web-sys bindings for WebGPU while the WebIDL is still unstable

Let's consider this fixed by #193
Amazing work of @grovesNL and everyone involved, thank you all!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

branpk picture branpk  Â·  3Comments

OptimisticPeach picture OptimisticPeach  Â·  3Comments

dmilford picture dmilford  Â·  3Comments

Lokathor picture Lokathor  Â·  3Comments

m4b picture m4b  Â·  5Comments