0
Files
src/gpu
Stephen White 6a73a13bd2 WebGPU: fix viewFormats validation in GPUContextCanvas.
If the viewFormats passed to GPUCanvasContext.configure() are invalid,
the spec requires that a validation error occur. Subsequent calls to
GPUCanvasContext.getCurrentTexture() must also generate a validation
error.

The SwiftShader path in Chrome uses
SharedImageRepresentationAndAccessSkiaFallback for WebGPU canvas
contents. When GPUCanvasContext.getCurrentTexture() causes
AssociateMailbox() to be called on an invalid context, this causes the
GPUTexture allocation in the SIRAASF constructor to fail. When the
canvas is later garbage collected, DissociateMailbox() calls
SharedImageRepresentationAndAccessSkiaFallback::UploadContentsToSkia(),
which fails on that invalid texture in
GPUCommandEncoder.copyTextureToBuffer(). This can cause validation
errors in unrelated code (leading to the flaky failed tests in the bug).

The fix is to move the texture creation to SIRAASF::Create() and detect
the texture creation failure with a a push/popErrorScope(). If it fails,
return nullptr, causing
WebGPUDecoderImpl::HandleAssociateMailboxImmediate() to create a
ErrorSharedImageRepresentationAndAccess instead, as the other backends
do. This will avoid doing anything with an invalid texture.

However, it turns out that the validation error from CreateTexture is
actually load-bearing, and is the only reason that getCurrentTexture()
generates a validation error at all! Removing it causes the viewFormats
CTS tests to fail, since they don't get a validation error they're
expecting. The fix for that is to explicitly validate the texture
descriptor each time GPUCanvasContext.getCurrentTexture() is called.

Bug: 40853211
Change-Id: I445b0aff0f05efac01e0d95966ade9945876f9fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6435571
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1444466}
2025-04-08 17:07:47 -07:00
..
2025-03-07 09:13:07 -08:00