|
| 1 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 2 | +<html xmlns="http://www.w3.org/1999/xhtml"> |
| 3 | +<head> |
| 4 | +<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
| 5 | +<meta http-equiv="X-UA-Compatible" content="IE=9"/> |
| 6 | +<meta name="generator" content="Doxygen 1.8.13"/> |
| 7 | +<meta name="viewport" content="width=device-width, initial-scale=1"/> |
| 8 | +<title>Vulkan Memory Allocator: General considerations</title> |
| 9 | +<link href="tabs.css" rel="stylesheet" type="text/css"/> |
| 10 | +<script type="text/javascript" src="jquery.js"></script> |
| 11 | +<script type="text/javascript" src="dynsections.js"></script> |
| 12 | +<link href="search/search.css" rel="stylesheet" type="text/css"/> |
| 13 | +<script type="text/javascript" src="search/searchdata.js"></script> |
| 14 | +<script type="text/javascript" src="search/search.js"></script> |
| 15 | +<link href="doxygen.css" rel="stylesheet" type="text/css" /> |
| 16 | +</head> |
| 17 | +<body> |
| 18 | +<div id="top"><!-- do not remove this div, it is closed by doxygen! --> |
| 19 | +<div id="titlearea"> |
| 20 | +<table cellspacing="0" cellpadding="0"> |
| 21 | + <tbody> |
| 22 | + <tr style="height: 56px;"> |
| 23 | + <td id="projectalign" style="padding-left: 0.5em;"> |
| 24 | + <div id="projectname">Vulkan Memory Allocator |
| 25 | + </div> |
| 26 | + </td> |
| 27 | + </tr> |
| 28 | + </tbody> |
| 29 | +</table> |
| 30 | +</div> |
| 31 | +<!-- end header part --> |
| 32 | +<!-- Generated by Doxygen 1.8.13 --> |
| 33 | +<script type="text/javascript"> |
| 34 | +var searchBox = new SearchBox("searchBox", "search",false,'Search'); |
| 35 | +</script> |
| 36 | +<script type="text/javascript" src="menudata.js"></script> |
| 37 | +<script type="text/javascript" src="menu.js"></script> |
| 38 | +<script type="text/javascript"> |
| 39 | +$(function() { |
| 40 | + initMenu('',true,false,'search.php','Search'); |
| 41 | + $(document).ready(function() { init_search(); }); |
| 42 | +}); |
| 43 | +</script> |
| 44 | +<div id="main-nav"></div> |
| 45 | +<!-- window showing the filter options --> |
| 46 | +<div id="MSearchSelectWindow" |
| 47 | + onmouseover="return searchBox.OnSearchSelectShow()" |
| 48 | + onmouseout="return searchBox.OnSearchSelectHide()" |
| 49 | + onkeydown="return searchBox.OnSearchSelectKey(event)"> |
| 50 | +</div> |
| 51 | + |
| 52 | +<!-- iframe showing the search results (closed by default) --> |
| 53 | +<div id="MSearchResultsWindow"> |
| 54 | +<iframe src="javascript:void(0)" frameborder="0" |
| 55 | + name="MSearchResults" id="MSearchResults"> |
| 56 | +</iframe> |
| 57 | +</div> |
| 58 | + |
| 59 | +<div id="nav-path" class="navpath"> |
| 60 | + <ul> |
| 61 | +<li class="navelem"><a class="el" href="index.html">Vulkan Memory Allocator</a></li> </ul> |
| 62 | +</div> |
| 63 | +</div><!-- top --> |
| 64 | +<div class="header"> |
| 65 | + <div class="headertitle"> |
| 66 | +<div class="title">General considerations </div> </div> |
| 67 | +</div><!--header--> |
| 68 | +<div class="contents"> |
| 69 | +<div class="textblock"><h1><a class="anchor" id="general_considerations_thread_safety"></a> |
| 70 | +Thread safety</h1> |
| 71 | +<ul> |
| 72 | +<li>The library has no global state, so separate <code>VmaAllocator</code> objects can be used independently. There should be no need to create multiple such objects though - one per <code>VkDevice</code> is enough.</li> |
| 73 | +<li>By default, all calls to functions that take <code>VmaAllocator</code> as first parameter are safe to call from multiple threads simultaneously because they are synchronized internally when needed.</li> |
| 74 | +<li>When the allocator is created with <a class="el" href="vk__mem__alloc_8h.html#a4f87c9100d154a65a4ad495f7763cf7ca4816ddaed324ba110172ca608a20f29d" title="Allocator and all objects created from it will not be synchronized internally, so you must guarantee ...">VMA_ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT</a> flag, calls to functions that take such <code>VmaAllocator</code> object must be synchronized externally.</li> |
| 75 | +<li>Access to a <code>VmaAllocation</code> object must be externally synchronized. For example, you must not call <a class="el" href="vk__mem__alloc_8h.html#a86dd08aba8633bfa4ad0df2e76481d8b" title="Returns current information about specified allocation and atomically marks it as used in current fra...">vmaGetAllocationInfo()</a> and <a class="el" href="vk__mem__alloc_8h.html#ad5bd1243512d099706de88168992f069" title="Maps memory represented by given allocation and returns pointer to it. ">vmaMapMemory()</a> from different threads at the same time if you pass the same <code>VmaAllocation</code> object to these functions.</li> |
| 76 | +</ul> |
| 77 | +<h1><a class="anchor" id="general_considerations_allocation_algorithm"></a> |
| 78 | +Allocation algorithm</h1> |
| 79 | +<p>The library uses following algorithm for allocation, in order:</p> |
| 80 | +<ol type="1"> |
| 81 | +<li>Try to find free range of memory in existing blocks.</li> |
| 82 | +<li>If failed, try to create a new block of <code>VkDeviceMemory</code>, with preferred block size.</li> |
| 83 | +<li>If failed, try to create such block with size/2, size/4, size/8.</li> |
| 84 | +<li>If failed and <a class="el" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a68686d0ce9beb0d4d1b9f2b8b1389a7e">VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT</a> flag was specified, try to find space in existing blocks, possilby making some other allocations lost.</li> |
| 85 | +<li>If failed, try to allocate separate <code>VkDeviceMemory</code> for this allocation, just like when you use <a class="el" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a3fc311d855c2ff53f1090ef5c722b38f" title="Set this flag if the allocation should have its own memory block. ">VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT</a>.</li> |
| 86 | +<li>If failed, choose other memory type that meets the requirements specified in <a class="el" href="struct_vma_allocation_create_info.html">VmaAllocationCreateInfo</a> and go to point 1.</li> |
| 87 | +<li>If failed, return <code>VK_ERROR_OUT_OF_DEVICE_MEMORY</code>.</li> |
| 88 | +</ol> |
| 89 | +<h1><a class="anchor" id="general_considerations_features_not_supported"></a> |
| 90 | +Features not supported</h1> |
| 91 | +<p>Features deliberately excluded from the scope of this library:</p> |
| 92 | +<ul> |
| 93 | +<li>Data transfer - issuing commands that transfer data between buffers or images, any usage of <code>VkCommandList</code> or <code>VkCommandQueue</code> and related synchronization is responsibility of the user.</li> |
| 94 | +<li>Support for any programming languages other than C/C++. Bindings to other languages are welcomed as external projects. </li> |
| 95 | +</ul> |
| 96 | +</div></div><!-- contents --> |
| 97 | +<!-- start footer part --> |
| 98 | +<hr class="footer"/><address class="footer"><small> |
| 99 | +Generated by  <a href="http://www.doxygen.org/index.html"> |
| 100 | +<img class="footer" src="doxygen.png" alt="doxygen"/> |
| 101 | +</a> 1.8.13 |
| 102 | +</small></address> |
| 103 | +</body> |
| 104 | +</html> |
0 commit comments