Last updated: 2026-09-07

Metal Runtime

Metal Device

All API Sections

Metal device wrapper — macOS Apple Silicon GPU backend.

This module owns Metal device initialization and capability queries used by the loader, diagnostics, and Metal inference runtime.

3 exports 10 methods src/metal/device.zig

3 exports shown

enum

GpuFamily

#
pub const GpuFamily = enum(u32)

Public Apple GPU family buckets exposed by the Metal shim.

src/metal/device.zig:10

Methods

2

method

GpuFamily.isApple9OrNewer

#
pub fn isApple9OrNewer(self: @This()) bool

Return whether the device is Apple9-class or newer.

src/metal/device.zig:18

method

GpuFamily.isM5Class

#
pub fn isM5Class(self: @This()) bool

Return whether the device should be treated as M5-class for tuning.

src/metal/device.zig:26

struct

MetalCapabilities

#
pub const MetalCapabilities = struct

Capability snapshot queried once from the active Metal device.

src/metal/device.zig:32

struct

MetalDevice

#
pub const MetalDevice = struct

Active Metal device wrapper plus capability metadata used by the backend.

src/metal/device.zig:45

Methods

8

method

MetalDevice.init

#
pub fn init(allocator: std.mem.Allocator, _: u32) !MetalDevice

Initialize the system-default Metal device and query its public capabilities.

src/metal/device.zig:53

method

MetalDevice.deinit

#
pub fn deinit(self: *MetalDevice) void

Destroy the active Metal device context.

src/metal/device.zig:83

method

MetalDevice.maxBufferSize

#
pub fn maxBufferSize(self: *const MetalDevice) u64

Return the largest single Metal buffer size reported by the driver.

src/metal/device.zig:91

method

MetalDevice.totalMemory

#
pub fn totalMemory(self: *const MetalDevice) u64

Return the total unified memory size reported for the active device.

src/metal/device.zig:97

method

MetalDevice.maxThreadgroupMemoryLength

#
pub fn maxThreadgroupMemoryLength(self: *const MetalDevice) u64

Return the per-threadgroup shared-memory limit reported by Metal.

src/metal/device.zig:108

method

MetalDevice.hasUnifiedMemory

#
pub fn hasUnifiedMemory(self: *const MetalDevice) bool

Return whether the active device exposes unified CPU/GPU memory.

src/metal/device.zig:113

method

MetalDevice.supportsRaytracing

#
pub fn supportsRaytracing(self: *const MetalDevice) bool

Return whether the active device reports public raytracing support.

src/metal/device.zig:118