Repository navigation
copyExternalImageToTexture: add validation, make validation async - #1737
Conversation
| Issue: The above list was written just for ImageBitmap. | ||
| Re-evaluate it for canvas (and video). | ||
| (It's probably still fine, though `rgb10a2unorm` is a bit of an outlier.) | ||
| 1. If |sourceImage| is an {{ImageBitmap}} and |
There was a problem hiding this comment.
Is there the same validation requirements for OffscreenCanvas?
There was a problem hiding this comment.
Good catch, OffscreenCanvas should be detachable as well but it doesn't seem to be detachable in the same way as a "platform object". I found this which I guess we can simply call into:
https://html.spec.whatwg.org/multipage/canvas.html#check-the-usability-of-the-image-argument
(and if that's missing checks for detachedness, that should be fixed upstream)
Notably, using that algorithm means that using zero-sized HTMLCanvasElement/OffscreenCanvas becomes an error (even if the copy size is zero). I guess we should adopt that since it's consistent with other usages.
If
imagehas either a horizontal dimension or a vertical dimension equal to zero, then throw an "InvalidStateError" DOMException.
e518964 to
a10785c
Compare
| - |source|.|origin|.[=Origin3D/y=] + |copySize|.[=Extent3D/height=] | ||
| must be ≤ the height of |sourceImage|. | ||
| - |source|.|origin|.[=Origin3D/z=] + |copySize|.[=Extent3D/depthOrArrayLayers=] | ||
| must be ≤ 1. |
There was a problem hiding this comment.
What's the rational for allowing a depth of 0? That's a departure from the validation logic this is replacing. Also, this implicitly prevents copying to texture array layers other than the 0th layer, which I'm not sure is intended?
Seems like the desired logic may be something along the lines of simply:
- |copySize|.[=Extent3D/depthOrArrayLayers=] must be 1;
There was a problem hiding this comment.
This only prevents copying from layers other than the 0th (the source image is 2d so always has only one layer).
This behavior is more consistent with copyTextureToTexture: it validates the same as a copy from a 2d texture with one layer.
| 1. Let |sourceImage| be |source|.{{GPUImageCopyExternalImage/source}} | ||
| 1. Run [=Check the usability of the image argument=](|sourceImage|). | ||
| If it throws an exception, stop. | ||
| If it does not return `good`, throw an {{InvalidStateException}} and stop. |
There was a problem hiding this comment.
I'm not sure this will cover the case below:
During the CopyExternalImageToTexture/ImportToTexture call, it might possible we hit some browser internal error which cause the externalImage content is invalid.
If not, then I think we need to define a behaviour on this case.
Fail silently is one option. (Not good, but webgl and canvas impl in chromium works like this)
There was a problem hiding this comment.
Honestly I don't know what we are supposed to do here. Ideally specs shouldn't need to say what to do if some unspecified problem occurred inside the browser. Hopefully those unspecified problems fall into the following buckets:
- Resource was lost due to gpu process loss. In this case the device is lost, too so it doesn't matter.
- Resource is in an "invalid" state because it hasn't been initialized or is in some other state that means, per-spec, it would be a blank image. In those cases we make sure the implementation copies from a blank image.
Update copyImageBitmapToTexture validation rules based on the new CL (gpuweb/gpuweb#1737)
* Update validation tests of copyImageBitmapToTexture Update copyImageBitmapToTexture validation rules based on the new CL (gpuweb/gpuweb#1737) * Remove float texture format support for operation tests * Clean up kValidTextureFormatsForCopyIB2T * `as readonly string[]`
8f94225 to
34b571c
Compare
|
Fixed the function call thing, and refreshed the PR to resolve merge conflicts. |
) SHA: 95ed421 Reason: push, by @kainino0x Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
) SHA: 95ed421 Reason: push, by @kainino0x Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
) SHA: 95ed421 Reason: push, by @kainino0x Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Preview | Diff