[HN Gopher] W3C Community Group Draft Report - WebGPU Explainer
___________________________________________________________________
W3C Community Group Draft Report - WebGPU Explainer
Author : Emigre_
Score : 32 points
Date : 2023-11-05 17:55 UTC (5 hours ago)
(HTM) web link (gpuweb.github.io)
(TXT) w3m dump (gpuweb.github.io)
| drfuchs wrote:
| Great. Now how do I call this API from WASM without any
| intervening JavaScript?
| pjmlp wrote:
| You don't.
|
| Maybe when reference types eventually become a thing.
| davexunit wrote:
| WASM GC reference types are rolling out to stable browser
| releases now. Chrome 119 just shipped with them enabled by
| default.
| pjmlp wrote:
| Those ones are unrelated to exposing browser APIs directly
| to WASM code.
|
| Setup is still required.
| davexunit wrote:
| I don't quite understand what you mean. WASM modules
| don't have direct access to _anything_. They have to be
| granted capabilities from by the host. Are you referring
| to optimizations that various engines do where they
| recognize well-known imports like Math.sin and compile
| things such that they don 't invoke JS at all?
| pjmlp wrote:
| Exactly, hence it is currently impossible to use WebGPU
| without JavaScript's help.
|
| There are some proposals regarding exposing the browser
| IDL to WASM via reference types, but it is far from
| happening.
| davexunit wrote:
| You need the host (whatever it is) to provide the
| capabilities to WASM. On the web, the host environment is
| JS. Browser engines are free to optimize well-known
| imports with or without any new proposals. I guess I just
| don't really see the issue...
| davexunit wrote:
| You'll need _some_ JavaScript to instantiate the WASM module
| and pass in a set of imported functions for using WebGPU. After
| passing in the capabilities it can be all WASM from there.
| jauntywundrkind wrote:
| Afaik, there's no means to pass in imported functions right
| now.
|
| Rust has a very extensive bindgen to make it kind of look
| like you can, but it's really a huge payload of js running on
| the page's main-thread that's converting back and forth. At
| significant cost.
|
| We just shipped garbage collection, which is one precondition
| to actually being able to pass things around (so things
| passed in can participate properly in gc). Next is component-
| model, which allows for passing non-trivial objects around;
| currently it's just primitives like numbers that can be
| passed. After that goes in, hopefully it won't be long before
| we have host-object bridging, where platform objects can be
| sent across. https://github.com/WebAssembly/component-model
| davexunit wrote:
| You can pass around arbitrary JS objects via the (ref
| extern) type. The (import "module" "name" ...) form can be
| used to declare an imported thing (function, global,
| memory, table.) I don't do Rust so I don't know what the
| limitations are with Rust on WASM right now but speaking
| just about core WASM stuff all the basic pieces are there
| now.
| jauntywundrkind wrote:
| Afaik, no. What you are talking about is the future, not
| anything available on any platforms today.
|
| Right now, different runtimes don't have any way to
| communicate what type an object or function is. That's
| what component model is trying to figure out. Without
| that, there's not really a way for a ref to do anyone any
| good, as far as I know.
|
| If you can link any docs or examples, that'd be great. I
| feel like it's been a long long long wait, & I've been
| very eager. But if I'm mistaken, and passing stuff across
| boundaries is possible, that'd be amazing to see.
| Buttons840 wrote:
| Soon, even our game engines will be written in JavaScript:
| https://www.youtube.com/watch?v=_SCfNhyIo_U
|
| Snark aside, the best resource I've found for learning WebGPU is:
| https://webgpufundamentals.org/
| pjmlp wrote:
| WebGPU will always have the issue to lang behind native
| capabilities.
|
| It is good enough if aiming to PS3 like games, though.
| Buttons840 wrote:
| Any WGPU users among us? How does native and web performance,
| with the same graphics code, compare?
| pjmlp wrote:
| Whatever WGPU might do in addition to WebGPU is naturally
| going beyond the standard features a browser is expected to
| provide, thus no different from any other graphics
| middleware.
| yarg wrote:
| It's heavily sandboxed, and there are other overheads to
| get around.
| astlouis44 wrote:
| My team is bringing Unreal Engine 5 to WebGPU, to enable next
| generation browser games and 3D web applications.
| dindresto wrote:
| As an official backend, or just for a specific game?
___________________________________________________________________
(page generated 2023-11-05 23:00 UTC)