diff options
Diffstat (limited to 'dom/webgpu/tests/cts/checkout/src/webgpu/web_platform/reftests/canvas_clear.html.ts')
-rw-r--r-- | dom/webgpu/tests/cts/checkout/src/webgpu/web_platform/reftests/canvas_clear.html.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/dom/webgpu/tests/cts/checkout/src/webgpu/web_platform/reftests/canvas_clear.html.ts b/dom/webgpu/tests/cts/checkout/src/webgpu/web_platform/reftests/canvas_clear.html.ts new file mode 100644 index 0000000000..c4ffef79a4 --- /dev/null +++ b/dom/webgpu/tests/cts/checkout/src/webgpu/web_platform/reftests/canvas_clear.html.ts @@ -0,0 +1,34 @@ +import { runRefTest } from './gpu_ref_test.js'; + +runRefTest(async t => { + function draw(canvasId: string, format: GPUTextureFormat) { + const canvas = document.getElementById(canvasId) as HTMLCanvasElement; + + const ctx = (canvas.getContext('webgpu') as unknown) as GPUCanvasContext; + ctx.configure({ + device: t.device, + format, + }); + + const colorAttachment = ctx.getCurrentTexture(); + const colorAttachmentView = colorAttachment.createView(); + + const encoder = t.device.createCommandEncoder(); + const pass = encoder.beginRenderPass({ + colorAttachments: [ + { + view: colorAttachmentView, + clearValue: { r: 0.4, g: 1.0, b: 0.0, a: 1.0 }, + loadOp: 'clear', + storeOp: 'store', + }, + ], + }); + pass.end(); + t.device.queue.submit([encoder.finish()]); + } + + draw('cvs0', 'bgra8unorm'); + draw('cvs1', 'rgba8unorm'); + draw('cvs2', 'rgba16float'); +}); |