mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-26 23:28:43 +00:00
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).
34 lines
1.4 KiB
JSON
34 lines
1.4 KiB
JSON
{
|
|
"name": "error-encoder-finished",
|
|
"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 encoder = device.createCommandEncoder()\n const buffer = encoder.finish()\n encoder.beginRenderPass(clear(\"scene\")).end()\n device.queue.submit([buffer])\n await widget.frame()\n}",
|
|
"canvases": [
|
|
{
|
|
"key": "scene",
|
|
"width": 200,
|
|
"height": 200
|
|
}
|
|
],
|
|
"gpu": {
|
|
"available": true,
|
|
"format": "rgba8unorm"
|
|
},
|
|
"errors": [
|
|
{
|
|
"message": "gpu op 2: the command encoder is finished",
|
|
"canvases": "all"
|
|
}
|
|
],
|
|
"end": "return",
|
|
"batches": [
|
|
{
|
|
"frame": true,
|
|
"bytes": "",
|
|
"ops": [
|
|
["context",1,"scene","rgba8unorm","opaque"],
|
|
["view",2,1,{"dimension":"2d","baseMipLevel":0,"mipLevelCount":1,"baseArrayLayer":0,"arrayLayerCount":1}],
|
|
["error","the command encoder is finished"],
|
|
["submit"]
|
|
]
|
|
}
|
|
]
|
|
}
|