Support for GPUImageCopyExternalImage #1888
Labels
area: api
Issues related to API surface
help required
We need community help to make this happen.
type: enhancement
New feature or request
Is your feature request related to a problem? Please describe.
WebGPU and WebGL have functions for directly loading images without copying them to wasm first. This is much more efficient. In WebGPU, an image source can be an
ImageBitmap
,HTMLCanvasElement
, orOffscreenCanvas
.Describe the solution you'd like
The WebGPU spec specifies GPUImageCopyExternalImage. I can't find any reference to this functionality in the wgpu code, so I assume that this is not implemented.
WebGL allows the same via the regular
texImage2D
, but it has even more formats, most notablyHTMLImageElement
andImageData
. However, it's quite easy to convert those intoImageBitmap
via createImageBitmap.Describe alternatives you've considered
It's possible to draw an image to a bitmap canvas and then extract it as a byte array from there, but this is highly inefficient. In theory you can also directly decode images in wasm, but the browser is much faster (since it can do that in native code) and also supports webp, which is not available for Rust on the wasm32 target right now.
Additional context
GPUExternalTextureDescriptor
, which allows using video as a source for textures. In WebGL, this is also implemented via thetexImage2D
call.The text was updated successfully, but these errors were encountered: