Skip to content

Commit ddb4d99

Browse files
Removed mention of tight alignment from docs on this branch
1 parent 58abb3c commit ddb4d99

2 files changed

Lines changed: 1 addition & 20 deletions

File tree

docs/html/optimal_allocation.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,7 @@ <h1><a class="anchor" id="optimal_allocation_resource_alignment"></a>
328328
<dl class="section user"><dt>Implementation detail</dt><dd>Default alignment required MSAA textures is <code>D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT</code> = 4 MB. Default alignment required for buffers and other textures is <code>D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT</code> = 64 KB.</dd></dl>
329329
<p>Because the alignment required for buffers is 64 KB, <b>small buffers</b> can waste a lot of memory in between when created as placed. When such small buffers are created as committed, some graphics drivers are able to pack them better. D3D12MA automatically takes advantage of this by preferring to create small buffers as committed. This heuristics is enabled by default. It is also a tradeoff - it can make the allocation of these buffers slower. It can be disabled for an individual resource by using <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645eaa3ded8847563c24b4522af0586dbd2cb">D3D12MA::ALLOCATION_FLAG_STRATEGY_MIN_TIME</a> and for the entire allocator by using <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a15c1ba5fbc182ac927b3011e23e74a72" title="Disable optimization that prefers creating small buffers as committed to avoid 64 KB alignment.">D3D12MA::ALLOCATOR_FLAG_DONT_PREFER_SMALL_BUFFERS_COMMITTED</a>.</p>
330330
<p>For certain textures that meet a complex set of requirements, special <b>"small alignment"</b> can be applied. Details can be found in Microsoft documentation of the <code>D3D12_RESOURCE_DESC</code> structure. For MSAA textures, the small alignment is <code>D3D12_SMALL_MSAA_RESOURCE_PLACEMENT_ALIGNMENT</code> = 64 KB. For other textures, the small alignment is <code>D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT</code> = 4 KB. D3D12MA uses this feature automatically. Detailed behavior can be disabled or controlled by predefining macro <a class="el" href="_d3_d12_mem_alloc_8h.html#ad04069a2e2bbc53b7d65f85a04a2dcbc" title="When defined to value other than 0, the library will try to use D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNM...">D3D12MA_USE_SMALL_RESOURCE_PLACEMENT_ALIGNMENT</a>.</p>
331-
<p>D3D12 also has a concept of <b>alignment of the entire heap</b>, passed through <code>D3D12_HEAP_DESC::Alignment</code>. This library automatically sets the alignment as small as possible. Unfortunately, any heap that has a chance of hosting an MSAA texture needs to have the alignment set to 4 MB. This problem can be overcome by passing <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916adfbfd20d716f2a46f74d6226056fef1e" title="Optimization, allocate MSAA textures as committed resources always.">D3D12MA::ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED</a> on the creation of the main allocator object and <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1acc379a89755438c0f76667783b778baa" title="Optimization, allocate MSAA textures as committed resources always.">D3D12MA::POOL_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED</a> on the creation of any custom heap that supports textures, not only buffers. With those flags, the alignment of the heaps created by D3D12MA can be lower, but any MSAA textures are created as committed. You should always use these flags in your code unless you really need to create some MSAA textures as placed.</p>
332-
<p>With DirectX 12 Agility SDK 1.716.0-preview, Microsoft added a new feature called <b>"tight alignment"</b>. Note this is a separate feature than the "small alignment" described earlier. When using this new SDK and a compatible graphics driver, the API exposes support for this new feature. Then, a new flag <code>D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT</code> can be added when creating a resource. D3D12 can then return the alignment required for the resource smaller than the default ones described above. This library automatically makes use of the tight alignment feature when available and adds that new resource flag. When the tight alignment is enabled, the heuristics that creates small buffers as committed described above is deactivated, as it is no longer needed.</p>
333-
<p>You can check if the tight alignment it is available in the current system by calling D3D12MA::Allocator::IsTightAlignmentSupported(). You can tell the library to not use it by specifying D3D12MA::ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT. Typically, you don't need to do any of those.</p>
334-
<p>The library automatically aligns all buffers to at least 256 B, even when the system supports smaller alignment. This is the alignment required for constant buffers, expressed by <code>D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT</code> constant. </p>
331+
<p>D3D12 also has a concept of <b>alignment of the entire heap</b>, passed through <code>D3D12_HEAP_DESC::Alignment</code>. This library automatically sets the alignment as small as possible. Unfortunately, any heap that has a chance of hosting an MSAA texture needs to have the alignment set to 4 MB. This problem can be overcome by passing <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916adfbfd20d716f2a46f74d6226056fef1e" title="Optimization, allocate MSAA textures as committed resources always.">D3D12MA::ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED</a> on the creation of the main allocator object and <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1acc379a89755438c0f76667783b778baa" title="Optimization, allocate MSAA textures as committed resources always.">D3D12MA::POOL_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED</a> on the creation of any custom heap that supports textures, not only buffers. With those flags, the alignment of the heaps created by D3D12MA can be lower, but any MSAA textures are created as committed. You should always use these flags in your code unless you really need to create some MSAA textures as placed. </p>
335332
</div></div><!-- contents -->
336333
</div><!-- PageDoc -->
337334
<!-- start footer part -->

include/D3D12MemAlloc.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2404,22 +2404,6 @@ and D3D12MA::POOL_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED on the creation of any cus
24042404
With those flags, the alignment of the heaps created by %D3D12MA can be lower, but any MSAA textures are created as committed.
24052405
You should always use these flags in your code unless you really need to create some MSAA textures as placed.
24062406
2407-
With DirectX 12 Agility SDK 1.716.0-preview, Microsoft added a new feature called **"tight alignment"**.
2408-
Note this is a separate feature than the "small alignment" described earlier.
2409-
When using this new SDK and a compatible graphics driver, the API exposes support for this new feature.
2410-
Then, a new flag `D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT` can be added when creating a resource.
2411-
D3D12 can then return the alignment required for the resource smaller than the default ones described above.
2412-
This library automatically makes use of the tight alignment feature when available and adds that new resource flag.
2413-
When the tight alignment is enabled, the heuristics that creates small buffers as committed described above is deactivated,
2414-
as it is no longer needed.
2415-
2416-
You can check if the tight alignment it is available in the current system by calling D3D12MA::Allocator::IsTightAlignmentSupported().
2417-
You can tell the library to not use it by specifying D3D12MA::ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT.
2418-
Typically, you don't need to do any of those.
2419-
2420-
The library automatically aligns all buffers to at least 256 B, even when the system supports smaller alignment.
2421-
This is the alignment required for constant buffers, expressed by `D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT` constant.
2422-
24232407
\page defragmentation Defragmentation
24242408
24252409
Interleaved allocations and deallocations of many objects of varying size can

0 commit comments

Comments
 (0)