mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
synced 2024-11-27 17:04:35 +00:00
fac8ef44d2
Regenerated documentation.
184 lines
25 KiB
HTML
184 lines
25 KiB
HTML
<!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=11"/>
|
|
<meta name="generator" content="Doxygen 1.9.2"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>Vulkan Memory Allocator: Virtual allocator</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">Vulkan Memory Allocator
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.9.2 -->
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
var searchBox = new SearchBox("searchBox", "search",'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:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
$(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="index.html">Vulkan Memory Allocator</a></li> </ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div><div class="header">
|
|
<div class="headertitle"><div class="title">Virtual allocator </div></div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<div class="textblock"><p >As an extra feature, the core allocation algorithm of the library is exposed through a simple and convenient API of "virtual allocator". It doesn't allocate any real GPU memory. It just keeps track of used and free regions of a "virtual block". You can use it to allocate your own memory or other objects, even completely unrelated to Vulkan. A common use case is sub-allocation of pieces of one large GPU buffer.</p>
|
|
<h1><a class="anchor" id="virtual_allocator_creating_virtual_block"></a>
|
|
Creating virtual block</h1>
|
|
<p >To use this functionality, there is no main "allocator" object. You don't need to have <a class="el" href="struct_vma_allocator.html" title="Represents main object of this library initialized.">VmaAllocator</a> object created. All you need to do is to create a separate <a class="el" href="struct_vma_virtual_block.html" title="Handle to a virtual block object that allows to use core allocation algorithm without allocating any ...">VmaVirtualBlock</a> object for each block of memory you want to be managed by the allocator:</p>
|
|
<ol type="1">
|
|
<li>Fill in <a class="el" href="struct_vma_virtual_block_create_info.html" title="Parameters of created VmaVirtualBlock object to be passed to vmaCreateVirtualBlock().">VmaVirtualBlockCreateInfo</a> structure.</li>
|
|
<li>Call <a class="el" href="vk__mem__alloc_8h.html#ab585754076877265fdae33e5c40ef13b" title="Creates new VmaVirtualBlock object.">vmaCreateVirtualBlock()</a>. Get new <a class="el" href="struct_vma_virtual_block.html" title="Handle to a virtual block object that allows to use core allocation algorithm without allocating any ...">VmaVirtualBlock</a> object.</li>
|
|
</ol>
|
|
<p >Example:</p>
|
|
<div class="fragment"><div class="line"><a class="code hl_struct" href="struct_vma_virtual_block_create_info.html">VmaVirtualBlockCreateInfo</a> blockCreateInfo = {};</div>
|
|
<div class="line">blockCreateInfo.<a class="code hl_variable" href="struct_vma_virtual_block_create_info.html#a670ab8c6a6e822f3c36781d79e8824e9">size</a> = 1048576; <span class="comment">// 1 MB</span></div>
|
|
<div class="line"> </div>
|
|
<div class="line"><a class="code hl_struct" href="struct_vma_virtual_block.html">VmaVirtualBlock</a> block;</div>
|
|
<div class="line">VkResult res = <a class="code hl_function" href="vk__mem__alloc_8h.html#ab585754076877265fdae33e5c40ef13b">vmaCreateVirtualBlock</a>(&blockCreateInfo, &block);</div>
|
|
<div class="ttc" id="astruct_vma_virtual_block_create_info_html"><div class="ttname"><a href="struct_vma_virtual_block_create_info.html">VmaVirtualBlockCreateInfo</a></div><div class="ttdoc">Parameters of created VmaVirtualBlock object to be passed to vmaCreateVirtualBlock().</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:2202</div></div>
|
|
<div class="ttc" id="astruct_vma_virtual_block_create_info_html_a670ab8c6a6e822f3c36781d79e8824e9"><div class="ttname"><a href="struct_vma_virtual_block_create_info.html#a670ab8c6a6e822f3c36781d79e8824e9">VmaVirtualBlockCreateInfo::size</a></div><div class="ttdeci">VkDeviceSize size</div><div class="ttdoc">Total size of the virtual block.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:2208</div></div>
|
|
<div class="ttc" id="astruct_vma_virtual_block_html"><div class="ttname"><a href="struct_vma_virtual_block.html">VmaVirtualBlock</a></div><div class="ttdoc">Handle to a virtual block object that allows to use core allocation algorithm without allocating any ...</div></div>
|
|
<div class="ttc" id="avk__mem__alloc_8h_html_ab585754076877265fdae33e5c40ef13b"><div class="ttname"><a href="vk__mem__alloc_8h.html#ab585754076877265fdae33e5c40ef13b">vmaCreateVirtualBlock</a></div><div class="ttdeci">VkResult vmaCreateVirtualBlock(const VmaVirtualBlockCreateInfo *pCreateInfo, VmaVirtualBlock *pVirtualBlock)</div><div class="ttdoc">Creates new VmaVirtualBlock object.</div></div>
|
|
</div><!-- fragment --><h1><a class="anchor" id="virtual_allocator_making_virtual_allocations"></a>
|
|
Making virtual allocations</h1>
|
|
<p ><a class="el" href="struct_vma_virtual_block.html" title="Handle to a virtual block object that allows to use core allocation algorithm without allocating any ...">VmaVirtualBlock</a> object contains internal data structure that keeps track of free and occupied regions using the same code as the main Vulkan memory allocator. However, there is no "virtual allocation" object. When you request a new allocation, a <code>VkDeviceSize</code> number is returned. It is an offset inside the block where the allocation has been placed, but it also uniquely identifies the allocation within this block.</p>
|
|
<p >In order to make an allocation:</p>
|
|
<ol type="1">
|
|
<li>Fill in <a class="el" href="struct_vma_virtual_allocation_create_info.html" title="Parameters of created virtual allocation to be passed to vmaVirtualAllocate().">VmaVirtualAllocationCreateInfo</a> structure.</li>
|
|
<li>Call <a class="el" href="vk__mem__alloc_8h.html#a1c15925e6745dacee0cfc877fffecec2" title="Allocates new virtual allocation inside given VmaVirtualBlock.">vmaVirtualAllocate()</a>. Get new <code>VkDeviceSize offset</code> that identifies the allocation.</li>
|
|
</ol>
|
|
<p >Example:</p>
|
|
<div class="fragment"><div class="line"><a class="code hl_struct" href="struct_vma_virtual_allocation_create_info.html">VmaVirtualAllocationCreateInfo</a> allocCreateInfo = {};</div>
|
|
<div class="line">allocCreateInfo.<a class="code hl_variable" href="struct_vma_virtual_allocation_create_info.html#aae08752b86817abd0d944c6025dc603e">size</a> = 4096; <span class="comment">// 4 KB</span></div>
|
|
<div class="line"> </div>
|
|
<div class="line">VkDeviceSize allocOffset;</div>
|
|
<div class="line">res = <a class="code hl_function" href="vk__mem__alloc_8h.html#a1c15925e6745dacee0cfc877fffecec2">vmaVirtualAllocate</a>(block, &allocCreateInfo, &allocOffset);</div>
|
|
<div class="line"><span class="keywordflow">if</span>(res == VK_SUCCESS)</div>
|
|
<div class="line">{</div>
|
|
<div class="line"> <span class="comment">// Use the 4 KB of your memory starting at allocOffset.</span></div>
|
|
<div class="line">}</div>
|
|
<div class="line"><span class="keywordflow">else</span></div>
|
|
<div class="line">{</div>
|
|
<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="astruct_vma_virtual_allocation_create_info_html"><div class="ttname"><a href="struct_vma_virtual_allocation_create_info.html">VmaVirtualAllocationCreateInfo</a></div><div class="ttdoc">Parameters of created virtual allocation to be passed to vmaVirtualAllocate().</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:2250</div></div>
|
|
<div class="ttc" id="astruct_vma_virtual_allocation_create_info_html_aae08752b86817abd0d944c6025dc603e"><div class="ttname"><a href="struct_vma_virtual_allocation_create_info.html#aae08752b86817abd0d944c6025dc603e">VmaVirtualAllocationCreateInfo::size</a></div><div class="ttdeci">VkDeviceSize size</div><div class="ttdoc">Size of the allocation.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:2255</div></div>
|
|
<div class="ttc" id="avk__mem__alloc_8h_html_a1c15925e6745dacee0cfc877fffecec2"><div class="ttname"><a href="vk__mem__alloc_8h.html#a1c15925e6745dacee0cfc877fffecec2">vmaVirtualAllocate</a></div><div class="ttdeci">VkResult vmaVirtualAllocate(VmaVirtualBlock virtualBlock, const VmaVirtualAllocationCreateInfo *pCreateInfo, VkDeviceSize *pOffset)</div><div class="ttdoc">Allocates new virtual allocation inside given VmaVirtualBlock.</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="vk__mem__alloc_8h.html#a13f01c44b3c1a06e695f1f5d24b80639" title="Frees virtual allocation inside given VmaVirtualBlock.">vmaVirtualFree()</a>. You can only pass to this function the exact offset that was previously returned by <a class="el" href="vk__mem__alloc_8h.html#a1c15925e6745dacee0cfc877fffecec2" title="Allocates new virtual allocation inside given VmaVirtualBlock.">vmaVirtualAllocate()</a> and not any other location within the memory.</p>
|
|
<p >When whole block is no longer needed, the block object can be released by calling <a class="el" href="vk__mem__alloc_8h.html#a3795f7783ae2c182cede067d656f66a5" title="Destroys VmaVirtualBlock object.">vmaDestroyVirtualBlock()</a>. All allocations must be freed before the block is destroyed, which is checked internally by an assert. However, if you don't want to call <a class="el" href="vk__mem__alloc_8h.html#a13f01c44b3c1a06e695f1f5d24b80639" title="Frees virtual allocation inside given VmaVirtualBlock.">vmaVirtualFree()</a> for each allocation, you can use <a class="el" href="vk__mem__alloc_8h.html#a5eda6f55919fb05bd2f56a112590c571" title="Frees all virtual allocations inside given VmaVirtualBlock.">vmaClearVirtualBlock()</a> to free them all at once - a feature not available in normal Vulkan memory allocator. Example:</p>
|
|
<div class="fragment"><div class="line"><a class="code hl_function" href="vk__mem__alloc_8h.html#a13f01c44b3c1a06e695f1f5d24b80639">vmaVirtualFree</a>(block, allocOffset);</div>
|
|
<div class="line"><a class="code hl_function" href="vk__mem__alloc_8h.html#a3795f7783ae2c182cede067d656f66a5">vmaDestroyVirtualBlock</a>(block);</div>
|
|
<div class="ttc" id="avk__mem__alloc_8h_html_a13f01c44b3c1a06e695f1f5d24b80639"><div class="ttname"><a href="vk__mem__alloc_8h.html#a13f01c44b3c1a06e695f1f5d24b80639">vmaVirtualFree</a></div><div class="ttdeci">void vmaVirtualFree(VmaVirtualBlock virtualBlock, VkDeviceSize offset)</div><div class="ttdoc">Frees virtual allocation inside given VmaVirtualBlock.</div></div>
|
|
<div class="ttc" id="avk__mem__alloc_8h_html_a3795f7783ae2c182cede067d656f66a5"><div class="ttname"><a href="vk__mem__alloc_8h.html#a3795f7783ae2c182cede067d656f66a5">vmaDestroyVirtualBlock</a></div><div class="ttdeci">void vmaDestroyVirtualBlock(VmaVirtualBlock virtualBlock)</div><div class="ttdoc">Destroys VmaVirtualBlock object.</div></div>
|
|
</div><!-- fragment --><h1><a class="anchor" id="virtual_allocator_allocation_parameters"></a>
|
|
Allocation parameters</h1>
|
|
<p >You can attach a custom pointer to each allocation by using <a class="el" href="vk__mem__alloc_8h.html#a4b96f835d38686df937e097a0c7db5e9" title="Changes custom pointer associated with given virtual allocation.">vmaSetVirtualAllocationUserData()</a>. Its default value is null. It can be used to store any data that needs to be associated with that allocation - e.g. an index, a handle, or a pointer to some larger data structure containing more information. Example:</p>
|
|
<div class="fragment"><div class="line"><span class="keyword">struct </span>CustomAllocData</div>
|
|
<div class="line">{</div>
|
|
<div class="line"> std::string m_AllocName;</div>
|
|
<div class="line">};</div>
|
|
<div class="line">CustomAllocData* allocData = <span class="keyword">new</span> CustomAllocData();</div>
|
|
<div class="line">allocData->m_AllocName = <span class="stringliteral">"My allocation 1"</span>;</div>
|
|
<div class="line"><a class="code hl_function" href="vk__mem__alloc_8h.html#a4b96f835d38686df937e097a0c7db5e9">vmaSetVirtualAllocationUserData</a>(block, allocOffset, allocData);</div>
|
|
<div class="ttc" id="avk__mem__alloc_8h_html_a4b96f835d38686df937e097a0c7db5e9"><div class="ttname"><a href="vk__mem__alloc_8h.html#a4b96f835d38686df937e097a0c7db5e9">vmaSetVirtualAllocationUserData</a></div><div class="ttdeci">void vmaSetVirtualAllocationUserData(VmaVirtualBlock virtualBlock, VkDeviceSize offset, void *pUserData)</div><div class="ttdoc">Changes custom pointer associated with given virtual allocation.</div></div>
|
|
</div><!-- fragment --><p >The pointer can later be fetched, along with allocation size, by passing the allocation offset to function <a class="el" href="vk__mem__alloc_8h.html#ab5fcb961ffea69023e7e0ea100bdad8e" title="Returns information about a specific virtual allocation within a virtual block, like its size and pUs...">vmaGetVirtualAllocationInfo()</a> and inspecting returned structure <a class="el" href="struct_vma_virtual_allocation_info.html" title="Parameters of an existing virtual allocation, returned by vmaGetVirtualAllocationInfo().">VmaVirtualAllocationInfo</a>. If you allocated a new object to be used as the custom pointer, don't forget to delete that object before freeing the allocation! Example:</p>
|
|
<div class="fragment"><div class="line"><a class="code hl_struct" href="struct_vma_virtual_allocation_info.html">VmaVirtualAllocationInfo</a> allocInfo;</div>
|
|
<div class="line"><a class="code hl_function" href="vk__mem__alloc_8h.html#ab5fcb961ffea69023e7e0ea100bdad8e">vmaGetVirtualAllocationInfo</a>(block, allocOffset, &allocInfo);</div>
|
|
<div class="line"><span class="keyword">delete</span> (CustomAllocData*)allocInfo.<a class="code hl_variable" href="struct_vma_virtual_allocation_info.html#a41d5cb09357656411653d82fee436f45">pUserData</a>;</div>
|
|
<div class="line"> </div>
|
|
<div class="line"><a class="code hl_function" href="vk__mem__alloc_8h.html#a13f01c44b3c1a06e695f1f5d24b80639">vmaVirtualFree</a>(block, allocOffset);</div>
|
|
<div class="ttc" id="astruct_vma_virtual_allocation_info_html"><div class="ttname"><a href="struct_vma_virtual_allocation_info.html">VmaVirtualAllocationInfo</a></div><div class="ttdoc">Parameters of an existing virtual allocation, returned by vmaGetVirtualAllocationInfo().</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:2273</div></div>
|
|
<div class="ttc" id="astruct_vma_virtual_allocation_info_html_a41d5cb09357656411653d82fee436f45"><div class="ttname"><a href="struct_vma_virtual_allocation_info.html#a41d5cb09357656411653d82fee436f45">VmaVirtualAllocationInfo::pUserData</a></div><div class="ttdeci">void * pUserData</div><div class="ttdoc">Custom pointer associated with the allocation.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:2283</div></div>
|
|
<div class="ttc" id="avk__mem__alloc_8h_html_ab5fcb961ffea69023e7e0ea100bdad8e"><div class="ttname"><a href="vk__mem__alloc_8h.html#ab5fcb961ffea69023e7e0ea100bdad8e">vmaGetVirtualAllocationInfo</a></div><div class="ttdeci">void vmaGetVirtualAllocationInfo(VmaVirtualBlock virtualBlock, VkDeviceSize offset, VmaVirtualAllocationInfo *pVirtualAllocInfo)</div><div class="ttdoc">Returns information about a specific virtual allocation within a virtual block, like its size and pUs...</div></div>
|
|
</div><!-- fragment --><h1><a class="anchor" id="virtual_allocator_alignment_and_units"></a>
|
|
Alignment and units</h1>
|
|
<p >It feels natural to express sizes and offsets in bytes. If an offset of an allocation needs to be aligned to a multiply of some number (e.g. 4 bytes), you can fill optional member <a class="el" href="struct_vma_virtual_allocation_create_info.html#a9d19709872fc1904a105079e1c885821" title="Required alignment of the allocation. Optional.">VmaVirtualAllocationCreateInfo::alignment</a> to request it. Example:</p>
|
|
<div class="fragment"><div class="line"><a class="code hl_struct" href="struct_vma_virtual_allocation_create_info.html">VmaVirtualAllocationCreateInfo</a> allocCreateInfo = {};</div>
|
|
<div class="line">allocCreateInfo.<a class="code hl_variable" href="struct_vma_virtual_allocation_create_info.html#aae08752b86817abd0d944c6025dc603e">size</a> = 4096; <span class="comment">// 4 KB</span></div>
|
|
<div class="line">allocCreateInfo.<a class="code hl_variable" href="struct_vma_virtual_allocation_create_info.html#a9d19709872fc1904a105079e1c885821">alignment</a> = 4; <span class="comment">// Returned offset must be a multiply of 4 B</span></div>
|
|
<div class="line"> </div>
|
|
<div class="line">VkDeviceSize allocOffset;</div>
|
|
<div class="line">res = <a class="code hl_function" href="vk__mem__alloc_8h.html#a1c15925e6745dacee0cfc877fffecec2">vmaVirtualAllocate</a>(block, &allocCreateInfo, &allocOffset);</div>
|
|
<div class="ttc" id="astruct_vma_virtual_allocation_create_info_html_a9d19709872fc1904a105079e1c885821"><div class="ttname"><a href="struct_vma_virtual_allocation_create_info.html#a9d19709872fc1904a105079e1c885821">VmaVirtualAllocationCreateInfo::alignment</a></div><div class="ttdeci">VkDeviceSize alignment</div><div class="ttdoc">Required alignment of the allocation. Optional.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:2260</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_vma_virtual_block_create_info.html#a670ab8c6a6e822f3c36781d79e8824e9" title="Total size of the virtual block.">VmaVirtualBlockCreateInfo::size</a></li>
|
|
<li><a class="el" href="struct_vma_virtual_allocation_create_info.html#aae08752b86817abd0d944c6025dc603e" title="Size of the allocation.">VmaVirtualAllocationCreateInfo::size</a> and <a class="el" href="struct_vma_virtual_allocation_create_info.html#a9d19709872fc1904a105079e1c885821" title="Required alignment of the allocation. Optional.">VmaVirtualAllocationCreateInfo::alignment</a></li>
|
|
<li>Using offset returned by <a class="el" href="vk__mem__alloc_8h.html#a1c15925e6745dacee0cfc877fffecec2" title="Allocates new virtual allocation inside given VmaVirtualBlock.">vmaVirtualAllocate()</a></li>
|
|
</ul>
|
|
<h1><a class="anchor" id="virtual_allocator_statistics"></a>
|
|
Statistics</h1>
|
|
<p >You can obtain statistics of a virtual block using <a class="el" href="vk__mem__alloc_8h.html#a95169b4730e94757897470086ec2768a" title="Calculates and returns statistics about virtual allocations and memory usage in given VmaVirtualBlock...">vmaCalculateVirtualBlockStats()</a>. The function fills structure <a class="el" href="struct_vma_stat_info.html" title="Calculated statistics of memory usage in entire allocator.">VmaStatInfo</a> - same as used by the normal Vulkan memory allocator. Example:</p>
|
|
<div class="fragment"><div class="line"><a class="code hl_struct" href="struct_vma_stat_info.html">VmaStatInfo</a> statInfo;</div>
|
|
<div class="line"><a class="code hl_function" href="vk__mem__alloc_8h.html#a95169b4730e94757897470086ec2768a">vmaCalculateVirtualBlockStats</a>(block, &statInfo);</div>
|
|
<div class="line">printf(<span class="stringliteral">"My virtual block has %llu bytes used by %u virtual allocations\n"</span>,</div>
|
|
<div class="line"> statInfo.<a class="code hl_variable" href="struct_vma_stat_info.html#ab0c6c73837e5a70c749fbd4f6064895a">usedBytes</a>, statInfo.<a class="code hl_variable" href="struct_vma_stat_info.html#a537741e4d5cdddc1c0ab95ec650afaff">allocationCount</a>);</div>
|
|
<div class="ttc" id="astruct_vma_stat_info_html"><div class="ttname"><a href="struct_vma_stat_info.html">VmaStatInfo</a></div><div class="ttdoc">Calculated statistics of memory usage in entire allocator.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:687</div></div>
|
|
<div class="ttc" id="astruct_vma_stat_info_html_a537741e4d5cdddc1c0ab95ec650afaff"><div class="ttname"><a href="struct_vma_stat_info.html#a537741e4d5cdddc1c0ab95ec650afaff">VmaStatInfo::allocationCount</a></div><div class="ttdeci">uint32_t allocationCount</div><div class="ttdoc">Number of VmaAllocation allocation objects allocated.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:691</div></div>
|
|
<div class="ttc" id="astruct_vma_stat_info_html_ab0c6c73837e5a70c749fbd4f6064895a"><div class="ttname"><a href="struct_vma_stat_info.html#ab0c6c73837e5a70c749fbd4f6064895a">VmaStatInfo::usedBytes</a></div><div class="ttdeci">VkDeviceSize usedBytes</div><div class="ttdoc">Total number of bytes occupied by all allocations.</div><div class="ttdef"><b>Definition:</b> vk_mem_alloc.h:695</div></div>
|
|
<div class="ttc" id="avk__mem__alloc_8h_html_a95169b4730e94757897470086ec2768a"><div class="ttname"><a href="vk__mem__alloc_8h.html#a95169b4730e94757897470086ec2768a">vmaCalculateVirtualBlockStats</a></div><div class="ttdeci">void vmaCalculateVirtualBlockStats(VmaVirtualBlock virtualBlock, VmaStatInfo *pStatInfo)</div><div class="ttdoc">Calculates and returns statistics about virtual allocations and memory usage in given VmaVirtualBlock...</div></div>
|
|
</div><!-- fragment --><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="vk__mem__alloc_8h.html#a52d810e1222c592e5d80556ad005f1e6" title="Builds and returns a null-terminated string in JSON format with information about given VmaVirtualBlo...">vmaBuildVirtualBlockStatsString()</a>. Returned string must be later freed using <a class="el" href="vk__mem__alloc_8h.html#a47fb8d8aa69df4a7c23a9719b4080623" title="Frees a string returned by vmaBuildVirtualBlockStatsString().">vmaFreeVirtualBlockStatsString()</a>. The format of this string differs from the one returned by the main Vulkan allocator, but it is similar.</p>
|
|
<h1><a class="anchor" id="virtual_allocator_additional_considerations"></a>
|
|
Additional considerations</h1>
|
|
<p >The "virtual allocator" functionality is implemented on a level of individual memory blocks. Keeping track of a whole collection of blocks, allocating new ones when out of free space, deleting empty ones, and deciding which one to try first for a new allocation must be implemented by the user.</p>
|
|
<p >Alternative allocation algorithms are supported, just like in custom pools of the real GPU memory. See enum <a class="el" href="vk__mem__alloc_8h.html#a88bcf8c1cd3bb1610ff7343811c65bca" title="Flags to be passed as VmaVirtualBlockCreateInfo::flags.">VmaVirtualBlockCreateFlagBits</a> to learn how to specify them (e.g. <a class="el" href="vk__mem__alloc_8h.html#a88bcf8c1cd3bb1610ff7343811c65bcaae6423e2fa2f3c9211b21c819e3f10f96" title="Enables alternative, linear allocation algorithm in this virtual block.">VMA_VIRTUAL_BLOCK_CREATE_LINEAR_ALGORITHM_BIT</a>). You can find their description in chapter <a class="el" href="custom_memory_pools.html">Custom memory pools</a>. Allocation strategies are also supported. See enum <a class="el" href="vk__mem__alloc_8h.html#a2e9c64d405b14156fea7e10c4ad06cb6" title="Flags to be passed as VmaVirtualAllocationCreateInfo::flags.">VmaVirtualAllocationCreateFlagBits</a> to learn how to specify them (e.g. <a class="el" href="vk__mem__alloc_8h.html#a2e9c64d405b14156fea7e10c4ad06cb6a562d10a46012719d33167d3dc5dbbf9b" title="Allocation strategy that tries to minimize allocation time.">VMA_VIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT</a>).</p>
|
|
<p >Following features are supported only by the allocator of the real GPU memory and not by virtual allocations: buffer-image granularity, <a class="el" href="lost_allocations.html">Lost allocations</a>, <code>VMA_DEBUG_MARGIN</code>, <code>VMA_MIN_ALIGNMENT</code>. </p>
|
|
</div></div><!-- contents -->
|
|
</div><!-- PageDoc -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
|
|
</small></address>
|
|
</body>
|
|
</html>
|