WebWorker and Device

Using chrome canary, I've been playing with using multiple webgpu canvases
in the same page. If I make a separate get adapter/device call for each
canvas it has a very high overhead (at least on Windows the gpu process was
1.7 GB for 20 canvases each drawing a single triangle). Using a single
shared device across all canvases works and greatly alleviates the
problem.It also made initialization of each canvas significantly faster.

As of now offscreen canvas support for webgpu is not implemented in chrome (
https://bugs.chromium.org/p/chromium/issues/detail?id=1064109). However, I
was setting up a demo just to confirm this was still broken and to have a
test to periodically try. I found that I would get a "GPUDevice object
could not be cloned." error trying to pass the GPUDevice to the worker. The
GPUDevice can't be passed to transfer because it's not transferable (but
this seemed like the wrong thing to do anyhow).

So mainly what I'm trying to understand is whether sharing a single device
instance with multiple workers is meant to be supported somehow from a
webgpu perspective.

Thanks,
Rob Conde

Received on Saturday, 18 April 2020 21:31:02 UTC