All Projects → GPUOpen-LibrariesAndSDKs → D3d12memoryallocator

GPUOpen-LibrariesAndSDKs / D3d12memoryallocator

Licence: mit
Easy to integrate memory allocation library for Direct3D 12

Projects that are alternatives of or similar to D3d12memoryallocator

Bgfx
Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.
Stars: ✭ 10,252 (+4281.2%)
Mutual labels:  directx, d3d12, directx-12
Diligentsamples
Sample projects demonstrating the usage of Diligent Engine
Stars: ✭ 138 (-41.03%)
Mutual labels:  directx, d3d12, directx-12
Methanekit
🎲 Modern 3D graphics made simple with cross-platform C++17 meta-API on top of DirectX 12 & Metal (Vulkan is coming)
Stars: ✭ 197 (-15.81%)
Mutual labels:  directx, d3d12
D912pxy
DirectX9 to DirectX12 API proxy for Guild Wars 2
Stars: ✭ 833 (+255.98%)
Mutual labels:  directx, d3d12
Qtdirect3d
QDirect3DWidget implementation similar to the built-in QOpenGLWidget
Stars: ✭ 60 (-74.36%)
Mutual labels:  directx, directx-12
Directxmesh
DirectXMesh geometry processing library
Stars: ✭ 447 (+91.03%)
Mutual labels:  directx, directx-12
Renderdoc
RenderDoc is a stand-alone graphics debugging tool.
Stars: ✭ 5,969 (+2450.85%)
Mutual labels:  directx, d3d12
Directxtex
DirectXTex texture processing library
Stars: ✭ 1,039 (+344.02%)
Mutual labels:  directx, directx-12
XUSG
XUSG, XU's supreme graphics lib, is a handy wrapper currently for DirectX 12. It can be a good reference for designing your own DX12 wrapper APIs.
Stars: ✭ 57 (-75.64%)
Mutual labels:  d3d12, directx-12
Awesome D3d12
Awesome D3D12 ecosystem
Stars: ✭ 130 (-44.44%)
Mutual labels:  directx, d3d12
Dgvoodoo2
Glide/DirectX implementation on D3D11/12
Stars: ✭ 137 (-41.45%)
Mutual labels:  directx, d3d12
Directx Headers
Official DirectX headers available under an open source license
Stars: ✭ 173 (-26.07%)
Mutual labels:  directx, d3d12
Diligentcore
Core functionality of Diligent Engine
Stars: ✭ 263 (+12.39%)
Mutual labels:  d3d12, directx-12
Directxtk12
The DirectX Tool Kit (aka DirectXTK12) is a collection of helper classes for writing DirectX 12 code in C++
Stars: ✭ 765 (+226.92%)
Mutual labels:  directx, directx-12
Fx Gltf
A C++14/C++17 header-only library for simple, efficient, and robust serialization/deserialization of glTF 2.0
Stars: ✭ 257 (+9.83%)
Mutual labels:  directx, directx-12
Llgl
Low Level Graphics Library (LLGL) is a thin abstraction layer for the modern graphics APIs OpenGL, Direct3D, Vulkan, and Metal
Stars: ✭ 1,011 (+332.05%)
Mutual labels:  directx, d3d12
CrossWindow-Demos
🥪 Examples of how to use CrossWindow for things like rendering graphics, listening to events, etc.
Stars: ✭ 48 (-79.49%)
Mutual labels:  directx, directx-12
DXSample
Sample Program for DirectX 12 + Swift
Stars: ✭ 57 (-75.64%)
Mutual labels:  directx, directx-12
Flycube
Graphics API wrapper is written in C++ on top of Directx 12 and Vulkan. Provides main features including ray tracing.
Stars: ✭ 78 (-66.67%)
Mutual labels:  d3d12, directx-12
Diligentengine
A modern cross-platform low-level graphics library and rendering framework
Stars: ✭ 2,142 (+815.38%)
Mutual labels:  directx, d3d12

D3D12 Memory Allocator

Easy to integrate memory allocation library for Direct3D 12.

License: MIT. See LICENSE.txt

Changelog: See CHANGELOG.md

Product page: D3D12 Memory Allocator on GPUOpen

Build status:

Windows: Build status

Problem

Memory allocation and resource (buffer and texture) creation in new, explicit graphics APIs (Vulkan® and Direct3D 12) is difficult comparing to older graphics APIs like Direct3D 11 or OpenGL® because it is recommended to allocate bigger blocks of memory and assign parts of them to resources. Vulkan Memory Allocator is a library that implements this functionality for Vulkan. It is available online since 2017 and it is successfully used in many software projects, including some AAA game studios. This is an equivalent library for D3D12.

Features

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 D3D12_RESOURCE_HEAP_TIER_1 that requires to keep certain classes of resources separate or D3D12_RESOURCE_HEAP_TIER_2 that allows to keep them all together.

Additional features:

  • Support for resource aliasing (overlap).
  • Virtual allocator - possibility to use core allocation algorithm without using real GPU memory, to allocate your own stuff, e.g. sub-allocate pieces of one large buffer.
  • Well-documented - description of all classes and functions provided, along with chapters that contain general description and example code.
  • Thread-safety: Library is designed to be used in multithreaded code.
  • Configuration: Fill optional members of ALLOCATOR_DESC structure to provide custom CPU memory allocator and other parameters.
  • Customization: Predefine appropriate macros to provide your own implementation of external facilities used by the library, like assert, mutex, and atomic.
  • Statistics: Obtain detailed statistics about the amount of memory used, unused, number of allocated blocks, number of allocations etc. - globally and per memory heap type.
  • Debug annotations: Associate string name with every allocation.
  • JSON dump: Obtain a string in JSON format with detailed map of internal state, including list of allocations and gaps between them.

Prerequisites

  • Self-contained C++ library in single pair of H + CPP files. No external dependencies other than standard C, C++ library and Windows SDK. STL containers, C++ exceptions, and RTTI are not used.
  • Object-oriented interface in a convention similar to D3D12.
  • Error handling implemented by returning HRESULT error codes - same way as in D3D12.
  • Interface documented using Doxygen-style comments.

Example

Basic usage of this library is very simple. Advanced features are optional. After you created global Allocator object, a complete code needed to create a texture may look like this:

D3D12_RESOURCE_DESC resourceDesc = {};
resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
resourceDesc.Alignment = 0;
resourceDesc.Width = 1024;
resourceDesc.Height = 1024;
resourceDesc.DepthOrArraySize = 1;
resourceDesc.MipLevels = 1;
resourceDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
resourceDesc.SampleDesc.Count = 1;
resourceDesc.SampleDesc.Quality = 0;
resourceDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
resourceDesc.Flags = D3D12_RESOURCE_FLAG_NONE;

D3D12MA::ALLOCATION_DESC allocationDesc = {};
allocDesc.HeapType = D3D12_HEAP_TYPE_DEFAULT;

D3D12Resource* resource;
D3D12MA::Allocation* allocation;
HRESULT hr = allocator->CreateResource(
    &allocationDesc,
    &resourceDesc,
    D3D12_RESOURCE_STATE_COPY_DEST,
    NULL,
    &allocation,
    IID_PPV_ARGS(&resource));

With this one function call:

  1. ID3D12Heap memory block is allocated if needed.
  2. An unused region of the memory block assigned.
  3. ID3D12Resource is created as placed resource, bound to this region.

Allocation is an object that represents memory assigned to this texture. It can be queried for parameters like offset and size.

Binaries

The release comes with precompiled binary executable for "D3D12Sample" application which contains test suite. It is compiled using Visual Studio 2019, so it requires appropriate libraries to work, including "MSVCP140.dll", "VCRUNTIME140.dll", "VCRUNTIME140_1.dll". If its launch fails with error message telling about those files missing, please download and install Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019, "x64" version.

Documentation

Documentation is provided together with the library in form of Doxygen-style comments inside the code, in file "src/D3D12MemAlloc.h". They can be read directly or turned into HTML and other convenient to read formats. Unfortunately we can't provide pregenerated version browseable online. You can generate it on your own by following these steps:

  1. Install Doxygen.
  2. Open command line and enter "src" directory.
  3. Type command: doxygen
  4. Open following file in a web browser: "docs/html/index.html".

Copyright notice

This software package uses third party software:

For more information see NOTICES.txt.

Software using this library

  • The Forge - cross-platform rendering framework. Apache License 2.0.

Some other projects on GitHub and some game development studios that use DX12 in their games.

See also

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].