Skip to content

Commit fbd11f0

Browse files
Added ALLOCATION_FLAG_CAN_ALIAS flag to prevent from using committed allocations on aliasing resources.
Code by @medranSolus
1 parent d263928 commit fbd11f0

14 files changed

Lines changed: 114 additions & 95 deletions

docs/html/_d3_d12_mem_alloc_8h.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,12 @@
178178
, <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645eab374417c1f22a833ead268a6c21424e6">D3D12MA::ALLOCATION_FLAG_WITHIN_BUDGET</a> = 0x4
179179
, <br />
180180
&#160;&#160;<a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645eafb0e2dacce691336e717550a1df72474">D3D12MA::ALLOCATION_FLAG_UPPER_ADDRESS</a> = 0x8
181-
, <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645ea4b4fa95bb0daf6a80add7fb292aa63ae">D3D12MA::ALLOCATION_FLAG_STRATEGY_MIN_MEMORY</a> = 0x10
182-
, <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645eaa3ded8847563c24b4522af0586dbd2cb">D3D12MA::ALLOCATION_FLAG_STRATEGY_MIN_TIME</a> = 0x20
183-
, <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645eac30b62e36906b3c6e97b8b1d2ad8709d">D3D12MA::ALLOCATION_FLAG_STRATEGY_MIN_OFFSET</a> = 0x40
181+
, <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645ea4d6808f27de6d0ae57014ec1f4d54326">D3D12MA::ALLOCATION_FLAG_CAN_ALIAS</a> = 0x10
182+
, <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645ea4b4fa95bb0daf6a80add7fb292aa63ae">D3D12MA::ALLOCATION_FLAG_STRATEGY_MIN_MEMORY</a> = 0x00010000
183+
, <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645eaa3ded8847563c24b4522af0586dbd2cb">D3D12MA::ALLOCATION_FLAG_STRATEGY_MIN_TIME</a> = 0x00020000
184184
, <br />
185-
&#160;&#160;<a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645eaaeed6a77f0fe7f33459df593cea44c35">D3D12MA::ALLOCATION_FLAG_STRATEGY_BEST_FIT</a> = ALLOCATION_FLAG_STRATEGY_MIN_MEMORY
185+
&#160;&#160;<a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645eac30b62e36906b3c6e97b8b1d2ad8709d">D3D12MA::ALLOCATION_FLAG_STRATEGY_MIN_OFFSET</a> = 0x0004000
186+
, <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645eaaeed6a77f0fe7f33459df593cea44c35">D3D12MA::ALLOCATION_FLAG_STRATEGY_BEST_FIT</a> = ALLOCATION_FLAG_STRATEGY_MIN_MEMORY
186187
, <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645ea103ff3115f3c2126779c25be435bf6aa">D3D12MA::ALLOCATION_FLAG_STRATEGY_FIRST_FIT</a> = ALLOCATION_FLAG_STRATEGY_MIN_TIME
187188
, <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645ea3e29297ad3c6cf9d9bb61b6d27a13ab3">D3D12MA::ALLOCATION_FLAG_STRATEGY_MASK</a>
188189
<br />

docs/html/configuration.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@ <h1><a class="anchor" id="custom_memory_allocator"></a>
101101
<div class="line"> </div>
102102
<div class="line"><a class="code hl_class" href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a>* allocator;</div>
103103
<div class="line">HRESULT hr = <a class="code hl_function" href="namespace_d3_d12_m_a.html#ab7a1cd1683986d75ce1488b0920f4cb0">D3D12MA::CreateAllocator</a>(&amp;allocatorDesc, &amp;allocator);</div>
104-
<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:1030</div></div>
104+
<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:1039</div></div>
105105
<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>
106106
<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:187</div></div>
107107
<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:191</div></div>
108108
<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:189</div></div>
109-
<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:991</div></div>
110-
<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:1011</div></div>
111-
<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:1017</div></div>
112-
<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:999</div></div>
109+
<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:1000</div></div>
110+
<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:1020</div></div>
111+
<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:1026</div></div>
112+
<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:1008</div></div>
113113
</div><!-- fragment --><h1><a class="anchor" id="debug_margins"></a>
114114
Debug margins</h1>
115115
<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>

docs/html/namespace_d3_d12_m_a.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,12 @@
158158
, <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645eab374417c1f22a833ead268a6c21424e6">ALLOCATION_FLAG_WITHIN_BUDGET</a> = 0x4
159159
, <br />
160160
&#160;&#160;<a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645eafb0e2dacce691336e717550a1df72474">ALLOCATION_FLAG_UPPER_ADDRESS</a> = 0x8
161-
, <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645ea4b4fa95bb0daf6a80add7fb292aa63ae">ALLOCATION_FLAG_STRATEGY_MIN_MEMORY</a> = 0x10
162-
, <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645eaa3ded8847563c24b4522af0586dbd2cb">ALLOCATION_FLAG_STRATEGY_MIN_TIME</a> = 0x20
163-
, <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645eac30b62e36906b3c6e97b8b1d2ad8709d">ALLOCATION_FLAG_STRATEGY_MIN_OFFSET</a> = 0x40
161+
, <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645ea4d6808f27de6d0ae57014ec1f4d54326">ALLOCATION_FLAG_CAN_ALIAS</a> = 0x10
162+
, <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645ea4b4fa95bb0daf6a80add7fb292aa63ae">ALLOCATION_FLAG_STRATEGY_MIN_MEMORY</a> = 0x00010000
163+
, <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645eaa3ded8847563c24b4522af0586dbd2cb">ALLOCATION_FLAG_STRATEGY_MIN_TIME</a> = 0x00020000
164164
, <br />
165-
&#160;&#160;<a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645eaaeed6a77f0fe7f33459df593cea44c35">ALLOCATION_FLAG_STRATEGY_BEST_FIT</a> = ALLOCATION_FLAG_STRATEGY_MIN_MEMORY
165+
&#160;&#160;<a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645eac30b62e36906b3c6e97b8b1d2ad8709d">ALLOCATION_FLAG_STRATEGY_MIN_OFFSET</a> = 0x0004000
166+
, <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645eaaeed6a77f0fe7f33459df593cea44c35">ALLOCATION_FLAG_STRATEGY_BEST_FIT</a> = ALLOCATION_FLAG_STRATEGY_MIN_MEMORY
166167
, <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645ea103ff3115f3c2126779c25be435bf6aa">ALLOCATION_FLAG_STRATEGY_FIRST_FIT</a> = ALLOCATION_FLAG_STRATEGY_MIN_TIME
167168
, <a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645ea3e29297ad3c6cf9d9bb61b6d27a13ab3">ALLOCATION_FLAG_STRATEGY_MASK</a>
168169
<br />
@@ -306,6 +307,9 @@ <h2 class="memtitle"><span class="permalink"><a href="#abbad31a7e0b3d09d77f3fb70
306307
<tr><td class="fieldname"><a id="abbad31a7e0b3d09d77f3fb704b77645eafb0e2dacce691336e717550a1df72474" name="abbad31a7e0b3d09d77f3fb704b77645eafb0e2dacce691336e717550a1df72474"></a>ALLOCATION_FLAG_UPPER_ADDRESS&#160;</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>
307308
<p >This flag is only allowed for custom pools created with <a class="el" href="namespace_d3_d12_m_a.html#a919d8545365d6b7209a964f2b99936d1aa37a0103f511954ea42a1d0bba286b6a" title="Enables alternative, linear allocation algorithm in this pool.">POOL_FLAG_ALGORITHM_LINEAR</a> flag. </p>
308309
</td></tr>
310+
<tr><td class="fieldname"><a id="abbad31a7e0b3d09d77f3fb704b77645ea4d6808f27de6d0ae57014ec1f4d54326" name="abbad31a7e0b3d09d77f3fb704b77645ea4d6808f27de6d0ae57014ec1f4d54326"></a>ALLOCATION_FLAG_CAN_ALIAS&#160;</td><td class="fielddoc"><p >Set this flag if the allocated memory will have aliasing resources.</p>
311+
<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-&gt;GetHeap() != NULL</code>. </p>
312+
</td></tr>
309313
<tr><td class="fieldname"><a id="abbad31a7e0b3d09d77f3fb704b77645ea4b4fa95bb0daf6a80add7fb292aa63ae" name="abbad31a7e0b3d09d77f3fb704b77645ea4b4fa95bb0daf6a80add7fb292aa63ae"></a>ALLOCATION_FLAG_STRATEGY_MIN_MEMORY&#160;</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> strategy that chooses smallest possible free range for the allocation to minimize memory usage and fragmentation, possibly at the expense of allocation time. </p>
310314
</td></tr>
311315
<tr><td class="fieldname"><a id="abbad31a7e0b3d09d77f3fb704b77645eaa3ded8847563c24b4522af0586dbd2cb" name="abbad31a7e0b3d09d77f3fb704b77645eaa3ded8847563c24b4522af0586dbd2cb"></a>ALLOCATION_FLAG_STRATEGY_MIN_TIME&#160;</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> strategy that chooses first suitable free range for the allocation - not necessarily in terms of the smallest offset but the one that is easiest and fastest to find to minimize allocation time, possibly at the expense of allocation quality. </p>

docs/html/namespacemembers.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666

6767
<h3><a id="index_a" name="index_a"></a>- a -</h3><ul>
6868
<li>ALLOCATE_FUNC_PTR&#160;:&#160;<a class="el" href="namespace_d3_d12_m_a.html#a8bcc49af3c53bbe04dbcb41c093dce58">D3D12MA</a></li>
69+
<li>ALLOCATION_FLAG_CAN_ALIAS&#160;:&#160;<a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645ea4d6808f27de6d0ae57014ec1f4d54326">D3D12MA</a></li>
6970
<li>ALLOCATION_FLAG_COMMITTED&#160;:&#160;<a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645ea661a5472dba3dcecc5a2cc92afd25675">D3D12MA</a></li>
7071
<li>ALLOCATION_FLAG_NEVER_ALLOCATE&#160;:&#160;<a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645ea9a52c6ae694eadcd20896091e77c0628">D3D12MA</a></li>
7172
<li>ALLOCATION_FLAG_NONE&#160;:&#160;<a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645ea0bf578b096d6ea73cea86b031541733e">D3D12MA</a></li>

docs/html/namespacemembers_eval.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
&#160;
6666

6767
<h3><a id="index_a" name="index_a"></a>- a -</h3><ul>
68+
<li>ALLOCATION_FLAG_CAN_ALIAS&#160;:&#160;<a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645ea4d6808f27de6d0ae57014ec1f4d54326">D3D12MA</a></li>
6869
<li>ALLOCATION_FLAG_COMMITTED&#160;:&#160;<a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645ea661a5472dba3dcecc5a2cc92afd25675">D3D12MA</a></li>
6970
<li>ALLOCATION_FLAG_NEVER_ALLOCATE&#160;:&#160;<a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645ea9a52c6ae694eadcd20896091e77c0628">D3D12MA</a></li>
7071
<li>ALLOCATION_FLAG_NONE&#160;:&#160;<a class="el" href="namespace_d3_d12_m_a.html#abbad31a7e0b3d09d77f3fb704b77645ea0bf578b096d6ea73cea86b031541733e">D3D12MA</a></li>

0 commit comments

Comments
 (0)