Direct3D®12 Memory Allocator
The industry-leading, open source, memory allocation library for the DirectX®12 API.
The D3D12 Memory Allocator (D3D12MA) is a C++ library that provides a simple and easy-to-integrate API to help you allocate memory for DirectX®12 buffers and textures.
Download the latest version - v2.0.0
*We recommend using the code from the master branch.
This release adds the following features:
- Powerful custom pools, which give an opportunity to not only keep certain resources together, reserve some minimum or limit the maximum amount of memory they can take, but also to pass additional allocation parameters unavailable to simple allocations. Among them, probably the most interesting is
POOL_DESC::HeapProperties
, which allows you to specify parameters of a custom memory type, which may be useful on UMA platforms. Committed allocations can now also be created in custom pools. - The API for statistics and budget has been redesigned – see structures Statistics, Budget, DetailedStatistics, TotalStatistics.
- The library exposes its core allocation algorithm via the “virtual allocator” interface. This can be used to allocate pieces of custom memory or whatever you like, even something completely unrelated to graphics.
- The allocation algorithm has been replaced with the new, more efficient TLSF.
- Added support for defragmentation.
- Objects of the library can be used with smart pointers designed for COM objects.
Benefits
This library can help developers to manage memory allocations and resource creation by offering function Allocator::CreateResource
similar to the standard ID3D12Device::CreateCommittedResource
.
It internally:
- Allocates and keeps track of bigger memory heaps, used and unused ranges inside them, finds best matching unused ranges to create new resources there as placed resources.
- Automatically respects size and alignment requirements for created resources.
- Automatically handles resource heap tier – whether it’s
D2D12_RESOURCE_HEAP_TIER_1
that requires to keep certain classes of resources separate orD3D12_RESOURCE_HEAP_TIER_2
that allows to keep them all together.
Additional features
- Self-contained C++ library in single pair of H + CPP files. Object-oriented interface in a convention similar to D3D12. No external dependencies other than standard C, C++ library and Windows SDK. Some features of C++14 used. STL containers, C++ exceptions, and RTTI are not used.
- Custom memory pools: Create a pool with desired parameters (e.g. fixed or limited maximum size, custom D3D12_HEAP_PROPERTIES and D3D12_HEAP_FLAGS) and allocate memory out of it.
- Linear allocator: Create a pool with linear algorithm and use it for much faster allocations and deallocations in free-at-once, stack, double stack, or ring buffer fashion.
- Defragmentation: Let the library move data around to free some memory blocks and make your allocations better compacted.
- Statistics: Obtain brief or detailed statistics about the amount of memory used, unused, number of allocated heaps, number of allocations etc. - globally and per memory heap type. Current memory usage and budget as reported by the system can also be queried.
- Debug annotations: Associate custom void* pPrivateData and debug LPCWSTR pName with each allocation.
- JSON dump: Obtain a string in JSON format with detailed map of internal state, including list of allocations, their string names, and gaps between them. Convert this JSON dump into a picture to visualize your memory using attached Python script.
- Virtual allocator - an API that exposes the core allocation algorithm to be used without allocating real GPU memory, to allocate your own stuff, e.g. sub-allocate pieces of one large buffer.
Version history
- Initial release
Our other SDKs
![AMD Capsaicin Framework](jpg/featured-232052451-a_amd_capsaicin_framework_lockup_rgb_wht.jpg)
Capsaicin is a Direct3D12 framework for real-time graphics research which implements the GI-1.0 technique and a reference path-tracer.
![AMD Render Pipeline Shaders (RPS) SDK](https://gpuopen.com/wp-content/uploads/2023/06/featured-231825267-A_AMD_Render_Pipeline_Shaders_Lockup_RGB_Wht.jpg)
The Render Pipeline Shaders (RPS) SDK provides a framework for graphics engines to use Render Graphs with explicit APIs.
![AMD Device Library eXtra](https://gpuopen.com/wp-content/uploads/2023/06/featured-231825260-A_AMD_Device_Library_eXtra_Lockup_RGB_Wht.jpg)
ADLX is a modern library designed to access features and functionality of AMD systems such as Display, 3D graphics, Performance Monitoring, GPU Tuning, and more.
![AMD Brotli-G SDK](https://gpuopen.com/wp-content/uploads/2023/06/featured-231825262-A_AMD_Brotli-G_SDK_Lockup_RGB_Wht.jpg)
Brotli-G is an open-source compression/decompression standard for digital assets (based on Brotli) that is compatible with GPU hardware.
![AMD HIP Ray Tracing](https://gpuopen.com/wp-content/uploads/2023/06/featured-231825263-A_AMD_HIP_Ray_Tracing_Lockup_RGB_Wht.jpg)
HIP RT is a ray tracing library for HIP, making it easy to write ray tracing applications in HIP.
![AMD Orochi](https://gpuopen.com/wp-content/uploads/2023/06/featured-231825264-A_AMD_Orochi_Lockup_RGB_Wht.jpg)
Orochi is a library which loads HIP and CUDA® APIs dynamically, allowing the user to switch APIs at runtime.
![AMD Radeon ProRender Developer Suite](https://gpuopen.com/wp-content/uploads/2023/06/featured-20457311-C_AMD_Radeon_ProRender_Developer_Suite_Lockup_RGB_Wht.jpg)
AMD Radeon™ ProRender is our fast, easy, and incredible physically-based rendering engine built on industry standards that enables accelerated rendering on virtually any GPU, any CPU, and any OS in over a dozen leading digital content creation and CAD applications.
![AMD Radeon ML](https://gpuopen.com/wp-content/uploads/2023/06/featured-231825265-A_AMD_Radeon_ML_Lockup_RGB_Wht.jpg)
Radeon™ Machine Learning (Radeon™ ML or RML) is an AMD SDK for high-performance deep learning inference on GPUs.
![AMD Radeon Image Filter](https://gpuopen.com/wp-content/uploads/2023/07/featured-radeon_image_filter.jpg)
Harness the power of machine learning to enhance images with denoising, enabling your application to produce high quality images in a fraction of the time traditional denoising filters take.
![AMD Advanced Media Framework](https://gpuopen.com/wp-content/uploads/2023/06/featured-231825259-A_AMD_Advanced_Media_Framework_Lockup_RGB_Wht.jpg)
The Advanced Media Framework SDK provides developers with optimal access to AMD GPUs for multimedia processing.
![ADL](https://gpuopen.com/wp-content/uploads/2023/06/featured-231825261-A_AMD_Display_Library_Lockup_RGB_Wht.jpg)
The AMD Display Library (ADL) SDK is designed to access display driver functionality for AMD Radeon™ and AMD FirePro™ graphics cards.
![AGS](https://gpuopen.com/wp-content/uploads/2023/06/featured-20673863-C_AMD_GPU_Services_Library_Lockup_RGB_Wht.jpg)
The AMD GPU Services (AGS) library provides software developers with the ability to query AMD GPU software and hardware state information that is not normally available through standard operating systems or graphics APIs.
![AMD GPUOpen Vulkan Memory Allocator](https://gpuopen.com/wp-content/uploads/2023/07/featured-GPUOpen-vma.jpg)
VMA is our single-header, MIT-licensed, C++ library for easily and efficiently managing memory allocation for your Vulkan® games and applications.
![AMD TrueAudio Next](https://gpuopen.com/wp-content/uploads/2023/07/featured-trueaudionext.jpg)
AMD TrueAudio Next is a software development kit for GPU accelerated and multi-core high-performance audio signal processing.
![AMD Radeon ProRender SDK](https://gpuopen.com/wp-content/uploads/2023/06/featured-18147992-E_AMD_Radeon_ProRender_Lockup_RGB_Wht.jpg)
AMD Radeon™ ProRender SDK is a powerful physically-based path traced rendering engine that enables creative professionals to produce stunningly photorealistic images.
![AMD Radeon Rays](https://gpuopen.com/wp-content/uploads/2023/06/featured-18147989-E_AMD_Radeon_Rays_Lockup_RGB_Wht.jpg)
The lightweight accelerated ray intersection library for DirectX®12 and Vulkan®.
![AMD GPU Performance API](https://gpuopen.com/wp-content/uploads/2023/06/featured-20673864-C_AMD_GPU_Performance_API_Lockup_RGB_Wht.jpg)
GPUPerfAPI provides access to GPU Performance Counters. It analyzes performance and execution characteristics of applications using a Radeon™ GPU.
![AMD Compressonator](https://gpuopen.com/wp-content/uploads/2023/06/featured-20665122-C_AMD_Compressonator_Lockup_RGB_Wht.jpg)
Compressonator is a set of tools to allow artists and developers to more easily work with compressed assets and easily visualize the quality impact of various compression technologies.
![](https://gpuopen.com/wp-content/uploads/2023/07/featured-liquidvr_oldstyle.jpg)
LiquidVR™ provides a Direct3D 11 based interface for applications to get access to the following GPU features regardless of whether a VR device is installed on a system.