webgpufundamentals icon indicating copy to clipboard operation
webgpufundamentals copied to clipboard

Switch to using HTMLImageElement

Open greggman opened this issue 1 year ago • 0 comments

When WebGPU shipped in May 2023 it didn't support loading images from HTMLImageElement. The spec was updated to allow this and Chrome shipped support in v118 so, ... update the examples to use HTMLImageElement

using ImageBitmap is supposedly "better", at least in Chrome, as the idea is that using ImageBitmap is supposed to load the image into the GPU so that when you actually go to use it for uploading into WebGPU (and WebGL) it's ready to use. Further, you can pass in options like "premultiplyAlpha" and "colorSpaceConversion"

Conversely, HTMLImageElement image might not be in a format that can be used immediately and so it forces the browser to re-decode the image, making it slow. For example the HTMLImageElement might use premultiplied alpha which is a lossy format. If you request premultiplyAlpha false, the browser is require to re-decode the image so it is not lossy.

In any case, HTMLImageElement is more common (probably) and the examples should probably be switched to use it? Or maybe just bring it up.

greggman avatar Oct 11 '23 18:10 greggman