blob: 3f879731782a53c29d0bdfd7de9ac45e12ab5bda [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Direct3D 12 Memory Allocator: D3D12MA::VirtualBlock Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">Direct3D 12 Memory Allocator
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="namespace_d3_d12_m_a.html">D3D12MA</a></li><li class="navelem"><a class="el" href="class_d3_d12_m_a_1_1_virtual_block.html">VirtualBlock</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="class_d3_d12_m_a_1_1_virtual_block-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">D3D12MA::VirtualBlock Class Reference</div> </div>
</div><!--header-->
<div class="contents">
<p>Represents pure allocation algorithm and a data structure with allocations in some memory block, without actually allocating any GPU memory.
<a href="class_d3_d12_m_a_1_1_virtual_block.html#details">More...</a></p>
<p><code>#include &lt;D3D12MemAlloc.h&gt;</code></p>
<div class="dynheader">
Inheritance diagram for D3D12MA::VirtualBlock:</div>
<div class="dyncontent">
<div class="center">
<img src="class_d3_d12_m_a_1_1_virtual_block.png" alt=""/>
</div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a7b23fd2da6f0343095fb14b31395678b"><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_virtual_block.html#a7b23fd2da6f0343095fb14b31395678b">IsEmpty</a> () const</td></tr>
<tr class="memdesc:a7b23fd2da6f0343095fb14b31395678b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns true if the block is empty - contains 0 allocations. <a href="class_d3_d12_m_a_1_1_virtual_block.html#a7b23fd2da6f0343095fb14b31395678b">More...</a><br /></td></tr>
<tr class="separator:a7b23fd2da6f0343095fb14b31395678b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a287b8f0e455ffc7f302094671f922afb"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_d3_d12_m_a_1_1_virtual_block.html#a287b8f0e455ffc7f302094671f922afb">GetAllocationInfo</a> (UINT64 offset, <a class="el" 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___i_n_f_o.html">VIRTUAL_ALLOCATION_INFO</a> *pInfo) const</td></tr>
<tr class="memdesc:a287b8f0e455ffc7f302094671f922afb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns information about an allocation at given offset - its size and custom pointer. <a href="class_d3_d12_m_a_1_1_virtual_block.html#a287b8f0e455ffc7f302094671f922afb">More...</a><br /></td></tr>
<tr class="separator:a287b8f0e455ffc7f302094671f922afb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa57575f1af18461012bde8c4b6f3c56c"><td class="memItemLeft" align="right" valign="top">HRESULT&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_d3_d12_m_a_1_1_virtual_block.html#aa57575f1af18461012bde8c4b6f3c56c">Allocate</a> (const <a class="el" 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">VIRTUAL_ALLOCATION_DESC</a> *pDesc, UINT64 *pOffset)</td></tr>
<tr class="memdesc:aa57575f1af18461012bde8c4b6f3c56c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates new allocation. <a href="class_d3_d12_m_a_1_1_virtual_block.html#aa57575f1af18461012bde8c4b6f3c56c">More...</a><br /></td></tr>
<tr class="separator:aa57575f1af18461012bde8c4b6f3c56c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a02dfae4c0856f22da885a332de7821fa"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_d3_d12_m_a_1_1_virtual_block.html#a02dfae4c0856f22da885a332de7821fa">FreeAllocation</a> (UINT64 offset)</td></tr>
<tr class="memdesc:a02dfae4c0856f22da885a332de7821fa"><td class="mdescLeft">&#160;</td><td class="mdescRight">Frees the allocation at given offset. <a href="class_d3_d12_m_a_1_1_virtual_block.html#a02dfae4c0856f22da885a332de7821fa">More...</a><br /></td></tr>
<tr class="separator:a02dfae4c0856f22da885a332de7821fa"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae22b18c0b7c31b44c1d740f886369189"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_d3_d12_m_a_1_1_virtual_block.html#ae22b18c0b7c31b44c1d740f886369189">Clear</a> ()</td></tr>
<tr class="memdesc:ae22b18c0b7c31b44c1d740f886369189"><td class="mdescLeft">&#160;</td><td class="mdescRight">Frees all the allocations. <a href="class_d3_d12_m_a_1_1_virtual_block.html#ae22b18c0b7c31b44c1d740f886369189">More...</a><br /></td></tr>
<tr class="separator:ae22b18c0b7c31b44c1d740f886369189"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0af4aec3d2efc913ee43b0725e8a0289"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_d3_d12_m_a_1_1_virtual_block.html#a0af4aec3d2efc913ee43b0725e8a0289">SetAllocationUserData</a> (UINT64 offset, void *pUserData)</td></tr>
<tr class="memdesc:a0af4aec3d2efc913ee43b0725e8a0289"><td class="mdescLeft">&#160;</td><td class="mdescRight">Changes custom pointer for an allocation at given offset to a new value. <a href="class_d3_d12_m_a_1_1_virtual_block.html#a0af4aec3d2efc913ee43b0725e8a0289">More...</a><br /></td></tr>
<tr class="separator:a0af4aec3d2efc913ee43b0725e8a0289"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a039ee8426818d0126cf7f44c1c658526"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_d3_d12_m_a_1_1_virtual_block.html#a039ee8426818d0126cf7f44c1c658526">CalculateStats</a> (<a class="el" href="struct_d3_d12_m_a_1_1_stat_info.html">StatInfo</a> *pInfo) const</td></tr>
<tr class="memdesc:a039ee8426818d0126cf7f44c1c658526"><td class="mdescLeft">&#160;</td><td class="mdescRight">Retrieves statistics from the current state of the block. <a href="class_d3_d12_m_a_1_1_virtual_block.html#a039ee8426818d0126cf7f44c1c658526">More...</a><br /></td></tr>
<tr class="separator:a039ee8426818d0126cf7f44c1c658526"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a828a27070bfa762cae796d4c8f2ef703"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_d3_d12_m_a_1_1_virtual_block.html#a828a27070bfa762cae796d4c8f2ef703">BuildStatsString</a> (WCHAR **ppStatsString) const</td></tr>
<tr class="memdesc:a828a27070bfa762cae796d4c8f2ef703"><td class="mdescLeft">&#160;</td><td class="mdescRight">Builds and returns statistics as a string in JSON format, including the list of allocations with their parameters. <a href="class_d3_d12_m_a_1_1_virtual_block.html#a828a27070bfa762cae796d4c8f2ef703">More...</a><br /></td></tr>
<tr class="separator:a828a27070bfa762cae796d4c8f2ef703"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6f78ddaa7da194e239089e52093e68a9"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_d3_d12_m_a_1_1_virtual_block.html#a6f78ddaa7da194e239089e52093e68a9">FreeStatsString</a> (WCHAR *pStatsString) const</td></tr>
<tr class="memdesc:a6f78ddaa7da194e239089e52093e68a9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Frees memory of a string returned from <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...">VirtualBlock::BuildStatsString</a>. <a href="class_d3_d12_m_a_1_1_virtual_block.html#a6f78ddaa7da194e239089e52093e68a9">More...</a><br /></td></tr>
<tr class="separator:a6f78ddaa7da194e239089e52093e68a9"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Represents pure allocation algorithm and a data structure with allocations in some memory block, without actually allocating any GPU memory. </p>
<p>This class allows to use the core algorithm of the library custom allocations e.g. CPU memory or sub-allocation regions inside a single GPU buffer.</p>
<p>To create this object, fill in <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" title="Parameters of created D3D12MA::VirtualBlock object to be passed to CreateVirtualBlock().">D3D12MA::VIRTUAL_BLOCK_DESC</a> and call <a class="el" href="class_d3_d12_m_a_1_1_virtual_block.html#ab8bb16e20c691720aad26ecbf105aa6f" title="Creates new D3D12MA::VirtualBlock object and returns it through ppVirtualBlock.">CreateVirtualBlock()</a>. To destroy it, call its method <code>VirtualBlock::Release()</code>. You need to free all the allocations within this block or call <a class="el" href="class_d3_d12_m_a_1_1_virtual_block.html#ae22b18c0b7c31b44c1d740f886369189" title="Frees all the allocations.">Clear()</a> before destroying it. </p>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a id="aa57575f1af18461012bde8c4b6f3c56c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa57575f1af18461012bde8c4b6f3c56c">&#9670;&nbsp;</a></span>Allocate()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">HRESULT D3D12MA::VirtualBlock::Allocate </td>
<td>(</td>
<td class="paramtype">const <a class="el" 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">VIRTUAL_ALLOCATION_DESC</a> *&#160;</td>
<td class="paramname"><em>pDesc</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">UINT64 *&#160;</td>
<td class="paramname"><em>pOffset</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Creates new allocation. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir"></td><td class="paramname">pDesc</td><td></td></tr>
<tr><td class="paramdir">[out]</td><td class="paramname">pOffset</td><td>Offset of the new allocation, which can also be treated as an unique identifier of the allocation within this block. <code>UINT64_MAX</code> if allocation failed. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>S_OK</code> if allocation succeeded, <code>E_OUTOFMEMORY</code> if it failed. </dd></dl>
</div>
</div>
<a id="a828a27070bfa762cae796d4c8f2ef703"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a828a27070bfa762cae796d4c8f2ef703">&#9670;&nbsp;</a></span>BuildStatsString()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void D3D12MA::VirtualBlock::BuildStatsString </td>
<td>(</td>
<td class="paramtype">WCHAR **&#160;</td>
<td class="paramname"><em>ppStatsString</em></td><td>)</td>
<td> const</td>
</tr>
</table>
</div><div class="memdoc">
<p>Builds and returns statistics as a string in JSON format, including the list of allocations with their parameters. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[out]</td><td class="paramname">ppStatsString</td><td>Must be 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.">VirtualBlock::FreeStatsString</a>. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a id="a039ee8426818d0126cf7f44c1c658526"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a039ee8426818d0126cf7f44c1c658526">&#9670;&nbsp;</a></span>CalculateStats()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void D3D12MA::VirtualBlock::CalculateStats </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_d3_d12_m_a_1_1_stat_info.html">StatInfo</a> *&#160;</td>
<td class="paramname"><em>pInfo</em></td><td>)</td>
<td> const</td>
</tr>
</table>
</div><div class="memdoc">
<p>Retrieves statistics from the current state of the block. </p>
</div>
</div>
<a id="ae22b18c0b7c31b44c1d740f886369189"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae22b18c0b7c31b44c1d740f886369189">&#9670;&nbsp;</a></span>Clear()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void D3D12MA::VirtualBlock::Clear </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Frees all the allocations. </p>
</div>
</div>
<a id="a02dfae4c0856f22da885a332de7821fa"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a02dfae4c0856f22da885a332de7821fa">&#9670;&nbsp;</a></span>FreeAllocation()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void D3D12MA::VirtualBlock::FreeAllocation </td>
<td>(</td>
<td class="paramtype">UINT64&#160;</td>
<td class="paramname"><em>offset</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Frees the allocation at given offset. </p>
</div>
</div>
<a id="a6f78ddaa7da194e239089e52093e68a9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6f78ddaa7da194e239089e52093e68a9">&#9670;&nbsp;</a></span>FreeStatsString()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void D3D12MA::VirtualBlock::FreeStatsString </td>
<td>(</td>
<td class="paramtype">WCHAR *&#160;</td>
<td class="paramname"><em>pStatsString</em></td><td>)</td>
<td> const</td>
</tr>
</table>
</div><div class="memdoc">
<p>Frees memory of a string returned from <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...">VirtualBlock::BuildStatsString</a>. </p>
</div>
</div>
<a id="a287b8f0e455ffc7f302094671f922afb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a287b8f0e455ffc7f302094671f922afb">&#9670;&nbsp;</a></span>GetAllocationInfo()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void D3D12MA::VirtualBlock::GetAllocationInfo </td>
<td>(</td>
<td class="paramtype">UINT64&#160;</td>
<td class="paramname"><em>offset</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" 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___i_n_f_o.html">VIRTUAL_ALLOCATION_INFO</a> *&#160;</td>
<td class="paramname"><em>pInfo</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td> const</td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns information about an allocation at given offset - its size and custom pointer. </p>
</div>
</div>
<a id="a7b23fd2da6f0343095fb14b31395678b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7b23fd2da6f0343095fb14b31395678b">&#9670;&nbsp;</a></span>IsEmpty()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">BOOL D3D12MA::VirtualBlock::IsEmpty </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns true if the block is empty - contains 0 allocations. </p>
</div>
</div>
<a id="a0af4aec3d2efc913ee43b0725e8a0289"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0af4aec3d2efc913ee43b0725e8a0289">&#9670;&nbsp;</a></span>SetAllocationUserData()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void D3D12MA::VirtualBlock::SetAllocationUserData </td>
<td>(</td>
<td class="paramtype">UINT64&#160;</td>
<td class="paramname"><em>offset</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&#160;</td>
<td class="paramname"><em>pUserData</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Changes custom pointer for an allocation at given offset to a new value. </p>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="_d3_d12_mem_alloc_8h.html">D3D12MemAlloc.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1
</small></address>
</body>
</html>