Skip to content

Supporting JS/webgpu as a backend for e.g. PyScript #407

@almarklein

Description

@almarklein

With PyScript most of wgpu should be runnable in a browser. If we can translate out API to WebGPU calls, people can use WebGPU via Python in a browser, which seems like a pretty big thing!

Since we follow the WebGPU IDL spec quite closely, this should not be that hard, though there are some cases to take into account.

I briefly looked into this. Some hurdles to take are:

  • We must provide a wheel that pyscript can load. This must either be a none-any.whl or a wasm32.whl. Even though we don't have any wasm in it, having none-any.whl can accidentally be installed on a desktop and we don't want that.
  • Code must be async, since there is no way to synchronously wait for a Future in js, we cannot implement our sync version of the async method. I find this the scariest hurdle. (I hope I'm overlooking something that still allows us to do that.)
  • We must provide a jswebgpu backend. Can partially autogenerate this. I don't expect this to be the hardest part.
  • We must provide a jscanvas gui backend if we want to render stuff.

Sub-goals to achieve:

  • Support importing wgpu and displaying the version numer.
  • Perform compute tasks.
  • Perform rendering tasks.
  • Now it should be possible to just run pygfx examples.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions