Zero-CGO WebGPU bindings for Go — GPU-accelerated graphics and compute in pure Go
Pure Go WebGPU bindings using goffi + wgpu-native. No CGO required.
Beta — Comprehensive API ready for testing and feedback.
| Feature | Status |
|---|---|
| Instance, Adapter, Device | ✅ |
| Buffers (vertex, index, uniform, storage) | ✅ |
| Textures, Samplers, Storage Textures | ✅ |
| Render Pipelines | ✅ |
| Compute Pipelines | ✅ |
| Depth Buffer | ✅ |
| MRT (Multiple Render Targets) | ✅ |
| Instanced Rendering | ✅ |
| Indirect Drawing (GPU-driven) | ✅ |
| RenderBundle (pre-recorded commands) | ✅ |
| Cross-Platform Surface (Win/Linux/macOS) | ✅ |
| Error Handling (error scopes) | ✅ |
| QuerySet (GPU timestamps) | ✅ |
| BindGroupLayout (explicit) | ✅ |
| 3D Math (Mat4, Vec3) | ✅ |
- Go 1.25+
- wgpu-native v24.0.3.1 (download)
go get github.com/go-webgpu/webgpuDownload wgpu-native and place wgpu_native.dll (Windows) or libwgpu_native.so (Linux) in your project directory or system PATH.
package main
import (
"fmt"
"log"
"github.com/go-webgpu/webgpu/wgpu"
)
func main() {
// Initialize library
if err := wgpu.Init(); err != nil {
log.Fatal(err)
}
// Create WebGPU instance
instance, err := wgpu.CreateInstance(nil)
if err != nil {
log.Fatal(err)
}
defer instance.Release()
// Request GPU adapter
adapter, err := instance.RequestAdapter(nil)
if err != nil {
log.Fatal(err)
}
defer adapter.Release()
fmt.Printf("Adapter: %#x\n", adapter.Handle())
}| Example | Description |
|---|---|
| triangle | Basic triangle rendering |
| colored-triangle | Vertex colors and buffers |
| textured-quad | Textures, samplers, index buffers |
| rotating-triangle | Uniform buffers, animation |
| cube | 3D rendering with depth buffer |
| instanced | Instanced rendering (25 objects in 1 draw call) |
| compute | Compute shader parallel processing |
| indirect | GPU-driven rendering (DrawIndirect) |
| render_bundle | Pre-recorded draw commands |
| timestamp_query | GPU profiling with timestamps |
| mrt | Multiple Render Targets |
| error_handling | Error scopes API |
Run examples:
cd examples/triangle && go run .┌─────────────────────────────────────────┐
│ Your Go Application │
├─────────────────────────────────────────┤
│ go-webgpu (this package) │
│ - Zero CGO │
│ - Pure Go FFI via goffi │
├─────────────────────────────────────────┤
│ wgpu-native (Rust WebGPU) │
├─────────────────────────────────────────┤
│ Vulkan / Metal / DX12 / OpenGL │
└─────────────────────────────────────────┘
- goffi — Pure Go FFI for callbacks
- wgpu-native — Rust WebGPU implementation
- golang.org/x/sys — Platform-specific syscalls
MIT
Contributions welcome! Please open an issue or PR.