Skip to content

Memory Management

Chuck Walbourn edited this page Apr 24, 2018 · 9 revisions

In DirectX 12, the application is responsible for much of the graphics memory management much as it is for system memory. This includes managing CPU/GPU synchronization and ensuring that resources are not modified by the CPU while the GPU is using them or vice-versa.

For the DirectX Tool Kit for DirectX 12 this is primarily handled through two classes: GraphicsMemory and ResourceUploadBatch.

Constant buffers

The primary use of the GraphicsMemory class is to allocate constant buffers from a D3D12_HEAP_TYPE_UPLOAD heap. CBs can persist for many frames, or be used for a single frame, but they must remain unchanged until their usage is completed. GraphicsMemory tracks this using a per-frame fence which is reclaimed each frame as they complete during the Present loop. CBs are in memory shared between the CPU and GPU as they are used for communication between CPU code and GPU shaders.

Index/Vertex buffers

UNDER DEVELOPMENT

Textures

Typically textures are created as ID3D12Resource interfaces as committed memory in the D3D12_HEAP_TYPE_DEFAULT heap, requiring a D3D12_HEAP_TYPE_UPLOAD heap to transfer data from the CPU to the GPU memory which is often managed by the ResourceUploadBatch class. For more information see Textures.

Direct3D 12 does support 'sparse textures'. For more information see the D3D12ReservedResources sample for PC / UWP

Further reading

MSDN: Memory Management in Direct3D 12

For Use

  • Universal Windows Platform apps
  • Windows desktop apps
  • Windows 11
  • Windows 10
  • Xbox One
  • Xbox Series X|S

Architecture

  • x86
  • x64
  • ARM64

For Development

  • Visual Studio 2022
  • Visual Studio 2019 (16.11)
  • clang/LLVM v12 - v18
  • MinGW 12.2, 13.2
  • CMake 3.20

Related Projects

DirectX Tool Kit for DirectX 11

DirectXMesh

DirectXTex

DirectXMath

Tools

Test Suite

Model Viewer

Content Exporter

DxCapsViewer

See also

DirectX Landing Page

Clone this wiki locally