Metal.NET
1.3.1
See the version list below for details.
dotnet add package Metal.NET --version 1.3.1
NuGet\Install-Package Metal.NET -Version 1.3.1
<PackageReference Include="Metal.NET" Version="1.3.1" />
<PackageVersion Include="Metal.NET" Version="1.3.1" />
<PackageReference Include="Metal.NET" />
paket add Metal.NET --version 1.3.1
#r "nuget: Metal.NET, 1.3.1"
#:package Metal.NET@1.3.1
#addin nuget:?package=Metal.NET&version=1.3.1
#tool nuget:?package=Metal.NET&version=1.3.1
Metal.NET
C# bindings for Apple's Metal graphics API, auto-generated from metal-cpp headers.
Installation
dotnet add package Metal.NET
Requirements: .NET 10+, macOS 15+
Quick Start
using Metal.NET;
MTLDevice device = MTLDevice.CreateSystemDefaultDevice();
using MTLCommandQueue queue = device.NewCommandQueue();
using MTLLibrary library = device.NewDefaultLibrary();
Memory Management
Every NativeObject wrapper has a NativeObjectOwnership that controls its lifetime:
| Ownership | Dispose() releases |
Finalizer releases | Usage |
|---|---|---|---|
Borrowed |
✗ | ✗ | Property getters, objectAtIndex: |
Owned |
✓ | ✗ | Method return values, out NSError |
Managed |
✓ | ✓ | Objects created via parameterless constructor (AllocInit) |
// Managed
var desc = new MTLTextureDescriptor();
// Owned
using MTLLibrary library = device.NewDefaultLibrary();
// Borrowed
MTLDevice device = commandQueue.Device;
Project Structure
Metal.NET.slnx
├── Metal.NET/
│ ├── Common/
│ │ ├── NativeObject.cs
│ │ ├── ObjectiveC.cs ← Auto-generated P/Invoke to libobjc (objc_msgSend)
│ │ ├── Selector.cs
│ │ └── Bool8.cs
│ ├── CoreGraphics/
│ │ └── CGColorSpace.cs
│ ├── Foundation/
│ │ ├── NSObject.cs
│ │ ├── NSString.cs
│ │ ├── NSError.cs
│ │ ├── NSArray.cs
│ │ ├── NSURL.cs
│ │ ├── NSDictionary.cs
│ │ ├── NSNumber.cs
│ │ ├── NSData.cs
│ │ ├── NSBundle.cs
│ │ ├── NSAutoreleasePool.cs
│ │ └── NSEnums.cs ← Auto-generated
│ ├── GCD/
│ │ ├── DispatchObject.cs
│ │ ├── DispatchData.cs
│ │ └── DispatchQueue.cs
│ ├── Metal/ ← Auto-generated (231 files)
│ ├── MetalFX/ ← Auto-generated (18 files)
│ └── QuartzCore/ ← Auto-generated (2 files)
│
└── Metal.NET.Generator/
├── Program.cs
├── Generator.cs
├── CppParser.cs
├── CSharpEmitter.cs
├── TypeMapper.cs
├── GeneratorContext.cs
├── Models.cs
└── metal-cpp/
Updating Bindings
Download the latest metal-cpp archive.
Replace the contents of
Metal.NET.Generator/metal-cpp/.Run the generator:
dotnet run --project Metal.NET.GeneratorBuild and verify:
dotnet build Metal.NET
Disclaimer
This library was built with AI assistance. It has undergone preliminary testing to verify basic usability, but has not been exhaustively validated in production scenarios. If you plan to use it in a real project, please ensure it meets your requirements through thorough testing.
Alternatives
License
This project is licensed under the MIT License.
Trademarks
"Metal" is a trademark of Apple Inc. This project is not affiliated with or endorsed by Apple Inc.
Third-Party Notices
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Metal.NET:
| Package | Downloads |
|---|---|
|
Zenith.NET.Metal
Zenith.NET is a modern, cross-platform graphics and compute library for .NET. It provides a unified GPU programming interface supporting DirectX12, Metal, and Vulkan backends. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.3.0 | 152 | 3/31/2026 |
| 2.2.1 | 101 | 3/29/2026 |
| 2.2.0 | 90 | 3/20/2026 |
| 2.1.0 | 92 | 3/18/2026 |
| 2.0.1 | 89 | 3/17/2026 |
| 2.0.0 | 95 | 3/17/2026 |
| 1.4.2 | 99 | 3/13/2026 |
| 1.4.1 | 94 | 3/13/2026 |
| 1.4.0 | 102 | 3/11/2026 |
| 1.3.1 | 99 | 3/5/2026 |
| 1.3.0 | 90 | 3/5/2026 |
| 1.2.0 | 94 | 3/3/2026 |
| 1.1.0 | 94 | 2/25/2026 |
| 1.0.9 | 88 | 2/25/2026 |
| 1.0.8 | 89 | 2/25/2026 |
| 1.0.7 | 92 | 2/25/2026 |
| 1.0.6 | 92 | 2/25/2026 |
| 1.0.5 | 93 | 2/24/2026 |
| 1.0.4 | 91 | 2/24/2026 |
| 1.0.3 | 89 | 2/21/2026 |