WebGPU type definitions for the gogpu ecosystem.
gputypes provides all WebGPU enums, structs, and constants as pure Go types with zero dependencies. It serves as the single source of truth for WebGPU types across the entire ecosystem.
go get github.com/gogpu/gputypesRequires: Go 1.25+
Without a shared types package, each project defines its own types:
// Different projects, incompatible types!
wgpu.TextureFormat // wgpu's type
webgpu.TextureFormat // go-webgpu's type
born.TextureFormat // born-ml's type
// User must convert everywhere - painful!
format := wgpu.TextureFormat(webgpuFormat)With gputypes, all projects use the same types:
import "github.com/gogpu/gputypes"
// All projects use gputypes.TextureFormat
// Types are directly compatible - no conversion needed! gputypes (ZERO deps)
All WebGPU types (100+)
│
┌─────────────────┼─────────────────┐
│ │ │
▼ ▼ ▼
gpucontext wgpu go-webgpu/webgpu
(imports gputypes) (imports) (imports)
│ │ │
└────────┬────────┴────────┬────────┘
│ │
▼ ▼
gogpu born-ml
Based on WebGPU spec and wgpu-types:
TextureFormat(97 formats including BC, ETC2, ASTC compressed)TextureUsage,TextureDimension,TextureViewDimension,TextureAspectTextureDescriptor,TextureViewDescriptor,TextureSampleTypeAddressMode,FilterMode,MipmapFilterMode,CompareFunctionSamplerDescriptor,SamplerBindingType
BufferUsage,BufferBindingType,BufferMapState,MapModeBufferDescriptor,IndexFormatBindGroupLayoutEntry,BindGroupEntry,BindingResourceBufferBindingLayout,SamplerBindingLayout,TextureBindingLayoutStorageTextureBindingLayout,PipelineLayoutDescriptor
ShaderStageflags (Vertex, Fragment, Compute)ShaderModuleDescriptor,ShaderSource(WGSL, SPIR-V, GLSL)ProgrammableStage
PrimitiveTopology,FrontFace,CullMode,PrimitiveStateBlendState,BlendFactor,BlendOperation,BlendComponentDepthStencilState,StencilOperation,StencilFaceStateMultisampleState,ColorTargetState,ColorWriteMask
VertexFormat(31 formats)VertexStepMode,VertexAttribute,VertexBufferLayoutVertexState,FragmentState
LoadOp,StoreOpRenderPassColorAttachment,RenderPassDepthStencilAttachmentRenderPassDescriptor
DeviceType,Backend,BackendsAdapterInfo,PowerPreference,MemoryHintsDeviceDescriptor,RequestAdapterOptionsInstanceDescriptor,InstanceFlagsDx12ShaderCompiler,GLBackend
Limitsstruct with all WebGPU limits (30+ fields)Featuresflags (20 optional capabilities)DefaultLimits(),DownlevelLimits()helpers
PresentMode(AutoVsync, Fifo, Immediate, Mailbox)CompositeAlphaMode(Auto, Opaque, PreMultiplied, etc.)SurfaceConfiguration,SurfaceCapabilities,SurfaceStatus
ImageSubresourceRange(for partial texture operations)TextureDataLayout,ImageCopyTexture
Extent3D,Origin3DColor(RGBA float64) with predefined colors
| Package | Purpose | Dependencies |
|---|---|---|
gputypes |
Data types (enums, structs, constants) | ZERO |
gpucontext |
Interfaces (DeviceProvider, EventSource, Texture) | imports gputypes |
| Aspect | gputypes | gpucontext |
|---|---|---|
| Responsibility | Data definitions | Behavioral contracts |
| Change frequency | Rare (WebGPU spec is stable) | Medium (API evolution) |
| Size | Large (100+ types) | Small (10-15 interfaces) |
Principle: Separation of data types from behavioral interfaces.
Interfaces need types in their signatures:
// gpucontext needs gputypes for type-safe interfaces
type DeviceProvider interface {
SurfaceFormat() gputypes.TextureFormat // ← uses gputypes
}
type Texture interface {
Format() gputypes.TextureFormat // ← uses gputypes
}This ensures type compatibility across all implementations.
| Package | Description | Uses gputypes |
|---|---|---|
| gogpu/gogpu | Graphics framework | ✅ |
| gogpu/wgpu | Pure Go WebGPU | ✅ |
| gogpu/gg | 2D graphics library | ✅ (via gpucontext) |
| gogpu/gpucontext | Shared interfaces | ✅ (imports) |
| go-webgpu/webgpu | Rust FFI bindings | ✅ |
| born-ml/born | ML framework | ✅ |
| Rust | Go (gogpu) | Purpose |
|---|---|---|
wgpu-types |
gputypes |
WebGPU type definitions |
| — | gpucontext |
Integration interfaces (Go-specific) |
wgpu-core |
wgpu/core |
WebGPU implementation |
wgpu-hal |
wgpu/hal |
Hardware abstraction |
Current: v0.1.0
Roadmap:
- v0.1.0 — Core types (TextureFormat, BufferUsage, etc.) DONE
- v0.2.0 — Full WebGPU spec coverage (remaining descriptor types)
- v1.0.0 — Stable API matching WebGPU spec
MIT License — see LICENSE for details.
Part of the gogpu ecosystem — Pure Go GPU Computing.