You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<dlclass="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>
329
329
<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 <aclass="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645eaa3ded8847563c24b4522af0586dbd2cb">D3D12MA::ALLOCATION_FLAG_STRATEGY_MIN_TIME</a> and for the entire allocator by using <aclass="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>
330
330
<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 <aclass="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 <aclass="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 <aclass="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 <aclass="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 <aclass="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>
0 commit comments