mps-rs
Safe Rust bindings for Apple's
MetalPerformanceShaders
framework on macOS.
The GitHub repository is mps-rs; the published crates.io package is
apple-mps because the mps-rs package name is already taken.
Install
Quick start
use MetalDevice;
use ;
let device = system_default.expect;
let queue = device.new_command_queue.expect;
let descriptor = new;
let src = new.expect;
let dst = new.expect;
let blur = new.expect;
let command_buffer = queue.new_command_buffer.expect;
blur.encode_image;
v0.2.1 surface
- Core helpers:
supports_mtl_device,preferred_device,hint_temporary_memory_high_water_mark,set_heap_cache_durationPredicateandMpsCommandBuffer
- Images:
ImageDescriptor+Imagefor lazily allocated MPS images or texture-backed images- Float32 image read/write helpers plus raw byte transfer with
MPSDataLayout - Unary image filters:
ImageGaussianBlurImageBoxImageSobelImageMedianImageConvolutionImageBilinearScaleImageLanczosScaleImageThresholdBinaryImageStatisticsMinAndMaxImageStatisticsMeanImageReduceRowMin,ImageReduceRowMax,ImageReduceRowMean,ImageReduceRowSum
ImageHistogram,ImageAdd, andImageScaleAndAdd
- Matrix/vector:
MatrixDescriptor,VectorDescriptor,MatrixMultiplicationDescriptor,Matrix,Vector, andMatrixMultiplication
NDArray:NDArrayDescriptor,NDArray,NDArrayIdentity, andNDArrayMatrixMultiplication
- State:
State,StateResourceList,StateTextureInfostate_batch_increment_read_count,state_batch_resource_size,state_batch_synchronize
- Ray tracing / denoising:
PolygonAccelerationStructure,RayIntersector, andSVGF
- Neural / optimizer / RNN:
NNImageNode,NNGraphCnnNeuronReluNode,CnnPoolingMaxNode,CnnSoftMaxNode,CnnUpsamplingNearestNodeCnnConvolutionDescriptor,CnnConvolution,CnnConvolutionWeightsAndBiasesStateNNOptimizerDescriptor,NNOptimizer,NNOptimizerStochasticGradientDescent,NNOptimizerRmsProp,NNOptimizerAdamRnnDescriptor,RnnSingleGateDescriptor,GruDescriptor,LstmDescriptor,RnnImageInferenceLayer,RnnRecurrentImageState
- Shared constants for
MPSKernelOptions,MPSImageEdgeMode,MPSImageFeatureChannelFormat,MPSDataType,MPSDataLayout, plus convolution / optimizer / RNN / state enums
See COVERAGE.md for the Wave-C audit and the implemented/partial matrix.
Validation