-
Notifications
You must be signed in to change notification settings - Fork 337
Open
Labels
apiWebGPU APIWebGPU API
Milestone
Description
Multiple components, for example multiple graph/plot widgets on a page, cannot effectively share a GPUDevice
because it is stateful:
- It has a global error scope state, which means any error scope spanning an async boundary will capture stuff from other components. This is very difficult for an application to work around.
- It can be destroyed, which means one component which wants to clean up after itself cannot take advantage of
GPUDevice.destroy()
to do so. An application can somewhat work around this by tracking its own resource allocations, which is also more flexible for more complex ownership models (like refcounting), though that only allows freeing Buffer/Texture/QuerySet.
This can be useful for some other things as well:
- An application/engine that has some asynchronous (e.g. loading) work that goes on in the "background" can separate the state for that work.
- A library that wants to expose its
GPUDevice
to a user can separate the user's state from its own.
It's currently possible to approximate this by carefully using error scopes. However, it requires the developer to be diligent about popping error scopes prior to await
and re-pushing afterward. In code that call into WebGPU from more than one level of async function, this becomes very complex very quickly.
Relevant past work:
- Make GPUDevice.destroy() a queued operation #2599
- Consider making ShaderModule compilation errors special #2119 (comment) comments about error sinks and forking devices
- https://hackmd.io/@webgpu/r1mBAEGCK messy brainstorm doc on a different topic
We don't need to solve this in V1, but we need to make sure we don't block ourselves from solving it later. Editors are working on a proposal about this (that should have no or minimal changes to the current API), will follow up soon.
Metadata
Metadata
Assignees
Labels
apiWebGPU APIWebGPU API