Table of Contents

Class MetalCommandEncoder

Namespace
DotCompute.Backends.Metal.Execution
Assembly
DotCompute.Backends.Metal.dll

High-level Metal command encoder abstraction for compute operations, providing a simplified interface over native Metal compute command encoders.

public sealed class MetalCommandEncoder : IDisposable
Inheritance
MetalCommandEncoder
Implements
Inherited Members
Extension Methods

Constructors

MetalCommandEncoder(nint, ILogger<MetalCommandEncoder>)

public MetalCommandEncoder(nint commandBuffer, ILogger<MetalCommandEncoder> logger)

Parameters

commandBuffer nint
logger ILogger<MetalCommandEncoder>

Properties

EncoderHandle

Gets the native encoder handle

public nint EncoderHandle { get; }

Property Value

nint

IsEncodingEnded

Gets whether encoding has been ended

public bool IsEncodingEnded { get; }

Property Value

bool

Methods

DispatchThreadgroups(MetalDispatchSize, MetalDispatchSize)

Dispatches threadgroups for compute execution

public void DispatchThreadgroups(MetalDispatchSize gridSize, MetalDispatchSize threadgroupSize)

Parameters

gridSize MetalDispatchSize
threadgroupSize MetalDispatchSize

DispatchThreadgroups1D(int, int)

Dispatches threadgroups with 1D configuration

public void DispatchThreadgroups1D(int gridWidth, int threadgroupWidth)

Parameters

gridWidth int
threadgroupWidth int

DispatchThreadgroups2D(int, int, int, int)

Dispatches threadgroups with 2D configuration

public void DispatchThreadgroups2D(int gridWidth, int gridHeight, int threadgroupWidth, int threadgroupHeight)

Parameters

gridWidth int
gridHeight int
threadgroupWidth int
threadgroupHeight int

Dispose()

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

public void Dispose()

EndEncoding()

Ends encoding and finalizes the command encoder

public void EndEncoding()

~MetalCommandEncoder()

protected ~MetalCommandEncoder()

GetCommandHistory()

Gets detailed information about all encoded commands

public IReadOnlyList<MetalEncoderCommand> GetCommandHistory()

Returns

IReadOnlyList<MetalEncoderCommand>

GetEncodingStats()

Gets a summary of all commands encoded

public MetalEncodingStats GetEncodingStats()

Returns

MetalEncodingStats

SetBuffer(nint, nuint, int)

Binds a buffer to the specified index

public void SetBuffer(nint buffer, nuint offset, int index)

Parameters

buffer nint
offset nuint
index int

SetBytes(ReadOnlySpan<byte>, int)

Sets constant data from a byte array

public void SetBytes(ReadOnlySpan<byte> data, int index)

Parameters

data ReadOnlySpan<byte>
index int

SetBytes<T>(T, int)

Sets constant data at the specified index

public void SetBytes<T>(T data, int index) where T : unmanaged

Parameters

data T
index int

Type Parameters

T

SetComputePipelineState(nint)

Sets the compute pipeline state for subsequent operations

public void SetComputePipelineState(nint pipelineState)

Parameters

pipelineState nint