Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 3.2.0 (2026-??-??)
# 3.2.0 (2026-06-05)

- Added `POOL_FLAG_DONT_USE_TIGHT_ALIGNMENT` (#91).
- Further improvements in the algorithm deciding when to use small alignment or tight alignment, including added support for `D3D12_FEATURE_DATA_D3D12_OPTIONS4::MSAA64KBAlignedTextureSupported`.
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.25)

project(D3D12MemoryAllocator VERSION 3.1.0)
project(D3D12MemoryAllocator VERSION 3.2.0)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

Expand Down
Binary file modified bin/D3D12Sample.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<div class="headertitle"><div class="title">D3D12 Memory Allocator </div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p><b>Version 3.1.0</b> (2026-02-23)</p>
<div class="textblock"><p><b>Version 3.2.0</b> (2026-06-05)</p>
<p>Copyright (c) 2019-2026 Advanced Micro Devices, Inc. All rights reserved. <br />
License: MIT</p>
<p>Documentation of all members: <a class="el" href="_d3_d12_mem_alloc_8h.html">D3D12MemAlloc.h</a></p>
Expand Down
2 changes: 1 addition & 1 deletion include/D3D12MemAlloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

/** \mainpage D3D12 Memory Allocator

<b>Version 3.1.0</b> (2026-02-23)
<b>Version 3.2.0</b> (2026-06-05)

Copyright (c) 2019-2026 Advanced Micro Devices, Inc. All rights reserved. \n
License: MIT
Expand Down
85 changes: 43 additions & 42 deletions src/Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1886,33 +1886,33 @@ static void TestSmallTextureAlignment(const TestContext& ctx)
UINT HeightAboveThreshold;
};

static const TextureCase NON_MSAA_CASES[] =
{
{ DXGI_FORMAT_R8_UNORM, 128, 128, 320, 320 },
{ DXGI_FORMAT_R8G8B8A8_UNORM, 64, 64, 160, 160 },
{ DXGI_FORMAT_BC1_UNORM, 128, 128, 640, 256 },
};
static const TextureCase MSAA_CASES[] =
{
{ DXGI_FORMAT_R8G8B8A8_UNORM, 256, 256, 1152, 512 },
{ DXGI_FORMAT_R16G16B16A16_FLOAT, 256, 128, 576, 512 },
{ DXGI_FORMAT_R32G32B32A32_FLOAT, 256, 128, 576, 256 },
};
static const TextureCase NON_MSAA_CASES[] =
{
{ DXGI_FORMAT_R8_UNORM, 128, 128, 320, 320 },
{ DXGI_FORMAT_R8G8B8A8_UNORM, 64, 64, 160, 160 },
{ DXGI_FORMAT_BC1_UNORM, 128, 128, 640, 256 },
};
static const TextureCase MSAA_CASES[] =
{
{ DXGI_FORMAT_R8G8B8A8_UNORM, 256, 256, 1152, 512 },
{ DXGI_FORMAT_R16G16B16A16_FLOAT, 256, 128, 576, 512 },
{ DXGI_FORMAT_R32G32B32A32_FLOAT, 256, 128, 576, 256 },
};

for (UINT msaaIndex = 0; msaaIndex < 2; ++msaaIndex)
{
const bool isMsaa = msaaIndex != 0;
const UINT64 largeAlignment = isMsaa ?
D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT :
D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
const UINT64 smallAlignment = isMsaa ?
D3D12_SMALL_MSAA_RESOURCE_PLACEMENT_ALIGNMENT :
D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT;
const TextureCase* textureCases = isMsaa ? MSAA_CASES : NON_MSAA_CASES;
const size_t textureCaseCount = isMsaa ? _countof(MSAA_CASES) : _countof(NON_MSAA_CASES);
const D3D12_HEAP_FLAGS heapFlags = isMsaa ?
D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES :
D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES;
const UINT64 smallAlignment = isMsaa ?
D3D12_SMALL_MSAA_RESOURCE_PLACEMENT_ALIGNMENT :
D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT;
const TextureCase* textureCases = isMsaa ? MSAA_CASES : NON_MSAA_CASES;
const size_t textureCaseCount = isMsaa ? _countof(MSAA_CASES) : _countof(NON_MSAA_CASES);
const D3D12_HEAP_FLAGS heapFlags = isMsaa ?
D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES :
D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES;
const D3D12_RESOURCE_FLAGS resourceFlags = isMsaa ?
D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET :
D3D12_RESOURCE_FLAG_NONE;
Expand All @@ -1932,11 +1932,11 @@ static void TestSmallTextureAlignment(const TestContext& ctx)

D3D12MA::CALLOCATION_DESC allocDesc = D3D12MA::CALLOCATION_DESC{ pool.Get() };

for (size_t textureCaseIndex = 0; textureCaseIndex < textureCaseCount; ++textureCaseIndex)
{
const TextureCase& textureCase = textureCases[textureCaseIndex];
for (UINT thresholdIndex = 0; thresholdIndex < 2; ++thresholdIndex)
{
for (size_t textureCaseIndex = 0; textureCaseIndex < textureCaseCount; ++textureCaseIndex)
{
const TextureCase& textureCase = textureCases[textureCaseIndex];
for (UINT thresholdIndex = 0; thresholdIndex < 2; ++thresholdIndex)
{
const bool belowThreshold = thresholdIndex == 0;
D3D12_RESOURCE_DESC resDesc = {};
resDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
Expand All @@ -1962,23 +1962,23 @@ static void TestSmallTextureAlignment(const TestContext& ctx)
CHECK_BOOL(alloc0->GetHeap() == alloc1->GetHeap());

// Note these asserts may fail if you use D3D12MA_USE_SMALL_RESOURCE_PLACEMENT_ALIGNMENT=2.
const UINT64 expectedAlignment = belowThreshold ? smallAlignment : largeAlignment;
CHECK_BOOL((alloc0->GetOffset() % expectedAlignment) == 0);
CHECK_BOOL((alloc1->GetOffset() % expectedAlignment) == 0);
if (belowThreshold)
{
const UINT64 nonZeroOffset = alloc0->GetOffset() > 0 ? alloc0->GetOffset() : alloc1->GetOffset();
wprintf(L" Small alignment case: format=%u msaa=%u size=%llux%u offset=%llu -> small alignment %s\n",
(UINT)textureCase.Format,
isMsaa ? 1u : 0u,
resDesc.Width,
resDesc.Height,
nonZeroOffset,
nonZeroOffset < largeAlignment ? L"YES" : L"NO");
}

alloc1.Reset();
alloc0.Reset();
const UINT64 expectedAlignment = belowThreshold ? smallAlignment : largeAlignment;
CHECK_BOOL((alloc0->GetOffset() % expectedAlignment) == 0);
CHECK_BOOL((alloc1->GetOffset() % expectedAlignment) == 0);
if (belowThreshold)
{
const UINT64 nonZeroOffset = alloc0->GetOffset() > 0 ? alloc0->GetOffset() : alloc1->GetOffset();
wprintf(L" Small alignment case: format=%u msaa=%u size=%llux%u offset=%llu -> small alignment %s\n",
(UINT)textureCase.Format,
isMsaa ? 1u : 0u,
resDesc.Width,
resDesc.Height,
nonZeroOffset,
nonZeroOffset < largeAlignment ? L"YES" : L"NO");
}
alloc1.Reset();
alloc0.Reset();
}
}

Expand Down Expand Up @@ -3574,6 +3574,7 @@ static void TestTightAlignment(const TestContext& ctx)

// Use a custom pool to make sure our small buffers are not created as committed.
POOL_DESC poolDesc = {};
poolDesc.HeapFlags = D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS;
poolDesc.BlockSize = MEGABYTE;
poolDesc.MinBlockCount = poolDesc.MaxBlockCount = 1;

Expand Down
Loading