Skip to content

v0.21.0

Choose a tag to compare

@kolkov kolkov released this 15 Jun 17:36

GPU Handles: Interface → Struct Tokens (BREAKING)

Device, Queue, Adapter, Surface, Instance changed from interfaces to opaque struct tokens wrapping unsafe.Pointer.

Why

v0.20.0 used unexported sentinel methods on interfaces, but Go spec prohibits cross-package satisfaction of interfaces with unexported methods. *wgpu.Device could never implement gpucontext.Device — build broke in gogpu/gg/ui. v0.20.0 is yanked.

New Pattern

Same as existing TextureView and CommandEncoder (ADR-018):

  • 8 bytes, value type, zero allocations
  • GC-safe: unsafe.Pointer in struct fields is traced by GC (reflect.Value precedent)
  • Compile-time type distinct: DeviceQueueAdapter

Migration

// Before (v0.19.0):
dev := provider.Device()           // interface
wgpuDev := dev.(*wgpu.Device)      // type assertion

// After (v0.21.0):
dev := provider.Device()           // struct
wgpuDev := (*wgpu.Device)(dev.Pointer())  // unsafe.Pointer extraction

// Nil check: dev != nil → !dev.IsNil()

Full Changelog: v0.20.0...v0.21.0