You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add more copyExternalImageToTexture tests as Chrome/Safari/Firefox are failing to agree how to load an image #4545
PNG is unpremultiplied, so if you copyExternalImageToTexture without premultipliedAlpha: true and copy that directly into the canvas you'll end up with undefined results on the display. That is not allowed to affect the readback result, but it does affect how it appears on screen.
Here are my notes from playing with this sample on Mac:
ImageMagick seems to confirm 130 101 73 1 (magick FurBaseColorAlpha.png -format '%[fx:255*u.p{0,0}.r] %[fx:255*u.p{0,0}.g] %[fx:255*u.p{0,0}.b] %[fx:255*u.p{0,0}.a]' info:) - noting it's not fully transparent so there shouldn't be any issues with transparent pixels having arbitrary color values.
Firefox is initially missing their texture-to-canvas-conversion step - probably specific to filling a canvas using copyTextureToTexture - causing the BGRA-RGBA conversion step and alphaMode: 'opaque' not to apply. It fixes after switching away from the tab for a few seconds and back.
In all browsers I think the createImageBitmapcolorSpaceConversion option is behaving correctly. It should have no effect because the image is already sRGB.
In Safari and Firefox, I think the createImageBitmappremultiplyAlpha option is behaving incorrectly. It always behaves like premultiplyAlpha: 'premultiply' which results in the R/G/B values getting "quantized" into the range of A (so either 0 or 1). Safari quantizes to 1,0,0, and Firefox quantizes to 1,1,1. Then they unpremultiply to 255,0,0 and 255,255,255, respectively.
In Safari something is going badly wrong with the Image path, I'm not sure what, but the color is very wrong (regardless of -srgb). At pixel 100,100, I'm getting RGBA 128,99,99,252 instead of the correct 130,100,71,252. Also, it doesn't do the red-blue flip when doing copyExternalImageToTexture into BGRA. No such issues in the ImageBitmap path.
I think the thing not being tested that's failing on firefox, there is no webgpu:web_platform,copyToTexture,ImageBitmap:from_ImageData:from_Image there is only from_ImageData, from_canvas
Activity
greggman commentedon Dec 23, 2025
Trying with
Imageinstead ofcreateImageBitmaphttps://jsgist.org/?src=2359aec968f72ec4b24f69c712753d59
Top-left RGBA: 130 101 73 1Top-left RGBA: 1 0 0 1Top-left RGBA: 130 101 73 1kainino0x commentedon Jan 2, 2026
PNG is unpremultiplied, so if you copyExternalImageToTexture without
premultipliedAlpha: trueand copy that directly into the canvas you'll end up with undefined results on the display. That is not allowed to affect the readback result, but it does affect how it appears on screen.Here are my notes from playing with this sample on Mac:
130 101 73 1(magick FurBaseColorAlpha.png -format '%[fx:255*u.p{0,0}.r] %[fx:255*u.p{0,0}.g] %[fx:255*u.p{0,0}.b] %[fx:255*u.p{0,0}.a]' info:) - noting it's not fully transparent so there shouldn't be any issues with transparent pixels having arbitrary color values.copyTextureToTexture- causing the BGRA-RGBA conversion step andalphaMode: 'opaque'not to apply. It fixes after switching away from the tab for a few seconds and back.kainino0x commentedon Jan 2, 2026
Oops, posted before I was done.
createImageBitmapcolorSpaceConversionoption is behaving correctly. It should have no effect because the image is already sRGB.createImageBitmappremultiplyAlphaoption is behaving incorrectly. It always behaves likepremultiplyAlpha: 'premultiply'which results in the R/G/B values getting "quantized" into the range of A (so either 0 or 1). Safari quantizes to1,0,0, and Firefox quantizes to1,1,1. Then they unpremultiply to255,0,0and255,255,255, respectively.Imagepath, I'm not sure what, but the color is very wrong (regardless of-srgb). At pixel100,100, I'm getting RGBA128,99,99,252instead of the correct130,100,71,252. Also, it doesn't do the red-blue flip when doing copyExternalImageToTexture into BGRA. No such issues in theImageBitmappath.kainino0x commentedon Jan 2, 2026
We do have tests that are supposed to test some of these things, but I don't think we try very hard to test
createImageBitmapitself. In particular, we don't have Blob-to-ImageBitmap or Image-to-ImageBitmap cases.https://github.com/gpuweb/cts/tree/main/src/webgpu/web_platform/copyToTexture
It would be useful to see if
createImageBitmapis broken even for WebGL.kainino0x commentedon Jan 2, 2026
https://gpuweb.github.io/cts/standalone/?q=webgpu:web_platform,copyToTexture,image:* does not pass in Safari at all - every test case fails. It passes in Chrome and Firefox (except for new formats Firefox doesn't implement yet).
greggman commentedon Jan 5, 2026
I think the thing not being tested that's failing on firefox, there is no
webgpu:web_platform,copyToTexture,ImageBitmap:from_ImageData:from_Imagethere is onlyfrom_ImageData,from_canvas