Added POOL_FLAG_ALWAYS_COMMITTED
diff --git a/docs/html/_d3_d12_mem_alloc_8h.html b/docs/html/_d3_d12_mem_alloc_8h.html index 75a0cf5..3ddeda1 100644 --- a/docs/html/_d3_d12_mem_alloc_8h.html +++ b/docs/html/_d3_d12_mem_alloc_8h.html
@@ -226,10 +226,14 @@ }</td></tr> <tr class="memdesc:a82bb787a69699a877b4166789a30e602"><td class="mdescLeft"> </td><td class="mdescRight">Operation performed on single defragmentation move. <a href="namespace_d3_d12_m_a.html#a82bb787a69699a877b4166789a30e602">More...</a><br /></td></tr> <tr class="separator:a82bb787a69699a877b4166789a30e602"><td class="memSeparator" colspan="2"> </td></tr> -<tr class="memitem:a919d8545365d6b7209a964f2b99936d1" id="r_a919d8545365d6b7209a964f2b99936d1"><td class="memItemLeft" align="right" valign="top">enum  </td><td class="memItemRight" valign="bottom"><a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1">D3D12MA::POOL_FLAGS</a> { <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1a5d8dc91add3423140809a550c7224d02">D3D12MA::POOL_FLAG_NONE</a> = 0 +<tr class="memitem:a919d8545365d6b7209a964f2b99936d1" id="r_a919d8545365d6b7209a964f2b99936d1"><td class="memItemLeft" align="right" valign="top">enum  </td><td class="memItemRight" valign="bottom"><a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1">D3D12MA::POOL_FLAGS</a> { <br /> +  <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1a5d8dc91add3423140809a550c7224d02">D3D12MA::POOL_FLAG_NONE</a> = 0 , <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1aa37a0103f511954ea42a1d0bba286b6a">D3D12MA::POOL_FLAG_ALGORITHM_LINEAR</a> = 0x1 , <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1acc379a89755438c0f76667783b778baa">D3D12MA::POOL_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED</a> = 0x2 -, <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1aec9d4939b8cc5438545b9df840b5f5f7">D3D12MA::POOL_FLAG_ALGORITHM_MASK</a> = POOL_FLAG_ALGORITHM_LINEAR +, <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1a15b7a6f8bfb6e4d534143f8adb6ac7ba">D3D12MA::POOL_FLAG_ALWAYS_COMMITTED</a> = 0x4 +, <br /> +  <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1aec9d4939b8cc5438545b9df840b5f5f7">D3D12MA::POOL_FLAG_ALGORITHM_MASK</a> = POOL_FLAG_ALGORITHM_LINEAR +<br /> }</td></tr> <tr class="memdesc:a919d8545365d6b7209a964f2b99936d1"><td class="mdescLeft"> </td><td class="mdescRight">Bit flags to be used with POOL_DESC::Flags. <a href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1">More...</a><br /></td></tr> <tr class="separator:a919d8545365d6b7209a964f2b99936d1"><td class="memSeparator" colspan="2"> </td></tr>
diff --git a/docs/html/configuration.html b/docs/html/configuration.html index a7ae8cf..3c35991 100644 --- a/docs/html/configuration.html +++ b/docs/html/configuration.html
@@ -123,15 +123,15 @@ <div class="line"> </div> <div class="line"><a class="code hl_class" href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a>* allocator;</div> <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="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:1107</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:1118</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_i_o_n___c_a_l_l_b_a_c_k_s_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_i_o_n___c_a_l_l_b_a_c_k_s.html">D3D12MA::ALLOCATION_CALLBACKS</a></div><div class="ttdoc">Custom callbacks to CPU memory allocation functions.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:217</div></div> <div class="ttc" id="astruct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_i_o_n___c_a_l_l_b_a_c_k_s_html_a114e6c4d63d6b020e01f526a975d6849"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_i_o_n___c_a_l_l_b_a_c_k_s.html#a114e6c4d63d6b020e01f526a975d6849">D3D12MA::ALLOCATION_CALLBACKS::pFree</a></div><div class="ttdeci">FREE_FUNC_PTR pFree</div><div class="ttdoc">Dellocation function.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:221</div></div> <div class="ttc" id="astruct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_i_o_n___c_a_l_l_b_a_c_k_s_html_af4d6436455728696fefd503869226436"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_i_o_n___c_a_l_l_b_a_c_k_s.html#af4d6436455728696fefd503869226436">D3D12MA::ALLOCATION_CALLBACKS::pAllocate</a></div><div class="ttdeci">ALLOCATE_FUNC_PTR pAllocate</div><div class="ttdoc">Allocation function.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:219</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:1068</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:1088</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:1094</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:1076</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:1079</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:1099</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:1105</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:1087</div></div> </div><!-- fragment --><h1><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 <code>ID3D12Device::GetResourceAllocationInfo</code>).</p>
diff --git a/docs/html/custom_pools.html b/docs/html/custom_pools.html index c5079f7..c4e6468 100644 --- a/docs/html/custom_pools.html +++ b/docs/html/custom_pools.html
@@ -103,7 +103,7 @@ <div class="line"> </div> <div class="line">Pool* pool;</div> <div class="line">HRESULT hr = allocator->CreatePool(&poolDesc, &pool);</div> -<div class="ttc" id="anamespace_d3_d12_m_a_html_a919d8545365d6b7209a964f2b99936d1acc379a89755438c0f76667783b778baa"><div class="ttname"><a href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1acc379a89755438c0f76667783b778baa">D3D12MA::POOL_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED</a></div><div class="ttdeci">@ POOL_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED</div><div class="ttdoc">Optimization, allocate MSAA textures as committed resources always.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:850</div></div> +<div class="ttc" id="anamespace_d3_d12_m_a_html_a919d8545365d6b7209a964f2b99936d1acc379a89755438c0f76667783b778baa"><div class="ttname"><a href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1acc379a89755438c0f76667783b778baa">D3D12MA::POOL_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED</a></div><div class="ttdeci">@ POOL_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:852</div></div> </div><!-- fragment --><p>To allocate resources out of a custom pool, only set member <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#ab06b85f3cf3254f855b29264477e3934" title="Custom pool to place the new resource in. Optional.">D3D12MA::ALLOCATION_DESC::CustomPool</a>. Example:</p> <div class="fragment"><div class="line">ALLOCATION_DESC allocDesc = {};</div> <div class="line">allocDesc.CustomPool = pool;</div>
diff --git a/docs/html/defragmentation.html b/docs/html/defragmentation.html index 95d5ca1..28bf51f 100644 --- a/docs/html/defragmentation.html +++ b/docs/html/defragmentation.html
@@ -207,7 +207,7 @@ <p><b>Thread safety:</b> It is safe to perform the defragmentation asynchronously to render frames and other Direct3D 12 and D3D12MA usage, possibly from multiple threads, with the exception that allocations returned in <a class="el" href="struct_d3_d12_m_a_1_1_d_e_f_r_a_g_m_e_n_t_a_t_i_o_n___p_a_s_s___m_o_v_e___i_n_f_o.html#a719fbdaae54251759605c41baeb24dc4" title="Array of moves to be performed by the user in the current defragmentation pass.">D3D12MA::DEFRAGMENTATION_PASS_MOVE_INFO::pMoves</a> shouldn't be released until the defragmentation pass is ended. During the call to <a class="el" href="class_d3_d12_m_a_1_1_defragmentation_context.html#a1606c015d02edc094bb246986159d592" title="Starts single defragmentation pass.">D3D12MA::DefragmentationContext::BeginPass()</a>, any operations on the memory pool affected by the defragmentation are blocked by a mutex.</p> <p>What it means in practice is that you shouldn't free any allocations from the defragmented pool since the moment a call to <code>BeginPass</code> begins. Otherwise, a thread performing the <code>allocation->Release()</code> would block for the time <code>BeginPass</code> executes and then free the allocation when it finishes, while the allocation could have ended up on the list of allocations to move. A solution to freeing allocations during defragmentation is to find such allocation on the list <code>pass.pMoves[i]</code> and set its operation to <a class="el" href="namespace_d3_d12_m_a.html#a82bb787a69699a877b4166789a30e602aa2143507d723de458c2ed94e143ac242" title="Set this value if you decide to abandon the allocation and you destroyed the resource....">D3D12MA::DEFRAGMENTATION_MOVE_OPERATION_DESTROY</a> instead of calling <code>allocation->Release()</code>, or simply deferring the release to the time after defragmentation finished.</p> <p><b>Mapping</b> is out of scope of this library and so it is not preserved after an allocation is moved during defragmentation. You need to map the new resource yourself if needed.</p> -<dl class="section note"><dt>Note</dt><dd>Defragmentation is not supported in custom pools created with <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1aa37a0103f511954ea42a1d0bba286b6a" title="Enables alternative, linear allocation algorithm in this pool.">D3D12MA::POOL_FLAG_ALGORITHM_LINEAR</a>. </dd></dl> +<dl class="section note"><dt>Note</dt><dd>Defragmentation is not supported in custom pools created with <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1aa37a0103f511954ea42a1d0bba286b6a">D3D12MA::POOL_FLAG_ALGORITHM_LINEAR</a>. </dd></dl> </div></div><!-- contents --> </div><!-- PageDoc --> <!-- start footer part -->
diff --git a/docs/html/doxygen_crawl.html b/docs/html/doxygen_crawl.html index 02b13fd..5407805 100644 --- a/docs/html/doxygen_crawl.html +++ b/docs/html/doxygen_crawl.html
@@ -150,6 +150,7 @@ <a href="namespace_d3_d12_m_a.html#a82bb787a69699a877b4166789a30e602aa2143507d723de458c2ed94e143ac242"/> <a href="namespace_d3_d12_m_a.html#a82bb787a69699a877b4166789a30e602abefe270a1803998dda3f8e01ec3a4ad6"/> <a href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1"/> +<a href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1a15b7a6f8bfb6e4d534143f8adb6ac7ba"/> <a href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1a5d8dc91add3423140809a550c7224d02"/> <a href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1aa37a0103f511954ea42a1d0bba286b6a"/> <a href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1acc379a89755438c0f76667783b778baa"/>
diff --git a/docs/html/linear_algorithm.html b/docs/html/linear_algorithm.html index 8281445..c5503ff 100644 --- a/docs/html/linear_algorithm.html +++ b/docs/html/linear_algorithm.html
@@ -93,7 +93,7 @@ <div class="contents"> <div class="textblock"><p>Each D3D12 memory block managed by this library has accompanying metadata that keeps track of used and unused regions. By default, the metadata structure and algorithm tries to find best place for new allocations among free regions to optimize memory usage. This way you can allocate and free objects in any order.</p> <p><img src="../gfx/Linear_allocator_1_algo_default.png" alt="Default allocation algorithm" class="inline"/></p> -<p>Sometimes there is a need to use simpler, linear allocation algorithm. You can create custom pool that uses such algorithm by adding flag <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1aa37a0103f511954ea42a1d0bba286b6a" title="Enables alternative, linear allocation algorithm in this pool.">D3D12MA::POOL_FLAG_ALGORITHM_LINEAR</a> to <a class="el" href="struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html#ac4ed93b0191344d68c0b4ac1a4822ff4" title="Flags.">D3D12MA::POOL_DESC::Flags</a> while creating <a class="el" href="class_d3_d12_m_a_1_1_pool.html" title="Custom memory pool.">D3D12MA::Pool</a> object. Then an alternative metadata management is used. It always creates new allocations after last one and doesn't reuse free regions after allocations freed in the middle. It results in better allocation performance and less memory consumed by metadata.</p> +<p>Sometimes there is a need to use simpler, linear allocation algorithm. You can create custom pool that uses such algorithm by adding flag <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1aa37a0103f511954ea42a1d0bba286b6a">D3D12MA::POOL_FLAG_ALGORITHM_LINEAR</a> to <a class="el" href="struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html#ac4ed93b0191344d68c0b4ac1a4822ff4" title="Flags.">D3D12MA::POOL_DESC::Flags</a> while creating <a class="el" href="class_d3_d12_m_a_1_1_pool.html" title="Custom memory pool.">D3D12MA::Pool</a> object. Then an alternative metadata management is used. It always creates new allocations after last one and doesn't reuse free regions after allocations freed in the middle. It results in better allocation performance and less memory consumed by metadata.</p> <p><img src="../gfx/Linear_allocator_2_algo_linear.png" alt="Linear allocation algorithm" class="inline"/></p> <p>With this one flag, you can create a custom pool that can be used in many ways: free-at-once, stack, double stack, and ring buffer. See below for details. You don't need to specify explicitly which of these options you are going to use - it is detected automatically.</p> <h1><a class="anchor" id="linear_algorithm_free_at_once"></a>
diff --git a/docs/html/namespace_d3_d12_m_a.html b/docs/html/namespace_d3_d12_m_a.html index f4fd6c4..6550c37 100644 --- a/docs/html/namespace_d3_d12_m_a.html +++ b/docs/html/namespace_d3_d12_m_a.html
@@ -205,10 +205,14 @@ }</td></tr> <tr class="memdesc:a82bb787a69699a877b4166789a30e602"><td class="mdescLeft"> </td><td class="mdescRight">Operation performed on single defragmentation move. <a href="#a82bb787a69699a877b4166789a30e602">More...</a><br /></td></tr> <tr class="separator:a82bb787a69699a877b4166789a30e602"><td class="memSeparator" colspan="2"> </td></tr> -<tr class="memitem:a919d8545365d6b7209a964f2b99936d1" id="r_a919d8545365d6b7209a964f2b99936d1"><td class="memItemLeft" align="right" valign="top">enum  </td><td class="memItemRight" valign="bottom"><a class="el" href="#a919d8545365d6b7209a964f2b99936d1">POOL_FLAGS</a> { <a class="el" href="#a919d8545365d6b7209a964f2b99936d1a5d8dc91add3423140809a550c7224d02">POOL_FLAG_NONE</a> = 0 +<tr class="memitem:a919d8545365d6b7209a964f2b99936d1" id="r_a919d8545365d6b7209a964f2b99936d1"><td class="memItemLeft" align="right" valign="top">enum  </td><td class="memItemRight" valign="bottom"><a class="el" href="#a919d8545365d6b7209a964f2b99936d1">POOL_FLAGS</a> { <br /> +  <a class="el" href="#a919d8545365d6b7209a964f2b99936d1a5d8dc91add3423140809a550c7224d02">POOL_FLAG_NONE</a> = 0 , <a class="el" href="#a919d8545365d6b7209a964f2b99936d1aa37a0103f511954ea42a1d0bba286b6a">POOL_FLAG_ALGORITHM_LINEAR</a> = 0x1 , <a class="el" href="#a919d8545365d6b7209a964f2b99936d1acc379a89755438c0f76667783b778baa">POOL_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED</a> = 0x2 -, <a class="el" href="#a919d8545365d6b7209a964f2b99936d1aec9d4939b8cc5438545b9df840b5f5f7">POOL_FLAG_ALGORITHM_MASK</a> = POOL_FLAG_ALGORITHM_LINEAR +, <a class="el" href="#a919d8545365d6b7209a964f2b99936d1a15b7a6f8bfb6e4d534143f8adb6ac7ba">POOL_FLAG_ALWAYS_COMMITTED</a> = 0x4 +, <br /> +  <a class="el" href="#a919d8545365d6b7209a964f2b99936d1aec9d4939b8cc5438545b9df840b5f5f7">POOL_FLAG_ALGORITHM_MASK</a> = POOL_FLAG_ALGORITHM_LINEAR +<br /> }</td></tr> <tr class="memdesc:a919d8545365d6b7209a964f2b99936d1"><td class="mdescLeft"> </td><td class="mdescRight">Bit flags to be used with POOL_DESC::Flags. <a href="#a919d8545365d6b7209a964f2b99936d1">More...</a><br /></td></tr> <tr class="separator:a919d8545365d6b7209a964f2b99936d1"><td class="memSeparator" colspan="2"> </td></tr> @@ -333,7 +337,7 @@ <tr><td class="fieldname"><a id="abbad31a7e0b3d09d77f3fb704b77645eab374417c1f22a833ead268a6c21424e6" name="abbad31a7e0b3d09d77f3fb704b77645eab374417c1f22a833ead268a6c21424e6"></a>ALLOCATION_FLAG_WITHIN_BUDGET </td><td class="fielddoc"><p>Create allocation only if additional memory required for it, if any, won't exceed memory budget. Otherwise return <code>E_OUTOFMEMORY</code>. </p> </td></tr> <tr><td class="fieldname"><a id="abbad31a7e0b3d09d77f3fb704b77645eafb0e2dacce691336e717550a1df72474" name="abbad31a7e0b3d09d77f3fb704b77645eafb0e2dacce691336e717550a1df72474"></a>ALLOCATION_FLAG_UPPER_ADDRESS </td><td class="fielddoc"><p><a class="el" href="class_d3_d12_m_a_1_1_allocation.html" title="Represents single memory allocation.">Allocation</a> will be created from upper stack in a double stack pool.</p> -<p>This flag is only allowed for custom pools created with <a class="el" href="#a919d8545365d6b7209a964f2b99936d1aa37a0103f511954ea42a1d0bba286b6a" title="Enables alternative, linear allocation algorithm in this pool.">POOL_FLAG_ALGORITHM_LINEAR</a> flag. </p> +<p>This flag is only allowed for custom pools created with <a class="el" href="#a919d8545365d6b7209a964f2b99936d1aa37a0103f511954ea42a1d0bba286b6a">POOL_FLAG_ALGORITHM_LINEAR</a> flag. </p> </td></tr> <tr><td class="fieldname"><a id="abbad31a7e0b3d09d77f3fb704b77645ea4d6808f27de6d0ae57014ec1f4d54326" name="abbad31a7e0b3d09d77f3fb704b77645ea4d6808f27de6d0ae57014ec1f4d54326"></a>ALLOCATION_FLAG_CAN_ALIAS </td><td class="fielddoc"><p>Set this flag if the allocated memory will have aliasing resources.</p> <p>Use this when calling <a class="el" href="class_d3_d12_m_a_1_1_allocator.html#aa37d6b9fe8ea0864f7a35b9d68e8345a" title="Allocates memory and creates a D3D12 resource (buffer or texture). This is the main allocation functi...">D3D12MA::Allocator::CreateResource()</a> and similar to guarantee creation of explicit heap for desired allocation and prevent it from using <code>CreateCommittedResource</code>, so that new allocation object will always have <code>allocation->GetHeap() != NULL</code>. </p> @@ -373,17 +377,19 @@ <tr><td class="fieldname"><a id="ad5ae5a5e42b878f2e18ab5d1fbfb9916a1b06bb21df006f76a9ed1bc41838bc52" name="ad5ae5a5e42b878f2e18ab5d1fbfb9916a1b06bb21df006f76a9ed1bc41838bc52"></a>ALLOCATOR_FLAG_SINGLETHREADED </td><td class="fielddoc"><p><a class="el" href="class_d3_d12_m_a_1_1_allocator.html" title="Represents main object of this library initialized for particular ID3D12Device.">Allocator</a> and all objects created from it will not be synchronized internally, so you must guarantee they are used from only one thread at a time or synchronized by you.</p> <p>Using this flag may increase performance because internal mutexes are not used. </p> </td></tr> -<tr><td class="fieldname"><a id="ad5ae5a5e42b878f2e18ab5d1fbfb9916a068863dc0538ff4ea153b046b31e94fb" name="ad5ae5a5e42b878f2e18ab5d1fbfb9916a068863dc0538ff4ea153b046b31e94fb"></a>ALLOCATOR_FLAG_ALWAYS_COMMITTED </td><td class="fielddoc"><p>Every allocation will have its own memory block. To be used for debugging purposes. </p> +<tr><td class="fieldname"><a id="ad5ae5a5e42b878f2e18ab5d1fbfb9916a068863dc0538ff4ea153b046b31e94fb" name="ad5ae5a5e42b878f2e18ab5d1fbfb9916a068863dc0538ff4ea153b046b31e94fb"></a>ALLOCATOR_FLAG_ALWAYS_COMMITTED </td><td class="fielddoc"><p>Every allocation will be created as a committed resource - will have its own memory block.</p> +<p>Affects both default pools and custom pools. To be used for debugging purposes only. There is also an equivalent flag for custom pools: <a class="el" href="#a919d8545365d6b7209a964f2b99936d1a15b7a6f8bfb6e4d534143f8adb6ac7ba">D3D12MA::POOL_FLAG_ALWAYS_COMMITTED</a>. </p> </td></tr> <tr><td class="fieldname"><a id="ad5ae5a5e42b878f2e18ab5d1fbfb9916ae7dc7ab9168148281ebfe1586f554335" name="ad5ae5a5e42b878f2e18ab5d1fbfb9916ae7dc7ab9168148281ebfe1586f554335"></a>ALLOCATOR_FLAG_DEFAULT_POOLS_NOT_ZEROED </td><td class="fielddoc"><p>Heaps created for the default pools will be created with flag <code>D3D12_HEAP_FLAG_CREATE_NOT_ZEROED</code>, allowing for their memory to be not zeroed by the system if possible, which can speed up allocation.</p> <p>Only affects default pools. To use the flag with <a class="el" href="custom_pools.html">Custom memory pools</a>, you need to add it manually:</p> <div class="fragment"><div class="line">poolDesc.heapFlags |= D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;</div> </div><!-- fragment --><p>Only avaiable if <code>ID3D12Device8</code> is present. Otherwise, the flag is ignored. </p> </td></tr> -<tr><td class="fieldname"><a id="ad5ae5a5e42b878f2e18ab5d1fbfb9916adfbfd20d716f2a46f74d6226056fef1e" name="ad5ae5a5e42b878f2e18ab5d1fbfb9916adfbfd20d716f2a46f74d6226056fef1e"></a>ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED </td><td class="fielddoc"><p>Optimization, allocate MSAA textures as committed resources always. </p> -<p>Specify this flag to create MSAA textures with implicit heaps, as if they were created with flag <a class="el" href="#abbad31a7e0b3d09d77f3fb704b77645ea661a5472dba3dcecc5a2cc92afd25675">D3D12MA::ALLOCATION_FLAG_COMMITTED</a>. Usage of this flags enables all default pools to create its heaps on smaller alignment not suitable for MSAA textures. </p> +<tr><td class="fieldname"><a id="ad5ae5a5e42b878f2e18ab5d1fbfb9916adfbfd20d716f2a46f74d6226056fef1e" name="ad5ae5a5e42b878f2e18ab5d1fbfb9916adfbfd20d716f2a46f74d6226056fef1e"></a>ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED </td><td class="fielddoc"><p>Optimization, allocate MSAA textures as committed resources always.</p> +<p>Specify this flag to create MSAA textures with implicit heaps, as if they were created with flag <a class="el" href="#abbad31a7e0b3d09d77f3fb704b77645ea661a5472dba3dcecc5a2cc92afd25675">D3D12MA::ALLOCATION_FLAG_COMMITTED</a>. Usage of this flags enables all default pools to create its heaps on smaller alignment not suitable for MSAA textures.</p> +<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> +<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> </td></tr> </table> @@ -456,12 +462,16 @@ <table class="fieldtable"> <tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="a919d8545365d6b7209a964f2b99936d1a5d8dc91add3423140809a550c7224d02" name="a919d8545365d6b7209a964f2b99936d1a5d8dc91add3423140809a550c7224d02"></a>POOL_FLAG_NONE </td><td class="fielddoc"><p>Zero. </p> </td></tr> -<tr><td class="fieldname"><a id="a919d8545365d6b7209a964f2b99936d1aa37a0103f511954ea42a1d0bba286b6a" name="a919d8545365d6b7209a964f2b99936d1aa37a0103f511954ea42a1d0bba286b6a"></a>POOL_FLAG_ALGORITHM_LINEAR </td><td class="fielddoc"><p>Enables alternative, linear allocation algorithm in this pool. </p> +<tr><td class="fieldname"><a id="a919d8545365d6b7209a964f2b99936d1aa37a0103f511954ea42a1d0bba286b6a" name="a919d8545365d6b7209a964f2b99936d1aa37a0103f511954ea42a1d0bba286b6a"></a>POOL_FLAG_ALGORITHM_LINEAR </td><td class="fielddoc"><p>Enables alternative, linear allocation algorithm in this pool.</p> <p>Specify this flag to enable linear allocation algorithm, which always creates new allocations after last one and doesn't reuse space from allocations freed in between. It trades memory consumption for simplified algorithm and data structure, which has better performance and uses less memory for metadata.</p> <p>By using this flag, you can achieve behavior of free-at-once, stack, ring buffer, and double stack. For details, see documentation chapter <a class="el" href="linear_algorithm.html">Linear allocation algorithm</a>. </p> </td></tr> -<tr><td class="fieldname"><a id="a919d8545365d6b7209a964f2b99936d1acc379a89755438c0f76667783b778baa" name="a919d8545365d6b7209a964f2b99936d1acc379a89755438c0f76667783b778baa"></a>POOL_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED </td><td class="fielddoc"><p>Optimization, allocate MSAA textures as committed resources always. </p> -<p>Specify this flag to create MSAA textures with implicit heaps, as if they were created with flag <a class="el" href="#abbad31a7e0b3d09d77f3fb704b77645ea661a5472dba3dcecc5a2cc92afd25675">D3D12MA::ALLOCATION_FLAG_COMMITTED</a>. Usage of this flags enables pool to create its heaps on smaller alignment not suitable for MSAA textures. </p> +<tr><td class="fieldname"><a id="a919d8545365d6b7209a964f2b99936d1acc379a89755438c0f76667783b778baa" name="a919d8545365d6b7209a964f2b99936d1acc379a89755438c0f76667783b778baa"></a>POOL_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED </td><td class="fielddoc"><p>Optimization, allocate MSAA textures as committed resources always.</p> +<p>Specify this flag to create MSAA textures with implicit heaps, as if they were created with flag <a class="el" href="#abbad31a7e0b3d09d77f3fb704b77645ea661a5472dba3dcecc5a2cc92afd25675">D3D12MA::ALLOCATION_FLAG_COMMITTED</a>. Usage of this flags enables pool to create its heaps on smaller alignment not suitable for MSAA textures.</p> +<p>You should always use this flag unless you really need to create some MSAA textures in this pool as placed. </p> +</td></tr> +<tr><td class="fieldname"><a id="a919d8545365d6b7209a964f2b99936d1a15b7a6f8bfb6e4d534143f8adb6ac7ba" name="a919d8545365d6b7209a964f2b99936d1a15b7a6f8bfb6e4d534143f8adb6ac7ba"></a>POOL_FLAG_ALWAYS_COMMITTED </td><td class="fielddoc"><p>Every allocation made in this pool will be created as a committed resource - will have its own memory block.</p> +<p>There is also an equivalent flag for the entire allocator: <a class="el" href="#ad5ae5a5e42b878f2e18ab5d1fbfb9916a068863dc0538ff4ea153b046b31e94fb">D3D12MA::ALLOCATOR_FLAG_ALWAYS_COMMITTED</a>. </p> </td></tr> <tr><td class="fieldname"><a id="a919d8545365d6b7209a964f2b99936d1aec9d4939b8cc5438545b9df840b5f5f7" name="a919d8545365d6b7209a964f2b99936d1aec9d4939b8cc5438545b9df840b5f5f7"></a>POOL_FLAG_ALGORITHM_MASK </td><td class="fielddoc"></td></tr> </table>
diff --git a/docs/html/namespacemembers.html b/docs/html/namespacemembers.html index 6457e2b..c645bcf 100644 --- a/docs/html/namespacemembers.html +++ b/docs/html/namespacemembers.html
@@ -139,6 +139,7 @@ <h3><a id="index_p" name="index_p"></a>- p -</h3><ul> <li>POOL_FLAG_ALGORITHM_LINEAR : <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1aa37a0103f511954ea42a1d0bba286b6a">D3D12MA</a></li> <li>POOL_FLAG_ALGORITHM_MASK : <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1aec9d4939b8cc5438545b9df840b5f5f7">D3D12MA</a></li> +<li>POOL_FLAG_ALWAYS_COMMITTED : <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1a15b7a6f8bfb6e4d534143f8adb6ac7ba">D3D12MA</a></li> <li>POOL_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED : <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1acc379a89755438c0f76667783b778baa">D3D12MA</a></li> <li>POOL_FLAG_NONE : <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1a5d8dc91add3423140809a550c7224d02">D3D12MA</a></li> <li>POOL_FLAGS : <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1">D3D12MA</a></li>
diff --git a/docs/html/namespacemembers_eval.html b/docs/html/namespacemembers_eval.html index 66f0cde..6ebdba1 100644 --- a/docs/html/namespacemembers_eval.html +++ b/docs/html/namespacemembers_eval.html
@@ -122,6 +122,7 @@ <h3><a id="index_p" name="index_p"></a>- p -</h3><ul> <li>POOL_FLAG_ALGORITHM_LINEAR : <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1aa37a0103f511954ea42a1d0bba286b6a">D3D12MA</a></li> <li>POOL_FLAG_ALGORITHM_MASK : <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1aec9d4939b8cc5438545b9df840b5f5f7">D3D12MA</a></li> +<li>POOL_FLAG_ALWAYS_COMMITTED : <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1a15b7a6f8bfb6e4d534143f8adb6ac7ba">D3D12MA</a></li> <li>POOL_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED : <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1acc379a89755438c0f76667783b778baa">D3D12MA</a></li> <li>POOL_FLAG_NONE : <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1a5d8dc91add3423140809a550c7224d02">D3D12MA</a></li> </ul>
diff --git a/docs/html/optimal_allocation.html b/docs/html/optimal_allocation.html index cfeb1c0..3c6034a 100644 --- a/docs/html/optimal_allocation.html +++ b/docs/html/optimal_allocation.html
@@ -174,14 +174,14 @@ <div class="line"> NULL, &alloc, IID_NULL, NULL);</div> <div class="line"><span class="comment">// Check hr...</span></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:491</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:943</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:950</div></div> <div class="ttc" id="astruct_d3_d12_m_a_1_1_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_a_l_l_o_c_a_t_i_o_n___d_e_s_c.html">D3D12MA::ALLOCATION_DESC</a></div><div class="ttdoc">Parameters of created D3D12MA::Allocation object. To be used with Allocator::CreateResource.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:307</div></div> <div class="ttc" id="astruct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_i_o_n___d_e_s_c_html_a92dec49b788a334fc91c55340dfbace6"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_i_o_n___d_e_s_c.html#a92dec49b788a334fc91c55340dfbace6">D3D12MA::ALLOCATION_DESC::Flags</a></div><div class="ttdeci">ALLOCATION_FLAGS Flags</div><div class="ttdoc">Flags.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:309</div></div> <div class="ttc" id="astruct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_i_o_n___d_e_s_c_html_ab06b85f3cf3254f855b29264477e3934"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_i_o_n___d_e_s_c.html#ab06b85f3cf3254f855b29264477e3934">D3D12MA::ALLOCATION_DESC::CustomPool</a></div><div class="ttdeci">Pool * CustomPool</div><div class="ttdoc">Custom pool to place the new resource in. Optional.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:337</div></div> -<div class="ttc" id="astruct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html">D3D12MA::POOL_DESC</a></div><div class="ttdoc">Parameters of created D3D12MA::Pool object. To be used with D3D12MA::Allocator::CreatePool.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:858</div></div> -<div class="ttc" id="astruct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c_html_a06e06813bcb5206e9f7a8b0564bf1d6a"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html#a06e06813bcb5206e9f7a8b0564bf1d6a">D3D12MA::POOL_DESC::HeapProperties</a></div><div class="ttdeci">D3D12_HEAP_PROPERTIES HeapProperties</div><div class="ttdoc">The parameters of memory heap where allocations of this pool should be placed.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:866</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:931</div></div> -<div class="ttc" id="astruct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c_html_a3795956e4fbfe7c3a23546e02e5d28dc"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html#a3795956e4fbfe7c3a23546e02e5d28dc">D3D12MA::POOL_DESC::HeapFlags</a></div><div class="ttdeci">D3D12_HEAP_FLAGS HeapFlags</div><div class="ttdoc">Heap flags to be used when allocating heaps of this pool.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:877</div></div> +<div class="ttc" id="astruct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html">D3D12MA::POOL_DESC</a></div><div class="ttdoc">Parameters of created D3D12MA::Pool object. To be used with D3D12MA::Allocator::CreatePool.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:865</div></div> +<div class="ttc" id="astruct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c_html_a06e06813bcb5206e9f7a8b0564bf1d6a"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html#a06e06813bcb5206e9f7a8b0564bf1d6a">D3D12MA::POOL_DESC::HeapProperties</a></div><div class="ttdeci">D3D12_HEAP_PROPERTIES HeapProperties</div><div class="ttdoc">The parameters of memory heap where allocations of this pool should be placed.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:873</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:938</div></div> +<div class="ttc" id="astruct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c_html_a3795956e4fbfe7c3a23546e02e5d28dc"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html#a3795956e4fbfe7c3a23546e02e5d28dc">D3D12MA::POOL_DESC::HeapFlags</a></div><div class="ttdeci">D3D12_HEAP_FLAGS HeapFlags</div><div class="ttdoc">Heap flags to be used when allocating heaps of this pool.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:884</div></div> </div><!-- fragment --><p>Note this is not the same as explicit eviction controlled using <code>ID3D12Device::Evict</code> and <code>MakeResident</code> functions. Resources evicted explicitly are illegal to access until they are made resident again, while the demotion described here happens automatically and only slows down the execution.</p> <h1><a class="anchor" id="optimal_allocation_gpu_upload_heap"></a> GPU upload heap</h1> @@ -276,7 +276,7 @@ <dl class="section user"><dt>Implementation detail</dt><dd>D3D12MA creates large heaps (default size is 64 MB) and creates resources as placed in them. However, it may decide that it is required or preferred to create the specific resource as committed for many reasons, including:<ul> <li>When the resource is large (larger than half of the default heap size).</li> <li>When allocating an entire new heap would exceed the current budget or when we are already over the budget.</li> -<li>When the resource is a very small buffer. Placed buffers need to be aligned to 64 KB by default, while creating them as committed can allow the driver to pack them better. This heuristics 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>.</li> +<li>When the resource is a very small buffer. Placed buffers need to be aligned to 64 KB by default, while creating them as committed can allow the driver to pack them better. This heuristics 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>.</li> <li>When the resource uses non-standard flags specified via <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#a97878838f976b2d1e6b1a76881035690" title="Additional heap flags to be used when allocating memory.">D3D12MA::ALLOCATION_DESC::ExtraHeapFlags</a>.</li> </ul> </dd></dl> @@ -319,16 +319,16 @@ <div class="line"><span class="comment">// Even a large buffer like this, filling 90% of the block, was created as placed!</span></div> <div class="line">assert(alloc-><a class="code hl_function" href="class_d3_d12_m_a_1_1_allocation.html#adca8d5a82bed492fe7265fcda6e53da2">GetHeap</a>() != NULL);</div> <div class="ttc" id="aclass_d3_d12_m_a_1_1_allocation_html_adca8d5a82bed492fe7265fcda6e53da2"><div class="ttname"><a href="class_d3_d12_m_a_1_1_allocation.html#adca8d5a82bed492fe7265fcda6e53da2">D3D12MA::Allocation::GetHeap</a></div><div class="ttdeci">ID3D12Heap * GetHeap() const</div><div class="ttdoc">Returns memory heap that the resource is created in.</div></div> -<div class="ttc" id="astruct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c_html_af7284cc51a8ed5b551075584256de23c"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html#af7284cc51a8ed5b551075584256de23c">D3D12MA::POOL_DESC::BlockSize</a></div><div class="ttdeci">UINT64 BlockSize</div><div class="ttdoc">Size of a single heap (memory block) to be allocated as part of this pool, in bytes....</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:884</div></div> +<div class="ttc" id="astruct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c_html_af7284cc51a8ed5b551075584256de23c"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html#af7284cc51a8ed5b551075584256de23c">D3D12MA::POOL_DESC::BlockSize</a></div><div class="ttdeci">UINT64 BlockSize</div><div class="ttdoc">Size of a single heap (memory block) to be allocated as part of this pool, in bytes....</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:891</div></div> </div><!-- fragment --><p><b>You can request a new resource to be created as placed</b> by using <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645ea4d6808f27de6d0ae57014ec1f4d54326">D3D12MA::ALLOCATION_FLAG_CAN_ALIAS</a>. This is required especially if you plan to create another resource in the same region of memory, aliasing with your resource - hence the name of this flag.</p> <p>Note <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645ea4d6808f27de6d0ae57014ec1f4d54326">D3D12MA::ALLOCATION_FLAG_CAN_ALIAS</a> can be even combined with <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645ea661a5472dba3dcecc5a2cc92afd25675">D3D12MA::ALLOCATION_FLAG_COMMITTED</a>. In this case, the resource is not created as committed, but it is also not placed as part of a larger heap. What happens instead is that a new heap is created with the exact size required for the resource, and the resource is created in it, placed at offset 0.</p> <h1><a class="anchor" id="optimal_allocation_resource_alignment"></a> Resource alignment</h1> <p>Certain types of resources require certain alignment in memory. An alignment is a requirement for the address or offset to the beginning of the resource to be a multiply of some value, which is always a power of 2. For committed resources, the problem is non-existent, because committed resources have their own implicit heaps where they are created at offset 0, which meets any alignment requirement. For placed resources, D3D12MA takes care of the alignment automatically.</p> <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> -<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> +<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 <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> -<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> +<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">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> </div></div><!-- contents --> </div><!-- PageDoc --> <!-- start footer part -->
diff --git a/docs/html/quick_start.html b/docs/html/quick_start.html index ef8282e..8a00dba 100644 --- a/docs/html/quick_start.html +++ b/docs/html/quick_start.html
@@ -115,14 +115,14 @@ <div class="line"> </div> <div class="line"><a class="code hl_class" href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a>* allocator;</div> <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="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:1107</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:1118</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="anamespace_d3_d12_m_a_html_ad5ae5a5e42b878f2e18ab5d1fbfb9916adfbfd20d716f2a46f74d6226056fef1e"><div class="ttname"><a href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916adfbfd20d716f2a46f74d6226056fef1e">D3D12MA::ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED</a></div><div class="ttdeci">@ ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED</div><div class="ttdoc">Optimization, allocate MSAA textures as committed resources always.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1053</div></div> -<div class="ttc" id="anamespace_d3_d12_m_a_html_ad5ae5a5e42b878f2e18ab5d1fbfb9916ae7dc7ab9168148281ebfe1586f554335"><div class="ttname"><a href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916ae7dc7ab9168148281ebfe1586f554335">D3D12MA::ALLOCATOR_FLAG_DEFAULT_POOLS_NOT_ZEROED</a></div><div class="ttdeci">@ ALLOCATOR_FLAG_DEFAULT_POOLS_NOT_ZEROED</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1045</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:1068</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:1094</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.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1070</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:1076</div></div> +<div class="ttc" id="anamespace_d3_d12_m_a_html_ad5ae5a5e42b878f2e18ab5d1fbfb9916adfbfd20d716f2a46f74d6226056fef1e"><div class="ttname"><a href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916adfbfd20d716f2a46f74d6226056fef1e">D3D12MA::ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED</a></div><div class="ttdeci">@ ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1064</div></div> +<div class="ttc" id="anamespace_d3_d12_m_a_html_ad5ae5a5e42b878f2e18ab5d1fbfb9916ae7dc7ab9168148281ebfe1586f554335"><div class="ttname"><a href="namespace_d3_d12_m_a.html#ad5ae5a5e42b878f2e18ab5d1fbfb9916ae7dc7ab9168148281ebfe1586f554335">D3D12MA::ALLOCATOR_FLAG_DEFAULT_POOLS_NOT_ZEROED</a></div><div class="ttdeci">@ ALLOCATOR_FLAG_DEFAULT_POOLS_NOT_ZEROED</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1054</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:1079</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:1105</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.</div><div class="ttdef"><b>Definition</b> D3D12MemAlloc.h:1081</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:1087</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> </div><!-- fragment --><p>Objects of this library must be destroyed by calling <code>Release</code> method. They are somewhat compatible with COM: they implement <code>IUnknown</code> interface with its virtual methods: <code>AddRef</code>, <code>Release</code>, <code>QueryInterface</code>, and they are reference-counted internally. You can use smart pointers designed for COM with objects of this library - e.g. <code>CComPtr</code> or <code>Microsoft::WRL::ComPtr</code>. The reference counter is thread-safe. <code>QueryInterface</code> method supports only <code>IUnknown</code>, as classes of this library don't define their own GUIDs.</p>
diff --git a/docs/html/search/all_e.js b/docs/html/search/all_e.js index 115c5cc..dc7f629 100644 --- a/docs/html/search/all_e.js +++ b/docs/html/search/all_e.js
@@ -14,15 +14,16 @@ ['pool_5fdesc_11',['POOL_DESC',['../struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html',1,'D3D12MA']]], ['pool_5fflag_5falgorithm_5flinear_12',['POOL_FLAG_ALGORITHM_LINEAR',['../namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1aa37a0103f511954ea42a1d0bba286b6a',1,'D3D12MA']]], ['pool_5fflag_5falgorithm_5fmask_13',['POOL_FLAG_ALGORITHM_MASK',['../namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1aec9d4939b8cc5438545b9df840b5f5f7',1,'D3D12MA']]], - ['pool_5fflag_5fmsaa_5ftextures_5falways_5fcommitted_14',['POOL_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED',['../namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1acc379a89755438c0f76667783b778baa',1,'D3D12MA']]], - ['pool_5fflag_5fnone_15',['POOL_FLAG_NONE',['../namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1a5d8dc91add3423140809a550c7224d02',1,'D3D12MA']]], - ['pool_5fflags_16',['POOL_FLAGS',['../namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1',1,'D3D12MA']]], - ['pools_17',['Custom memory pools',['../custom_pools.html',1,'optimal_allocation']]], - ['pprivatedata_18',['pPrivateData',['../struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_i_o_n___c_a_l_l_b_a_c_k_s.html#a98173cc9e239a84c2ce369854966e1e3',1,'D3D12MA::ALLOCATION_CALLBACKS::pPrivateData'],['../struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_i_o_n___d_e_s_c.html#ac638dd987f1326e2fdab91892d994d35',1,'D3D12MA::ALLOCATION_DESC::pPrivateData'],['../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#aa1281297154e3823e98a7cc7e23b5d6b',1,'D3D12MA::VIRTUAL_ALLOCATION_DESC::pPrivateData'],['../struct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___a_l_l_o_c_a_t_i_o_n___i_n_f_o.html#a05c258ea40ea47667ddcc395b13a47a5',1,'D3D12MA::VIRTUAL_ALLOCATION_INFO::pPrivateData']]], - ['pprotectedsession_19',['pProtectedSession',['../struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html#a475840ec05c19732c8d5aa8bb27270f4',1,'D3D12MA::POOL_DESC']]], - ['preferredblocksize_20',['PreferredBlockSize',['../struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c.html#a97149c9559deae943c2cfa49aeeff8a6',1,'D3D12MA::ALLOCATOR_DESC']]], - ['prev_21',['prev',['../class_d3_d12_m_a_1_1_allocation.html#adc3ac89758a915a409e047f9b89aa160',1,'D3D12MA::Allocation']]], - ['priority_22',['Residency priority',['../optimal_allocation.html#optimal_allocation_residency_priority',1,'']]], - ['project_20setup_20and_20initialization_23',['Project setup and initialization',['../quick_start.html#quick_start_project_setup',1,'']]], - ['psrcallocation_24',['pSrcAllocation',['../struct_d3_d12_m_a_1_1_d_e_f_r_a_g_m_e_n_t_a_t_i_o_n___m_o_v_e.html#a4946b874c958a71c21fac25b515cf5f7',1,'D3D12MA::DEFRAGMENTATION_MOVE']]] + ['pool_5fflag_5falways_5fcommitted_14',['POOL_FLAG_ALWAYS_COMMITTED',['../namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1a15b7a6f8bfb6e4d534143f8adb6ac7ba',1,'D3D12MA']]], + ['pool_5fflag_5fmsaa_5ftextures_5falways_5fcommitted_15',['POOL_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED',['../namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1acc379a89755438c0f76667783b778baa',1,'D3D12MA']]], + ['pool_5fflag_5fnone_16',['POOL_FLAG_NONE',['../namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1a5d8dc91add3423140809a550c7224d02',1,'D3D12MA']]], + ['pool_5fflags_17',['POOL_FLAGS',['../namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1',1,'D3D12MA']]], + ['pools_18',['Custom memory pools',['../custom_pools.html',1,'optimal_allocation']]], + ['pprivatedata_19',['pPrivateData',['../struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_i_o_n___c_a_l_l_b_a_c_k_s.html#a98173cc9e239a84c2ce369854966e1e3',1,'D3D12MA::ALLOCATION_CALLBACKS::pPrivateData'],['../struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_i_o_n___d_e_s_c.html#ac638dd987f1326e2fdab91892d994d35',1,'D3D12MA::ALLOCATION_DESC::pPrivateData'],['../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#aa1281297154e3823e98a7cc7e23b5d6b',1,'D3D12MA::VIRTUAL_ALLOCATION_DESC::pPrivateData'],['../struct_d3_d12_m_a_1_1_v_i_r_t_u_a_l___a_l_l_o_c_a_t_i_o_n___i_n_f_o.html#a05c258ea40ea47667ddcc395b13a47a5',1,'D3D12MA::VIRTUAL_ALLOCATION_INFO::pPrivateData']]], + ['pprotectedsession_20',['pProtectedSession',['../struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html#a475840ec05c19732c8d5aa8bb27270f4',1,'D3D12MA::POOL_DESC']]], + ['preferredblocksize_21',['PreferredBlockSize',['../struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c.html#a97149c9559deae943c2cfa49aeeff8a6',1,'D3D12MA::ALLOCATOR_DESC']]], + ['prev_22',['prev',['../class_d3_d12_m_a_1_1_allocation.html#adc3ac89758a915a409e047f9b89aa160',1,'D3D12MA::Allocation']]], + ['priority_23',['Residency priority',['../optimal_allocation.html#optimal_allocation_residency_priority',1,'']]], + ['project_20setup_20and_20initialization_24',['Project setup and initialization',['../quick_start.html#quick_start_project_setup',1,'']]], + ['psrcallocation_25',['pSrcAllocation',['../struct_d3_d12_m_a_1_1_d_e_f_r_a_g_m_e_n_t_a_t_i_o_n___m_o_v_e.html#a4946b874c958a71c21fac25b515cf5f7',1,'D3D12MA::DEFRAGMENTATION_MOVE']]] ];
diff --git a/docs/html/search/enumvalues_2.js b/docs/html/search/enumvalues_2.js index 10b4213..075de46 100644 --- a/docs/html/search/enumvalues_2.js +++ b/docs/html/search/enumvalues_2.js
@@ -2,6 +2,7 @@ [ ['pool_5fflag_5falgorithm_5flinear_0',['POOL_FLAG_ALGORITHM_LINEAR',['../namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1aa37a0103f511954ea42a1d0bba286b6a',1,'D3D12MA']]], ['pool_5fflag_5falgorithm_5fmask_1',['POOL_FLAG_ALGORITHM_MASK',['../namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1aec9d4939b8cc5438545b9df840b5f5f7',1,'D3D12MA']]], - ['pool_5fflag_5fmsaa_5ftextures_5falways_5fcommitted_2',['POOL_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED',['../namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1acc379a89755438c0f76667783b778baa',1,'D3D12MA']]], - ['pool_5fflag_5fnone_3',['POOL_FLAG_NONE',['../namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1a5d8dc91add3423140809a550c7224d02',1,'D3D12MA']]] + ['pool_5fflag_5falways_5fcommitted_2',['POOL_FLAG_ALWAYS_COMMITTED',['../namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1a15b7a6f8bfb6e4d534143f8adb6ac7ba',1,'D3D12MA']]], + ['pool_5fflag_5fmsaa_5ftextures_5falways_5fcommitted_3',['POOL_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED',['../namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1acc379a89755438c0f76667783b778baa',1,'D3D12MA']]], + ['pool_5fflag_5fnone_4',['POOL_FLAG_NONE',['../namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1a5d8dc91add3423140809a550c7224d02',1,'D3D12MA']]] ];
diff --git a/docs/html/virtual_allocator.html b/docs/html/virtual_allocator.html index 8a54179..0b4d615 100644 --- a/docs/html/virtual_allocator.html +++ b/docs/html/virtual_allocator.html
@@ -105,9 +105,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:1519</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:1425</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:1433</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:1530</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:1436</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:1444</div></div> </div><!-- fragment --><h1><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> @@ -132,8 +132,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:1470</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:1477</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:1481</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:1488</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:471</div></div> </div><!-- fragment --><h1><a class="anchor" id="virtual_allocator_deallocation"></a> Deallocation</h1> @@ -171,7 +171,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:1482</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:1493</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 <code>sizeof(MyDataStruct)</code>, 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 cd14773..3e0a687 100644 --- a/include/D3D12MemAlloc.h +++ b/include/D3D12MemAlloc.h
@@ -828,7 +828,7 @@ /// Zero POOL_FLAG_NONE = 0, - /** \brief Enables alternative, linear allocation algorithm in this pool. + /** Enables alternative, linear allocation algorithm in this pool. Specify this flag to enable linear allocation algorithm, which always creates new allocations after last one and doesn't reuse space from allocations freed in @@ -841,13 +841,20 @@ */ POOL_FLAG_ALGORITHM_LINEAR = 0x1, - /** \brief Optimization, allocate MSAA textures as committed resources always. + /** Optimization, allocate MSAA textures as committed resources always. Specify this flag to create MSAA textures with implicit heaps, as if they were created with flag D3D12MA::ALLOCATION_FLAG_COMMITTED. Usage of this flags enables pool to create its heaps on smaller alignment not suitable for MSAA textures. + + You should always use this flag unless you really need to create some MSAA textures in this pool as placed. */ POOL_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED = 0x2, + /** Every allocation made in this pool will be created as a committed resource - will have its own memory block. + + There is also an equivalent flag for the entire allocator: D3D12MA::ALLOCATOR_FLAG_ALWAYS_COMMITTED. + */ + POOL_FLAG_ALWAYS_COMMITTED = 0x4, // Bit mask to extract only `ALGORITHM` bits from entire set of flags. POOL_FLAG_ALGORITHM_MASK = POOL_FLAG_ALGORITHM_LINEAR @@ -1022,9 +1029,11 @@ */ ALLOCATOR_FLAG_SINGLETHREADED = 0x1, - /** - Every allocation will have its own memory block. - To be used for debugging purposes. + /** Every allocation will be created as a committed resource - will have its own memory block. + + Affects both default pools and custom pools. + To be used for debugging purposes only. + There is also an equivalent flag for custom pools: D3D12MA::POOL_FLAG_ALWAYS_COMMITTED. */ ALLOCATOR_FLAG_ALWAYS_COMMITTED = 0x2, @@ -1044,14 +1053,16 @@ */ ALLOCATOR_FLAG_DEFAULT_POOLS_NOT_ZEROED = 0x4, - /** \brief Optimization, allocate MSAA textures as committed resources always. + /** Optimization, allocate MSAA textures as committed resources always. Specify this flag to create MSAA textures with implicit heaps, as if they were created with flag D3D12MA::ALLOCATION_FLAG_COMMITTED. Usage of this flags enables all default pools to create its heaps on smaller alignment not suitable for MSAA textures. + + You should always use this flag unless you really need to create some MSAA textures as placed. */ ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED = 0x8, - /** \brief Disable optimization that prefers creating small buffers as committed to avoid 64 KB alignment. + /** Disable optimization that prefers creating small buffers as committed to avoid 64 KB alignment. 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.
diff --git a/src/D3D12MemAlloc.cpp b/src/D3D12MemAlloc.cpp index 0696578..9a34407 100644 --- a/src/D3D12MemAlloc.cpp +++ b/src/D3D12MemAlloc.cpp
@@ -5855,6 +5855,7 @@ AllocatorPimpl* GetAllocator() const { return m_Allocator; } const POOL_DESC& GetDesc() const { return m_Desc; } + bool AlwaysCommitted() const { return (m_Desc.Flags & POOL_FLAG_ALWAYS_COMMITTED) != 0; } bool SupportsCommittedAllocations() const { return m_Desc.BlockSize == 0; } LPCWSTR GetName() const { return m_Name; } @@ -7410,7 +7411,8 @@ PoolPimpl* const pool = allocDesc.CustomPool->m_Pimpl; msaaAlwaysCommitted = pool->GetBlockVector()->DeniesMsaaTextures(); - outBlockVector = pool->GetBlockVector(); + if(!pool->AlwaysCommitted()) + outBlockVector = pool->GetBlockVector(); const auto& desc = pool->GetDesc(); outCommittedAllocationParams.m_ProtectedSession = desc.pProtectedSession; @@ -9514,6 +9516,8 @@ // Check for support if (m_Pimpl->GetBlockVector()->GetAlgorithm() & POOL_FLAG_ALGORITHM_LINEAR) return E_NOINTERFACE; + if(m_Pimpl->AlwaysCommitted()) + return E_NOINTERFACE; AllocatorPimpl* allocator = m_Pimpl->GetAllocator(); *ppContext = D3D12MA_NEW(allocator->GetAllocs(), DefragmentationContext)(allocator, *pDesc, m_Pimpl->GetBlockVector()); @@ -9737,6 +9741,12 @@ D3D12MA_ASSERT(0 && "Invalid arguments passed to Allocator::CreatePool."); return E_INVALIDARG; } + if ((pPoolDesc->Flags & POOL_FLAG_ALWAYS_COMMITTED) != 0 && + (pPoolDesc->BlockSize != 0 || pPoolDesc->MinBlockCount > 0)) + { + D3D12MA_ASSERT(0 && "Invalid arguments passed to Allocator::CreatePool while POOL_FLAG_ALWAYS_COMMITTED is specified."); + return E_INVALIDARG; + } if (!m_Pimpl->HeapFlagsFulfillResourceHeapTier(pPoolDesc->HeapFlags)) { D3D12MA_ASSERT(0 && "Invalid pPoolDesc->HeapFlags passed to Allocator::CreatePool. Did you forget to handle ResourceHeapTier=1?");
diff --git a/src/Tests.cpp b/src/Tests.cpp index 48cfbac..cd0c2ad 100644 --- a/src/Tests.cpp +++ b/src/Tests.cpp
@@ -62,6 +62,14 @@ L"GPU_UPLOAD", }; +bool operator==(const D3D12MA::Statistics& lhs, const D3D12MA::Statistics& rhs) +{ + return lhs.BlockCount == rhs.BlockCount && + lhs.AllocationCount == rhs.AllocationCount && + lhs.BlockBytes == rhs.BlockBytes && + lhs.AllocationBytes == rhs.AllocationBytes; +} + static void CurrentTimeToStr(std::string& out) { time_t rawTime; time(&rawTime); @@ -1313,6 +1321,52 @@ CHECK_BOOL(alloc->GetOffset() == 0); } +static void TestCustomPool_AlwaysCommitted(const TestContext& ctx) +{ + wprintf(L"Test custom pool always committed\n"); + + const UINT64 BUFFER_SIZE = 256; + + D3D12MA::POOL_DESC poolDesc = {}; + poolDesc.HeapProperties.Type = D3D12_HEAP_TYPE_DEFAULT; + poolDesc.HeapFlags = D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS; + poolDesc.Flags = D3D12MA::POOL_FLAG_ALWAYS_COMMITTED; + + ComPtr<D3D12MA::Pool> pool; + CHECK_HR(ctx.allocator->CreatePool(&poolDesc, &pool)); + + D3D12MA::ALLOCATION_DESC allocDesc = {}; + allocDesc.CustomPool = pool.Get(); + + D3D12_RESOURCE_DESC resDesc; + FillResourceDescForBuffer(resDesc, BUFFER_SIZE); + + ComPtr<D3D12MA::Allocation> alloc; + CHECK_HR(ctx.allocator->CreateResource(&allocDesc, &resDesc, + D3D12_RESOURCE_STATE_COMMON, + NULL, // pOptimizedClearValue + &alloc, + IID_NULL, NULL)); // riidResource, ppvResource + CHECK_BOOL(alloc->GetHeap() == NULL); + CHECK_BOOL(alloc->GetResource() != NULL); + CHECK_BOOL(alloc->GetOffset() == 0); + + D3D12MA::Statistics stats = {}; + pool->GetStatistics(&stats); + CHECK_BOOL(stats.AllocationBytes >= BUFFER_SIZE); + CHECK_BOOL(stats.AllocationCount == 1); + CHECK_BOOL(stats.BlockBytes >= BUFFER_SIZE); + CHECK_BOOL(stats.BlockCount == 1); + + D3D12MA::DetailedStatistics detailedStats = {}; + pool->CalculateStatistics(&detailedStats); + CHECK_BOOL(detailedStats.Stats == stats); + CHECK_BOOL(detailedStats.AllocationSizeMin == stats.AllocationBytes); + CHECK_BOOL(detailedStats.AllocationSizeMax == stats.AllocationBytes); + CHECK_BOOL(detailedStats.UnusedRangeCount == 0); + CHECK_BOOL(detailedStats.UnusedRangeSizeMax == 0); +} + static HRESULT TestCustomHeap(const TestContext& ctx, const D3D12_HEAP_PROPERTIES& heapProps) { D3D12MA::TotalStatistics globalStatsBeg = {}; @@ -4250,6 +4304,7 @@ TestCustomPools(ctx); TestCustomPool_MinAllocationAlignment(ctx); TestCustomPool_Committed(ctx); + TestCustomPool_AlwaysCommitted(ctx); TestPoolsAndAllocationParameters(ctx); TestCustomHeaps(ctx); TestStandardCustomCommittedPlaced(ctx);