Skip to content

Class MetalDevice

Namespace: Apogee.Graphics.Metal
Assembly: Apogee.Graphics.dll

The Metal implementation of (macOS 15 and later, on a GPU with Metal 3 and tier 2 argument buffers: Apple silicon and the Intel Macs of 2017 and later). It owns one command queue and a residency set: everything the GPU reaches through an address or an argument buffer must be resident, so every buffer and texture is added to the set when it is made.

public sealed class MetalDevice : GraphicsDevice, IDisposable

Inheritance

object ← GraphicsDevice ← MetalDevice

Implements

IDisposable

Inherited Members

GraphicsDevice.Backend, GraphicsDevice.ShaderBackend, GraphicsDevice.Name, GraphicsDevice.Kind, GraphicsDevice.Immediate, GraphicsDevice.Bindless, GraphicsDevice.TimestampPeriod, GraphicsDevice.SupportsTimestamps, GraphicsDevice.MinUniformBufferOffsetAlignment, GraphicsDevice.MaxSamplerAnisotropy, GraphicsDevice.SupportsBc, GraphicsDevice.SupportsAstc, GraphicsDevice.SupportsAnisotropy, GraphicsDevice.SupportsDrawIndirectCount, GraphicsDevice.SupportsSamplerFilterMinMax, GraphicsDevice.ValidationErrorCount, GraphicsDevice.TakeValidationErrors(), GraphicsDevice.DefaultBackend, GraphicsDevice.RequiredWindowOptions(GraphicsBackend?), GraphicsDevice.Create(GraphicsDeviceOptions?), GraphicsDevice.TryCreate(GraphicsDeviceOptions?, out GraphicsDevice?, out string?), GraphicsDevice.EnumerateDevices(GraphicsDeviceOptions?), GraphicsDevice.CreateBuffer(ulong, BufferUsage, MemoryKind, string?), GraphicsDevice.CreateImage(in ImageDescription, string?), GraphicsDevice.CreateSampler(in SamplerDescription, string?), GraphicsDevice.CreateComputePipeline(in ShaderCode, string?), GraphicsDevice.CreateGraphicsPipeline(GraphicsPipelineDescription, string?), GraphicsDevice.CreateSwapchain(bool), GraphicsDevice.CreateFrameLoop(Swapchain?, int, int), GraphicsDevice.WaitIdle(), GraphicsDevice.Dispose(), GraphicsDevice.CreateBuffer(ReadOnlySpan<byte>, BufferUsage, string?), GraphicsDevice.UploadBuffer(GpuBuffer, ReadOnlySpan<byte>, ulong), GraphicsDevice.UploadImage(GpuImage, ReadOnlySpan<byte>, ReadOnlySpan<ImageRegion>, ImageState), GraphicsDevice.ReadBuffer(GpuBuffer, ulong, int), GraphicsDevice.ReadImage(GpuImage, ImageState, uint, uint), object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Properties

Backend

public override GraphicsBackend Backend { get; }

Property Value

GraphicsBackend

Kind

public override GpuKind Kind { get; }

Property Value

GpuKind

MaxSamplerAnisotropy

public override float MaxSamplerAnisotropy { get; }

Property Value

float

MetalBindless

The bindless heap as a Metal one: the argument buffer.

public MetalBindlessHeap MetalBindless { get; }

Property Value

MetalBindlessHeap

MinUniformBufferOffsetAlignment

Constant buffers are bound at offsets that are a multiple of this on macOS.

public override ulong MinUniformBufferOffsetAlignment { get; }

Property Value

ulong

Name

public override string Name { get; }

Property Value

string

ShaderBackend

The kind of shader code this device runs: pass it to .

public override ShaderBackend ShaderBackend { get; }

Property Value

ShaderBackend

SupportsAnisotropy

public override bool SupportsAnisotropy { get; }

Property Value

bool

SupportsAstc

ASTC LDR textures can be sampled (mobile and Apple GPUs).

public override bool SupportsAstc { get; }

Property Value

bool

SupportsBc

BC1-7 textures can be sampled (desktop GPUs); otherwise transcode Basis textures to ASTC or RGBA8.

public override bool SupportsBc { get; }

Property Value

bool

SupportsDrawIndirectCount

works: the GPU decides how many draws to make (Vulkan's optional drawIndirectCount). Metal has no such draw; use with a maximum count instead.

public override bool SupportsDrawIndirectCount { get; }

Property Value

bool

SupportsSamplerFilterMinMax

Samplers can return the minimum or maximum of their footprint (): a Hi-Z pyramid can be built with a single sample per texel. Metal has none; a shader takes the four texels itself.

public override bool SupportsSamplerFilterMinMax { get; }

Property Value

bool

SupportsTimestamps

The queue writes timestamps (all of graphics and compute can).

public override bool SupportsTimestamps { get; }

Property Value

bool

TimestampPeriod

Nanoseconds per timestamp tick, for GPU timings.

public override float TimestampPeriod { get; }

Property Value

float

ValidationErrorCount

How many warnings and errors the API's validation layer has reported; tests fail on any.

public override int ValidationErrorCount { get; }

Property Value

int

Methods

CreateBuffer(ulong, BufferUsage, MemoryKind, string?)

public override GpuBuffer CreateBuffer(ulong size, BufferUsage usage, MemoryKind kind = MemoryKind.DeviceLocal, string? name = null)

Parameters

size ulong

usage BufferUsage

kind MemoryKind

name string?

Returns

GpuBuffer

CreateComputePipeline(in ShaderCode, string?)

public override Pipeline CreateComputePipeline(in ShaderCode shader, string? name = null)

Parameters

shader ShaderCode

name string?

Returns

Pipeline

CreateFrameLoop(Swapchain?, int, int)

The loop that records and submits frames, to swapchain or headless.

public override FrameLoop CreateFrameLoop(Swapchain? swapchain = null, int framesInFlight = 2, int arenaBytes = 4194304)

Parameters

swapchain Swapchain?

framesInFlight int

arenaBytes int

Returns

FrameLoop

CreateGraphicsPipeline(GraphicsPipelineDescription, string?)

public override Pipeline CreateGraphicsPipeline(GraphicsPipelineDescription description, string? name = null)

Parameters

description GraphicsPipelineDescription

name string?

Returns

Pipeline

CreateImage(in ImageDescription, string?)

public override GpuImage CreateImage(in ImageDescription description, string? name = null)

Parameters

description ImageDescription

name string?

Returns

GpuImage

CreateSampler(in SamplerDescription, string?)

public override GpuSampler CreateSampler(in SamplerDescription description, string? name = null)

Parameters

description SamplerDescription

name string?

Returns

GpuSampler

CreateSwapchain(bool)

A swapchain for the window the device was created for ().

public override Swapchain CreateSwapchain(bool vsync = true)

Parameters

vsync bool

Returns

Swapchain

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public override void Dispose()

TakeValidationErrors()

Takes the validation messages reported so far.

public override string[] TakeValidationErrors()

Returns

string[]

WaitIdle()

public override void WaitIdle()