Documentation
¶
Overview ¶
Package wire is the format of the batched command stream a webgpu.Recorder writes and replay.js executes: opcodes, argument layout, and the Go reader that mirrors replay.js.
It is portable (no GOOS constraint) so that a stream can be carried outside the browser that recorded it — for example from a virtual machine's guest to a host over a virtio-gpu context — and checked and remapped there by the one implementation of the format, instead of a copy. The Recorder (package webgpu) is the only writer; replay.js and Decode are the readers, and the package tests keep them in agreement.
A stream is a []uint32 of commands plus a data []byte that writeBuffer commands point into. Object arguments are ids: indices of a table the replayer holds (replay.js's object table, or a remote host's).
Index ¶
Constants ¶
const ( MaxColorAttachments = 8 MaxDynamicOffsets = 1 << 16 MaxBundles = 1 << 16 )
Limits the readers enforce on counts inside one command.
const StreamVersion = 1
StreamVersion is the version of this format. It changes whenever an opcode's layout changes, so that a remote host and its guests can check they speak the same stream.
Variables ¶
This section is empty.
Functions ¶
func Remap ¶
Remap rewrites, in place, every object id of a stream through f, which returns the replacement and whether the id is valid. Id 0 where the format allows "none" is left alone and not passed to f. Remap checks the stream exactly as Decode does; on error the words are partly rewritten and must be discarded.
A transport uses it to translate ids from the namespace of the program that recorded the stream to the table of the replayer: an id f does not know is an error, so a stream can only name objects f grants.
Types ¶
type Op ¶
type Op uint32
Op is a command's opcode, the first word of a command.
const ( SetPipeline Op = 1 // id SetBindGroup Op = 2 // index id n offsets[n] (id 0: unbind) Draw Op = 3 // vertexCount instanceCount firstVertex firstInstance DrawIndexed Op = 4 // indexCount instanceCount firstIndex baseVertex(int32) firstInstance SetVertexBuffer Op = 5 // slot id offset(2) size(2) SetIndexBuffer Op = 6 // id format offset(2) size(2) SetViewport Op = 7 // x y w h minDepth maxDepth (float32 bits) SetScissorRect Op = 8 // x y w h SetBlendConstant Op = 9 // r g b a (float32 bits) SetStencilReference Op = 10 // ref ExecuteBundles Op = 11 // n ids[n] DrawIndirect Op = 12 // id offset(2) DrawIndexedIndirect Op = 13 // id offset(2) BeginRenderPass Op = 20 // nColors, 8 words per color, depth flag, 9 depth words if 1 EndPass Op = 21 BeginComputePass Op = 22 Dispatch Op = 23 // x y z DispatchIndirect Op = 24 // id offset(2) WriteBuffer Op = 30 // id offset(2) dataOffset length CopyBufferToBuffer Op = 31 // src srcOffset(2) dst dstOffset(2) size(2) Submit Op = 40 )
Opcodes; after each, the words that follow it. (2) is a uint64 as low, high words.