webgpu: Simplify presentation and handle cleared in script (#38717)

There are many important changes here:

- Generalize the presentation buffer into standalone staging buffers
that hold their own state. This allow them to be used by getImage.
- Move all clear handling to the ScriptThread and send the configuration
on each request present/getimage, thus avoiding any recreate/clearing
messages. This means that we prepare staging buffers lazily, on the
first request.

Try run for this change:
https://github.com/sagudev/servo/actions/runs/17341982368
Testing: This is covered by existing WebGPU CTS tests. There are some
bad expectations updates, but they are also on main (presumably from
last update the rendering work) although I think CTS is actually wrong
(see https://github.com/gpuweb/cts/issues/4440).
Fixes: #36820
Fixes: #37705
Fixes: #33368 (we now keep reference alive in hashmap)

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Sam 2025-09-09 05:35:12 +02:00 committed by GitHub
parent 8d2723b2c9
commit 1f0f079203
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 1023 additions and 935 deletions

View file

@ -80659,8 +80659,12 @@
if os == "linux" and not debug: FAIL
[:canvasType="onscreen";contextType="bitmaprenderer";awaitLost=false]
expected:
if os == "linux" and not debug: FAIL
[:canvasType="onscreen";contextType="bitmaprenderer";awaitLost=true]
expected:
if os == "linux" and not debug: FAIL
[:canvasType="onscreen";contextType="webgl";awaitLost=false]
expected:
@ -547197,8 +547201,12 @@
[cts.https.html?q=webgpu:web_platform,canvas,getCurrentTexture:multiple_frames:*]
[:canvasType="offscreen"]
expected:
if os == "linux" and not debug: FAIL
[:canvasType="onscreen"]
expected:
if os == "linux" and not debug: FAIL
[cts.https.html?q=webgpu:web_platform,canvas,getCurrentTexture:resize:*]
@ -547575,16 +547583,10 @@
if os == "linux" and not debug: FAIL
[:format="bgra8unorm";alphaMode="opaque";colorSpace="srgb";snapshotType="imageBitmap"]
expected:
if os == "linux" and not debug: FAIL
[:format="bgra8unorm";alphaMode="opaque";colorSpace="srgb";snapshotType="toBlob"]
expected:
if os == "linux" and not debug: FAIL
[:format="bgra8unorm";alphaMode="opaque";colorSpace="srgb";snapshotType="toDataURL"]
expected:
if os == "linux" and not debug: FAIL
[:format="bgra8unorm";alphaMode="premultiplied";colorSpace="display-p3";snapshotType="imageBitmap"]
expected:
@ -547599,16 +547601,10 @@
if os == "linux" and not debug: FAIL
[:format="bgra8unorm";alphaMode="premultiplied";colorSpace="srgb";snapshotType="imageBitmap"]
expected:
if os == "linux" and not debug: FAIL
[:format="bgra8unorm";alphaMode="premultiplied";colorSpace="srgb";snapshotType="toBlob"]
expected:
if os == "linux" and not debug: FAIL
[:format="bgra8unorm";alphaMode="premultiplied";colorSpace="srgb";snapshotType="toDataURL"]
expected:
if os == "linux" and not debug: FAIL
[:format="rgba16float";alphaMode="opaque";colorSpace="display-p3";snapshotType="imageBitmap"]
expected:
@ -547671,16 +547667,10 @@
if os == "linux" and not debug: FAIL
[:format="rgba8unorm";alphaMode="opaque";colorSpace="srgb";snapshotType="imageBitmap"]
expected:
if os == "linux" and not debug: FAIL
[:format="rgba8unorm";alphaMode="opaque";colorSpace="srgb";snapshotType="toBlob"]
expected:
if os == "linux" and not debug: FAIL
[:format="rgba8unorm";alphaMode="opaque";colorSpace="srgb";snapshotType="toDataURL"]
expected:
if os == "linux" and not debug: FAIL
[:format="rgba8unorm";alphaMode="premultiplied";colorSpace="display-p3";snapshotType="imageBitmap"]
expected:
@ -547695,50 +547685,28 @@
if os == "linux" and not debug: FAIL
[:format="rgba8unorm";alphaMode="premultiplied";colorSpace="srgb";snapshotType="imageBitmap"]
expected:
if os == "linux" and not debug: FAIL
[:format="rgba8unorm";alphaMode="premultiplied";colorSpace="srgb";snapshotType="toBlob"]
expected:
if os == "linux" and not debug: FAIL
[:format="rgba8unorm";alphaMode="premultiplied";colorSpace="srgb";snapshotType="toDataURL"]
expected:
if os == "linux" and not debug: FAIL
[cts.https.html?q=webgpu:web_platform,canvas,readbackFromWebGPUCanvas:onscreenCanvas,uploadToWebGL:*]
[:format="bgra8unorm";alphaMode="opaque";webgl="webgl";upload="texImage2D"]
expected:
if os == "linux" and not debug: FAIL
[:format="bgra8unorm";alphaMode="opaque";webgl="webgl";upload="texSubImage2D"]
expected:
if os == "linux" and not debug: FAIL
[:format="bgra8unorm";alphaMode="opaque";webgl="webgl2";upload="texImage2D"]
expected:
if os == "linux" and not debug: FAIL
[:format="bgra8unorm";alphaMode="opaque";webgl="webgl2";upload="texSubImage2D"]
expected:
if os == "linux" and not debug: FAIL
[:format="bgra8unorm";alphaMode="premultiplied";webgl="webgl";upload="texImage2D"]
expected:
if os == "linux" and not debug: FAIL
[:format="bgra8unorm";alphaMode="premultiplied";webgl="webgl";upload="texSubImage2D"]
expected:
if os == "linux" and not debug: FAIL
[:format="bgra8unorm";alphaMode="premultiplied";webgl="webgl2";upload="texImage2D"]
expected:
if os == "linux" and not debug: FAIL
[:format="bgra8unorm";alphaMode="premultiplied";webgl="webgl2";upload="texSubImage2D"]
expected:
if os == "linux" and not debug: FAIL
[:format="rgba16float";alphaMode="opaque";webgl="webgl";upload="texImage2D"]
expected:
@ -547773,36 +547741,20 @@
if os == "linux" and not debug: FAIL
[:format="rgba8unorm";alphaMode="opaque";webgl="webgl";upload="texImage2D"]
expected:
if os == "linux" and not debug: FAIL
[:format="rgba8unorm";alphaMode="opaque";webgl="webgl";upload="texSubImage2D"]
expected:
if os == "linux" and not debug: FAIL
[:format="rgba8unorm";alphaMode="opaque";webgl="webgl2";upload="texImage2D"]
expected:
if os == "linux" and not debug: FAIL
[:format="rgba8unorm";alphaMode="opaque";webgl="webgl2";upload="texSubImage2D"]
expected:
if os == "linux" and not debug: FAIL
[:format="rgba8unorm";alphaMode="premultiplied";webgl="webgl";upload="texImage2D"]
expected:
if os == "linux" and not debug: FAIL
[:format="rgba8unorm";alphaMode="premultiplied";webgl="webgl";upload="texSubImage2D"]
expected:
if os == "linux" and not debug: FAIL
[:format="rgba8unorm";alphaMode="premultiplied";webgl="webgl2";upload="texImage2D"]
expected:
if os == "linux" and not debug: FAIL
[:format="rgba8unorm";alphaMode="premultiplied";webgl="webgl2";upload="texSubImage2D"]
expected:
if os == "linux" and not debug: FAIL
[cts.https.html?q=webgpu:web_platform,canvas,readbackFromWebGPUCanvas:transferToImageBitmap_huge_size:*]

View file

@ -1,6 +1,3 @@
[canvas_colorspace_bgra8unorm.https.html]
expected:
if os == "win": TIMEOUT
if os == "linux" and debug: TIMEOUT
if os == "linux" and not debug: FAIL
if os == "mac": TIMEOUT

View file

@ -0,0 +1,3 @@
[canvas_colorspace_rgba16float.https.html]
expected:
if os == "linux" and not debug: PASS

View file

@ -1,6 +1,3 @@
[canvas_colorspace_rgba8unorm.https.html]
expected:
if os == "win": TIMEOUT
if os == "linux" and debug: TIMEOUT
if os == "linux" and not debug: FAIL
if os == "mac": TIMEOUT

View file

@ -1,6 +1,3 @@
[canvas_complex_bgra8unorm_copy.https.html]
expected:
if os == "win": TIMEOUT
if os == "linux" and debug: TIMEOUT
if os == "linux" and not debug: FAIL
if os == "mac": TIMEOUT

View file

@ -1,6 +1,3 @@
[canvas_complex_bgra8unorm_draw.https.html]
expected:
if os == "win": TIMEOUT
if os == "linux" and debug: TIMEOUT
if os == "linux" and not debug: FAIL
if os == "mac": TIMEOUT

View file

@ -1,6 +1,3 @@
[canvas_complex_rgba8unorm_draw.https.html]
expected:
if os == "win": TIMEOUT
if os == "linux" and debug: TIMEOUT
if os == "linux" and not debug: FAIL
if os == "mac": TIMEOUT

View file

@ -1,3 +1,3 @@
[canvas_complex_rgba8unorm_store.https.html]
expected:
if os == "linux" and not debug: [PASS, FAIL]
if os == "linux" and not debug: PASS

View file

@ -1,3 +1,3 @@
[canvas_composite_alpha_bgra8unorm_opaque_copy.https.html]
expected:
if os == "linux" and not debug: [CRASH, PASS, FAIL]
if os == "linux" and not debug: PASS

View file

@ -1,6 +1,3 @@
[canvas_composite_alpha_bgra8unorm_opaque_draw.https.html]
expected:
if os == "win": PASS
if os == "linux" and debug: PASS
if os == "linux" and not debug: [PASS, FAIL]
if os == "mac": PASS
if os == "linux" and not debug: PASS

View file

@ -1,3 +1,3 @@
[canvas_composite_alpha_bgra8unorm_premultiplied_copy.https.html]
expected:
if os == "linux" and not debug: [PASS, FAIL]
if os == "linux" and not debug: PASS

View file

@ -1,3 +1,3 @@
[canvas_composite_alpha_bgra8unorm_premultiplied_draw.https.html]
expected:
if os == "linux" and not debug: [PASS, FAIL]
if os == "linux" and not debug: PASS

View file

@ -1,3 +1,3 @@
[canvas_composite_alpha_rgba8unorm_opaque_copy.https.html]
expected:
if os == "linux" and not debug: [PASS, FAIL]
if os == "linux" and not debug: PASS

View file

@ -1,3 +1,3 @@
[canvas_composite_alpha_rgba8unorm_opaque_draw.https.html]
expected:
if os == "linux" and not debug: [PASS, FAIL]
if os == "linux" and not debug: PASS

View file

@ -1,3 +1,3 @@
[canvas_composite_alpha_rgba8unorm_premultiplied_copy.https.html]
expected:
if os == "linux" and not debug: [CRASH, FAIL]
if os == "linux" and not debug: PASS

View file

@ -1,3 +1,3 @@
[canvas_composite_alpha_rgba8unorm_premultiplied_draw.https.html]
expected:
if os == "linux" and not debug: [CRASH, PASS, FAIL]
if os == "linux" and not debug: PASS

View file

@ -1,3 +1,3 @@
[canvas_image_rendering.https.html]
expected:
if os == "linux" and not debug: [CRASH, PASS]
if os == "linux" and not debug: PASS

View file

@ -1,2 +1,3 @@
[resize_observer.https.html]
expected: TIMEOUT
expected:
if os == "linux" and not debug: TIMEOUT