Added support for GPU Upload Heaps from Agility SDK 1.710.0-preview

Added Allocator::IsGPUUploadHeapSupported.
Extended TotalStatistics::HeapType[] to 5 elements.
This commit is contained in:
Adam Sawicki 2023-07-05 10:09:03 +02:00
parent 554cd184af
commit b6c5bea3cd
23 changed files with 438 additions and 110 deletions

View File

@ -97,8 +97,9 @@ $(function() {
<tr class="odd"><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html#ae276d2358a58a36f8c6639f837f29be5">GetD3D12Options</a>() const</td><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a></td><td class="entry"></td></tr>
<tr class="even"><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a434ae3147209953253da26687bfd62dc">GetMemoryCapacity</a>(UINT memorySegmentGroup) const</td><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a></td><td class="entry"></td></tr>
<tr class="odd"><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a08210561b92c4bd7ede9dd7beba4bb80">IsCacheCoherentUMA</a>() const</td><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a></td><td class="entry"></td></tr>
<tr class="even"><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a9e742884bd45dd7f01193d13fcd05af0">IsUMA</a>() const</td><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a></td><td class="entry"></td></tr>
<tr class="odd"><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a468ba0c93121eaaee402b08775f1dd11">SetCurrentFrameIndex</a>(UINT frameIndex)</td><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a></td><td class="entry"></td></tr>
<tr class="even"><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a3f3fd1e88cf2cd02257fe272e08a273c">IsGPUUploadHeapSupported</a>() const</td><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a></td><td class="entry"></td></tr>
<tr class="odd"><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a9e742884bd45dd7f01193d13fcd05af0">IsUMA</a>() const</td><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a></td><td class="entry"></td></tr>
<tr class="even"><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a468ba0c93121eaaee402b08775f1dd11">SetCurrentFrameIndex</a>(UINT frameIndex)</td><td class="entry"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html">D3D12MA::Allocator</a></td><td class="entry"></td></tr>
</table></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>

View File

@ -102,6 +102,9 @@ Public Member Functions</h2></td></tr>
<tr class="memitem:a08210561b92c4bd7ede9dd7beba4bb80"><td class="memItemLeft" align="right" valign="top">BOOL&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a08210561b92c4bd7ede9dd7beba4bb80">IsCacheCoherentUMA</a> () const</td></tr>
<tr class="memdesc:a08210561b92c4bd7ede9dd7beba4bb80"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns true if <code>D3D12_FEATURE_DATA_ARCHITECTURE1::CacheCoherentUMA</code> was found to be true. <br /></td></tr>
<tr class="separator:a08210561b92c4bd7ede9dd7beba4bb80"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3f3fd1e88cf2cd02257fe272e08a273c"><td class="memItemLeft" align="right" valign="top">BOOL&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a3f3fd1e88cf2cd02257fe272e08a273c">IsGPUUploadHeapSupported</a> () const</td></tr>
<tr class="memdesc:a3f3fd1e88cf2cd02257fe272e08a273c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns true if GPU Upload Heaps are supported on the current system. <br /></td></tr>
<tr class="separator:a3f3fd1e88cf2cd02257fe272e08a273c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a434ae3147209953253da26687bfd62dc"><td class="memItemLeft" align="right" valign="top">UINT64&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a434ae3147209953253da26687bfd62dc">GetMemoryCapacity</a> (UINT memorySegmentGroup) const</td></tr>
<tr class="memdesc:a434ae3147209953253da26687bfd62dc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns total amount of memory of specific segment group, in bytes. <br /></td></tr>
<tr class="separator:a434ae3147209953253da26687bfd62dc"><td class="memSeparator" colspan="2">&#160;</td></tr>
@ -893,6 +896,28 @@ Public Member Functions</h2></td></tr>
<li>"ID3D12Device::GetCustomHeapProperties method (d3d12.h)" </li>
</ul>
</div>
</div>
<a id="a3f3fd1e88cf2cd02257fe272e08a273c" name="a3f3fd1e88cf2cd02257fe272e08a273c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3f3fd1e88cf2cd02257fe272e08a273c">&#9670;&#160;</a></span>IsGPUUploadHeapSupported()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">BOOL D3D12MA::Allocator::IsGPUUploadHeapSupported </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns true if GPU Upload Heaps are supported on the current system. </p>
<p>When true, you can use <code>D3D12_HEAP_TYPE_GPU_UPLOAD</code>.</p>
<p>This flag is fetched from <code>D3D12_FEATURE_D3D12_OPTIONS16::GPUUploadHeapSupported</code>.</p>
<p><code>#define D3D12MA_OPTIONS16_SUPPORTED 1</code> is needed for the compilation of this library. Otherwise the flag is always false. </p>
</div>
</div>
<a id="a9e742884bd45dd7f01193d13fcd05af0" name="a9e742884bd45dd7f01193d13fcd05af0"></a>

View File

@ -108,15 +108,15 @@ Custom CPU memory allocator</h1>
<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>(&amp;allocatorDesc, &amp;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:1102</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:1112</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:200</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:204</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:202</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:1063</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:1083</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:1089</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:1071</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:209</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:213</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:211</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:1073</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:1093</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: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_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:1081</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>

View File

@ -134,19 +134,19 @@ $(function() {
<div class="line">defragCtx-&gt;Release();</div>
<div class="ttc" id="aclass_d3_d12_m_a_1_1_allocation_html_a414a088c22bae0f29b1038f5f9346d14"><div class="ttname"><a href="class_d3_d12_m_a_1_1_allocation.html#a414a088c22bae0f29b1038f5f9346d14">D3D12MA::Allocation::SetResource</a></div><div class="ttdeci">void SetResource(ID3D12Resource *pResource)</div><div class="ttdoc">Releases the resource currently pointed by the allocation (if any), sets it to new one,...</div></div>
<div class="ttc" id="aclass_d3_d12_m_a_1_1_allocation_html_a47be9557d441797b65de177a3d5cdf60"><div class="ttname"><a href="class_d3_d12_m_a_1_1_allocation.html#a47be9557d441797b65de177a3d5cdf60">D3D12MA::Allocation::GetOffset</a></div><div class="ttdeci">UINT64 GetOffset() const</div><div class="ttdoc">Returns offset in bytes from the start of memory heap.</div></div>
<div class="ttc" id="aclass_d3_d12_m_a_1_1_allocation_html_ad00308118252f82d8f803c623c67bf18"><div class="ttname"><a href="class_d3_d12_m_a_1_1_allocation.html#ad00308118252f82d8f803c623c67bf18">D3D12MA::Allocation::GetResource</a></div><div class="ttdeci">ID3D12Resource * GetResource() const</div><div class="ttdoc">Returns D3D12 resource associated with this object.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:502</div></div>
<div class="ttc" id="aclass_d3_d12_m_a_1_1_allocation_html_ad00308118252f82d8f803c623c67bf18"><div class="ttname"><a href="class_d3_d12_m_a_1_1_allocation.html#ad00308118252f82d8f803c623c67bf18">D3D12MA::Allocation::GetResource</a></div><div class="ttdeci">ID3D12Resource * GetResource() const</div><div class="ttdoc">Returns D3D12 resource associated with this object.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:512</div></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="aclass_d3_d12_m_a_1_1_defragmentation_context_html"><div class="ttname"><a href="class_d3_d12_m_a_1_1_defragmentation_context.html">D3D12MA::DefragmentationContext</a></div><div class="ttdoc">Represents defragmentation process in progress.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:781</div></div>
<div class="ttc" id="aclass_d3_d12_m_a_1_1_defragmentation_context_html"><div class="ttname"><a href="class_d3_d12_m_a_1_1_defragmentation_context.html">D3D12MA::DefragmentationContext</a></div><div class="ttdoc">Represents defragmentation process in progress.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:791</div></div>
<div class="ttc" id="aclass_d3_d12_m_a_1_1_defragmentation_context_html_a1606c015d02edc094bb246986159d592"><div class="ttname"><a href="class_d3_d12_m_a_1_1_defragmentation_context.html#a1606c015d02edc094bb246986159d592">D3D12MA::DefragmentationContext::BeginPass</a></div><div class="ttdeci">HRESULT BeginPass(DEFRAGMENTATION_PASS_MOVE_INFO *pPassInfo)</div><div class="ttdoc">Starts single defragmentation pass.</div></div>
<div class="ttc" id="aclass_d3_d12_m_a_1_1_defragmentation_context_html_aad502ba70d6dadaeee37703fd8bf90ae"><div class="ttname"><a href="class_d3_d12_m_a_1_1_defragmentation_context.html#aad502ba70d6dadaeee37703fd8bf90ae">D3D12MA::DefragmentationContext::EndPass</a></div><div class="ttdeci">HRESULT EndPass(DEFRAGMENTATION_PASS_MOVE_INFO *pPassInfo)</div><div class="ttdoc">Ends single defragmentation pass.</div></div>
<div class="ttc" id="anamespace_d3_d12_m_a_html_ab433989212ee6736bf9d63c5bc565df4a9d0301a81136ca79e3ba52542c6d2e13"><div class="ttname"><a href="namespace_d3_d12_m_a.html#ab433989212ee6736bf9d63c5bc565df4a9d0301a81136ca79e3ba52542c6d2e13">D3D12MA::DEFRAGMENTATION_FLAG_ALGORITHM_FAST</a></div><div class="ttdeci">@ DEFRAGMENTATION_FLAG_ALGORITHM_FAST</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:661</div></div>
<div class="ttc" id="astruct_d3_d12_m_a_1_1_d_e_f_r_a_g_m_e_n_t_a_t_i_o_n___d_e_s_c_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_d_e_f_r_a_g_m_e_n_t_a_t_i_o_n___d_e_s_c.html">D3D12MA::DEFRAGMENTATION_DESC</a></div><div class="ttdoc">Parameters for defragmentation.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:683</div></div>
<div class="ttc" id="astruct_d3_d12_m_a_1_1_d_e_f_r_a_g_m_e_n_t_a_t_i_o_n___d_e_s_c_html_aac9a357e679a0afa9ab84cd06057630b"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_d_e_f_r_a_g_m_e_n_t_a_t_i_o_n___d_e_s_c.html#aac9a357e679a0afa9ab84cd06057630b">D3D12MA::DEFRAGMENTATION_DESC::Flags</a></div><div class="ttdeci">DEFRAGMENTATION_FLAGS Flags</div><div class="ttdoc">Flags.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:685</div></div>
<div class="ttc" id="astruct_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"><div class="ttname"><a href="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">D3D12MA::DEFRAGMENTATION_MOVE::pSrcAllocation</a></div><div class="ttdeci">Allocation * pSrcAllocation</div><div class="ttdoc">Allocation that should be moved.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:719</div></div>
<div class="ttc" id="astruct_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_aec0c7f51ccc870c6a88af7c7390d8eda"><div class="ttname"><a href="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#aec0c7f51ccc870c6a88af7c7390d8eda">D3D12MA::DEFRAGMENTATION_MOVE::pDstTmpAllocation</a></div><div class="ttdeci">Allocation * pDstTmpAllocation</div><div class="ttdoc">Temporary allocation pointing to destination memory that will replace pSrcAllocation.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:727</div></div>
<div class="ttc" id="astruct_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"><div class="ttname"><a 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">D3D12MA::DEFRAGMENTATION_PASS_MOVE_INFO</a></div><div class="ttdoc">Parameters for incremental defragmentation steps.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:735</div></div>
<div class="ttc" id="astruct_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"><div class="ttname"><a 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">D3D12MA::DEFRAGMENTATION_PASS_MOVE_INFO::pMoves</a></div><div class="ttdeci">DEFRAGMENTATION_MOVE * pMoves</div><div class="ttdoc">Array of moves to be performed by the user in the current defragmentation pass.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:759</div></div>
<div class="ttc" id="astruct_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_a8df22d990c318d82fe9fcc5f04132c04"><div class="ttname"><a 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#a8df22d990c318d82fe9fcc5f04132c04">D3D12MA::DEFRAGMENTATION_PASS_MOVE_INFO::MoveCount</a></div><div class="ttdeci">UINT32 MoveCount</div><div class="ttdoc">Number of elements in the pMoves array.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:737</div></div>
<div class="ttc" id="anamespace_d3_d12_m_a_html_ab433989212ee6736bf9d63c5bc565df4a9d0301a81136ca79e3ba52542c6d2e13"><div class="ttname"><a href="namespace_d3_d12_m_a.html#ab433989212ee6736bf9d63c5bc565df4a9d0301a81136ca79e3ba52542c6d2e13">D3D12MA::DEFRAGMENTATION_FLAG_ALGORITHM_FAST</a></div><div class="ttdeci">@ DEFRAGMENTATION_FLAG_ALGORITHM_FAST</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:671</div></div>
<div class="ttc" id="astruct_d3_d12_m_a_1_1_d_e_f_r_a_g_m_e_n_t_a_t_i_o_n___d_e_s_c_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_d_e_f_r_a_g_m_e_n_t_a_t_i_o_n___d_e_s_c.html">D3D12MA::DEFRAGMENTATION_DESC</a></div><div class="ttdoc">Parameters for defragmentation.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:693</div></div>
<div class="ttc" id="astruct_d3_d12_m_a_1_1_d_e_f_r_a_g_m_e_n_t_a_t_i_o_n___d_e_s_c_html_aac9a357e679a0afa9ab84cd06057630b"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_d_e_f_r_a_g_m_e_n_t_a_t_i_o_n___d_e_s_c.html#aac9a357e679a0afa9ab84cd06057630b">D3D12MA::DEFRAGMENTATION_DESC::Flags</a></div><div class="ttdeci">DEFRAGMENTATION_FLAGS Flags</div><div class="ttdoc">Flags.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:695</div></div>
<div class="ttc" id="astruct_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"><div class="ttname"><a href="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">D3D12MA::DEFRAGMENTATION_MOVE::pSrcAllocation</a></div><div class="ttdeci">Allocation * pSrcAllocation</div><div class="ttdoc">Allocation that should be moved.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:729</div></div>
<div class="ttc" id="astruct_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_aec0c7f51ccc870c6a88af7c7390d8eda"><div class="ttname"><a href="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#aec0c7f51ccc870c6a88af7c7390d8eda">D3D12MA::DEFRAGMENTATION_MOVE::pDstTmpAllocation</a></div><div class="ttdeci">Allocation * pDstTmpAllocation</div><div class="ttdoc">Temporary allocation pointing to destination memory that will replace pSrcAllocation.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:737</div></div>
<div class="ttc" id="astruct_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"><div class="ttname"><a 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">D3D12MA::DEFRAGMENTATION_PASS_MOVE_INFO</a></div><div class="ttdoc">Parameters for incremental defragmentation steps.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:745</div></div>
<div class="ttc" id="astruct_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"><div class="ttname"><a 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">D3D12MA::DEFRAGMENTATION_PASS_MOVE_INFO::pMoves</a></div><div class="ttdeci">DEFRAGMENTATION_MOVE * pMoves</div><div class="ttdoc">Array of moves to be performed by the user in the current defragmentation pass.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:769</div></div>
<div class="ttc" id="astruct_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_a8df22d990c318d82fe9fcc5f04132c04"><div class="ttname"><a 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#a8df22d990c318d82fe9fcc5f04132c04">D3D12MA::DEFRAGMENTATION_PASS_MOVE_INFO::MoveCount</a></div><div class="ttdeci">UINT32 MoveCount</div><div class="ttdoc">Number of elements in the pMoves array.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:747</div></div>
</div><!-- fragment --><p>Although functions like <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> create an allocation and a buffer/texture at once, these are just a shortcut for allocating memory and creating a placed resource. Defragmentation works on memory allocations only. You must handle the rest manually. Defragmentation is an iterative process that should repreat "passes" as long as related functions return <code>S_FALSE</code> not <code>S_OK</code>. In each pass:</p>
<ol type="1">
<li><a class="el" href="class_d3_d12_m_a_1_1_defragmentation_context.html#a1606c015d02edc094bb246986159d592" title="Starts single defragmentation pass.">D3D12MA::DefragmentationContext::BeginPass()</a> function call:<ul>

View File

@ -156,13 +156,14 @@ $(function() {
<li>HeapFlags&#160;:&#160;<a class="el" href="struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html#a3795956e4fbfe7c3a23546e02e5d28dc">D3D12MA::POOL_DESC</a></li>
<li>HeapProperties&#160;:&#160;<a class="el" href="struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html#a06e06813bcb5206e9f7a8b0564bf1d6a">D3D12MA::POOL_DESC</a></li>
<li>HeapsFreed&#160;:&#160;<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___s_t_a_t_s.html#aecc6120afcf75028c9850f8d475b727d">D3D12MA::DEFRAGMENTATION_STATS</a></li>
<li>HeapType&#160;:&#160;<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#aa46b3c0456e5a23edef3328607ebf4d7">D3D12MA::ALLOCATION_DESC</a>, <a class="el" href="struct_d3_d12_m_a_1_1_total_statistics.html#a07247152fc70a8ee5605cab0fe220ea5">D3D12MA::TotalStatistics</a></li>
<li>HeapType&#160;:&#160;<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#aa46b3c0456e5a23edef3328607ebf4d7">D3D12MA::ALLOCATION_DESC</a>, <a class="el" href="struct_d3_d12_m_a_1_1_total_statistics.html#abad2e48b38f8a73a4daf8577e7a33b89">D3D12MA::TotalStatistics</a></li>
</ul>
<h3><a id="index_i" name="index_i"></a>- i -</h3><ul>
<li>IsCacheCoherentUMA()&#160;:&#160;<a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a08210561b92c4bd7ede9dd7beba4bb80">D3D12MA::Allocator</a></li>
<li>IsEmpty()&#160;:&#160;<a class="el" href="class_d3_d12_m_a_1_1_virtual_block.html#a7b23fd2da6f0343095fb14b31395678b">D3D12MA::VirtualBlock</a></li>
<li>IsGPUUploadHeapSupported()&#160;:&#160;<a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a3f3fd1e88cf2cd02257fe272e08a273c">D3D12MA::Allocator</a></li>
<li>IsUMA()&#160;:&#160;<a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a9e742884bd45dd7f01193d13fcd05af0">D3D12MA::Allocator</a></li>
</ul>

View File

@ -129,6 +129,7 @@ $(function() {
<h3><a id="index_i" name="index_i"></a>- i -</h3><ul>
<li>IsCacheCoherentUMA()&#160;:&#160;<a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a08210561b92c4bd7ede9dd7beba4bb80">D3D12MA::Allocator</a></li>
<li>IsEmpty()&#160;:&#160;<a class="el" href="class_d3_d12_m_a_1_1_virtual_block.html#a7b23fd2da6f0343095fb14b31395678b">D3D12MA::VirtualBlock</a></li>
<li>IsGPUUploadHeapSupported()&#160;:&#160;<a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a3f3fd1e88cf2cd02257fe272e08a273c">D3D12MA::Allocator</a></li>
<li>IsUMA()&#160;:&#160;<a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a9e742884bd45dd7f01193d13fcd05af0">D3D12MA::Allocator</a></li>
</ul>

View File

@ -114,7 +114,7 @@ $(function() {
<li>HeapFlags&#160;:&#160;<a class="el" href="struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html#a3795956e4fbfe7c3a23546e02e5d28dc">D3D12MA::POOL_DESC</a></li>
<li>HeapProperties&#160;:&#160;<a class="el" href="struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html#a06e06813bcb5206e9f7a8b0564bf1d6a">D3D12MA::POOL_DESC</a></li>
<li>HeapsFreed&#160;:&#160;<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___s_t_a_t_s.html#aecc6120afcf75028c9850f8d475b727d">D3D12MA::DEFRAGMENTATION_STATS</a></li>
<li>HeapType&#160;:&#160;<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#aa46b3c0456e5a23edef3328607ebf4d7">D3D12MA::ALLOCATION_DESC</a>, <a class="el" href="struct_d3_d12_m_a_1_1_total_statistics.html#a07247152fc70a8ee5605cab0fe220ea5">D3D12MA::TotalStatistics</a></li>
<li>HeapType&#160;:&#160;<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#aa46b3c0456e5a23edef3328607ebf4d7">D3D12MA::ALLOCATION_DESC</a>, <a class="el" href="struct_d3_d12_m_a_1_1_total_statistics.html#abad2e48b38f8a73a4daf8577e7a33b89">D3D12MA::TotalStatistics</a></li>
</ul>

View File

@ -72,8 +72,8 @@ $(function() {
<div class="headertitle"><div class="title">D3D12 Memory Allocator </div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p><b>Version 2.1.0-development</b> (2022-12-15)</p>
<p>Copyright (c) 2019-2022 Advanced Micro Devices, Inc. All rights reserved. <br />
<div class="textblock"><p><b>Version 2.1.0-development</b> (2023-07-05)</p>
<p>Copyright (c) 2019-2023 Advanced Micro Devices, Inc. All rights reserved. <br />
License: MIT</p>
<p>Documentation of all members: <a class="el" href="_d3_d12_mem_alloc_8h.html">D3D12MemAlloc.h</a></p>
<h1><a class="anchor" id="main_table_of_contents"></a>

View File

@ -97,11 +97,11 @@ Project setup and initialization</h1>
<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>(&amp;allocatorDesc, &amp;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:1102</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:1112</div></div>
<div class="ttc" id="anamespace_d3_d12_m_a_html_ab7a1cd1683986d75ce1488b0920f4cb0"><div class="ttname"><a href="namespace_d3_d12_m_a.html#ab7a1cd1683986d75ce1488b0920f4cb0">D3D12MA::CreateAllocator</a></div><div class="ttdeci">D3D12MA_API HRESULT CreateAllocator(const ALLOCATOR_DESC *pDesc, Allocator **ppAllocator)</div><div class="ttdoc">Creates new main D3D12MA::Allocator object and returns it through ppAllocator.</div></div>
<div class="ttc" id="astruct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_o_r___d_e_s_c.html">D3D12MA::ALLOCATOR_DESC</a></div><div class="ttdoc">Parameters of created Allocator object. To be used with CreateAllocator().</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:1063</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:1089</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:1071</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:1073</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: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_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:1081</div></div>
</div><!-- fragment --><p>(5.) Right before destroying the D3D12 device, destroy the allocator object.</p>
<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>
<div class="fragment"><div class="line">allocator-&gt;Release();</div>
@ -136,10 +136,10 @@ Creating resources</h1>
<div class="line"> IID_NULL, NULL);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Use allocation-&gt;GetResource()...</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:473</div></div>
<div class="ttc" id="aclass_d3_d12_m_a_1_1_allocation_html"><div class="ttname"><a href="class_d3_d12_m_a_1_1_allocation.html">D3D12MA::Allocation</a></div><div class="ttdoc">Represents single memory allocation.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:483</div></div>
<div class="ttc" id="aclass_d3_d12_m_a_1_1_allocator_html_aa37d6b9fe8ea0864f7a35b9d68e8345a"><div class="ttname"><a href="class_d3_d12_m_a_1_1_allocator.html#aa37d6b9fe8ea0864f7a35b9d68e8345a">D3D12MA::Allocator::CreateResource</a></div><div class="ttdeci">HRESULT CreateResource(const ALLOCATION_DESC *pAllocDesc, const D3D12_RESOURCE_DESC *pResourceDesc, D3D12_RESOURCE_STATES InitialResourceState, const D3D12_CLEAR_VALUE *pOptimizedClearValue, Allocation **ppAllocation, REFIID riidResource, void **ppvResource)</div><div class="ttdoc">Allocates memory and creates a D3D12 resource (buffer or texture). This is the main allocation functi...</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:290</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_aa46b3c0456e5a23edef3328607ebf4d7"><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#aa46b3c0456e5a23edef3328607ebf4d7">D3D12MA::ALLOCATION_DESC::HeapType</a></div><div class="ttdeci">D3D12_HEAP_TYPE HeapType</div><div class="ttdoc">The type of memory heap where the new allocation should be placed.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:299</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:299</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_aa46b3c0456e5a23edef3328607ebf4d7"><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#aa46b3c0456e5a23edef3328607ebf4d7">D3D12MA::ALLOCATION_DESC::HeapType</a></div><div class="ttdeci">D3D12_HEAP_TYPE HeapType</div><div class="ttdoc">The type of memory heap where the new allocation should be placed.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:308</div></div>
</div><!-- fragment --><p>You need to release the allocation object when no longer needed. This will also release the D3D12 resource.</p>
<div class="fragment"><div class="line">allocation-&gt;Release();</div>
</div><!-- fragment --><p>The advantage of using the allocator instead of creating committed resource, and the main purpose of this library, is that it can decide to allocate bigger memory heap internally using <code>ID3D12Device::CreateHeap</code> and place multiple resources in it, at different offsets, using <code>ID3D12Device::CreatePlacedResource</code>. The library manages its own collection of allocated memory blocks (heaps) and remembers which parts of them are occupied and which parts are free to be used for new resources.</p>

View File

@ -151,11 +151,11 @@ $(function() {
<div class="line">res2-&gt;Release();</div>
<div class="line">res1-&gt;Release();</div>
<div class="line">alloc-&gt;Release();</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:473</div></div>
<div class="ttc" id="aclass_d3_d12_m_a_1_1_allocation_html"><div class="ttname"><a href="class_d3_d12_m_a_1_1_allocation.html">D3D12MA::Allocation</a></div><div class="ttdoc">Represents single memory allocation.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:483</div></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_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:290</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_a97878838f976b2d1e6b1a76881035690"><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#a97878838f976b2d1e6b1a76881035690">D3D12MA::ALLOCATION_DESC::ExtraHeapFlags</a></div><div class="ttdeci">D3D12_HEAP_FLAGS ExtraHeapFlags</div><div class="ttdoc">Additional heap flags to be used when allocating memory.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:315</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_aa46b3c0456e5a23edef3328607ebf4d7"><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#aa46b3c0456e5a23edef3328607ebf4d7">D3D12MA::ALLOCATION_DESC::HeapType</a></div><div class="ttdeci">D3D12_HEAP_TYPE HeapType</div><div class="ttdoc">The type of memory heap where the new allocation should be placed.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:299</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:299</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_a97878838f976b2d1e6b1a76881035690"><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#a97878838f976b2d1e6b1a76881035690">D3D12MA::ALLOCATION_DESC::ExtraHeapFlags</a></div><div class="ttdeci">D3D12_HEAP_FLAGS ExtraHeapFlags</div><div class="ttdoc">Additional heap flags to be used when allocating memory.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:324</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_aa46b3c0456e5a23edef3328607ebf4d7"><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#aa46b3c0456e5a23edef3328607ebf4d7">D3D12MA::ALLOCATION_DESC::HeapType</a></div><div class="ttdeci">D3D12_HEAP_TYPE HeapType</div><div class="ttdoc">The type of memory heap where the new allocation should be placed.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:308</div></div>
</div><!-- fragment --><p>Remember that using resouces that alias in memory requires proper synchronization. You need to issue a special barrier of type <code>D3D12_RESOURCE_BARRIER_TYPE_ALIASING</code>. You also need to treat a resource after aliasing as uninitialized - containing garbage data. For example, if you use <code>res1</code> and then want to use <code>res2</code>, you need to first initialize <code>res2</code> using either Clear, Discard, or Copy to the entire resource.</p>
<p>Additional considerations:</p>
<ul>

View File

@ -4,5 +4,5 @@ var searchData=
['heapflags_1',['HeapFlags',['../struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html#a3795956e4fbfe7c3a23546e02e5d28dc',1,'D3D12MA::POOL_DESC']]],
['heapproperties_2',['HeapProperties',['../struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html#a06e06813bcb5206e9f7a8b0564bf1d6a',1,'D3D12MA::POOL_DESC']]],
['heapsfreed_3',['HeapsFreed',['../struct_d3_d12_m_a_1_1_d_e_f_r_a_g_m_e_n_t_a_t_i_o_n___s_t_a_t_s.html#aecc6120afcf75028c9850f8d475b727d',1,'D3D12MA::DEFRAGMENTATION_STATS']]],
['heaptype_4',['HeapType',['../struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_i_o_n___d_e_s_c.html#aa46b3c0456e5a23edef3328607ebf4d7',1,'D3D12MA::ALLOCATION_DESC::HeapType()'],['../struct_d3_d12_m_a_1_1_total_statistics.html#a07247152fc70a8ee5605cab0fe220ea5',1,'D3D12MA::TotalStatistics::HeapType()']]]
['heaptype_4',['HeapType',['../struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_i_o_n___d_e_s_c.html#aa46b3c0456e5a23edef3328607ebf4d7',1,'D3D12MA::ALLOCATION_DESC::HeapType()'],['../struct_d3_d12_m_a_1_1_total_statistics.html#abad2e48b38f8a73a4daf8577e7a33b89',1,'D3D12MA::TotalStatistics::HeapType()']]]
];

View File

@ -2,5 +2,6 @@ var searchData=
[
['iscachecoherentuma_0',['IsCacheCoherentUMA',['../class_d3_d12_m_a_1_1_allocator.html#a08210561b92c4bd7ede9dd7beba4bb80',1,'D3D12MA::Allocator']]],
['isempty_1',['IsEmpty',['../class_d3_d12_m_a_1_1_virtual_block.html#a7b23fd2da6f0343095fb14b31395678b',1,'D3D12MA::VirtualBlock']]],
['isuma_2',['IsUMA',['../class_d3_d12_m_a_1_1_allocator.html#a9e742884bd45dd7f01193d13fcd05af0',1,'D3D12MA::Allocator']]]
['isgpuuploadheapsupported_2',['IsGPUUploadHeapSupported',['../class_d3_d12_m_a_1_1_allocator.html#a3f3fd1e88cf2cd02257fe272e08a273c',1,'D3D12MA::Allocator']]],
['isuma_3',['IsUMA',['../class_d3_d12_m_a_1_1_allocator.html#a9e742884bd45dd7f01193d13fcd05af0',1,'D3D12MA::Allocator']]]
];

View File

@ -2,5 +2,6 @@ var searchData=
[
['iscachecoherentuma_0',['IsCacheCoherentUMA',['../class_d3_d12_m_a_1_1_allocator.html#a08210561b92c4bd7ede9dd7beba4bb80',1,'D3D12MA::Allocator']]],
['isempty_1',['IsEmpty',['../class_d3_d12_m_a_1_1_virtual_block.html#a7b23fd2da6f0343095fb14b31395678b',1,'D3D12MA::VirtualBlock']]],
['isuma_2',['IsUMA',['../class_d3_d12_m_a_1_1_allocator.html#a9e742884bd45dd7f01193d13fcd05af0',1,'D3D12MA::Allocator']]]
['isgpuuploadheapsupported_2',['IsGPUUploadHeapSupported',['../class_d3_d12_m_a_1_1_allocator.html#a3f3fd1e88cf2cd02257fe272e08a273c',1,'D3D12MA::Allocator']]],
['isuma_3',['IsUMA',['../class_d3_d12_m_a_1_1_allocator.html#a9e742884bd45dd7f01193d13fcd05af0',1,'D3D12MA::Allocator']]]
];

View File

@ -4,5 +4,5 @@ var searchData=
['heapflags_1',['HeapFlags',['../struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html#a3795956e4fbfe7c3a23546e02e5d28dc',1,'D3D12MA::POOL_DESC']]],
['heapproperties_2',['HeapProperties',['../struct_d3_d12_m_a_1_1_p_o_o_l___d_e_s_c.html#a06e06813bcb5206e9f7a8b0564bf1d6a',1,'D3D12MA::POOL_DESC']]],
['heapsfreed_3',['HeapsFreed',['../struct_d3_d12_m_a_1_1_d_e_f_r_a_g_m_e_n_t_a_t_i_o_n___s_t_a_t_s.html#aecc6120afcf75028c9850f8d475b727d',1,'D3D12MA::DEFRAGMENTATION_STATS']]],
['heaptype_4',['HeapType',['../struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_i_o_n___d_e_s_c.html#aa46b3c0456e5a23edef3328607ebf4d7',1,'D3D12MA::ALLOCATION_DESC::HeapType()'],['../struct_d3_d12_m_a_1_1_total_statistics.html#a07247152fc70a8ee5605cab0fe220ea5',1,'D3D12MA::TotalStatistics::HeapType()']]]
['heaptype_4',['HeapType',['../struct_d3_d12_m_a_1_1_a_l_l_o_c_a_t_i_o_n___d_e_s_c.html#aa46b3c0456e5a23edef3328607ebf4d7',1,'D3D12MA::ALLOCATION_DESC::HeapType()'],['../struct_d3_d12_m_a_1_1_total_statistics.html#abad2e48b38f8a73a4daf8577e7a33b89',1,'D3D12MA::TotalStatistics::HeapType()']]]
];

View File

@ -92,9 +92,9 @@ Numeric statistics</h1>
<div class="line">printf(<span class="stringliteral">&quot;D3D12 reports total usage %llu B with budget %llu B.\n&quot;</span>,</div>
<div class="line"> localBudget.<a class="code hl_variable" href="struct_d3_d12_m_a_1_1_budget.html#a77a8c9e32d6602f95b7d1c285cddd253">UsageBytes</a>,</div>
<div class="line"> localBudget.<a class="code hl_variable" href="struct_d3_d12_m_a_1_1_budget.html#a326515f08d89ee2e31dcfdd5c1e8ac71">BudgetBytes</a>);</div>
<div class="ttc" id="astruct_d3_d12_m_a_1_1_budget_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_budget.html">D3D12MA::Budget</a></div><div class="ttdoc">Statistics of current memory usage and available budget for a specific memory segment group.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:424</div></div>
<div class="ttc" id="astruct_d3_d12_m_a_1_1_budget_html_a326515f08d89ee2e31dcfdd5c1e8ac71"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_budget.html#a326515f08d89ee2e31dcfdd5c1e8ac71">D3D12MA::Budget::BudgetBytes</a></div><div class="ttdeci">UINT64 BudgetBytes</div><div class="ttdoc">Estimated amount of memory available to the program.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:447</div></div>
<div class="ttc" id="astruct_d3_d12_m_a_1_1_budget_html_a77a8c9e32d6602f95b7d1c285cddd253"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_budget.html#a77a8c9e32d6602f95b7d1c285cddd253">D3D12MA::Budget::UsageBytes</a></div><div class="ttdeci">UINT64 UsageBytes</div><div class="ttdoc">Estimated current memory usage of the program.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:436</div></div>
<div class="ttc" id="astruct_d3_d12_m_a_1_1_budget_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_budget.html">D3D12MA::Budget</a></div><div class="ttdoc">Statistics of current memory usage and available budget for a specific memory segment group.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:434</div></div>
<div class="ttc" id="astruct_d3_d12_m_a_1_1_budget_html_a326515f08d89ee2e31dcfdd5c1e8ac71"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_budget.html#a326515f08d89ee2e31dcfdd5c1e8ac71">D3D12MA::Budget::BudgetBytes</a></div><div class="ttdeci">UINT64 BudgetBytes</div><div class="ttdoc">Estimated amount of memory available to the program.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:457</div></div>
<div class="ttc" id="astruct_d3_d12_m_a_1_1_budget_html_a77a8c9e32d6602f95b7d1c285cddd253"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_budget.html#a77a8c9e32d6602f95b7d1c285cddd253">D3D12MA::Budget::UsageBytes</a></div><div class="ttdeci">UINT64 UsageBytes</div><div class="ttdoc">Estimated current memory usage of the program.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:446</div></div>
</div><!-- fragment --><p>You can query for more detailed statistics per heap type, memory segment group, and totals, including minimum and maximum allocation size and unused range size, by calling function <a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a99db00df909963573a976c203b107d22" title="Retrieves statistics from current state of the allocator.">D3D12MA::Allocator::CalculateStatistics()</a> and inspecting structure <a class="el" href="struct_d3_d12_m_a_1_1_total_statistics.html" title="General statistics from current state of the allocator - total memory usage across all memory heaps a...">D3D12MA::TotalStatistics</a>. This function is slower though, as it has to traverse all the internal data structures, so it should be used only for debugging purposes.</p>
<p>You can query for statistics of a custom pool using function <a class="el" href="class_d3_d12_m_a_1_1_pool.html#aa9d849dc4667314b2a53eddf02f5af91" title="Retrieves basic statistics of the custom pool that are fast to calculate.">D3D12MA::Pool::GetStatistics()</a> or <a class="el" href="class_d3_d12_m_a_1_1_pool.html#ad07999ac5dc8f0c63187afd45d551910" title="Retrieves detailed statistics of the custom pool that are slower to calculate.">D3D12MA::Pool::CalculateStatistics()</a>.</p>
<p>You can query for information about a specific allocation using functions of the <a class="el" href="class_d3_d12_m_a_1_1_allocation.html" title="Represents single memory allocation.">D3D12MA::Allocation</a> class, e.g. <code>GetSize()</code>, <code>GetOffset()</code>, <code>GetHeap()</code>.</p>

View File

@ -79,7 +79,7 @@ $(function() {
<p>This is the complete list of members for <a class="el" href="struct_d3_d12_m_a_1_1_total_statistics.html">D3D12MA::TotalStatistics</a>, including all inherited members.</p>
<table class="directory">
<tr class="even"><td class="entry"><a class="el" href="struct_d3_d12_m_a_1_1_total_statistics.html#a07247152fc70a8ee5605cab0fe220ea5">HeapType</a></td><td class="entry"><a class="el" href="struct_d3_d12_m_a_1_1_total_statistics.html">D3D12MA::TotalStatistics</a></td><td class="entry"></td></tr>
<tr class="even"><td class="entry"><a class="el" href="struct_d3_d12_m_a_1_1_total_statistics.html#abad2e48b38f8a73a4daf8577e7a33b89">HeapType</a></td><td class="entry"><a class="el" href="struct_d3_d12_m_a_1_1_total_statistics.html">D3D12MA::TotalStatistics</a></td><td class="entry"></td></tr>
<tr class="odd"><td class="entry"><a class="el" href="struct_d3_d12_m_a_1_1_total_statistics.html#aed7d22d5cd773aa896bc4c786c7f3650">MemorySegmentGroup</a></td><td class="entry"><a class="el" href="struct_d3_d12_m_a_1_1_total_statistics.html">D3D12MA::TotalStatistics</a></td><td class="entry"></td></tr>
<tr class="even"><td class="entry"><a class="el" href="struct_d3_d12_m_a_1_1_total_statistics.html#ac0bb53579457ddec2872c547ae8922a6">Total</a></td><td class="entry"><a class="el" href="struct_d3_d12_m_a_1_1_total_statistics.html">D3D12MA::TotalStatistics</a></td><td class="entry"></td></tr>
</table></div><!-- contents -->

View File

@ -87,9 +87,9 @@ $(function() {
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-attribs" name="pub-attribs"></a>
Public Attributes</h2></td></tr>
<tr class="memitem:a07247152fc70a8ee5605cab0fe220ea5"><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct_d3_d12_m_a_1_1_detailed_statistics.html">DetailedStatistics</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_d3_d12_m_a_1_1_total_statistics.html#a07247152fc70a8ee5605cab0fe220ea5">HeapType</a> [4]</td></tr>
<tr class="memdesc:a07247152fc70a8ee5605cab0fe220ea5"><td class="mdescLeft">&#160;</td><td class="mdescRight">One element for each type of heap located at the following indices: <br /></td></tr>
<tr class="separator:a07247152fc70a8ee5605cab0fe220ea5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abad2e48b38f8a73a4daf8577e7a33b89"><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct_d3_d12_m_a_1_1_detailed_statistics.html">DetailedStatistics</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_d3_d12_m_a_1_1_total_statistics.html#abad2e48b38f8a73a4daf8577e7a33b89">HeapType</a> [5]</td></tr>
<tr class="memdesc:abad2e48b38f8a73a4daf8577e7a33b89"><td class="mdescLeft">&#160;</td><td class="mdescRight">One element for each type of heap located at the following indices: <br /></td></tr>
<tr class="separator:abad2e48b38f8a73a4daf8577e7a33b89"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aed7d22d5cd773aa896bc4c786c7f3650"><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct_d3_d12_m_a_1_1_detailed_statistics.html">DetailedStatistics</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_d3_d12_m_a_1_1_total_statistics.html#aed7d22d5cd773aa896bc4c786c7f3650">MemorySegmentGroup</a> [2]</td></tr>
<tr class="memdesc:aed7d22d5cd773aa896bc4c786c7f3650"><td class="mdescLeft">&#160;</td><td class="mdescRight">One element for each memory segment group located at the following indices: <br /></td></tr>
<tr class="separator:aed7d22d5cd773aa896bc4c786c7f3650"><td class="memSeparator" colspan="2">&#160;</td></tr>
@ -101,14 +101,14 @@ Public Attributes</h2></td></tr>
<div class="textblock"><p>General statistics from current state of the allocator - total memory usage across all memory heaps and segments. </p>
<p>These are slower to calculate. Use for debugging purposes. See function <a class="el" href="class_d3_d12_m_a_1_1_allocator.html#a99db00df909963573a976c203b107d22" title="Retrieves statistics from current state of the allocator.">D3D12MA::Allocator::CalculateStatistics()</a>. </p>
</div><h2 class="groupheader">Member Data Documentation</h2>
<a id="a07247152fc70a8ee5605cab0fe220ea5" name="a07247152fc70a8ee5605cab0fe220ea5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a07247152fc70a8ee5605cab0fe220ea5">&#9670;&#160;</a></span>HeapType</h2>
<a id="abad2e48b38f8a73a4daf8577e7a33b89" name="abad2e48b38f8a73a4daf8577e7a33b89"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abad2e48b38f8a73a4daf8577e7a33b89">&#9670;&#160;</a></span>HeapType</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="struct_d3_d12_m_a_1_1_detailed_statistics.html">DetailedStatistics</a> D3D12MA::TotalStatistics::HeapType[4]</td>
<td class="memname"><a class="el" href="struct_d3_d12_m_a_1_1_detailed_statistics.html">DetailedStatistics</a> D3D12MA::TotalStatistics::HeapType[5]</td>
</tr>
</table>
</div><div class="memdoc">
@ -118,7 +118,8 @@ Public Attributes</h2></td></tr>
<li>0 = <code>D3D12_HEAP_TYPE_DEFAULT</code></li>
<li>1 = <code>D3D12_HEAP_TYPE_UPLOAD</code></li>
<li>2 = <code>D3D12_HEAP_TYPE_READBACK</code></li>
<li>3 = <code>D3D12_HEAP_TYPE_CUSTOM</code> </li>
<li>3 = <code>D3D12_HEAP_TYPE_CUSTOM</code></li>
<li>4 = <code>D3D12_HEAP_TYPE_GPU_UPLOAD</code> </li>
</ul>
</div>
@ -143,7 +144,7 @@ Public Attributes</h2></td></tr>
<p>Meaning of these segment groups is:</p>
<ul>
<li>When <code>IsUMA() == FALSE</code> (discrete graphics card):<ul>
<li><code>DXGI_MEMORY_SEGMENT_GROUP_LOCAL</code> (index 0) represents GPU memory (resources allocated in <code>D3D12_HEAP_TYPE_DEFAULT</code> or <code>D3D12_MEMORY_POOL_L1</code>).</li>
<li><code>DXGI_MEMORY_SEGMENT_GROUP_LOCAL</code> (index 0) represents GPU memory (resources allocated in <code>D3D12_HEAP_TYPE_DEFAULT</code>, <code>D3D12_HEAP_TYPE_GPU_UPLOAD</code> or <code>D3D12_MEMORY_POOL_L1</code>).</li>
<li><code>DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL</code> (index 1) represents system memory (resources allocated in <code>D3D12_HEAP_TYPE_UPLOAD</code>, <code>D3D12_HEAP_TYPE_READBACK</code>, or <code>D3D12_MEMORY_POOL_L0</code>).</li>
</ul>
</li>

View File

@ -90,9 +90,9 @@ Creating virtual block</h1>
<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(&amp;blockDesc, &amp;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:1507</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:1413</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:1421</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:1526</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:1432</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:1440</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>
@ -117,9 +117,9 @@ Making virtual allocations</h1>
<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:1458</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:1465</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:453</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: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_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:1484</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:463</div></div>
</div><!-- fragment --><h1><a class="anchor" id="virtual_allocator_deallocation"></a>
Deallocation</h1>
<p>When no longer needed, an allocation can be freed by calling <a class="el" href="class_d3_d12_m_a_1_1_virtual_block.html#aab44e46bd122054c894fc84740f1e8fb" title="Frees the allocation.">D3D12MA::VirtualBlock::FreeAllocation</a>.</p>
@ -156,7 +156,7 @@ Alignment and units</h1>
<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-&gt;<a class="code hl_function" href="class_d3_d12_m_a_1_1_virtual_block.html#a9281daf76e888ea1bd5247d5732e8179">Allocate</a>(&amp;allocDesc, &amp;alloc, &amp;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: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_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:1489</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>
@ -171,9 +171,9 @@ Statistics</h1>
<div class="line">printf(<span class="stringliteral">&quot;My virtual block has %llu bytes used by %u virtual allocations\n&quot;</span>,</div>
<div class="line"> stats.<a class="code hl_variable" href="struct_d3_d12_m_a_1_1_statistics.html#a53cfe3d241124b5a8e8058871a4b50e8">AllocationBytes</a>, stats.<a class="code hl_variable" href="struct_d3_d12_m_a_1_1_statistics.html#aef88ac53531db43a8888ad2be4a06c68">AllocationCount</a>);</div>
<div class="ttc" id="aclass_d3_d12_m_a_1_1_virtual_block_html_a0f1dda0e019e218b021f64987a74b110"><div class="ttname"><a href="class_d3_d12_m_a_1_1_virtual_block.html#a0f1dda0e019e218b021f64987a74b110">D3D12MA::VirtualBlock::GetStatistics</a></div><div class="ttdeci">void GetStatistics(Statistics *pStats) const</div><div class="ttdoc">Retrieves basic statistics of the virtual block that are fast to calculate.</div></div>
<div class="ttc" id="astruct_d3_d12_m_a_1_1_statistics_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_statistics.html">D3D12MA::Statistics</a></div><div class="ttdoc">Calculated statistics of memory usage e.g. in a specific memory heap type, memory segment group,...</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:332</div></div>
<div class="ttc" id="astruct_d3_d12_m_a_1_1_statistics_html_a53cfe3d241124b5a8e8058871a4b50e8"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_statistics.html#a53cfe3d241124b5a8e8058871a4b50e8">D3D12MA::Statistics::AllocationBytes</a></div><div class="ttdeci">UINT64 AllocationBytes</div><div class="ttdoc">Total number of bytes occupied by all D3D12MA::Allocation objects.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:350</div></div>
<div class="ttc" id="astruct_d3_d12_m_a_1_1_statistics_html_aef88ac53531db43a8888ad2be4a06c68"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_statistics.html#aef88ac53531db43a8888ad2be4a06c68">D3D12MA::Statistics::AllocationCount</a></div><div class="ttdeci">UINT AllocationCount</div><div class="ttdoc">Number of D3D12MA::Allocation objects allocated.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:340</div></div>
<div class="ttc" id="astruct_d3_d12_m_a_1_1_statistics_html"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_statistics.html">D3D12MA::Statistics</a></div><div class="ttdoc">Calculated statistics of memory usage e.g. in a specific memory heap type, memory segment group,...</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:341</div></div>
<div class="ttc" id="astruct_d3_d12_m_a_1_1_statistics_html_a53cfe3d241124b5a8e8058871a4b50e8"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_statistics.html#a53cfe3d241124b5a8e8058871a4b50e8">D3D12MA::Statistics::AllocationBytes</a></div><div class="ttdeci">UINT64 AllocationBytes</div><div class="ttdoc">Total number of bytes occupied by all D3D12MA::Allocation objects.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:359</div></div>
<div class="ttc" id="astruct_d3_d12_m_a_1_1_statistics_html_aef88ac53531db43a8888ad2be4a06c68"><div class="ttname"><a href="struct_d3_d12_m_a_1_1_statistics.html#aef88ac53531db43a8888ad2be4a06c68">D3D12MA::Statistics::AllocationCount</a></div><div class="ttdeci">UINT AllocationCount</div><div class="ttdoc">Number of D3D12MA::Allocation objects allocated.</div><div class="ttdef"><b>Definition:</b> D3D12MemAlloc.h:349</div></div>
</div><!-- fragment --><p>More detailed statistics can be obtained using function <a class="el" href="class_d3_d12_m_a_1_1_virtual_block.html#a614a82247ce6cf29c38895e16eb971d9" title="Retrieves detailed statistics of the virtual block that are slower to calculate.">D3D12MA::VirtualBlock::CalculateStatistics()</a>, but they are slower to calculate.</p>
<p>You can also request a full list of allocations and free regions as a string in JSON format by calling <a class="el" href="class_d3_d12_m_a_1_1_virtual_block.html#a828a27070bfa762cae796d4c8f2ef703" title="Builds and returns statistics as a string in JSON format, including the list of allocations with thei...">D3D12MA::VirtualBlock::BuildStatsString</a>. Returned string must be later freed using <a class="el" href="class_d3_d12_m_a_1_1_virtual_block.html#a6f78ddaa7da194e239089e52093e68a9" title="Frees memory of a string returned from VirtualBlock::BuildStatsString.">D3D12MA::VirtualBlock::FreeStatsString</a>. The format of this string may differ from the one returned by the main D3D12 allocator, but it is similar.</p>
<h1><a class="anchor" id="virtual_allocator_additional_considerations"></a>

View File

@ -24,9 +24,9 @@
/** \mainpage D3D12 Memory Allocator
<b>Version 2.1.0-development</b> (2022-12-15)
<b>Version 2.1.0-development</b> (2023-07-05)
Copyright (c) 2019-2022 Advanced Micro Devices, Inc. All rights reserved. \n
Copyright (c) 2019-2023 Advanced Micro Devices, Inc. All rights reserved. \n
License: MIT
Documentation of all members: D3D12MemAlloc.h
@ -402,8 +402,9 @@ struct TotalStatistics
- 1 = `D3D12_HEAP_TYPE_UPLOAD`
- 2 = `D3D12_HEAP_TYPE_READBACK`
- 3 = `D3D12_HEAP_TYPE_CUSTOM`
- 4 = `D3D12_HEAP_TYPE_GPU_UPLOAD`
*/
DetailedStatistics HeapType[4];
DetailedStatistics HeapType[5];
/** \brief One element for each memory segment group located at the following indices:
- 0 = `DXGI_MEMORY_SEGMENT_GROUP_LOCAL`
@ -413,9 +414,9 @@ struct TotalStatistics
- When `IsUMA() == FALSE` (discrete graphics card):
- `DXGI_MEMORY_SEGMENT_GROUP_LOCAL` (index 0) represents GPU memory
(resources allocated in `D3D12_HEAP_TYPE_DEFAULT` or `D3D12_MEMORY_POOL_L1`).
(resources allocated in `D3D12_HEAP_TYPE_DEFAULT`, `D3D12_HEAP_TYPE_GPU_UPLOAD` or `D3D12_MEMORY_POOL_L1`).
- `DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL` (index 1) represents system memory
(resources allocated in `D3D12_HEAP_TYPE_UPLOAD`, `D3D12_HEAP_TYPE_READBACK`, or `D3D12_MEMORY_POOL_L0`).
(resources allocated in `D3D12_HEAP_TYPE_UPLOAD`, `D3D12_HEAP_TYPE_READBACK`, or `D3D12_MEMORY_POOL_L0`).
- When `IsUMA() == TRUE` (integrated graphics chip):
- `DXGI_MEMORY_SEGMENT_GROUP_LOCAL` = (index 0) represents memory shared for all the resources.
- `DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL` = (index 1) is unused and always 0.
@ -1130,6 +1131,15 @@ public:
- "ID3D12Device::GetCustomHeapProperties method (d3d12.h)"
*/
BOOL IsCacheCoherentUMA() const;
/** \brief Returns true if GPU Upload Heaps are supported on the current system.
When true, you can use `D3D12_HEAP_TYPE_GPU_UPLOAD`.
This flag is fetched from `D3D12_FEATURE_D3D12_OPTIONS16::GPUUploadHeapSupported`.
`#define D3D12MA_OPTIONS16_SUPPORTED 1` is needed for the compilation of this library. Otherwise the flag is always false.
*/
BOOL IsGPUUploadHeapSupported() const;
/** \brief Returns total amount of memory of specific segment group, in bytes.
\param memorySegmentGroup use `DXGI_MEMORY_SEGMENT_GROUP_LOCAL` or DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL`.
@ -1333,7 +1343,7 @@ public:
- `pNonLocalBudget` returns the budget of the system memory available for D3D12 resources.
- When IsUMA() `== TRUE` (integrated graphics chip):
- `pLocalBudget` returns the budget of the shared memory available for all D3D12 resources.
All memory is considered "local".
All memory is considered "local".
- `pNonLocalBudget` is not applicable and returns zeros.
This function is called "get" not "calculate" because it is very fast, suitable to be called

View File

@ -17,8 +17,7 @@ set_target_properties(
D3D12MemoryAllocator PROPERTIES
CXX_EXTENSIONS OFF
# Use C++14
CXX_STANDARD 14
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
OUTPUT_NAME "D3D12MA"
@ -108,8 +107,7 @@ if(D3D12MA_BUILD_SAMPLE)
D3D12Sample PROPERTIES
CXX_EXTENSIONS OFF
# Use C++14
CXX_STANDARD 14
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
)
@ -126,3 +124,35 @@ if(D3D12MA_BUILD_SAMPLE)
message(STATUS "D3D12Sample application is not supported to Linux")
endif()
endif()
set(D3D12MA_AGILITY_SDK_DIRECTORY "" CACHE STRING "Path to unpacked DX12 Agility SDK. Leave empty to compile without it.")
option(D3D12MA_AGILITY_SDK_PREVIEW "Set if DX12 Agility SDK is preview version." OFF)
if(D3D12MA_AGILITY_SDK_DIRECTORY)
if(EXISTS "${D3D12MA_AGILITY_SDK_DIRECTORY}/build/native/include/d3d12.h")
message(STATUS "DX12 Agility SDK used from \"${D3D12MA_AGILITY_SDK_DIRECTORY}\".")
target_compile_definitions(D3D12MemoryAllocator PRIVATE D3D12MA_USE_AGILITY_SDK=1)
target_include_directories(D3D12MemoryAllocator BEFORE PRIVATE "${D3D12MA_AGILITY_SDK_DIRECTORY}/build/native/include")
if(D3D12MA_AGILITY_SDK_PREVIEW)
target_compile_definitions(D3D12MemoryAllocator PRIVATE D3D12MA_USE_AGILITY_SDK_PREVIEW=1)
endif()
if(${D3D12MA_BUILD_SAMPLE} AND ${WIN32})
target_compile_definitions(D3D12Sample PRIVATE D3D12MA_USE_AGILITY_SDK=1)
target_include_directories(D3D12Sample BEFORE PRIVATE "${D3D12MA_AGILITY_SDK_DIRECTORY}/build/native/include")
if(D3D12MA_AGILITY_SDK_PREVIEW)
target_compile_definitions(D3D12Sample PRIVATE D3D12MA_USE_AGILITY_SDK_PREVIEW=1)
endif()
endif()
else()
message(FATAL_ERROR "DX12 Agility SDK not found - cannot find file \"${D3D12MA_AGILITY_SDK_DIRECTORY}/build/native/include/d3d12.h\".")
endif()
else()
message(STATUS "DX12 Agility SDK not used.")
endif()
option(D3D12MA_OPTIONS16_SUPPORTED "Set if using Agility SDK 1.710.0-preview or newer that defines D3D12_FEATURE_DATA_D3D12_OPTIONS16." OFF)
if(D3D12MA_OPTIONS16_SUPPORTED)
target_compile_definitions(D3D12MemoryAllocator PRIVATE D3D12MA_OPTIONS16_SUPPORTED=1)
if(${D3D12MA_BUILD_SAMPLE} AND ${WIN32})
target_compile_definitions(D3D12Sample PRIVATE D3D12MA_OPTIONS16_SUPPORTED=1)
endif()
endif()

View File

@ -134,9 +134,9 @@ especially to test compatibility with D3D12_RESOURCE_HEAP_TIER_1 on modern GPUs.
namespace D3D12MA
{
static constexpr UINT HEAP_TYPE_COUNT = 4;
static constexpr UINT STANDARD_HEAP_TYPE_COUNT = 3; // Only DEFAULT, UPLOAD, READBACK.
static constexpr UINT DEFAULT_POOL_MAX_COUNT = 9;
static constexpr UINT HEAP_TYPE_COUNT = 5;
static constexpr UINT STANDARD_HEAP_TYPE_COUNT = 4; // Only DEFAULT, UPLOAD, READBACK, GPU_UPLOAD.
static constexpr UINT DEFAULT_POOL_MAX_COUNT = STANDARD_HEAP_TYPE_COUNT * 3;
static const UINT NEW_BLOCK_SIZE_SHIFT_MAX = 3;
// Minimum size of a free suballocation to register it in the free suballocation collection.
static const UINT64 MIN_FREE_SUBALLOCATION_SIZE_TO_REGISTER = 16;
@ -147,6 +147,14 @@ static const WCHAR* const HeapTypeNames[] =
L"UPLOAD",
L"READBACK",
L"CUSTOM",
L"GPU_UPLOAD",
};
static const WCHAR* const StandardHeapTypeNames[] =
{
L"DEFAULT",
L"UPLOAD",
L"READBACK",
L"GPU_UPLOAD",
};
static const D3D12_HEAP_FLAGS RESOURCE_CLASS_HEAP_FLAGS =
@ -154,6 +162,8 @@ static const D3D12_HEAP_FLAGS RESOURCE_CLASS_HEAP_FLAGS =
static const D3D12_RESIDENCY_PRIORITY D3D12_RESIDENCY_PRIORITY_NONE = D3D12_RESIDENCY_PRIORITY(0);
static const D3D12_HEAP_TYPE D3D12_HEAP_TYPE_GPU_UPLOAD_COPY = (D3D12_HEAP_TYPE)5;
#ifndef _D3D12MA_ENUM_DECLARATIONS
// Local copy of this enum, as it is provided only by <dxgi1_4.h>, so it may not be available.
@ -452,23 +462,28 @@ static IterT BinaryFindSorted(const IterT& beg, const IterT& end, const KeyT& va
return end;
}
static UINT HeapTypeToIndex(D3D12_HEAP_TYPE type)
static UINT StandardHeapTypeToIndex(D3D12_HEAP_TYPE type)
{
switch (type)
{
case D3D12_HEAP_TYPE_DEFAULT: return 0;
case D3D12_HEAP_TYPE_UPLOAD: return 1;
case D3D12_HEAP_TYPE_READBACK: return 2;
case D3D12_HEAP_TYPE_CUSTOM: return 3;
case D3D12_HEAP_TYPE_GPU_UPLOAD_COPY: return 3;
default: D3D12MA_ASSERT(0); return UINT_MAX;
}
}
static D3D12_HEAP_TYPE IndexToHeapType(UINT heapTypeIndex)
static D3D12_HEAP_TYPE IndexToStandardHeapType(UINT heapTypeIndex)
{
D3D12MA_ASSERT(heapTypeIndex < 4);
// D3D12_HEAP_TYPE_DEFAULT starts at 1.
return (D3D12_HEAP_TYPE)(heapTypeIndex + 1);
switch(heapTypeIndex)
{
case 0: return D3D12_HEAP_TYPE_DEFAULT;
case 1: return D3D12_HEAP_TYPE_UPLOAD;
case 2: return D3D12_HEAP_TYPE_READBACK;
case 3: return D3D12_HEAP_TYPE_GPU_UPLOAD_COPY;
default: D3D12MA_ASSERT(0); return D3D12_HEAP_TYPE_CUSTOM;
}
}
static UINT64 HeapFlagsToAlignment(D3D12_HEAP_FLAGS flags, bool denyMsaaTextures)
@ -516,7 +531,8 @@ static bool IsHeapTypeStandard(D3D12_HEAP_TYPE type)
{
return type == D3D12_HEAP_TYPE_DEFAULT ||
type == D3D12_HEAP_TYPE_UPLOAD ||
type == D3D12_HEAP_TYPE_READBACK;
type == D3D12_HEAP_TYPE_READBACK ||
type == D3D12_HEAP_TYPE_GPU_UPLOAD_COPY;
}
static D3D12_HEAP_PROPERTIES StandardHeapTypeToHeapProperties(D3D12_HEAP_TYPE type)
@ -6558,6 +6574,7 @@ public:
BOOL IsUMA() const { return m_D3D12Architecture.UMA; }
BOOL IsCacheCoherentUMA() const { return m_D3D12Architecture.CacheCoherentUMA; }
bool SupportsResourceHeapTier2() const { return m_D3D12Options.ResourceHeapTier >= D3D12_RESOURCE_HEAP_TIER_2; }
bool IsGPUUploadHeapSupported() const { return m_GPUUploadHeapSupported != FALSE; }
bool UseMutex() const { return m_UseMutex; }
AllocationObjectAllocator& GetAllocationObjectAllocator() { return m_AllocationObjectAllocator; }
UINT GetCurrentFrameIndex() const { return m_CurrentFrameIndex.load(); }
@ -6566,6 +6583,7 @@ public:
0: D3D12_HEAP_TYPE_DEFAULT
1: D3D12_HEAP_TYPE_UPLOAD
2: D3D12_HEAP_TYPE_READBACK
3: D3D12_HEAP_TYPE_GPU_UPLOAD
else:
0: D3D12_HEAP_TYPE_DEFAULT + buffer
1: D3D12_HEAP_TYPE_DEFAULT + texture
@ -6576,8 +6594,11 @@ public:
6: D3D12_HEAP_TYPE_READBACK + buffer
7: D3D12_HEAP_TYPE_READBACK + texture
8: D3D12_HEAP_TYPE_READBACK + texture RT or DS
9: D3D12_HEAP_TYPE_GPU_UPLOAD + buffer
10: D3D12_HEAP_TYPE_GPU_UPLOAD + texture
11: D3D12_HEAP_TYPE_GPU_UPLOAD + texture RT or DS
*/
UINT GetDefaultPoolCount() const { return SupportsResourceHeapTier2() ? 3 : 9; }
UINT GetDefaultPoolCount() const { return SupportsResourceHeapTier2() ? 4 : 12; }
BlockVector** GetDefaultPools() { return m_BlockVectors; }
HRESULT Init(const ALLOCATOR_DESC& desc);
@ -6625,8 +6646,8 @@ public:
void SetResidencyPriority(ID3D12Pageable* obj, D3D12_RESIDENCY_PRIORITY priority) const;
void SetCurrentFrameIndex(UINT frameIndex);
// For more deailed stats use outCutomHeaps to access statistics divided into L0 and L1 group
void CalculateStatistics(TotalStatistics& outStats, DetailedStatistics outCutomHeaps[2] = NULL);
// For more deailed stats use outCustomHeaps to access statistics divided into L0 and L1 group
void CalculateStatistics(TotalStatistics& outStats, DetailedStatistics outCustomHeaps[2] = NULL);
void GetBudget(Budget* outLocalBudget, Budget* outNonLocalBudget);
void GetBudgetForHeapType(Budget& outBudget, D3D12_HEAP_TYPE heapType);
@ -6663,6 +6684,7 @@ private:
D3D12MA_ATOMIC_UINT32 m_CurrentFrameIndex;
DXGI_ADAPTER_DESC m_AdapterDesc;
D3D12_FEATURE_DATA_D3D12_OPTIONS m_D3D12Options;
BOOL m_GPUUploadHeapSupported = FALSE;
D3D12_FEATURE_DATA_ARCHITECTURE m_D3D12Architecture;
AllocationObjectAllocator m_AllocationObjectAllocator;
@ -6747,7 +6769,7 @@ AllocatorPimpl::AllocatorPimpl(const ALLOCATION_CALLBACKS& allocationCallbacks,
{
m_CommittedAllocations[i].Init(
m_UseMutex,
(D3D12_HEAP_TYPE)(D3D12_HEAP_TYPE_DEFAULT + i),
IndexToStandardHeapType(i),
NULL); // pool
}
@ -6802,6 +6824,20 @@ HRESULT AllocatorPimpl::Init(const ALLOCATOR_DESC& desc)
m_D3D12Options.ResourceHeapTier = (D3D12MA_FORCE_RESOURCE_HEAP_TIER);
#endif
// You must define this macro to like `#define D3D12MA_OPTIONS16_SUPPORTED 1` to enable GPU Upload Heaps!
// Unfortunately there is no way to programmatically check if the included <d3d12.h> defines D3D12_FEATURE_DATA_D3D12_OPTIONS16 or not.
// Main interfaces have respective macros like __ID3D12Device4_INTERFACE_DEFINED__, but structures like this do not.
#if D3D12MA_OPTIONS16_SUPPORTED
{
D3D12_FEATURE_DATA_D3D12_OPTIONS16 options16 = {};
hr = m_Device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS16, &options16, sizeof(options16));
if (SUCCEEDED(hr))
{
m_GPUUploadHeapSupported = options16.GPUUploadHeapSupported;
}
}
#endif
hr = m_Device->CheckFeatureSupport(D3D12_FEATURE_ARCHITECTURE, &m_D3D12Architecture, sizeof(m_D3D12Architecture));
if (FAILED(hr))
{
@ -6901,7 +6937,7 @@ UINT AllocatorPimpl::StandardHeapTypeToMemorySegmentGroup(D3D12_HEAP_TYPE heapTy
D3D12MA_ASSERT(IsHeapTypeStandard(heapType));
if (IsUMA())
return DXGI_MEMORY_SEGMENT_GROUP_LOCAL_COPY;
return heapType == D3D12_HEAP_TYPE_DEFAULT ?
return (heapType == D3D12_HEAP_TYPE_DEFAULT || heapType == D3D12_HEAP_TYPE_GPU_UPLOAD_COPY) ?
DXGI_MEMORY_SEGMENT_GROUP_LOCAL_COPY : DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL_COPY;
}
@ -7253,7 +7289,7 @@ void AllocatorPimpl::SetCurrentFrameIndex(UINT frameIndex)
#endif
}
void AllocatorPimpl::CalculateStatistics(TotalStatistics& outStats, DetailedStatistics outCutomHeaps[2])
void AllocatorPimpl::CalculateStatistics(TotalStatistics& outStats, DetailedStatistics outCustomHeaps[2])
{
// Init stats
for (size_t i = 0; i < HEAP_TYPE_COUNT; i++)
@ -7261,21 +7297,22 @@ void AllocatorPimpl::CalculateStatistics(TotalStatistics& outStats, DetailedStat
for (size_t i = 0; i < DXGI_MEMORY_SEGMENT_GROUP_COUNT; i++)
ClearDetailedStatistics(outStats.MemorySegmentGroup[i]);
ClearDetailedStatistics(outStats.Total);
if (outCutomHeaps)
if (outCustomHeaps)
{
ClearDetailedStatistics(outCutomHeaps[0]);
ClearDetailedStatistics(outCutomHeaps[1]);
ClearDetailedStatistics(outCustomHeaps[0]);
ClearDetailedStatistics(outCustomHeaps[1]);
}
// Process default pools. 3 standard heap types only. Add them to outStats.HeapType[i].
// Process default pools. 4 standard heap types only. Add them to outStats.HeapType[i].
if (SupportsResourceHeapTier2())
{
// DEFAULT, UPLOAD, READBACK.
// DEFAULT, UPLOAD, READBACK, GPU_UPLOAD.
for (size_t heapTypeIndex = 0; heapTypeIndex < STANDARD_HEAP_TYPE_COUNT; ++heapTypeIndex)
{
BlockVector* const pBlockVector = m_BlockVectors[heapTypeIndex];
D3D12MA_ASSERT(pBlockVector);
pBlockVector->AddDetailedStatistics(outStats.HeapType[heapTypeIndex]);
const size_t outputIndex = heapTypeIndex < 3 ? heapTypeIndex : 4; // GPU_UPLOAD 3 -> 4
pBlockVector->AddDetailedStatistics(outStats.HeapType[outputIndex]);
}
}
else
@ -7287,7 +7324,9 @@ void AllocatorPimpl::CalculateStatistics(TotalStatistics& outStats, DetailedStat
{
BlockVector* const pBlockVector = m_BlockVectors[heapTypeIndex * 3 + heapSubType];
D3D12MA_ASSERT(pBlockVector);
pBlockVector->AddDetailedStatistics(outStats.HeapType[heapTypeIndex]);
const size_t outputIndex = heapTypeIndex < 3 ? heapTypeIndex : 4; // GPU_UPLOAD 3 -> 4
pBlockVector->AddDetailedStatistics(outStats.HeapType[outputIndex]);
}
}
}
@ -7302,6 +7341,9 @@ void AllocatorPimpl::CalculateStatistics(TotalStatistics& outStats, DetailedStat
AddDetailedStatistics(
outStats.MemorySegmentGroup[StandardHeapTypeToMemorySegmentGroup(D3D12_HEAP_TYPE_READBACK)],
outStats.HeapType[2]);
AddDetailedStatistics(
outStats.MemorySegmentGroup[StandardHeapTypeToMemorySegmentGroup(D3D12_HEAP_TYPE_GPU_UPLOAD_COPY)],
outStats.HeapType[4]);
// Process custom pools.
DetailedStatistics tmpStats;
@ -7321,20 +7363,21 @@ void AllocatorPimpl::CalculateStatistics(TotalStatistics& outStats, DetailedStat
AddDetailedStatistics(
outStats.MemorySegmentGroup[memorySegment], tmpStats);
if (outCutomHeaps)
AddDetailedStatistics(outCutomHeaps[memorySegment], tmpStats);
if (outCustomHeaps)
AddDetailedStatistics(outCustomHeaps[memorySegment], tmpStats);
}
}
// Process committed allocations. 3 standard heap types only.
// Process committed allocations. standard heap types only.
for (UINT heapTypeIndex = 0; heapTypeIndex < STANDARD_HEAP_TYPE_COUNT; ++heapTypeIndex)
{
ClearDetailedStatistics(tmpStats);
m_CommittedAllocations[heapTypeIndex].AddDetailedStatistics(tmpStats);
const size_t outputIndex = heapTypeIndex < 3 ? heapTypeIndex : 4; // GPU_UPLOAD 3 -> 4
AddDetailedStatistics(
outStats.HeapType[heapTypeIndex], tmpStats);
outStats.HeapType[outputIndex], tmpStats);
AddDetailedStatistics(
outStats.MemorySegmentGroup[StandardHeapTypeToMemorySegmentGroup(IndexToHeapType(heapTypeIndex))], tmpStats);
outStats.MemorySegmentGroup[StandardHeapTypeToMemorySegmentGroup(IndexToStandardHeapType(heapTypeIndex))], tmpStats);
}
// Sum up memory segment groups to totals.
@ -7354,19 +7397,24 @@ void AllocatorPimpl::CalculateStatistics(TotalStatistics& outStats, DetailedStat
D3D12MA_ASSERT(outStats.Total.Stats.BlockCount ==
outStats.HeapType[0].Stats.BlockCount + outStats.HeapType[1].Stats.BlockCount +
outStats.HeapType[2].Stats.BlockCount + outStats.HeapType[3].Stats.BlockCount);
outStats.HeapType[2].Stats.BlockCount + outStats.HeapType[3].Stats.BlockCount +
outStats.HeapType[4].Stats.BlockCount);
D3D12MA_ASSERT(outStats.Total.Stats.AllocationCount ==
outStats.HeapType[0].Stats.AllocationCount + outStats.HeapType[1].Stats.AllocationCount +
outStats.HeapType[2].Stats.AllocationCount + outStats.HeapType[3].Stats.AllocationCount);
outStats.HeapType[2].Stats.AllocationCount + outStats.HeapType[3].Stats.AllocationCount +
outStats.HeapType[4].Stats.AllocationCount);
D3D12MA_ASSERT(outStats.Total.Stats.BlockBytes ==
outStats.HeapType[0].Stats.BlockBytes + outStats.HeapType[1].Stats.BlockBytes +
outStats.HeapType[2].Stats.BlockBytes + outStats.HeapType[3].Stats.BlockBytes);
outStats.HeapType[2].Stats.BlockBytes + outStats.HeapType[3].Stats.BlockBytes +
outStats.HeapType[4].Stats.BlockBytes);
D3D12MA_ASSERT(outStats.Total.Stats.AllocationBytes ==
outStats.HeapType[0].Stats.AllocationBytes + outStats.HeapType[1].Stats.AllocationBytes +
outStats.HeapType[2].Stats.AllocationBytes + outStats.HeapType[3].Stats.AllocationBytes);
outStats.HeapType[2].Stats.AllocationBytes + outStats.HeapType[3].Stats.AllocationBytes +
outStats.HeapType[4].Stats.AllocationBytes);
D3D12MA_ASSERT(outStats.Total.UnusedRangeCount ==
outStats.HeapType[0].UnusedRangeCount + outStats.HeapType[1].UnusedRangeCount +
outStats.HeapType[2].UnusedRangeCount + outStats.HeapType[3].UnusedRangeCount);
outStats.HeapType[2].UnusedRangeCount + outStats.HeapType[3].UnusedRangeCount +
outStats.HeapType[4].UnusedRangeCount);
}
void AllocatorPimpl::GetBudget(Budget* outLocalBudget, Budget* outNonLocalBudget)
@ -7414,6 +7462,7 @@ void AllocatorPimpl::GetBudgetForHeapType(Budget& outBudget, D3D12_HEAP_TYPE hea
switch (heapType)
{
case D3D12_HEAP_TYPE_DEFAULT:
case D3D12_HEAP_TYPE_GPU_UPLOAD_COPY:
GetBudget(&outBudget, NULL);
break;
case D3D12_HEAP_TYPE_UPLOAD:
@ -7470,6 +7519,9 @@ void AllocatorPimpl::BuildStatsString(WCHAR** ppStatsString, BOOL detailedMap)
json.WriteBool(m_D3D12Architecture.UMA);
json.WriteString(L"CacheCoherentUMA");
json.WriteBool(m_D3D12Architecture.CacheCoherentUMA);
json.WriteString(L"GPUUploadHeapSupported");
json.WriteBool(m_GPUUploadHeapSupported != FALSE);
}
json.EndObject();
}
@ -7502,6 +7554,17 @@ void AllocatorPimpl::BuildStatsString(WCHAR** ppStatsString, BOOL detailedMap)
json.AddDetailedStatisticsInfoObject(stats.HeapType[0]);
}
json.EndObject();
if(IsGPUUploadHeapSupported())
{
json.WriteString(L"GPU_UPLOAD");
json.BeginObject();
{
json.WriteString(L"Stats");
json.AddDetailedStatisticsInfoObject(stats.HeapType[4]);
}
json.EndObject();
}
}
json.WriteString(L"UPLOAD");
json.BeginObject();
@ -7552,6 +7615,17 @@ void AllocatorPimpl::BuildStatsString(WCHAR** ppStatsString, BOOL detailedMap)
}
json.EndObject();
if(IsGPUUploadHeapSupported())
{
json.WriteString(L"GPU_UPLOAD");
json.BeginObject();
{
json.WriteString(L"Stats");
json.AddDetailedStatisticsInfoObject(stats.HeapType[4]);
}
json.EndObject();
}
json.WriteString(L"CUSTOM");
json.BeginObject();
{
@ -7678,7 +7752,7 @@ void AllocatorPimpl::BuildStatsString(WCHAR** ppStatsString, BOOL detailedMap)
{
for (uint8_t heapType = 0; heapType < STANDARD_HEAP_TYPE_COUNT; ++heapType)
{
json.WriteString(HeapTypeNames[heapType]);
json.WriteString(StandardHeapTypeNames[heapType]);
json.BeginObject();
writeHeapInfo(m_BlockVectors[heapType], m_CommittedAllocations + heapType, false);
json.EndObject();
@ -7695,11 +7769,11 @@ void AllocatorPimpl::BuildStatsString(WCHAR** ppStatsString, BOOL detailedMap)
L" - Textures",
L" - Textures RT/DS",
};
json.BeginString(HeapTypeNames[heapType]);
json.BeginString(StandardHeapTypeNames[heapType]);
json.EndString(heapSubTypeName[heapSubType]);
json.BeginObject();
writeHeapInfo(m_BlockVectors[heapType + heapSubType], m_CommittedAllocations + heapType, false);
writeHeapInfo(m_BlockVectors[heapType * 3 + heapSubType], m_CommittedAllocations + heapType, false);
json.EndObject();
}
}
@ -7989,6 +8063,9 @@ HRESULT AllocatorPimpl::CalcAllocationParams(const ALLOCATION_DESC& allocDesc, U
outCommittedAllocationParams = CommittedAllocationParameters();
outPreferCommitted = false;
D3D12MA_ASSERT((allocDesc.HeapType != D3D12_HEAP_TYPE_GPU_UPLOAD_COPY || IsGPUUploadHeapSupported()) &&
"Trying to allocate from D3D12_HEAP_TYPE_GPU_UPLOAD while GPUUploadHeapSupported == FALSE or D3D12MA_OPTIONS16_SUPPORTED macro was not defined when compiling D3D12MA library.");
bool msaaAlwaysCommitted;
if (allocDesc.CustomPool != NULL)
{
@ -8014,7 +8091,7 @@ HRESULT AllocatorPimpl::CalcAllocationParams(const ALLOCATION_DESC& allocDesc, U
outCommittedAllocationParams.m_HeapProperties = StandardHeapTypeToHeapProperties(allocDesc.HeapType);
outCommittedAllocationParams.m_HeapFlags = allocDesc.ExtraHeapFlags;
outCommittedAllocationParams.m_List = &m_CommittedAllocations[HeapTypeToIndex(allocDesc.HeapType)];
outCommittedAllocationParams.m_List = &m_CommittedAllocations[StandardHeapTypeToIndex(allocDesc.HeapType)];
// outCommittedAllocationParams.m_ResidencyPriority intentionally left with default value.
const ResourceClass resourceClass = (resDesc != NULL) ?
@ -8088,6 +8165,7 @@ UINT AllocatorPimpl::CalcDefaultPoolIndex(const ALLOCATION_DESC& allocDesc, Reso
case D3D12_HEAP_TYPE_DEFAULT: poolIndex = 0; break;
case D3D12_HEAP_TYPE_UPLOAD: poolIndex = 1; break;
case D3D12_HEAP_TYPE_READBACK: poolIndex = 2; break;
case D3D12_HEAP_TYPE_GPU_UPLOAD_COPY: poolIndex = 3; break;
default: D3D12MA_ASSERT(0);
}
@ -8143,6 +8221,9 @@ void AllocatorPimpl::CalcDefaultPoolParams(D3D12_HEAP_TYPE& outHeapType, D3D12_H
case 2:
outHeapType = D3D12_HEAP_TYPE_READBACK;
break;
case 3:
outHeapType = D3D12_HEAP_TYPE_GPU_UPLOAD_COPY;
break;
default:
D3D12MA_ASSERT(0);
}
@ -8150,7 +8231,7 @@ void AllocatorPimpl::CalcDefaultPoolParams(D3D12_HEAP_TYPE& outHeapType, D3D12_H
void AllocatorPimpl::RegisterPool(Pool* pool, D3D12_HEAP_TYPE heapType)
{
const UINT heapTypeIndex = HeapTypeToIndex(heapType);
const UINT heapTypeIndex = (UINT)heapType - 1;
MutexLockWrite lock(m_PoolsMutex[heapTypeIndex], m_UseMutex);
m_Pools[heapTypeIndex].PushBack(pool->m_Pimpl);
@ -8158,7 +8239,7 @@ void AllocatorPimpl::RegisterPool(Pool* pool, D3D12_HEAP_TYPE heapType)
void AllocatorPimpl::UnregisterPool(Pool* pool, D3D12_HEAP_TYPE heapType)
{
const UINT heapTypeIndex = HeapTypeToIndex(heapType);
const UINT heapTypeIndex = (UINT)heapType - 1;
MutexLockWrite lock(m_PoolsMutex[heapTypeIndex], m_UseMutex);
m_Pools[heapTypeIndex].Remove(pool->m_Pimpl);
@ -10133,6 +10214,11 @@ BOOL Allocator::IsCacheCoherentUMA() const
return m_Pimpl->IsCacheCoherentUMA();
}
BOOL Allocator::IsGPUUploadHeapSupported() const
{
return m_Pimpl->IsGPUUploadHeapSupported();
}
UINT64 Allocator::GetMemoryCapacity(UINT memorySegmentGroup) const
{
return m_Pimpl->GetMemoryCapacity(memorySegmentGroup);

View File

@ -26,6 +26,7 @@
#include <atomic>
#include <Shlwapi.h> // For StrStrI
namespace VS
{
#include "Shaders\VS_Compiled.h"
@ -35,6 +36,15 @@ namespace PS
#include "Shaders\PS_Compiled.h"
}
#if D3D12MA_USE_AGILITY_SDK
#if D3D12MA_USE_AGILITY_SDK_PREVIEW
extern "C" { __declspec(dllexport) extern const UINT D3D12SDKVersion = D3D12_PREVIEW_SDK_VERSION; }
#else
extern "C" { __declspec(dllexport) extern const UINT D3D12SDKVersion = D3D12_SDK_VERSION; }
#endif
extern "C" { __declspec(dllexport) extern const char* D3D12SDKPath = u8".\\D3D12\\"; }
#endif
enum class ExitCode : int
{
GPUList = 2,
@ -563,6 +573,8 @@ static std::wstring SizeToStr(size_t size)
static void PrintAdapterInformation(IDXGIAdapter1* adapter)
{
assert(g_Allocator);
wprintf(L"DXGI_ADAPTER_DESC1:\n");
wprintf(L" Description = %s\n", g_AdapterDesc.Description);
wprintf(L" VendorId = 0x%X (%s)\n", g_AdapterDesc.VendorId, VendorIDToStr(g_AdapterDesc.VendorId));
@ -589,6 +601,9 @@ static void PrintAdapterInformation(IDXGIAdapter1* adapter)
assert(0);
}
wprintf(L"D3D12_FEATURE_DATA_D3D12_OPTIONS16:\n");
wprintf(L" GPUUploadHeapSupported = %u\n", g_Allocator->IsGPUUploadHeapSupported() ? 1 : 0);
ComPtr<IDXGIAdapter3> adapter3;
if(SUCCEEDED(adapter->QueryInterface(IID_PPV_ARGS(&adapter3))))
{

View File

@ -2856,6 +2856,14 @@ static void TestDevice10(const TestContext& ctx)
{
wprintf(L"Test ID3D12Device10\n");
D3D12_FEATURE_DATA_D3D12_OPTIONS12 options12 = {};
if(FAILED(ctx.device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS12, &options12, sizeof(options12))) ||
!options12.EnhancedBarriersSupported)
{
wprintf(L" Skipped due to D3D12_FEATURE_DATA_D3D12_OPTIONS12::EnhancedBarriersSupported == FALSE.\n");
return;
}
ComPtr<ID3D12Device10> dev10;
CHECK_HR(ctx.device->QueryInterface(IID_PPV_ARGS(&dev10)));
@ -2914,6 +2922,152 @@ static void TestDevice10(const TestContext& ctx)
}
#endif // #ifdef __ID3D12Device10_INTERFACE_DEFINED__
static void TestGPUUploadHeap(const TestContext& ctx)
{
#if D3D12MA_OPTIONS16_SUPPORTED
using namespace D3D12MA;
wprintf(L"Test GPU Upload Heap\n");
if(!ctx.allocator->IsGPUUploadHeapSupported())
{
wprintf(L" Skipped due to GPUUploadHeap not supported.\n");
return;
}
Budget begLocalBudget = {};
ctx.allocator->GetBudget(&begLocalBudget, NULL);
TotalStatistics begStats = {};
ctx.allocator->CalculateStatistics(&begStats);
// Create a buffer, likely placed.
ALLOCATION_DESC allocDesc = {};
allocDesc.HeapType = D3D12_HEAP_TYPE_GPU_UPLOAD;
D3D12_RESOURCE_DESC resDesc;
FillResourceDescForBuffer(resDesc, 64 * KILOBYTE);
ComPtr<Allocation> alloc;
CHECK_HR(ctx.allocator->CreateResource(&allocDesc, &resDesc,
D3D12_RESOURCE_STATE_COMMON, NULL, &alloc, IID_NULL, NULL));
CHECK_BOOL(alloc && alloc->GetResource());
CHECK_BOOL(alloc->GetResource()->GetGPUVirtualAddress() != 0);
{
D3D12_HEAP_PROPERTIES heapProps = {};
D3D12_HEAP_FLAGS heapFlags = {};
CHECK_HR(alloc->GetResource()->GetHeapProperties(&heapProps, &heapFlags));
CHECK_BOOL(heapProps.Type == D3D12_HEAP_TYPE_GPU_UPLOAD);
}
// Create a committed one.
ALLOCATION_DESC committedAllocDesc = allocDesc;
committedAllocDesc.Flags |= ALLOCATION_FLAG_COMMITTED;
ComPtr<Allocation> committedAlloc;
CHECK_HR(ctx.allocator->CreateResource(&committedAllocDesc, &resDesc,
D3D12_RESOURCE_STATE_COMMON, NULL, &committedAlloc, IID_NULL, NULL));
CHECK_BOOL(committedAlloc && committedAlloc->GetResource());
CHECK_BOOL(committedAlloc->GetHeap() == NULL); // Committed, heap is implicit and inaccessible.
// Create a custom pool and a buffer inside of it.
POOL_DESC poolDesc = {};
poolDesc.HeapProperties.Type = D3D12_HEAP_TYPE_GPU_UPLOAD;
ComPtr<Pool> pool;
CHECK_HR(ctx.allocator->CreatePool(&poolDesc, &pool));
ALLOCATION_DESC poolAllocDesc = {};
poolAllocDesc.CustomPool = pool.Get();
ComPtr<Allocation> poolAlloc;
CHECK_HR(ctx.allocator->CreateResource(&poolAllocDesc, &resDesc,
D3D12_RESOURCE_STATE_COMMON, NULL, &poolAlloc, IID_NULL, NULL));
CHECK_BOOL(poolAlloc && poolAlloc->GetResource());
// Map the original buffer, write, then read
{
const auto res = alloc->GetResource();
UINT* mappedData = NULL;
CHECK_HR(res->Map(0, &EMPTY_RANGE, (void**)&mappedData)); // {0, 0} - not reading anything.
for(UINT i = 0; i < resDesc.Width / sizeof(UINT); ++i)
{
mappedData[i] = i * 3;
}
res->Unmap(0, NULL); // NULL - written everything.
CHECK_HR(res->Map(0, NULL, (void**)&mappedData)); // NULL - reading everything.
CHECK_BOOL(mappedData[100] = 300);
res->Unmap(0, &EMPTY_RANGE); // {0, 0} - not written anything.
}
// Create two big buffers.
D3D12_RESOURCE_DESC bigResDesc = resDesc;
bigResDesc.Width = 128 * MEGABYTE;
ComPtr<Allocation> bigAllocs[2];
for(UINT i = 0; i < 2; ++i)
{
CHECK_HR(ctx.allocator->CreateResource(&allocDesc, &bigResDesc,
D3D12_RESOURCE_STATE_COMMON, NULL, &bigAllocs[i], IID_NULL, NULL));
CHECK_BOOL(bigAllocs[i] && bigAllocs[i]->GetResource());
}
// Create a texture.
constexpr UINT texSize = 256;
D3D12_RESOURCE_DESC texDesc = {};
texDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
texDesc.Alignment = 0;
texDesc.Width = texSize;
texDesc.Height = texSize;
texDesc.DepthOrArraySize = 1;
texDesc.MipLevels = 1;
texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
texDesc.SampleDesc.Count = 1;
texDesc.SampleDesc.Quality = 0;
texDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
texDesc.Flags = D3D12_RESOURCE_FLAG_NONE;
ComPtr<Allocation> texAlloc;
CHECK_HR(ctx.allocator->CreateResource(&allocDesc, &texDesc,
D3D12_RESOURCE_STATE_COMMON, NULL, &texAlloc, IID_NULL, NULL));
CHECK_BOOL(texAlloc && texAlloc->GetResource());
{
std::vector<UINT> texPixels(texSize * texSize);
// Contents of texPixels[i] doesn't matter.
const auto texRes = texAlloc->GetResource();
// Need to pass ppData == NULL for Map() to be used with a texture having D3D12_TEXTURE_LAYOUT_UNKNOWN.
CHECK_HR(texRes->Map(0, &EMPTY_RANGE, NULL)); // {0, 0} - not reading anything.
CHECK_HR(texRes->WriteToSubresource(
0, // DstSubresource
NULL, // pDstBox
texPixels.data(), // pSrcData
texSize * sizeof(DWORD), // SrcRowPitch
texSize * texSize * sizeof(DWORD))); // SrcDepthPitch
texRes->Unmap(0, NULL); // NULL - written everything.
}
// Check budget and stats
constexpr UINT totalAllocCount = 6;
Budget endLocalBudget = {};
ctx.allocator->GetBudget(&endLocalBudget, NULL);
TotalStatistics endStats = {};
ctx.allocator->CalculateStatistics(&endStats);
CHECK_BOOL(endLocalBudget.UsageBytes >= begLocalBudget.UsageBytes
+ 2 * bigResDesc.Width
&& "This can fail if GPU_UPLOAD falls back to system RAM e.g. when under PIX?");
auto validateStats = [totalAllocCount, &bigResDesc](const Statistics& begStats, const Statistics& endStats)
{
CHECK_BOOL(endStats.BlockCount >= begStats.BlockCount);
CHECK_BOOL(endStats.BlockBytes >= begStats.BlockBytes);
CHECK_BOOL(endStats.AllocationCount == begStats.AllocationCount + totalAllocCount);
CHECK_BOOL(endStats.AllocationBytes > begStats.AllocationBytes + 2 * bigResDesc.Width);
};
validateStats(begLocalBudget.Stats, endLocalBudget.Stats);
validateStats(begStats.Total.Stats, endStats.Total.Stats);
validateStats(begStats.MemorySegmentGroup[0].Stats, endStats.MemorySegmentGroup[0].Stats); // DXGI_MEMORY_SEGMENT_GROUP_LOCAL
validateStats(begStats.HeapType[4].Stats, endStats.HeapType[4].Stats); // D3D12_HEAP_TYPE_GPU_UPLOAD
#endif
}
static void TestVirtualBlocks(const TestContext& ctx)
{
wprintf(L"Test virtual blocks\n");
@ -4180,6 +4334,8 @@ static void TestGroupBasics(const TestContext& ctx)
TestDevice10(ctx);
#endif
TestGPUUploadHeap(ctx);
FILE* file;
fopen_s(&file, "Results.csv", "w");
assert(file != NULL);