VmaCS 0.2.0
.NET 8.0
This package targets .NET 8.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
dotnet add package VmaCS --version 0.2.0
NuGet\Install-Package VmaCS -Version 0.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VmaCS" Version="0.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="VmaCS" Version="0.2.0" />
<PackageReference Include="VmaCS" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add VmaCS --version 0.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: VmaCS, 0.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package VmaCS@0.2.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=VmaCS&version=0.2.0
#tool nuget:?package=VmaCS&version=0.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
VmaCS
VmaCS is a C# port of AMD Vulkan Memory Allocator (VMA) 3.4.0 for .NET. VmaCS uses Silk.NET as Vulkan API provider.
Features
- TLSF allocator
- Linear allocator
- Defragmentation
- Virtual blocks
- Custom pools
- Buffer and image allocation
- Memory mapping (Map/Unmap)
- Dedicated allocation
- Automatic
VK_KHR_maintenance4/maintenance5detection
See docs/port-parity.md for full feature parity.
Documentation
This README provides a quick start. For full API details, refer to the original VMA documentation and docs/port-parity.md for C#-specific mapping.
Quick start
Target frameworks
- .NET 8.0+
- .NET 9.0+
- .NET 10.0+
- .NET Standard 2.0
- .NET Standard 2.1
Prerequisites
- A Vulkan-capable GPU with up-to-date drivers
Installation
dotnet add package VmaCS
Allocations
using Silk.NET.Vulkan;
using VmaCS;
var createInfo = new VulkanMemoryAllocatorCreateInfo
{
VulkanAPIObject = vk,
VulkanAPIVersion = Version32.MakeVersion(1, 3, 0),
Instance = instance,
PhysicalDevice = physicalDevice,
LogicalDevice = device,
ThrowOnError = false //set true if you want exceptions for methods that returns Result
};
using var allocator = new VulkanMemoryAllocator(in createInfo);
var bufferInfo = new BufferCreateInfo
{
SType = StructureType.BufferCreateInfo,
Size = 65536,
Usage = BufferUsageFlags.VertexBufferBit | BufferUsageFlags.TransferDstBit,
};
var allocInfo = new AllocationCreateInfo { Usage = MemoryUsage.GPU_Only };
var res = allocator.CreateBuffer(in bufferInfo, in allocInfo, out var buffer, out var allocation);
if (res.IsError())
{
// handle error
}
var imageInfo = new ImageCreateInfo
{
SType = StructureType.ImageCreateInfo,
ImageType = ImageType.Type2D,
Format = Format.R8G8B8A8Unorm,
Extent = new Extent3D { Width = 256, Height = 256, Depth = 1 },
MipLevels = 1,
ArrayLayers = 1,
Samples = SampleCountFlags.Count1Bit,
Tiling = ImageTiling.Optimal,
Usage = ImageUsageFlags.SampledBit | ImageUsageFlags.TransferDstBit,
InitialLayout = ImageLayout.Undefined,
};
res = allocator.CreateImage(in imageInfo, in allocInfo, out var image, out var imageAllocation);
if (res.IsError())
{
// handle error
}
allocation!.Map(out var ptr);
Unsafe.WriteUnaligned(ptr, 42);
allocation!.Unmap();
allocation!.Dispose();
vk.DestroyBuffer(device, buffer, ReadOnlySpan<AllocationCallbacks>.Empty);
Custom pool
var memType = allocator.FindMemoryTypeIndexForBufferInfo(in bufferInfo, in allocInfo, out var idx)
.IsSuccess() ? idx!.Value : 0;
using var pool = allocator.CreatePool(new AllocationPoolCreateInfo
{
MemoryTypeIndex = memType,
BlockSize = 4 * 1024 * 1024,
MinBlockCount = 1,
MaxBlockCount = 16,
});
var pooledAllocInfo = new AllocationCreateInfo
{
Usage = MemoryUsage.GPU_Only,
Pool = pool,
};
allocator.CreateBuffer(in bufferInfo, in pooledAllocInfo, out var pooledBuffer, out var pooledAllocation);
Defragmentation
// Collect allocations to defragment
var handles = new[] { alloc1, alloc2, alloc3 };
var defragInfo = new DefragmentationInfo
{
Allocations = handles,
Flags = DefragmentationFlags.AlgorithmFast,
};
using var defragCtx = allocator.DefragmentationBegin(in defragInfo);
while (true)
{
var pass = defragCtx.PassBegin();
if (pass.Moves is not { Length: > 0 })
{
break;
}
foreach (var move in pass.Moves)
{
if (move.Operation == DefragmentationMoveOperation.Copy
&& move.Source is { } src
&& move.Destination is { } dst)
{
// Copy data from src to dst
src.Map(out var srcPtr);
dst.Map(out var dstPtr);
Buffer.MemoryCopy(srcPtr, dstPtr, dst.Size, src.Size);
dst.Unmap();
src.Unmap();
}
}
defragCtx.PassEnd();
}
var stats = defragCtx.End();
Console.WriteLine($"Moved: {stats.AllocationsMoved}");
Virtual allocator
var vbRes = allocator.CreateVirtualBlock(new VirtualBlockCreateInfo
{
Size = 256 * 1024 * 1024,
}, out var vb);
if (vbRes.IsError())
{
// handle error
}
vb.Allocate(new VirtualAllocationCreateInfo { Size = 4096, Alignment = 256 }, out var valloc);
// valloc.Offset, valloc.Size available here
// No GPU memory is actually allocated
Examples
- VmaCS.Examples.Allocations — minimal console app demonstrating allocator setup, buffer/image allocation, and cleanup
- VulkanCube — adapted from the VMASharp example
Planned tasks
- Increase unit test coverage to 80%+
- Add benchmark coverage for more allocator paths
- Add more usage examples (dedicated allocation, aliasing, budget updates)
- Write API reference documentation based on VMA docs
- Add conditional compilation flags for optimized builds
Attribution
- Ported from https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator (c) 2017-2026 Advanced Micro Devices, Inc., MIT License.
- Inspired by https://github.com/sunkin351/VMASharp (c) 2020 sunkin351, MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.Bcl.HashCode (>= 6.0.0)
- Polyfill (>= 1.2.0)
- Silk.NET.Vulkan (>= 2.23.0)
- Silk.NET.Vulkan.Extensions.EXT (>= 2.23.0)
- Silk.NET.Vulkan.Extensions.KHR (>= 2.23.0)
- System.Memory (>= 4.6.3)
- System.Runtime.CompilerServices.Unsafe (>= 6.1.2)
- System.Text.Json (>= 10.0.11)
-
.NETStandard 2.1
- Polyfill (>= 1.2.0)
- Silk.NET.Vulkan (>= 2.23.0)
- Silk.NET.Vulkan.Extensions.EXT (>= 2.23.0)
- Silk.NET.Vulkan.Extensions.KHR (>= 2.23.0)
- System.Text.Json (>= 10.0.11)
-
net10.0
- Polyfill (>= 1.2.0)
- Silk.NET.Vulkan (>= 2.23.0)
- Silk.NET.Vulkan.Extensions.EXT (>= 2.23.0)
- Silk.NET.Vulkan.Extensions.KHR (>= 2.23.0)
-
net8.0
- Polyfill (>= 1.2.0)
- Silk.NET.Vulkan (>= 2.23.0)
- Silk.NET.Vulkan.Extensions.EXT (>= 2.23.0)
- Silk.NET.Vulkan.Extensions.KHR (>= 2.23.0)
-
net9.0
- Polyfill (>= 1.2.0)
- Silk.NET.Vulkan (>= 2.23.0)
- Silk.NET.Vulkan.Extensions.EXT (>= 2.23.0)
- Silk.NET.Vulkan.Extensions.KHR (>= 2.23.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.2.0 | 121 | 9/8/2026 |