-
Notifications
You must be signed in to change notification settings - Fork 344
Description
The current spec copyexternalimagetotexture says that If source.source is an HTMLCanvasElement: Its canvas context mode must be "2d", "webgl", or "webgl2". It seems that webgpu context mode is not supported.
However, for tfjs-webgpu, we are meeting a scenario which may need webgpu context mode supported.
Some users of tfjs are using tfjs' result in their gpu programs. If they directly use gpu backend (webgl/webgpu) to do the prediction, they hope only have gpu->gpu copying to move tfjs's result to the GPUTexture of their gpu program. However, for tfjs-webgpu, we create a GPUDevice silently for webgpu backend and donot expose it to upper user. To get the result, the user either reads data to cpu by tensor.data() or gets data from a HTMLCanvasElement. For the latter, the user can implement gpu-gpu copying to move tfjs's result to another device's GPUTexture. However, to support the latter path, we need webgpu context mode is supported for copyExternalImageToTexture. Otherwise, there will be an extra copy needed (webgpu canvas -> 2d canvas/webgl canvas -> webgpu canvas). And webgl doesn't exist such kind of problem.