metal

package
v0.16.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package metal provides a Metal backend for the HAL.

Metal is Apple's low-overhead, low-level graphics and compute API for macOS, iOS, iPadOS, and tvOS platforms.

Architecture

The Metal backend uses Pure Go FFI via github.com/go-webgpu/goffi to call into Apple's Metal.framework and Objective-C runtime without requiring CGO. This enables zero-CGO cross-compilation for macOS/iOS.

Key Components

  • objc.go: Objective-C runtime bindings for message passing
  • metal.go: Metal framework loader and initialization
  • types.go: Metal types, enums, and constants
  • device.go: MTLDevice wrapper
  • queue.go: MTLCommandQueue wrapper
  • buffer.go: MTLBuffer management with storage modes
  • texture.go: MTLTexture management
  • sampler.go: MTLSamplerState
  • surface.go: CAMetalLayer integration for windowed rendering
  • encoder.go: MTLCommandBuffer and MTLRenderCommandEncoder
  • pipeline.go: MTLRenderPipelineState and MTLComputePipelineState
  • bindgroup.go: Resource binding via argument buffers
  • conv.go: WebGPU to Metal type conversions
  • api.go: HAL Backend interface implementation

Storage Modes

Metal uses storage modes for memory management:

  • Shared: CPU and GPU can both access (for mappable buffers)
  • Private: GPU-only access (fastest for GPU operations)
  • Memoryless: Tile-based deferred rendering (iOS optimization)

Autorelease Pools

Metal objects returned from APIs like nextDrawable are autoreleased. This backend uses autorelease pools to manage object lifetimes correctly.

References

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL