Skip to main content

Module gpu

Module gpu 

Source
Expand description

Wire format of the 0x1 GPU API (“sg-gpu v1”).

The guest (a sandboxed wasm module) never holds a GPU object. It holds Ids that index a per-game table in the host. Requests are postcard-encoded Req values passed to the sg.gpu_call import; the host validates every field and replies with a postcard-encoded Reply. Command encoders are recorded entirely on the guest side and sent as one Req::CreateCommandBuffer when finished, so a frame costs a handful of host calls, not thousands.

Bulk data (buffer/texture uploads, mapped-range reads/writes) bypasses the serializer through dedicated imports; see sg-guest::sys.

The descriptor structs embed wgpu-types 30 types. Their postcard encoding is part of this wire format, so the protocol version must be bumped if the pinned wgpu-types version changes in a layout-affecting way.

Modules§

error_kind
Error kinds, matching wgpu::ErrorFilter order.
frame_controls
Req::FrameControls replies.
surface_status
Surface acquisition status, matching wgpu::SurfaceStatus semantics.

Structs§

AdapterDesc
BindGroupEntry
BlasBuild
BlasTriangles
BufferBinding
ColorAttachment
CompilationMessage
ComputePipelineDesc
DepthStencilAttachment
ErrorInfo
FrameControls
Inputs a game gives the host’s frame pass for the next presented frame.
MeshPipelineDesc
ProgrammableStage
RenderBundleEncoderDesc
RenderPassDesc
RenderPipelineDesc
SurfaceCaps
TexelCopyBufferInfo
TimestampWrites
TlasBuild
TlasInstance
VertexBufferLayout
WriteTexture
Write to a texture from guest memory (the data travels separately).

Enums§

Cmd
ComputeCmd
Event
RenderCmd
Commands shared by render passes and render bundles.
Reply
Req
Resource

Constants§

MIN_VERSION
The oldest guest protocol a host accepts.
VERSION
Bumped on any incompatible change to the types below. v2 added Req::FrameControls; hosts still accept v1 guests (which never send it).

Functions§

decode
encode

Type Aliases§

Id
A host object handle. 0 is never a valid handle and encodes “none”.
Label
TexelCopyTextureInfo