Skip to content

Support for GPUImageCopyExternalImage #1888

Closed
@anlumo

Description

@anlumo

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, or OffscreenCanvas.

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 notably HTMLImageElement and ImageData. However, it's quite easy to convert those into ImageBitmap 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

  • This is only relevant for the wasm32 target of course.
  • The same applies to GPUExternalTextureDescriptor, which allows using video as a source for textures. In WebGL, this is also implemented via the texImage2D call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: apiIssues related to API surfacehelp requiredWe need community help to make this happen.type: enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions