Merge remote-tracking branch 'origin/feature/resource-tight-alignment'
diff --git a/docs/html/_d3_d12_mem_alloc_8h.html b/docs/html/_d3_d12_mem_alloc_8h.html index 99d4b5a..36f1863 100644 --- a/docs/html/_d3_d12_mem_alloc_8h.html +++ b/docs/html/_d3_d12_mem_alloc_8h.html
@@ -218,6 +218,7 @@ , <br />   <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916adfbfd20d716f2a46f74d6226056fef1e">D3D12MA::ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED</a> = 0x8 , <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a15c1ba5fbc182ac927b3011e23e74a72">D3D12MA::ALLOCATOR_FLAG_DONT_PREFER_SMALL_BUFFERS_COMMITTED</a> = 0x10 +, <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916af13bc700d7b799c856c6516acac12fed">D3D12MA::ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT</a> = 0x20 <br /> }</td></tr> <tr class="memdesc:ad5ae5a5e42b878f2e18ab5d1fbfb9916"><td class="mdescLeft"> </td><td class="mdescRight">Bit flags to be used with ALLOCATOR_DESC::Flags. <a href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916">More...</a><br /></td></tr>
diff --git a/docs/html/class_d3_d12_m_a_1_1_allocator-members.html b/docs/html/class_d3_d12_m_a_1_1_allocator-members.html index ca74e46..4e80d94 100644 --- a/docs/html/class_d3_d12_m_a_1_1_allocator-members.html +++ b/docs/html/class_d3_d12_m_a_1_1_allocator-members.html
@@ -100,8 +100,9 @@ <tr class="even"><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a434ae3147209953253da26687bfd62dc">GetMemoryCapacity</a>(UINT memorySegmentGroup) const</td><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a></td><td class="entry"></td></tr> <tr class="odd"><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a08210561b92c4bd7ede9dd7beba4bb80">IsCacheCoherentUMA</a>() const</td><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a></td><td class="entry"></td></tr> <tr class="even"><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a3f3fd1e88cf2cd02257fe272e08a273c">IsGPUUploadHeapSupported</a>() const</td><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a></td><td class="entry"></td></tr> - <tr class="odd"><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a9e742884bd45dd7f01193d13fcd05af0">IsUMA</a>() const</td><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a></td><td class="entry"></td></tr> - <tr class="even"><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a468ba0c93121eaaee402b08775f1dd11">SetCurrentFrameIndex</a>(UINT frameIndex)</td><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a></td><td class="entry"></td></tr> + <tr class="odd"><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a3f5aa191cebdca7c1932da4723cfc03e">IsTightAlignmentSupported</a>() const</td><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a></td><td class="entry"></td></tr> + <tr class="even"><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a9e742884bd45dd7f01193d13fcd05af0">IsUMA</a>() const</td><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a></td><td class="entry"></td></tr> + <tr class="odd"><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a468ba0c93121eaaee402b08775f1dd11">SetCurrentFrameIndex</a>(UINT frameIndex)</td><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a></td><td class="entry"></td></tr> </table></div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small>
diff --git a/docs/html/class_d3_d12_m_a_1_1_allocator.html b/docs/html/class_d3_d12_m_a_1_1_allocator.html index 08b73a0..997e7d0 100644 --- a/docs/html/class_d3_d12_m_a_1_1_allocator.html +++ b/docs/html/class_d3_d12_m_a_1_1_allocator.html
@@ -103,6 +103,8 @@ <tr class="memdesc:a08210561b92c4bd7ede9dd7beba4bb80"><td class="mdescLeft"> </td><td class="mdescRight">Returns true if <span class="tt">D3D12_FEATURE_DATA_ARCHITECTURE1::CacheCoherentUMA</span> was found to be true. <br /></td></tr> <tr class="memitem:a3f3fd1e88cf2cd02257fe272e08a273c" id="r_a3f3fd1e88cf2cd02257fe272e08a273c"><td class="memItemLeft" align="right" valign="top">BOOL </td><td class="memItemRight" valign="bottom"><a class="el" href="#a3f3fd1e88cf2cd02257fe272e08a273c">IsGPUUploadHeapSupported</a> () const</td></tr> <tr class="memdesc:a3f3fd1e88cf2cd02257fe272e08a273c"><td class="mdescLeft"> </td><td class="mdescRight">Returns true if GPU Upload Heaps are supported on the current system. <br /></td></tr> +<tr class="memitem:a3f5aa191cebdca7c1932da4723cfc03e" id="r_a3f5aa191cebdca7c1932da4723cfc03e"><td class="memItemLeft" align="right" valign="top">BOOL </td><td class="memItemRight" valign="bottom"><a class="el" href="#a3f5aa191cebdca7c1932da4723cfc03e">IsTightAlignmentSupported</a> () const</td></tr> +<tr class="memdesc:a3f5aa191cebdca7c1932da4723cfc03e"><td class="mdescLeft"> </td><td class="mdescRight">Returns true if resource tight alignment is supported on the current system. When supported, it is automatically used by the library, unless <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916af13bc700d7b799c856c6516acac12fed">ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT</a> flag was specified on allocator creation. This flag is fetched from <span class="tt">D3D12_FEATURE_DATA_TIGHT_ALIGNMENT::SupportTier</span>. <br /></td></tr> <tr class="memitem:a434ae3147209953253da26687bfd62dc" id="r_a434ae3147209953253da26687bfd62dc"><td class="memItemLeft" align="right" valign="top">UINT64 </td><td class="memItemRight" valign="bottom"><a class="el" href="#a434ae3147209953253da26687bfd62dc">GetMemoryCapacity</a> (UINT memorySegmentGroup) const</td></tr> <tr class="memdesc:a434ae3147209953253da26687bfd62dc"><td class="mdescLeft"> </td><td class="mdescRight">Returns total amount of memory of specific segment group, in bytes. <br /></td></tr> <tr class="memitem:aa37d6b9fe8ea0864f7a35b9d68e8345a" id="r_aa37d6b9fe8ea0864f7a35b9d68e8345a"><td class="memItemLeft" align="right" valign="top">HRESULT </td><td class="memItemRight" valign="bottom"><a class="el" href="#aa37d6b9fe8ea0864f7a35b9d68e8345a">CreateResource</a> (const <a class="el" href="struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_i_o_n___d_e_s_c.html">ALLOCATION_DESC</a> *pAllocDesc, const D3D12_RESOURCE_DESC *pResourceDesc, D3D12_RESOURCE_STATES InitialResourceState, const D3D12_CLEAR_VALUE *pOptimizedClearValue, <a class="el" href="class_d3_d12_m_a_1_1_allocation.html">Allocation</a> **ppAllocation, REFIID riidResource, void **ppvResource)</td></tr> @@ -787,6 +789,25 @@ </div> </div> +<a id="a3f5aa191cebdca7c1932da4723cfc03e" name="a3f5aa191cebdca7c1932da4723cfc03e"></a> +<h2 class="memtitle"><span class="permalink"><a href="#a3f5aa191cebdca7c1932da4723cfc03e">◆ </a></span>IsTightAlignmentSupported()</h2> + +<div class="memitem"> +<div class="memproto"> + <table class="memname"> + <tr> + <td class="memname">BOOL D3D12MA::Allocator::IsTightAlignmentSupported </td> + <td>(</td> + <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td> + <td> const</td> + </tr> + </table> +</div><div class="memdoc"> + +<p>Returns true if resource tight alignment is supported on the current system. When supported, it is automatically used by the library, unless <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916af13bc700d7b799c856c6516acac12fed">ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT</a> flag was specified on allocator creation. This flag is fetched from <span class="tt">D3D12_FEATURE_DATA_TIGHT_ALIGNMENT::SupportTier</span>. </p> + +</div> +</div> <a id="a9e742884bd45dd7f01193d13fcd05af0" name="a9e742884bd45dd7f01193d13fcd05af0"></a> <h2 class="memtitle"><span class="permalink"><a href="#a9e742884bd45dd7f01193d13fcd05af0">◆ </a></span>IsUMA()</h2>
diff --git a/docs/html/configuration.html b/docs/html/configuration.html index 65d7bdd..3ab9ada 100644 --- a/docs/html/configuration.html +++ b/docs/html/configuration.html
@@ -113,13 +113,13 @@ <div class="line">HRESULT hr = <a class="code hl_function" href="namespace_d3_d12_m_a.html#ab7a1cd1683986d75ce1488b0920f4cb0">D3D12MA::CreateAllocator</a>(&allocatorDesc, &allocator);</div> <div class="line"><span class="comment">// Check hr...</span></div> <div class="ttc" id="a_d3_d12_mem_alloc_8h_html_accfbeae642feeacf353ce695e91a5e73"><div class="ttname"><a href="_d3_d12_mem_alloc_8h.html#accfbeae642feeacf353ce695e91a5e73">D3D12MA_RECOMMENDED_ALLOCATOR_FLAGS</a></div><div class="ttdeci">#define D3D12MA_RECOMMENDED_ALLOCATOR_FLAGS</div><div class="ttdoc">Set of flags recommended for use in D3D12MA::ALLOCATOR_DESC::Flags for optimal performance.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:128</div></div> -<div class="ttc" id="aclass_d3_d12_m_a_1_1_allocator_html"><div class="ttname"><a href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a></div><div class="ttdoc">Represents main object of this library initialized for particular ID3D12Device.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1163</div></div> +<div class="ttc" id="aclass_d3_d12_m_a_1_1_allocator_html"><div class="ttname"><a href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a></div><div class="ttdoc">Represents main object of this library initialized for particular ID3D12Device.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1174</div></div> <div class="ttc" id="anamespace_d3_d12_m_a_html_ab7a1cd1683986d75ce1488b0920f4cb0"><div class="ttname"><a href="namespace_d3_d12_m_a.html#ab7a1cd1683986d75ce1488b0920f4cb0">D3D12MA::CreateAllocator</a></div><div class="ttdeci">D3D12MA_API HRESULT CreateAllocator(const ALLOCATOR_DESC *pDesc, Allocator **ppAllocator)</div><div class="ttdoc">Creates new main D3D12MA::Allocator object and returns it through ppAllocator.</div></div> -<div class="ttc" id="astruct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c.html">D3D12MA::ALLOCATOR_DESC</a></div><div class="ttdoc">Parameters of created Allocator object. To be used with CreateAllocator().</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1121</div></div> -<div class="ttc" id="astruct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c_html_a773ecc1945eb47c20e06455c3759e4ef"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c.html#a773ecc1945eb47c20e06455c3759e4ef">D3D12MA::ALLOCATOR_DESC::pAllocationCallbacks</a></div><div class="ttdeci">const ALLOCATION_CALLBACKS * pAllocationCallbacks</div><div class="ttdoc">Custom CPU memory allocation callbacks. Optional.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1144</div></div> -<div class="ttc" id="astruct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c_html_abf9a9f87f0ffea52816efd363c5fcd7b"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c.html#abf9a9f87f0ffea52816efd363c5fcd7b">D3D12MA::ALLOCATOR_DESC::pAdapter</a></div><div class="ttdeci">IDXGIAdapter * pAdapter</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1150</div></div> -<div class="ttc" id="astruct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c_html_ad8abad7c80ea0d8df27c85243ce720f3"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c.html#ad8abad7c80ea0d8df27c85243ce720f3">D3D12MA::ALLOCATOR_DESC::Flags</a></div><div class="ttdeci">ALLOCATOR_FLAGS Flags</div><div class="ttdoc">Flags for the entire allocator.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1126</div></div> -<div class="ttc" id="astruct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c_html_ada1bf21205065b3aa0284b5a9ee1cb3c"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c.html#ada1bf21205065b3aa0284b5a9ee1cb3c">D3D12MA::ALLOCATOR_DESC::pDevice</a></div><div class="ttdeci">ID3D12Device * pDevice</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1132</div></div> +<div class="ttc" id="astruct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c.html">D3D12MA::ALLOCATOR_DESC</a></div><div class="ttdoc">Parameters of created Allocator object. To be used with CreateAllocator().</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1132</div></div> +<div class="ttc" id="astruct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c_html_a773ecc1945eb47c20e06455c3759e4ef"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c.html#a773ecc1945eb47c20e06455c3759e4ef">D3D12MA::ALLOCATOR_DESC::pAllocationCallbacks</a></div><div class="ttdeci">const ALLOCATION_CALLBACKS * pAllocationCallbacks</div><div class="ttdoc">Custom CPU memory allocation callbacks. Optional.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1155</div></div> +<div class="ttc" id="astruct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c_html_abf9a9f87f0ffea52816efd363c5fcd7b"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c.html#abf9a9f87f0ffea52816efd363c5fcd7b">D3D12MA::ALLOCATOR_DESC::pAdapter</a></div><div class="ttdeci">IDXGIAdapter * pAdapter</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1161</div></div> +<div class="ttc" id="astruct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c_html_ad8abad7c80ea0d8df27c85243ce720f3"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c.html#ad8abad7c80ea0d8df27c85243ce720f3">D3D12MA::ALLOCATOR_DESC::Flags</a></div><div class="ttdeci">ALLOCATOR_FLAGS Flags</div><div class="ttdoc">Flags for the entire allocator.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1137</div></div> +<div class="ttc" id="astruct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c_html_ada1bf21205065b3aa0284b5a9ee1cb3c"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c.html#ada1bf21205065b3aa0284b5a9ee1cb3c">D3D12MA::ALLOCATOR_DESC::pDevice</a></div><div class="ttdeci">ID3D12Device * pDevice</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1143</div></div> </div><!-- fragment --><h1 class="doxsection"><a class="anchor" id="debug_margins"></a> Debug margins</h1> <p>By default, allocations are laid out in memory blocks next to each other if possible (considering required alignment returned by <span class="tt">ID3D12Device::GetResourceAllocationInfo</span>).</p>
diff --git a/docs/html/doxygen_crawl.html b/docs/html/doxygen_crawl.html index 6b8ae0b..c4ffff1 100644 --- a/docs/html/doxygen_crawl.html +++ b/docs/html/doxygen_crawl.html
@@ -53,6 +53,7 @@ <a href="class_d3_d12_m_a_1_1_allocator.html#a1ac113daec5f6ef28ecb1786cf544144"/> <a href="class_d3_d12_m_a_1_1_allocator.html#a29716b3084916abed7793bf2ec4b65db"/> <a href="class_d3_d12_m_a_1_1_allocator.html#a3f3fd1e88cf2cd02257fe272e08a273c"/> +<a href="class_d3_d12_m_a_1_1_allocator.html#a3f5aa191cebdca7c1932da4723cfc03e"/> <a href="class_d3_d12_m_a_1_1_allocator.html#a434ae3147209953253da26687bfd62dc"/> <a href="class_d3_d12_m_a_1_1_allocator.html#a468ba0c93121eaaee402b08775f1dd11"/> <a href="class_d3_d12_m_a_1_1_allocator.html#a6e114ef3b4a791a3bf2e3109a3971559"/> @@ -187,6 +188,7 @@ <a href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a2fb30967b492c27823a80b5de3aea26f"/> <a href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916adfbfd20d716f2a46f74d6226056fef1e"/> <a href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916ae7dc7ab9168148281ebfe1586f554335"/> +<a href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916af13bc700d7b799c856c6516acac12fed"/> <a href="namespace_d3_d12_m_a.html#ad998d40b4601b84dbc538694b1faf4d5"/> <a href="namespacemembers.html"/> <a href="namespacemembers_enum.html"/>
diff --git a/docs/html/functions.html b/docs/html/functions.html index e1beea4..de18e05 100644 --- a/docs/html/functions.html +++ b/docs/html/functions.html
@@ -170,6 +170,7 @@ <li>IsCacheCoherentUMA() : <a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a08210561b92c4bd7ede9dd7beba4bb80">D3D12MA::Allocator</a></li> <li>IsEmpty() : <a class="el" href="class_d3_d12_m_a_1_1_virtual_block.html#a7b23fd2da6f0343095fb14b31395678b">D3D12MA::VirtualBlock</a></li> <li>IsGPUUploadHeapSupported() : <a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a3f3fd1e88cf2cd02257fe272e08a273c">D3D12MA::Allocator</a></li> +<li>IsTightAlignmentSupported() : <a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a3f5aa191cebdca7c1932da4723cfc03e">D3D12MA::Allocator</a></li> <li>IsUMA() : <a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a9e742884bd45dd7f01193d13fcd05af0">D3D12MA::Allocator</a></li> </ul>
diff --git a/docs/html/functions_func.html b/docs/html/functions_func.html index 8f38cf0..9bc7749 100644 --- a/docs/html/functions_func.html +++ b/docs/html/functions_func.html
@@ -136,6 +136,7 @@ <li>IsCacheCoherentUMA() : <a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a08210561b92c4bd7ede9dd7beba4bb80">D3D12MA::Allocator</a></li> <li>IsEmpty() : <a class="el" href="class_d3_d12_m_a_1_1_virtual_block.html#a7b23fd2da6f0343095fb14b31395678b">D3D12MA::VirtualBlock</a></li> <li>IsGPUUploadHeapSupported() : <a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a3f3fd1e88cf2cd02257fe272e08a273c">D3D12MA::Allocator</a></li> +<li>IsTightAlignmentSupported() : <a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a3f5aa191cebdca7c1932da4723cfc03e">D3D12MA::Allocator</a></li> <li>IsUMA() : <a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a9e742884bd45dd7f01193d13fcd05af0">D3D12MA::Allocator</a></li> </ul>
diff --git a/docs/html/index.html b/docs/html/index.html index d7434ba..d99307f 100644 --- a/docs/html/index.html +++ b/docs/html/index.html
@@ -74,7 +74,7 @@ <div class="headertitle"><div class="title">D3D12 Memory Allocator </div></div> </div><!--header--> <div class="contents"> -<div class="textblock"><p><b>Version 3.0.2</b> (2025-XX-XX)</p> +<div class="textblock"><p><b>Version 3.1.0-development</b> (2025-XX-XX)</p> <p>Copyright (c) 2019-2025 Advanced Micro Devices, Inc. All rights reserved. <br /> License: MIT</p> <p>Documentation of all members: D3D12MemAlloc.h</p>
diff --git a/docs/html/namespace_d3_d12_m_a.html b/docs/html/namespace_d3_d12_m_a.html index b4ae5de..d801b62 100644 --- a/docs/html/namespace_d3_d12_m_a.html +++ b/docs/html/namespace_d3_d12_m_a.html
@@ -191,6 +191,7 @@ , <br />   <a class="el" href="#ad5ae5a5e42b878f2e18ab5d1fbfb9916adfbfd20d716f2a46f74d6226056fef1e">ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED</a> = 0x8 , <a class="el" href="#ad5ae5a5e42b878f2e18ab5d1fbfb9916a15c1ba5fbc182ac927b3011e23e74a72">ALLOCATOR_FLAG_DONT_PREFER_SMALL_BUFFERS_COMMITTED</a> = 0x10 +, <a class="el" href="#ad5ae5a5e42b878f2e18ab5d1fbfb9916af13bc700d7b799c856c6516acac12fed">ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT</a> = 0x20 <br /> }</td></tr> <tr class="memdesc:ad5ae5a5e42b878f2e18ab5d1fbfb9916"><td class="mdescLeft"> </td><td class="mdescRight">Bit flags to be used with ALLOCATOR_DESC::Flags. <a href="#ad5ae5a5e42b878f2e18ab5d1fbfb9916">More...</a><br /></td></tr> @@ -352,7 +353,11 @@ <p>You should always use this flag unless you really need to create some MSAA textures as placed. </p> </td></tr> <tr><td class="fieldname"><a id="ad5ae5a5e42b878f2e18ab5d1fbfb9916a15c1ba5fbc182ac927b3011e23e74a72" name="ad5ae5a5e42b878f2e18ab5d1fbfb9916a15c1ba5fbc182ac927b3011e23e74a72"></a>ALLOCATOR_FLAG_DONT_PREFER_SMALL_BUFFERS_COMMITTED </td><td class="fielddoc"><p>Disable optimization that prefers creating small buffers as committed to avoid 64 KB alignment.</p> -<p>By default, the library prefers creating small buffers <= 32 KB as committed, because drivers tend to pack them better, while placed buffers require 64 KB alignment. This, however, may decrease performance, as creating committed resources involves allocation of implicit heaps, which may take longer than creating placed resources in existing heaps. Passing this flag will disable this committed preference globally for the allocator. It can also be disabled for a single allocation by using <a class="el" href="#abbad31a7e0b3d09d77f3fb704b77645eaa3ded8847563c24b4522af0586dbd2cb">ALLOCATION_FLAG_STRATEGY_MIN_TIME</a>. </p> +<p>By default, the library prefers creating small buffers <= 32 KB as committed, because drivers tend to pack them better, while placed buffers require 64 KB alignment. This, however, may decrease performance, as creating committed resources involves allocation of implicit heaps, which may take longer than creating placed resources in existing heaps. Passing this flag will disable this committed preference globally for the allocator. It can also be disabled for a single allocation by using <a class="el" href="#abbad31a7e0b3d09d77f3fb704b77645eaa3ded8847563c24b4522af0586dbd2cb">ALLOCATION_FLAG_STRATEGY_MIN_TIME</a>.</p> +<p>If the tight resource alignment feature is used by the library (which happens automatically whenever supported, unless you use flag <a class="el" href="#ad5ae5a5e42b878f2e18ab5d1fbfb9916af13bc700d7b799c856c6516acac12fed">ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT</a>), then small buffers are not preferred as committed. Long story short, you don't need to specify any of these flags. The library chooses the most optimal method automatically. </p> +</td></tr> +<tr><td class="fieldname"><a id="ad5ae5a5e42b878f2e18ab5d1fbfb9916af13bc700d7b799c856c6516acac12fed" name="ad5ae5a5e42b878f2e18ab5d1fbfb9916af13bc700d7b799c856c6516acac12fed"></a>ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT </td><td class="fielddoc"><p>Disables the use of the tight alignment feature even when it is supported on the current system. By default, the feature is used whenever available.</p> +<p>Support can be checked by <a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a3f5aa191cebdca7c1932da4723cfc03e" title="Returns true if resource tight alignment is supported on the current system. When supported,...">D3D12MA::Allocator::IsTightAlignmentSupported()</a> regardless of using this flag. </p> </td></tr> </table>
diff --git a/docs/html/namespacemembers.html b/docs/html/namespacemembers.html index 4cadc29..d6237ba 100644 --- a/docs/html/namespacemembers.html +++ b/docs/html/namespacemembers.html
@@ -91,6 +91,7 @@ <li>ALLOCATOR_FLAG_ALWAYS_COMMITTED : <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a068863dc0538ff4ea153b046b31e94fb">D3D12MA</a></li> <li>ALLOCATOR_FLAG_DEFAULT_POOLS_NOT_ZEROED : <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916ae7dc7ab9168148281ebfe1586f554335">D3D12MA</a></li> <li>ALLOCATOR_FLAG_DONT_PREFER_SMALL_BUFFERS_COMMITTED : <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a15c1ba5fbc182ac927b3011e23e74a72">D3D12MA</a></li> +<li>ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT : <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916af13bc700d7b799c856c6516acac12fed">D3D12MA</a></li> <li>ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED : <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916adfbfd20d716f2a46f74d6226056fef1e">D3D12MA</a></li> <li>ALLOCATOR_FLAG_NONE : <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a2fb30967b492c27823a80b5de3aea26f">D3D12MA</a></li> <li>ALLOCATOR_FLAG_SINGLETHREADED : <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a1b06bb21df006f76a9ed1bc41838bc52">D3D12MA</a></li>
diff --git a/docs/html/namespacemembers_eval.html b/docs/html/namespacemembers_eval.html index 4a4922b..2efa466 100644 --- a/docs/html/namespacemembers_eval.html +++ b/docs/html/namespacemembers_eval.html
@@ -89,6 +89,7 @@ <li>ALLOCATOR_FLAG_ALWAYS_COMMITTED : <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a068863dc0538ff4ea153b046b31e94fb">D3D12MA</a></li> <li>ALLOCATOR_FLAG_DEFAULT_POOLS_NOT_ZEROED : <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916ae7dc7ab9168148281ebfe1586f554335">D3D12MA</a></li> <li>ALLOCATOR_FLAG_DONT_PREFER_SMALL_BUFFERS_COMMITTED : <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a15c1ba5fbc182ac927b3011e23e74a72">D3D12MA</a></li> +<li>ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT : <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916af13bc700d7b799c856c6516acac12fed">D3D12MA</a></li> <li>ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED : <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916adfbfd20d716f2a46f74d6226056fef1e">D3D12MA</a></li> <li>ALLOCATOR_FLAG_NONE : <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a2fb30967b492c27823a80b5de3aea26f">D3D12MA</a></li> <li>ALLOCATOR_FLAG_SINGLETHREADED : <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a1b06bb21df006f76a9ed1bc41838bc52">D3D12MA</a></li>
diff --git a/docs/html/optimal_allocation.html b/docs/html/optimal_allocation.html index 88f3e62..8d72300 100644 --- a/docs/html/optimal_allocation.html +++ b/docs/html/optimal_allocation.html
@@ -153,8 +153,8 @@ <div class="ttc" id="a_d3_d12_mem_alloc_8h_html_ac3d50f134ad24c58df4a934b87847653"><div class="ttname"><a href="_d3_d12_mem_alloc_8h.html#ac3d50f134ad24c58df4a934b87847653">D3D12MA_RECOMMENDED_HEAP_FLAGS</a></div><div class="ttdeci">#define D3D12MA_RECOMMENDED_HEAP_FLAGS</div><div class="ttdoc">Set of flags recommended for use in D3D12MA::POOL_DESC::HeapFlags for optimal performance.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:136</div></div> <div class="ttc" id="aclass_d3_d12_m_a_1_1_allocation_html"><div class="ttname"><a href="class_d3_d12_m_a_1_1_allocation.html">D3D12MA::Allocation</a></div><div class="ttdoc">Represents single memory allocation.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:523</div></div> <div class="ttc" id="aclass_d3_d12_m_a_1_1_pool_html"><div class="ttname"><a href="class_d3_d12_m_a_1_1_pool.html">D3D12MA::Pool</a></div><div class="ttdoc">Custom memory pool.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:992</div></div> -<div class="ttc" id="astruct_d3_d12_m_a_1_1_c_a_l_l_o_c_a_t_i_o_n___d_e_s_c_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_c_a_l_l_o_c_a_t_i_o_n___d_e_s_c.html">D3D12MA::CALLOCATION_DESC</a></div><div class="ttdoc">Helper structure that helps with complete and conscise initialization of the D3D12MA::ALLOCATION_DESC...</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1659</div></div> -<div class="ttc" id="astruct_d3_d12_m_a_1_1_c_p_o_o_l___d_e_s_c_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_c_p_o_o_l___d_e_s_c.html">D3D12MA::CPOOL_DESC</a></div><div class="ttdoc">Helper structure that helps with complete and conscise initialization of the D3D12MA::POOL_DESC struc...</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1695</div></div> +<div class="ttc" id="astruct_d3_d12_m_a_1_1_c_a_l_l_o_c_a_t_i_o_n___d_e_s_c_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_c_a_l_l_o_c_a_t_i_o_n___d_e_s_c.html">D3D12MA::CALLOCATION_DESC</a></div><div class="ttdoc">Helper structure that helps with complete and conscise initialization of the D3D12MA::ALLOCATION_DESC...</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1676</div></div> +<div class="ttc" id="astruct_d3_d12_m_a_1_1_c_p_o_o_l___d_e_s_c_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_c_p_o_o_l___d_e_s_c.html">D3D12MA::CPOOL_DESC</a></div><div class="ttdoc">Helper structure that helps with complete and conscise initialization of the D3D12MA::POOL_DESC struc...</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1712</div></div> <div class="ttc" id="astruct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c_html_a2e6074af8c8ff7b957fe8d4b5036a5e6"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html#a2e6074af8c8ff7b957fe8d4b5036a5e6">D3D12MA::POOL_DESC::ResidencyPriority</a></div><div class="ttdeci">D3D12_RESIDENCY_PRIORITY ResidencyPriority</div><div class="ttdoc">Residency priority to be set for all allocations made in this pool. Optional.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:980</div></div> </div><!-- fragment --><p>When you have a committed allocation created, you can also set the residency priority of its resource using the D3D12 function:</p> <div class="fragment"><div class="line"><a class="code hl_class" href="class_d3_d12_m_a_1_1_allocation.html">D3D12MA::Allocation</a>* committedAlloc = ...</div> @@ -296,7 +296,10 @@ <dl class="section user"><dt>Implementation detail</dt><dd>Default alignment required MSAA textures is <span class="tt">D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT</span> = 4 MB. Default alignment required for buffers and other textures is <span class="tt">D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT</span> = 64 KB.</dd></dl> <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">D3D12MA::ALLOCATOR_FLAG_DONT_PREFER_SMALL_BUFFERS_COMMITTED</a>.</p> <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 <span class="tt">D3D12_RESOURCE_DESC</span> structure. For MSAA textures, the small alignment is <span class="tt">D3D12_SMALL_MSAA_RESOURCE_PLACEMENT_ALIGNMENT</span> = 64 KB. For other textures, the small alignment is <span class="tt">D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT</span> = 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> -<p>D3D12 also has a concept of <b>alignment of the entire heap</b>, passed through <span class="tt">D3D12_HEAP_DESC::Alignment</span>. 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">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">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> +<p>D3D12 also has a concept of <b>alignment of the entire heap</b>, passed through <span class="tt">D3D12_HEAP_DESC::Alignment</span>. 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">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">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> +<p>With DirectX 12 Agility SDK 1.618.1, 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 <span class="tt">D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT</span> 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> +<p>You can check if the tight alignment it is available in the current system by calling <a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a3f5aa191cebdca7c1932da4723cfc03e" title="Returns true if resource tight alignment is supported on the current system. When supported,...">D3D12MA::Allocator::IsTightAlignmentSupported()</a>. You can tell the library to not use it by specifying <a class="el" href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916af13bc700d7b799c856c6516acac12fed">D3D12MA::ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT</a>. Typically, you don't need to do any of those.</p> +<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 <span class="tt">D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT</span> constant. You can override this logic for <a class="el" href="custom_pools.html">Custom memory pools</a> with a specific <a class="el" href="struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html#a0a6283eeb1f3f99d8c4ae264aec7f749" title="Additional minimum alignment to be used for all allocations created from this pool....">D3D12MA::POOL_DESC::MinAllocationAlignment</a>. </p> </div></div><!-- contents --> </div><!-- PageDoc --> <!-- start footer part -->
diff --git a/docs/html/quick_start.html b/docs/html/quick_start.html index 4eba7e6..de33ff7 100644 --- a/docs/html/quick_start.html +++ b/docs/html/quick_start.html
@@ -102,7 +102,7 @@ <div class="line">HRESULT hr = <a class="code hl_function" href="namespace_d3_d12_m_a.html#ab7a1cd1683986d75ce1488b0920f4cb0">D3D12MA::CreateAllocator</a>(&allocatorDesc, &allocator);</div> <div class="line"><span class="comment">// Check hr...</span></div> <div class="ttc" id="a_d3_d12_mem_alloc_8h_html_accfbeae642feeacf353ce695e91a5e73"><div class="ttname"><a href="_d3_d12_mem_alloc_8h.html#accfbeae642feeacf353ce695e91a5e73">D3D12MA_RECOMMENDED_ALLOCATOR_FLAGS</a></div><div class="ttdeci">#define D3D12MA_RECOMMENDED_ALLOCATOR_FLAGS</div><div class="ttdoc">Set of flags recommended for use in D3D12MA::ALLOCATOR_DESC::Flags for optimal performance.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:128</div></div> -<div class="ttc" id="aclass_d3_d12_m_a_1_1_allocator_html"><div class="ttname"><a href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a></div><div class="ttdoc">Represents main object of this library initialized for particular ID3D12Device.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1163</div></div> +<div class="ttc" id="aclass_d3_d12_m_a_1_1_allocator_html"><div class="ttname"><a href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a></div><div class="ttdoc">Represents main object of this library initialized for particular ID3D12Device.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1174</div></div> <div class="ttc" id="anamespace_d3_d12_m_a_html_ab7a1cd1683986d75ce1488b0920f4cb0"><div class="ttname"><a href="namespace_d3_d12_m_a.html#ab7a1cd1683986d75ce1488b0920f4cb0">D3D12MA::CreateAllocator</a></div><div class="ttdeci">D3D12MA_API HRESULT CreateAllocator(const ALLOCATOR_DESC *pDesc, Allocator **ppAllocator)</div><div class="ttdoc">Creates new main D3D12MA::Allocator object and returns it through ppAllocator.</div></div> </div><!-- fragment --><p>(5.) Right before destroying the D3D12 device, destroy the allocator object.</p> <div class="fragment"><div class="line">allocator->Release();</div> @@ -273,7 +273,7 @@ <div class="line">HRESULT hr = allocator-><a class="code hl_function" href="class_d3_d12_m_a_1_1_allocator.html#aa37d6b9fe8ea0864f7a35b9d68e8345a">CreateResource</a>(&allocDesc, &resDesc,</div> <div class="line"> D3D12_RESOURCE_STATE_COMMON, NULL, &alloc, IID_PPV_ARGS(&res));</div> <div class="line"><span class="comment">// Check hr...</span></div> -<div class="ttc" id="astruct_d3_d12_m_a_1_1_c_a_l_l_o_c_a_t_i_o_n___d_e_s_c_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_c_a_l_l_o_c_a_t_i_o_n___d_e_s_c.html">D3D12MA::CALLOCATION_DESC</a></div><div class="ttdoc">Helper structure that helps with complete and conscise initialization of the D3D12MA::ALLOCATION_DESC...</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1659</div></div> +<div class="ttc" id="astruct_d3_d12_m_a_1_1_c_a_l_l_o_c_a_t_i_o_n___d_e_s_c_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_c_a_l_l_o_c_a_t_i_o_n___d_e_s_c.html">D3D12MA::CALLOCATION_DESC</a></div><div class="ttdoc">Helper structure that helps with complete and conscise initialization of the D3D12MA::ALLOCATION_DESC...</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1676</div></div> </div><!-- fragment --> </div></div><!-- contents --> </div><!-- PageDoc --> <!-- start footer part -->
diff --git a/docs/html/search/all_0.js b/docs/html/search/all_0.js index f5b2737..6c29668 100644 --- a/docs/html/search/all_0.js +++ b/docs/html/search/all_0.js
@@ -42,17 +42,18 @@ ['allocator_5fflag_5falways_5fcommitted_39',['ALLOCATOR_FLAG_ALWAYS_COMMITTED',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a068863dc0538ff4ea153b046b31e94fb',1,'D3D12MA']]], ['allocator_5fflag_5fdefault_5fpools_5fnot_5fzeroed_40',['ALLOCATOR_FLAG_DEFAULT_POOLS_NOT_ZEROED',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916ae7dc7ab9168148281ebfe1586f554335',1,'D3D12MA']]], ['allocator_5fflag_5fdont_5fprefer_5fsmall_5fbuffers_5fcommitted_41',['ALLOCATOR_FLAG_DONT_PREFER_SMALL_BUFFERS_COMMITTED',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a15c1ba5fbc182ac927b3011e23e74a72',1,'D3D12MA']]], - ['allocator_5fflag_5fmsaa_5ftextures_5falways_5fcommitted_42',['ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916adfbfd20d716f2a46f74d6226056fef1e',1,'D3D12MA']]], - ['allocator_5fflag_5fnone_43',['ALLOCATOR_FLAG_NONE',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a2fb30967b492c27823a80b5de3aea26f',1,'D3D12MA']]], - ['allocator_5fflag_5fsinglethreaded_44',['ALLOCATOR_FLAG_SINGLETHREADED',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a1b06bb21df006f76a9ed1bc41838bc52',1,'D3D12MA']]], - ['allocator_5fflags_45',['ALLOCATOR_FLAGS',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916',1,'D3D12MA']]], - ['allochandle_46',['AllocHandle',['../struct_d3_d12_m_a_1_1_virtual_allocation.html#a5d3166cf1f284fbbea4d0b169c4dba13',1,'D3D12MA::VirtualAllocation::AllocHandle'],['../namespace_d3_d12_m_a.html#a15e349adce86a40e0417d405aef1af80',1,'D3D12MA::AllocHandle']]], - ['allochandle_47',['allocHandle',['../class_d3_d12_m_a_1_1_allocation.html#a5c38846905b1ca0ff228c6081f2fc20c',1,'D3D12MA::Allocation']]], - ['and_20benefits_48',['Features and benefits',['../custom_pools.html#custom_pools_features_and_benefits',1,'']]], - ['and_20compatibility_49',['Versioning and compatibility',['../general_considerations.html#general_considerations_versioning_and_compatibility',1,'']]], - ['and_20initialization_50',['Project setup and initialization',['../quick_start.html#quick_start_project_setup',1,'']]], - ['and_20units_51',['Alignment and units',['../virtual_allocator.html#virtual_allocator_alignment_and_units',1,'']]], - ['asked_20questions_52',['Frequently asked questions',['../faq.html',1,'index']]], - ['at_20once_53',['Free-at-once',['../linear_algorithm.html#linear_algorithm_free_at_once',1,'']]], - ['avoiding_20running_20out_20of_20memory_54',['Avoiding running out of memory',['../optimal_allocation.html#optimal_allocation_avoiding_running_out_of_memory',1,'']]] + ['allocator_5fflag_5fdont_5fuse_5ftight_5falignment_42',['ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916af13bc700d7b799c856c6516acac12fed',1,'D3D12MA']]], + ['allocator_5fflag_5fmsaa_5ftextures_5falways_5fcommitted_43',['ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916adfbfd20d716f2a46f74d6226056fef1e',1,'D3D12MA']]], + ['allocator_5fflag_5fnone_44',['ALLOCATOR_FLAG_NONE',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a2fb30967b492c27823a80b5de3aea26f',1,'D3D12MA']]], + ['allocator_5fflag_5fsinglethreaded_45',['ALLOCATOR_FLAG_SINGLETHREADED',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a1b06bb21df006f76a9ed1bc41838bc52',1,'D3D12MA']]], + ['allocator_5fflags_46',['ALLOCATOR_FLAGS',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916',1,'D3D12MA']]], + ['allochandle_47',['AllocHandle',['../struct_d3_d12_m_a_1_1_virtual_allocation.html#a5d3166cf1f284fbbea4d0b169c4dba13',1,'D3D12MA::VirtualAllocation::AllocHandle'],['../namespace_d3_d12_m_a.html#a15e349adce86a40e0417d405aef1af80',1,'D3D12MA::AllocHandle']]], + ['allochandle_48',['allocHandle',['../class_d3_d12_m_a_1_1_allocation.html#a5c38846905b1ca0ff228c6081f2fc20c',1,'D3D12MA::Allocation']]], + ['and_20benefits_49',['Features and benefits',['../custom_pools.html#custom_pools_features_and_benefits',1,'']]], + ['and_20compatibility_50',['Versioning and compatibility',['../general_considerations.html#general_considerations_versioning_and_compatibility',1,'']]], + ['and_20initialization_51',['Project setup and initialization',['../quick_start.html#quick_start_project_setup',1,'']]], + ['and_20units_52',['Alignment and units',['../virtual_allocator.html#virtual_allocator_alignment_and_units',1,'']]], + ['asked_20questions_53',['Frequently asked questions',['../faq.html',1,'index']]], + ['at_20once_54',['Free-at-once',['../linear_algorithm.html#linear_algorithm_free_at_once',1,'']]], + ['avoiding_20running_20out_20of_20memory_55',['Avoiding running out of memory',['../optimal_allocation.html#optimal_allocation_avoiding_running_out_of_memory',1,'']]] ];
diff --git a/docs/html/search/all_8.js b/docs/html/search/all_8.js index 90457e4..aca0ae9 100644 --- a/docs/html/search/all_8.js +++ b/docs/html/search/all_8.js
@@ -4,5 +4,6 @@ ['iscachecoherentuma_1',['IsCacheCoherentUMA',['../class_d3_d12_m_a_1_1_allocator.html#a08210561b92c4bd7ede9dd7beba4bb80',1,'D3D12MA::Allocator']]], ['isempty_2',['IsEmpty',['../class_d3_d12_m_a_1_1_virtual_block.html#a7b23fd2da6f0343095fb14b31395678b',1,'D3D12MA::VirtualBlock']]], ['isgpuuploadheapsupported_3',['IsGPUUploadHeapSupported',['../class_d3_d12_m_a_1_1_allocator.html#a3f3fd1e88cf2cd02257fe272e08a273c',1,'D3D12MA::Allocator']]], - ['isuma_4',['IsUMA',['../class_d3_d12_m_a_1_1_allocator.html#a9e742884bd45dd7f01193d13fcd05af0',1,'D3D12MA::Allocator']]] + ['istightalignmentsupported_4',['IsTightAlignmentSupported',['../class_d3_d12_m_a_1_1_allocator.html#a3f5aa191cebdca7c1932da4723cfc03e',1,'D3D12MA::Allocator']]], + ['isuma_5',['IsUMA',['../class_d3_d12_m_a_1_1_allocator.html#a9e742884bd45dd7f01193d13fcd05af0',1,'D3D12MA::Allocator']]] ];
diff --git a/docs/html/search/enumvalues_0.js b/docs/html/search/enumvalues_0.js index ac4eaeb..3fcb12f 100644 --- a/docs/html/search/enumvalues_0.js +++ b/docs/html/search/enumvalues_0.js
@@ -15,7 +15,8 @@ ['allocator_5fflag_5falways_5fcommitted_12',['ALLOCATOR_FLAG_ALWAYS_COMMITTED',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a068863dc0538ff4ea153b046b31e94fb',1,'D3D12MA']]], ['allocator_5fflag_5fdefault_5fpools_5fnot_5fzeroed_13',['ALLOCATOR_FLAG_DEFAULT_POOLS_NOT_ZEROED',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916ae7dc7ab9168148281ebfe1586f554335',1,'D3D12MA']]], ['allocator_5fflag_5fdont_5fprefer_5fsmall_5fbuffers_5fcommitted_14',['ALLOCATOR_FLAG_DONT_PREFER_SMALL_BUFFERS_COMMITTED',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a15c1ba5fbc182ac927b3011e23e74a72',1,'D3D12MA']]], - ['allocator_5fflag_5fmsaa_5ftextures_5falways_5fcommitted_15',['ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916adfbfd20d716f2a46f74d6226056fef1e',1,'D3D12MA']]], - ['allocator_5fflag_5fnone_16',['ALLOCATOR_FLAG_NONE',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a2fb30967b492c27823a80b5de3aea26f',1,'D3D12MA']]], - ['allocator_5fflag_5fsinglethreaded_17',['ALLOCATOR_FLAG_SINGLETHREADED',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a1b06bb21df006f76a9ed1bc41838bc52',1,'D3D12MA']]] + ['allocator_5fflag_5fdont_5fuse_5ftight_5falignment_15',['ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916af13bc700d7b799c856c6516acac12fed',1,'D3D12MA']]], + ['allocator_5fflag_5fmsaa_5ftextures_5falways_5fcommitted_16',['ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916adfbfd20d716f2a46f74d6226056fef1e',1,'D3D12MA']]], + ['allocator_5fflag_5fnone_17',['ALLOCATOR_FLAG_NONE',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a2fb30967b492c27823a80b5de3aea26f',1,'D3D12MA']]], + ['allocator_5fflag_5fsinglethreaded_18',['ALLOCATOR_FLAG_SINGLETHREADED',['../namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916a1b06bb21df006f76a9ed1bc41838bc52',1,'D3D12MA']]] ];
diff --git a/docs/html/search/functions_6.js b/docs/html/search/functions_6.js index 22c80f9..538639e 100644 --- a/docs/html/search/functions_6.js +++ b/docs/html/search/functions_6.js
@@ -3,5 +3,6 @@ ['iscachecoherentuma_0',['IsCacheCoherentUMA',['../class_d3_d12_m_a_1_1_allocator.html#a08210561b92c4bd7ede9dd7beba4bb80',1,'D3D12MA::Allocator']]], ['isempty_1',['IsEmpty',['../class_d3_d12_m_a_1_1_virtual_block.html#a7b23fd2da6f0343095fb14b31395678b',1,'D3D12MA::VirtualBlock']]], ['isgpuuploadheapsupported_2',['IsGPUUploadHeapSupported',['../class_d3_d12_m_a_1_1_allocator.html#a3f3fd1e88cf2cd02257fe272e08a273c',1,'D3D12MA::Allocator']]], - ['isuma_3',['IsUMA',['../class_d3_d12_m_a_1_1_allocator.html#a9e742884bd45dd7f01193d13fcd05af0',1,'D3D12MA::Allocator']]] + ['istightalignmentsupported_3',['IsTightAlignmentSupported',['../class_d3_d12_m_a_1_1_allocator.html#a3f5aa191cebdca7c1932da4723cfc03e',1,'D3D12MA::Allocator']]], + ['isuma_4',['IsUMA',['../class_d3_d12_m_a_1_1_allocator.html#a9e742884bd45dd7f01193d13fcd05af0',1,'D3D12MA::Allocator']]] ];
diff --git a/docs/html/virtual_allocator.html b/docs/html/virtual_allocator.html index 43cc74b..5cd93d6 100644 --- a/docs/html/virtual_allocator.html +++ b/docs/html/virtual_allocator.html
@@ -92,9 +92,9 @@ <div class="line"> </div> <div class="line"><a class="code hl_class" href="class_d3_d12_m_a_1_1_virtual_block.html">D3D12MA::VirtualBlock</a> *block;</div> <div class="line">HRESULT hr = CreateVirtualBlock(&blockDesc, &block);</div> -<div class="ttc" id="aclass_d3_d12_m_a_1_1_virtual_block_html"><div class="ttname"><a href="class_d3_d12_m_a_1_1_virtual_block.html">D3D12MA::VirtualBlock</a></div><div class="ttdoc">Represents pure allocation algorithm and a data structure with allocations in some memory block,...</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1577</div></div> -<div class="ttc" id="astruct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___b_l_o_c_k___d_e_s_c_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___b_l_o_c_k___d_e_s_c.html">D3D12MA::VIRTUAL_BLOCK_DESC</a></div><div class="ttdoc">Parameters of created D3D12MA::VirtualBlock object to be passed to CreateVirtualBlock().</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1483</div></div> -<div class="ttc" id="astruct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___b_l_o_c_k___d_e_s_c_html_ac56491679f276a5a9956ed99bc4654e4"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___b_l_o_c_k___d_e_s_c.html#ac56491679f276a5a9956ed99bc4654e4">D3D12MA::VIRTUAL_BLOCK_DESC::Size</a></div><div class="ttdeci">UINT64 Size</div><div class="ttdoc">Total size of the block.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1491</div></div> +<div class="ttc" id="aclass_d3_d12_m_a_1_1_virtual_block_html"><div class="ttname"><a href="class_d3_d12_m_a_1_1_virtual_block.html">D3D12MA::VirtualBlock</a></div><div class="ttdoc">Represents pure allocation algorithm and a data structure with allocations in some memory block,...</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1594</div></div> +<div class="ttc" id="astruct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___b_l_o_c_k___d_e_s_c_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___b_l_o_c_k___d_e_s_c.html">D3D12MA::VIRTUAL_BLOCK_DESC</a></div><div class="ttdoc">Parameters of created D3D12MA::VirtualBlock object to be passed to CreateVirtualBlock().</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1500</div></div> +<div class="ttc" id="astruct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___b_l_o_c_k___d_e_s_c_html_ac56491679f276a5a9956ed99bc4654e4"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___b_l_o_c_k___d_e_s_c.html#ac56491679f276a5a9956ed99bc4654e4">D3D12MA::VIRTUAL_BLOCK_DESC::Size</a></div><div class="ttdeci">UINT64 Size</div><div class="ttdoc">Total size of the block.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1508</div></div> </div><!-- fragment --><h1 class="doxsection"><a class="anchor" id="virtual_allocator_making_virtual_allocations"></a> Making virtual allocations</h1> <p><a class="el" href="class_d3_d12_m_a_1_1_virtual_block.html" title="Represents pure allocation algorithm and a data structure with allocations in some memory block,...">D3D12MA::VirtualBlock</a> object contains internal data structure that keeps track of free and occupied regions using the same code as the main D3D12 memory allocator. A single allocation is identified by a lightweight structure <a class="el" href="struct_d3_d12_m_a_1_1_virtual_allocation.html" title="Represents single memory allocation done inside VirtualBlock.">D3D12MA::VirtualAllocation</a>. You will also likely want to know the offset at which the allocation was made in the block.</p> @@ -119,8 +119,8 @@ <div class="line"> <span class="comment">// Allocation failed - no space for it could be found. Handle this error!</span></div> <div class="line">}</div> <div class="ttc" id="aclass_d3_d12_m_a_1_1_virtual_block_html_a9281daf76e888ea1bd5247d5732e8179"><div class="ttname"><a href="class_d3_d12_m_a_1_1_virtual_block.html#a9281daf76e888ea1bd5247d5732e8179">D3D12MA::VirtualBlock::Allocate</a></div><div class="ttdeci">HRESULT Allocate(const VIRTUAL_ALLOCATION_DESC *pDesc, VirtualAllocation *pAllocation, UINT64 *pOffset)</div><div class="ttdoc">Creates new allocation.</div></div> -<div class="ttc" id="astruct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___a_l_l_o_c_a_t_i_o_n___d_e_s_c_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___a_l_l_o_c_a_t_i_o_n___d_e_s_c.html">D3D12MA::VIRTUAL_ALLOCATION_DESC</a></div><div class="ttdoc">Parameters of created virtual allocation to be passed to VirtualBlock::Allocate().</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1528</div></div> -<div class="ttc" id="astruct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___a_l_l_o_c_a_t_i_o_n___d_e_s_c_html_a976b649e45abdd0769da0d79acde4bac"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___a_l_l_o_c_a_t_i_o_n___d_e_s_c.html#a976b649e45abdd0769da0d79acde4bac">D3D12MA::VIRTUAL_ALLOCATION_DESC::Size</a></div><div class="ttdeci">UINT64 Size</div><div class="ttdoc">Size of the allocation.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1535</div></div> +<div class="ttc" id="astruct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___a_l_l_o_c_a_t_i_o_n___d_e_s_c_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___a_l_l_o_c_a_t_i_o_n___d_e_s_c.html">D3D12MA::VIRTUAL_ALLOCATION_DESC</a></div><div class="ttdoc">Parameters of created virtual allocation to be passed to VirtualBlock::Allocate().</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1545</div></div> +<div class="ttc" id="astruct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___a_l_l_o_c_a_t_i_o_n___d_e_s_c_html_a976b649e45abdd0769da0d79acde4bac"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___a_l_l_o_c_a_t_i_o_n___d_e_s_c.html#a976b649e45abdd0769da0d79acde4bac">D3D12MA::VIRTUAL_ALLOCATION_DESC::Size</a></div><div class="ttdeci">UINT64 Size</div><div class="ttdoc">Size of the allocation.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1552</div></div> <div class="ttc" id="astruct_d3_d12_m_a_1_1_virtual_allocation_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_virtual_allocation.html">D3D12MA::VirtualAllocation</a></div><div class="ttdoc">Represents single memory allocation done inside VirtualBlock.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:503</div></div> </div><!-- fragment --><h1 class="doxsection"><a class="anchor" id="virtual_allocator_deallocation"></a> Deallocation</h1> @@ -158,7 +158,7 @@ <div class="line"><a class="code hl_struct" href="struct_d3_d12_m_a_1_1_virtual_allocation.html">D3D12MA::VirtualAllocation</a> alloc;</div> <div class="line">UINT64 allocOffset;</div> <div class="line">hr = block-><a class="code hl_function" href="class_d3_d12_m_a_1_1_virtual_block.html#a9281daf76e888ea1bd5247d5732e8179">Allocate</a>(&allocDesc, &alloc, &allocOffset);</div> -<div class="ttc" id="astruct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___a_l_l_o_c_a_t_i_o_n___d_e_s_c_html_aaa95e62f2f399339a09dcbb312a42de0"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___a_l_l_o_c_a_t_i_o_n___d_e_s_c.html#aaa95e62f2f399339a09dcbb312a42de0">D3D12MA::VIRTUAL_ALLOCATION_DESC::Alignment</a></div><div class="ttdeci">UINT64 Alignment</div><div class="ttdoc">Required alignment of the allocation.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1540</div></div> +<div class="ttc" id="astruct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___a_l_l_o_c_a_t_i_o_n___d_e_s_c_html_aaa95e62f2f399339a09dcbb312a42de0"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___a_l_l_o_c_a_t_i_o_n___d_e_s_c.html#aaa95e62f2f399339a09dcbb312a42de0">D3D12MA::VIRTUAL_ALLOCATION_DESC::Alignment</a></div><div class="ttdeci">UINT64 Alignment</div><div class="ttdoc">Required alignment of the allocation.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1557</div></div> </div><!-- fragment --><p>Alignments of different allocations made from one block may vary. However, if all alignments and sizes are always multiply of some size e.g. 4 B or <span class="tt">sizeof(MyDataStruct)</span>, you can express all sizes, alignments, and offsets in multiples of that size instead of individual bytes. It might be more convenient, but you need to make sure to use this new unit consistently in all the places:</p> <ul> <li><a class="el" href="struct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___b_l_o_c_k___d_e_s_c.html#ac56491679f276a5a9956ed99bc4654e4" title="Total size of the block.">D3D12MA::VIRTUAL_BLOCK_DESC::Size</a></li>
diff --git a/include/D3D12MemAlloc.h b/include/D3D12MemAlloc.h index d3a258a..ae358e3 100644 --- a/include/D3D12MemAlloc.h +++ b/include/D3D12MemAlloc.h
@@ -24,7 +24,7 @@ /** \mainpage D3D12 Memory Allocator -<b>Version 3.0.2</b> (2025-XX-XX) +<b>Version 3.1.0-development</b> (2025-XX-XX) Copyright (c) 2019-2025 Advanced Micro Devices, Inc. All rights reserved. \n License: MIT @@ -1112,8 +1112,19 @@ which may take longer than creating placed resources in existing heaps. Passing this flag will disable this committed preference globally for the allocator. It can also be disabled for a single allocation by using #ALLOCATION_FLAG_STRATEGY_MIN_TIME. + + If the tight resource alignment feature is used by the library (which happens automatically whenever supported, + unless you use flag #ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT), then small buffers are not preferred as committed. + Long story short, you don't need to specify any of these flags. + The library chooses the most optimal method automatically. */ ALLOCATOR_FLAG_DONT_PREFER_SMALL_BUFFERS_COMMITTED = 0x10, + /** Disables the use of the tight alignment feature even when it is supported on the current system. + By default, the feature is used whenever available. + + Support can be checked by D3D12MA::Allocator::IsTightAlignmentSupported() regardless of using this flag. + */ + ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT = 0x20, }; /// \brief Parameters of created Allocator object. To be used with CreateAllocator(). @@ -1189,6 +1200,12 @@ This flag is fetched from `D3D12_FEATURE_D3D12_OPTIONS16::GPUUploadHeapSupported`. */ BOOL IsGPUUploadHeapSupported() const; + /** \brief Returns true if resource tight alignment is supported on the current system. + When supported, it is automatically used by the library, unless + #ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT flag was specified on allocator creation. + This flag is fetched from `D3D12_FEATURE_DATA_TIGHT_ALIGNMENT::SupportTier`. + */ + BOOL IsTightAlignmentSupported() const; /** \brief Returns total amount of memory of specific segment group, in bytes. \param memorySegmentGroup use `DXGI_MEMORY_SEGMENT_GROUP_LOCAL` or `DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL`. @@ -2864,6 +2881,23 @@ 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. +With DirectX 12 Agility SDK 1.618.1, Microsoft added a new feature called **"tight alignment"**. +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 `D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT` 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. + +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. + +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 `D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT` constant. +You can override this logic for \subpage custom_pools with a specific D3D12MA::POOL_DESC::MinAllocationAlignment. + \page defragmentation Defragmentation Interleaved allocations and deallocations of many objects of varying size can
diff --git a/src/D3D12MemAlloc.cpp b/src/D3D12MemAlloc.cpp index e637874..0666868 100644 --- a/src/D3D12MemAlloc.cpp +++ b/src/D3D12MemAlloc.cpp
@@ -106,6 +106,14 @@ #endif #endif +#ifndef D3D12MA_DEFAULT_ALIGNMENT + /* + Default alignment of allocations in default pools and custom pools with MinAllocationAlignment == 0. + Can be lowered for custom pools by specifying custom MinAllocationAlignment > 0. + */ + #define D3D12MA_DEFAULT_ALIGNMENT D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT +#endif + #ifndef D3D12MA_DEBUG_ALIGNMENT /* Minimum alignment of all allocations, in bytes. @@ -139,6 +147,14 @@ #define D3D12MA_DEFAULT_BLOCK_SIZE (64ull * 1024 * 1024) #endif +#ifndef D3D12MA_TIGHT_ALIGNMENT_SUPPORTED + #if D3D12_SDK_VERSION >= 618 + #define D3D12MA_TIGHT_ALIGNMENT_SUPPORTED 1 + #else + #define D3D12MA_TIGHT_ALIGNMENT_SUPPORTED 0 + #endif +#endif + #ifndef D3D12MA_OPTIONS16_SUPPORTED #if D3D12_SDK_VERSION >= 610 #define D3D12MA_OPTIONS16_SUPPORTED 1 @@ -5973,6 +5989,8 @@ BOOL IsCacheCoherentUMA() const { return m_D3D12Architecture.CacheCoherentUMA; } bool SupportsResourceHeapTier2() const { return m_D3D12Options.ResourceHeapTier >= D3D12_RESOURCE_HEAP_TIER_2; } bool IsGPUUploadHeapSupported() const { return m_GPUUploadHeapSupported != FALSE; } + bool IsTightAlignmentSupported() const { return m_TightAlignmentSupported != FALSE; } + bool IsTightAlignmentEnabled() const { return IsTightAlignmentSupported() && m_UseTightAlignment; } bool UseMutex() const { return m_UseMutex; } AllocationObjectAllocator& GetAllocationObjectAllocator() { return m_AllocationObjectAllocator; } UINT GetCurrentFrameIndex() const { return m_CurrentFrameIndex.load(); } @@ -6059,7 +6077,8 @@ const bool m_UseMutex; const bool m_AlwaysCommitted; const bool m_MsaaAlwaysCommitted; - const bool m_PreferSmallBuffersCommitted; + bool m_PreferSmallBuffersCommitted; + const bool m_UseTightAlignment; bool m_DefaultPoolsNotZeroed = false; ID3D12Device* m_Device; // AddRef #ifdef __ID3D12Device1_INTERFACE_DEFINED__ @@ -6087,6 +6106,7 @@ DXGI_ADAPTER_DESC m_AdapterDesc; D3D12_FEATURE_DATA_D3D12_OPTIONS m_D3D12Options; BOOL m_GPUUploadHeapSupported = FALSE; + BOOL m_TightAlignmentSupported = FALSE; D3D12_FEATURE_DATA_ARCHITECTURE m_D3D12Architecture; AllocationObjectAllocator m_AllocationObjectAllocator; @@ -6168,7 +6188,8 @@ : m_UseMutex((desc.Flags & ALLOCATOR_FLAG_SINGLETHREADED) == 0), m_AlwaysCommitted((desc.Flags & ALLOCATOR_FLAG_ALWAYS_COMMITTED) != 0), m_MsaaAlwaysCommitted((desc.Flags & ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED) != 0), - m_PreferSmallBuffersCommitted((desc.Flags & ALLOCATOR_FLAG_DONT_PREFER_SMALL_BUFFERS_COMMITTED) == 0), + m_PreferSmallBuffersCommitted((desc.Flags& ALLOCATOR_FLAG_DONT_PREFER_SMALL_BUFFERS_COMMITTED) == 0), + m_UseTightAlignment((desc.Flags & ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT) == 0), m_Device(desc.pDevice), m_Adapter(desc.pAdapter), m_PreferredBlockSize(desc.PreferredBlockSize != 0 ? desc.PreferredBlockSize : D3D12MA_DEFAULT_BLOCK_SIZE), @@ -6257,6 +6278,25 @@ } #endif // #if D3D12MA_OPTIONS16_SUPPORTED +#if D3D12MA_TIGHT_ALIGNMENT_SUPPORTED + { + D3D12_FEATURE_DATA_TIGHT_ALIGNMENT tightAlignment = {}; + hr = m_Device->CheckFeatureSupport(D3D12_FEATURE_D3D12_TIGHT_ALIGNMENT, &tightAlignment, sizeof(tightAlignment)); + if (SUCCEEDED(hr)) + { + m_TightAlignmentSupported = tightAlignment.SupportTier >= D3D12_TIGHT_ALIGNMENT_TIER_1; + + // If tight alignment is supported (checked by the code above) and wasn't disabled by the developer + // (with ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT), disable the preference for creating small buffers as committed, + // as if ALLOCATOR_FLAG_DONT_PREFER_SMALL_BUFFERS_COMMITTED was specified. + if (IsTightAlignmentEnabled()) + { + m_PreferSmallBuffersCommitted = false; + } + } + } +#endif // #if D3D12MA_TIGHT_ALIGNMENT_SUPPORTED + hr = m_Device->CheckFeatureSupport(D3D12_FEATURE_ARCHITECTURE, &m_D3D12Architecture, sizeof(m_D3D12Architecture)); if (FAILED(hr)) { @@ -6286,7 +6326,7 @@ 0, // minBlockCount SIZE_MAX, // maxBlockCount false, // explicitBlockSize - D3D12MA_DEBUG_ALIGNMENT, // minAllocationAlignment + (UINT64)D3D12MA_DEFAULT_ALIGNMENT, // minAllocationAlignment 0, // Default algorithm, m_MsaaAlwaysCommitted, NULL, // pProtectedSession @@ -6953,6 +6993,9 @@ json.WriteString(L"GPUUploadHeapSupported"); json.WriteBool(m_GPUUploadHeapSupported != FALSE); + + json.WriteString(L"TightAlignmentSupported"); + json.WriteBool(m_TightAlignmentSupported != FALSE); } json.EndObject(); } @@ -7771,8 +7814,19 @@ D3D12_RESOURCE_ALLOCATION_INFO& outAllocInfo) const { #ifdef __ID3D12Device1_INTERFACE_DEFINED__ - /* Optional optimization: Microsoft documentation says: - https://docs.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12device-getresourceallocationinfo + +#if D3D12MA_TIGHT_ALIGNMENT_SUPPORTED + if (IsTightAlignmentEnabled() && + // Don't allow USE_TIGHT_ALIGNMENT together with ALLOW_CROSS_ADAPTER as there is a D3D Debug Layer error: + // D3D12 ERROR: ID3D12Device::GetResourceAllocationInfo: D3D12_RESOURCE_DESC::Flag D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT will be ignored since D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER is set. [ STATE_CREATION ERROR #599: CREATERESOURCE_INVALIDMISCFLAGS] + (inOutResourceDesc.Flags & D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER) == 0) + { + inOutResourceDesc.Flags |= D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT; + } +#endif // #if D3D12MA_TIGHT_ALIGNMENT_SUPPORTED + + /* Optional optimization: Microsoft documentation of the ID3D12Device:: + GetResourceAllocationInfo function says: Your application can forgo using GetResourceAllocationInfo for buffer resources (D3D12_RESOURCE_DIMENSION_BUFFER). Buffers have the same size on all adapters, @@ -7780,13 +7834,15 @@ D3D12_RESOURCE_DESC::Width. */ if (inOutResourceDesc.Alignment == 0 && - inOutResourceDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) + inOutResourceDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER && + !IsTightAlignmentEnabled()) { outAllocInfo = { AlignUp<UINT64>(inOutResourceDesc.Width, D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT), // SizeInBytes D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT }; // Alignment return S_OK; } + #endif // #ifdef __ID3D12Device1_INTERFACE_DEFINED__ HRESULT hr = S_OK; @@ -8103,7 +8159,7 @@ m_MinBlockCount(minBlockCount), m_MaxBlockCount(maxBlockCount), m_ExplicitBlockSize(explicitBlockSize), - m_MinAllocationAlignment(minAllocationAlignment), + m_MinAllocationAlignment(D3D12MA_MAX(minAllocationAlignment, (UINT64)D3D12MA_DEBUG_ALIGNMENT)), m_Algorithm(algorithm), m_DenyMsaaTextures(denyMsaaTextures), m_ProtectedSession(pProtectedSession), @@ -9256,12 +9312,14 @@ D3D12MA_ASSERT(m_Desc.pProtectedSession == NULL); #endif + const UINT64 minAlignment = desc.MinAllocationAlignment > 0 ? desc.MinAllocationAlignment : D3D12MA_DEFAULT_ALIGNMENT; + m_BlockVector = D3D12MA_NEW(allocator->GetAllocs(), BlockVector)( allocator, desc.HeapProperties, desc.HeapFlags, preferredBlockSize, desc.MinBlockCount, maxBlockCount, explicitBlockSize, - D3D12MA_MAX(desc.MinAllocationAlignment, (UINT64)D3D12MA_DEBUG_ALIGNMENT), + minAlignment, (desc.Flags & POOL_FLAG_ALGORITHM_MASK) != 0, (desc.Flags & POOL_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED) != 0, desc.pProtectedSession, @@ -9724,6 +9782,11 @@ return m_Pimpl->IsGPUUploadHeapSupported(); } +BOOL Allocator::IsTightAlignmentSupported() const +{ + return m_Pimpl->IsTightAlignmentSupported(); +} + UINT64 Allocator::GetMemoryCapacity(UINT memorySegmentGroup) const { return m_Pimpl->GetMemoryCapacity(memorySegmentGroup);
diff --git a/src/Tests.cpp b/src/Tests.cpp index 152b23a..09576d0 100644 --- a/src/Tests.cpp +++ b/src/Tests.cpp
@@ -51,6 +51,8 @@ static constexpr CONFIG_TYPE ConfigType = CONFIG_TYPE_AVERAGE; static const char* FREE_ORDER_NAMES[] = { "FORWARD", "BACKWARD", "RANDOM", }; +constexpr D3D12_RESOURCE_FLAGS D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT_COPY = (D3D12_RESOURCE_FLAGS)0x400; + // Indexes match enum D3D12_HEAP_TYPE. static const WCHAR* const HEAP_TYPE_NAMES[] = { @@ -213,6 +215,10 @@ D3D12_RESOURCE_DESC resDesc = alloc->GetResource()->GetDesc(); if (resDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) { + // Fix for D3D12 ERROR: ID3D12Device::CreatePlacedResource: D3D12_RESOURCE_DESC::Alignment is invalid. The value is 8. When D3D12_RESOURCE_DESC::Flag bit for D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT is set, Alignment must be 0. [ STATE_CREATION ERROR #721: CREATERESOURCE_INVALIDALIGNMENT] + if ((resDesc.Flags & D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT_COPY) != 0) + resDesc.Alignment = 0; + ComPtr<D3D12MA::Allocation> uploadAlloc; CHECK_HR(ctx.allocator->CreateResource(&allocDesc, &resDesc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, &uploadAlloc, IID_NULL, nullptr)); @@ -306,6 +312,10 @@ D3D12_RESOURCE_DESC resDesc = alloc->GetResource()->GetDesc(); if (resDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) { + // Fix for D3D12 ERROR: ID3D12Device::CreatePlacedResource: D3D12_RESOURCE_DESC::Alignment is invalid. The value is 8. When D3D12_RESOURCE_DESC::Flag bit for D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT is set, Alignment must be 0. [ STATE_CREATION ERROR #721: CREATERESOURCE_INVALIDALIGNMENT] + if ((resDesc.Flags & D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT_COPY) != 0) + resDesc.Alignment = 0; + ComPtr<D3D12MA::Allocation> downloadAlloc; CHECK_HR(ctx.allocator->CreateResource(&allocDesc, &resDesc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, &downloadAlloc, IID_NULL, nullptr)); @@ -718,6 +728,12 @@ { wprintf(L"Test small buffers\n"); + const bool isTightAlignmentEnabled = ctx.allocator->IsTightAlignmentSupported() && + (ctx.allocatorFlags & D3D12MA::ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT) == 0; + const bool expectSmallBuffersCommitted = !isTightAlignmentEnabled && + (ctx.allocatorFlags & D3D12MA::ALLOCATOR_FLAG_DONT_PREFER_SMALL_BUFFERS_COMMITTED) == 0; + + D3D12MA::CPOOL_DESC poolDesc = D3D12MA::CPOOL_DESC{ D3D12_HEAP_TYPE_DEFAULT, D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS }; @@ -763,13 +779,9 @@ CHECK_HR(ctx.allocator->CreateResource(&allocDesc, &resDesc, D3D12_RESOURCE_STATE_COMMON, nullptr, &resWithAlloc.allocation, IID_PPV_ARGS(&resWithAlloc.resource))); CHECK_BOOL(resWithAlloc.allocation && resWithAlloc.allocation->GetResource()); - // May or may not be committed, depending on the PREFER_SMALL_BUFFERS_COMMITTED - // and TIGHT_ALIGNMENT settings. + // Expected to be committed? const bool isCommitted = resWithAlloc.allocation->GetHeap() == NULL; - if (isCommitted) - wprintf(L" Small buffer %llu B inside a custom pool was created as committed.\n", resDesc.Width); - else - wprintf(L" Small buffer %llu B inside a custom pool was created as placed.\n", resDesc.Width); + CHECK_BOOL(isCommitted == expectSmallBuffersCommitted); } // Test 3: NEVER_ALLOCATE. @@ -3340,6 +3352,70 @@ #endif } +static void TestTightAlignment(const TestContext& ctx) +{ + using namespace D3D12MA; + + wprintf(L"Test resource tight alignment\n"); + + const bool isTightAlignmentEnabled = ctx.allocator->IsTightAlignmentSupported() && + (ctx.allocatorFlags & ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT) == 0; + + // Use a custom pool to make sure our small buffers are not created as committed. + POOL_DESC poolDesc = {}; + poolDesc.BlockSize = MEGABYTE; + poolDesc.MinBlockCount = poolDesc.MaxBlockCount = 1; + + D3D12_RESOURCE_DESC resDesc; + FillResourceDescForBuffer(resDesc, 4); + + const D3D12_HEAP_TYPE heapTypes[] = { D3D12_HEAP_TYPE_DEFAULT, D3D12_HEAP_TYPE_UPLOAD }; + for (auto heapType : heapTypes) + { + poolDesc.HeapProperties.Type = heapType; + for (uint32_t minAlignmentTestIndex = 0; minAlignmentTestIndex < 2; ++minAlignmentTestIndex) + { + // MinAllocationAlignment == 0 - default alignment. + // MinAllocationAlignment == 1 - minimum possible alignment. + poolDesc.MinAllocationAlignment = minAlignmentTestIndex; + + ComPtr<Pool> pool; + CHECK_HR(ctx.allocator->CreatePool(&poolDesc, &pool)); + + ALLOCATION_DESC allocDesc = {}; + allocDesc.CustomPool = pool.Get(); + + ComPtr<Allocation> allocs[2] = {}; + + for (size_t i = 0; i < _countof(allocs); ++i) + { + CHECK_HR(ctx.allocator->CreateResource(&allocDesc, &resDesc, + D3D12_RESOURCE_STATE_COMMON, NULL, &allocs[i], IID_NULL, NULL)); + CHECK_BOOL(allocs[i] && allocs[i]->GetResource()); + } + + const UINT64 secondAllocOffset = allocs[1]->GetOffset(); + + // Print the offset of the 2nd buffer. + wprintf(L" In D3D12_HEAP_TYPE_%s, with MinAllocationAlignment=%llu, a %llu B buffer was aligned to %llu B.\n", + HEAP_TYPE_NAMES[(size_t)heapType], + poolDesc.MinAllocationAlignment, + resDesc.Width, + secondAllocOffset); + + UINT64 expectedMinAlignment = 1; + if (isTightAlignmentEnabled) + { + if (minAlignmentTestIndex == 0) + expectedMinAlignment = D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT; + } + else + expectedMinAlignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT; + CHECK_BOOL(secondAllocOffset % expectedMinAlignment == 0); + } + } +} + static void TestVirtualBlocks(const TestContext& ctx) { wprintf(L"Test virtual blocks\n"); @@ -3720,6 +3796,11 @@ const bool isDefaultHeap = stepInfo.pMoves[i].pSrcAllocation->GetHeap()->GetDesc().Properties.Type == D3D12_HEAP_TYPE_DEFAULT; // Create new resource D3D12_RESOURCE_DESC desc = stepInfo.pMoves[i].pSrcAllocation->GetResource()->GetDesc(); + + // Fix for D3D12 ERROR: ID3D12Device::CreatePlacedResource: D3D12_RESOURCE_DESC::Alignment is invalid. The value is 8. When D3D12_RESOURCE_DESC::Flag bit for D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT is set, Alignment must be 0. [ STATE_CREATION ERROR #721: CREATERESOURCE_INVALIDALIGNMENT] + if ((desc.Flags & D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT_COPY) != 0) + desc.Alignment = 0; + ComPtr<ID3D12Resource> dstRes; CHECK_HR(ctx.device->CreatePlacedResource(stepInfo.pMoves[i].pDstTmpAllocation->GetHeap(), stepInfo.pMoves[i].pDstTmpAllocation->GetOffset(), &desc, @@ -4625,6 +4706,7 @@ #endif TestGPUUploadHeap(ctx); + TestTightAlignment(ctx); FILE* file; fopen_s(&file, "Results.csv", "w");