Vortice.D3D12MemoryAllocator 3.8.3

dotnet add package Vortice.D3D12MemoryAllocator --version 3.8.3
                    
NuGet\Install-Package Vortice.D3D12MemoryAllocator -Version 3.8.3
                    
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="Vortice.D3D12MemoryAllocator" Version="3.8.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Vortice.D3D12MemoryAllocator" Version="3.8.3" />
                    
Directory.Packages.props
<PackageReference Include="Vortice.D3D12MemoryAllocator" />
                    
Project file
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 Vortice.D3D12MemoryAllocator --version 3.8.3
                    
#r "nuget: Vortice.D3D12MemoryAllocator, 3.8.3"
                    
#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 Vortice.D3D12MemoryAllocator@3.8.3
                    
#: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=Vortice.D3D12MemoryAllocator&version=3.8.3
                    
Install as a Cake Addin
#tool nuget:?package=Vortice.D3D12MemoryAllocator&version=3.8.3
                    
Install as a Cake Tool

Vortice.D3D12MemoryAllocator

Bindings for D3D12MemoryAllocator, using Vortice.Direct3D12 and Vortice.DXGI objects.

The package targets .NET 8, 9, and 10. Its dependency on Vortice.D3D12MA.Native supplies the Windows x64 and ARM64 native library, which the runtime loads from the package's runtimes folder; publishing with a runtime identifier such as win-x64 only changes the output layout. Applications with a custom native library location can subscribe to D3D12MA.ResolveLibrary.

The bindings cover the native allocator, allocations, custom pools, virtual blocks, statistics, budgets, and defragmentation, including all resource creation and aliasing versions. Resource creation versions retain the native Windows/device feature requirements.

Resource allocation

CreateResource returns an allocation and a separately owned resource reference. Both must be disposed:

using Vortice.D3D12MemoryAllocator;
using Vortice.Direct3D12;

// device and adapter are existing Vortice objects.
using Allocator allocator = D3D12MA.CreateAllocator(new AllocatorDescription(device, adapter));
using Allocation allocation = allocator.CreateResource(
    new AllocationDescription(HeapType.Upload),
    ResourceDescription.Buffer(65536),
    ResourceStates.GenericRead,
    out ID3D12Resource resource);
using (resource)
{
    resource.SetData<uint>([1, 2, 3, 4]);
}

Overloads returning Result expose failures without throwing. Generic overloads request a specific ID3D12Resource interface. CreateResource2 accepts ResourceDescription1; CreateResource3 also accepts a barrier layout and a span of castable formats. Aliasing versions follow the same native progression.

Dispose resources before their allocations, a pool's allocations and defragmentation contexts before that pool, and all allocations, pools, and defragmentation contexts before their allocator. The caller must finish GPU work before releasing or reusing the underlying memory.

Allocation.Resource and Allocation.Heap acquire independent references on each read; dispose each returned wrapper. Assigning Allocation.Resource lets the native allocation retain its own resource reference. Pool.Description.ProtectedSession, when present, also returns an owned reference that must be disposed.

Virtual allocation

Virtual blocks allocate offsets without requiring a D3D12 device:

using VirtualBlock block = D3D12MA.CreateVirtualBlock(new VirtualBlockDescription(4096));
VirtualAllocation allocation = block.Allocate(new VirtualAllocationDescription(256, 64), out ulong offset);
// Use the offset in an application-managed buffer or other address space.
block.FreeAllocation(allocation);

VirtualAllocation is a value handle, not a disposable object. Free allocations with their original block or call Clear before disposing the block. Handles become invalid after freeing, clearing, or destroying the block.

Defragmentation

Allocator.BeginDefragmentation processes default pools; Pool.BeginDefragmentation processes a custom pool. The allocator's native entry point returns no HRESULT, while the pool entry point returns Result.

BeginPass returns S_FALSE (code 1) when pass.Moves contains work, or S_OK when no moves remain. Only each move's Operation may be changed. A pass and every copy of its move span expire at EndPass; dispose references acquired through GetSourceAllocation and GetDestinationTemporaryAllocation before ending the pass.

For a Copy move, create a placed resource at the temporary destination (for example through CreateAliasingResource), copy the data, wait for GPU completion, and assign the new resource to the temporary allocation's Resource. Dispose acquired resource wrappers before EndPass. The original source allocation remains valid and refers to the moved resource afterward; reacquire resources and update application descriptors and addresses as needed.

Ignore leaves the source allocation unchanged. Destroy makes EndPass release the application's original source allocation reference. To transfer that reference, set the original owning wrapper's NativePointer = 0 without calling Dispose or Release on the transferred pointer. Separately acquired references still need normal disposal before EndPass. Do not use a destroyed allocation afterward.

Callbacks and statistics

AllocationCallbacks uses unmanaged Cdecl function pointers. The native library copies the callback structure, but the functions and any PrivateData they reference must remain valid until native destruction completes. Callbacks must not throw across the native boundary and must honor the requested size and alignment.

BuildStatsString returns a managed copy of the native JSON text and frees the native string. Names are copied by native setters. Private data pointers are passed through without managed ownership.

The native library escapes some non-ASCII characters in names incorrectly in that JSON output (for example, λ). Use ASCII names when a statistics dump must be parsed as JSON; Unicode name setters and getters still work.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
3.8.3 133 10/5/2026