Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for GPUImageCopyExternalImage #1888

Closed
anlumo opened this issue Aug 30, 2021 · 0 comments · Fixed by #3288
Closed

Support for GPUImageCopyExternalImage #1888

anlumo opened this issue Aug 30, 2021 · 0 comments · Fixed by #3288
Labels
area: api Issues related to API surface help required We need community help to make this happen. type: enhancement New feature or request

Comments

@anlumo
Copy link
Contributor

anlumo commented Aug 30, 2021

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.
@kvark kvark added area: api Issues related to API surface help required We need community help to make this happen. type: enhancement New feature or request labels Aug 31, 2021
@anlumo anlumo mentioned this issue Sep 18, 2021
7 tasks
cwfitzgerald added a commit that referenced this issue Jan 24, 2023
… WebGPU Impl (#3288)

Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
Closes #1888
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: api Issues related to API surface help required We need community help to make this happen. type: enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants