Documentation
¶
Overview ¶
Package wasigpu is the guest side of wasi:webgpu (wasi:webgpu@0.3.0-rc.2) for Go programs built with GOOS=wasip1: the compute subset (adapter, device, buffers, WGSL modules, compute pipelines, bind groups, command encoders, queue, mapping). Every call lowers its arguments and lifts its result with package wit, the same Canonical ABI code the host uses; imports_wasip1.go is generated from the WIT by internal/cmd/witgen. Outside wasip1 every call fails with ErrUnavailable.
Resources are released with Drop (the WIT's resource-drop). Objects not dropped are released when the process ends.
Index ¶
- Constants
- Variables
- type Buffer
- type Device
- func (d *Device) Buffer(size uint64, usage uint32) (*Buffer, error)
- func (d *Device) ComputePipeline(wgsl, entry string) (*Pipeline, error)
- func (d *Device) Copy(src, dst *Buffer, size uint64) error
- func (d *Device) Dispatch(p *Pipeline, buffers []*Buffer, x, y, z uint32) error
- func (d *Device) Drop()
- func (d *Device) Write(b *Buffer, offset uint64, data []byte) error
- type Pipeline
Constants ¶
const ( MapRead = 1 << 0 MapWrite = 1 << 1 CopySrc = 1 << 2 CopyDst = 1 << 3 Index = 1 << 4 Vertex = 1 << 5 Uniform = 1 << 6 Storage = 1 << 7 )
Buffer usages (gpu-buffer-usage flags, in WIT order).
Variables ¶
var ErrNoAdapter = errors.New("wasi:webgpu: no adapter")
ErrNoAdapter is returned when the host offers no GPU (none there, or the container was not started with --gpu).
ErrUnavailable is returned outside GOOS=wasip1.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
Size uint64
// contains filtered or unexported fields
}
Buffer is a GPU buffer.
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device is a GPU device and its queue.
func Open ¶
Open asks for an adapter and a device: ErrNoAdapter when the host has none for this process.
func (*Device) ComputePipeline ¶
ComputePipeline compiles WGSL and makes a compute pipeline of its entry point (layout "auto").