opencode/packages/widget/test/fixtures/gpu/error-destroyed-buffer.json
OpenCode Agent 0786c7331c feat(core): widget.gpu, the WebGPU subset for live widgets, with host checks and conformance fixtures
The prelude records WebGPU's API (devices, contexts by canvas key, resources, pipelines, bind
groups, command encoders and passes) into batches of ops and bytes with prelude-assigned handles
and every default filled in; batches ride frame requests, or go before other waits and at the
end. device.lost, unavailable GPUs and encoder misuse (error ops) are handled.
The TypeScript host (LiveWidget) passes { available, format } in the live input and checks
batches without a GPU: op shapes, handles and limits, with exact messages; an error stops the
canvases its batch renders into, else all. GPU batches never overtake waiting renders or draws.
widgets-gpu.md gains the normalised op shapes, the host checks and the conformance driver;
test/fixtures/gpu holds 34 fixtures, among them four example widget templates (a lit cube, a
textured quad, post-processing, a first-person maze).
2026-11-22 23:51:45 +00:00

34 lines
1.3 KiB
JSON

{
"name": "error-destroyed-buffer",
"source": "async function main() {\n widget.render(ui.column([ui.canvas({ key: \"scene\", gpu: true, height: 100 })]))\n const device = await widget.gpu.requestDevice()\n const format = widget.gpu.getPreferredCanvasFormat()\n const contexts = {}\n for (const key of [\"scene\"]) {\n contexts[key] = widget.gpu.getContext(key)\n contexts[key].configure({ device, format })\n }\n const view = (key) => contexts[key].getCurrentTexture().createView()\n const clear = (key) => ({ colorAttachments: [{ view: view(key), loadOp: \"clear\", storeOp: \"store\" }] })\n\n const buffer = device.createBuffer({ size: 16, usage: GPUBufferUsage.COPY_DST })\n buffer.destroy()\n device.queue.writeBuffer(buffer, 0, new Float32Array(4))\n await widget.frame()\n}",
"canvases": [
{
"key": "scene",
"width": 200,
"height": 200
}
],
"gpu": {
"available": true,
"format": "rgba8unorm"
},
"errors": [
{
"message": "gpu op 3: handle 2 was destroyed",
"canvases": "all"
}
],
"end": "return",
"batches": [
{
"frame": true,
"bytes": "AAAAAAAAAAAAAAAAAAAAAA==",
"ops": [
["context",1,"scene","rgba8unorm","opaque"],
["buffer",2,16,8],
["destroy",2],
["writeBuffer",2,0,0,16]
]
}
]
}