Added function vmaCreateAliasingBuffer2, vmaCreateAliasingImage2 with new parameter allocationLocalOffset

Thanks @sagaceilo for the idea!
This commit is contained in:
Adam Sawicki 2022-09-04 13:26:39 +02:00
parent 2a7110f078
commit d6b705bf75
15 changed files with 341 additions and 146 deletions

View file

@ -338,6 +338,9 @@ Functions</h2></td></tr>
<tr class="memitem:ga60d5d4803e3c82505a2bfddb929adb03"><td class="memItemLeft" align="right" valign="top">VkResult&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__alloc.html#ga60d5d4803e3c82505a2bfddb929adb03">vmaCreateAliasingBuffer</a> (<a class="el" href="struct_vma_allocator.html">VmaAllocator</a> allocator, <a class="el" href="struct_vma_allocation.html">VmaAllocation</a> allocation, const VkBufferCreateInfo *pBufferCreateInfo, VkBuffer *pBuffer)</td></tr>
<tr class="memdesc:ga60d5d4803e3c82505a2bfddb929adb03"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates a new <code>VkBuffer</code>, binds already created memory for it. <a href="group__group__alloc.html#ga60d5d4803e3c82505a2bfddb929adb03">More...</a><br /></td></tr>
<tr class="separator:ga60d5d4803e3c82505a2bfddb929adb03"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf0cf014344213e117bd9f9cf5f928122"><td class="memItemLeft" align="right" valign="top">VkResult&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__alloc.html#gaf0cf014344213e117bd9f9cf5f928122">vmaCreateAliasingBuffer2</a> (<a class="el" href="struct_vma_allocator.html">VmaAllocator</a> allocator, <a class="el" href="struct_vma_allocation.html">VmaAllocation</a> allocation, VkDeviceSize allocationLocalOffset, const VkBufferCreateInfo *pBufferCreateInfo, VkBuffer *pBuffer)</td></tr>
<tr class="memdesc:gaf0cf014344213e117bd9f9cf5f928122"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates a new <code>VkBuffer</code>, binds already created memory for it. <a href="group__group__alloc.html#gaf0cf014344213e117bd9f9cf5f928122">More...</a><br /></td></tr>
<tr class="separator:gaf0cf014344213e117bd9f9cf5f928122"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga0d9f4e4ba5bf9aab1f1c746387753d77"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__alloc.html#ga0d9f4e4ba5bf9aab1f1c746387753d77">vmaDestroyBuffer</a> (<a class="el" href="struct_vma_allocator.html">VmaAllocator</a> allocator, VkBuffer buffer, <a class="el" href="struct_vma_allocation.html">VmaAllocation</a> allocation)</td></tr>
<tr class="memdesc:ga0d9f4e4ba5bf9aab1f1c746387753d77"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destroys Vulkan buffer and frees allocated memory. <a href="group__group__alloc.html#ga0d9f4e4ba5bf9aab1f1c746387753d77">More...</a><br /></td></tr>
<tr class="separator:ga0d9f4e4ba5bf9aab1f1c746387753d77"><td class="memSeparator" colspan="2">&#160;</td></tr>
@ -345,8 +348,11 @@ Functions</h2></td></tr>
<tr class="memdesc:ga02a94f25679275851a53e82eacbcfc73"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function similar to <a class="el" href="group__group__alloc.html#gac72ee55598617e8eecca384e746bab51" title="Creates a new VkBuffer, allocates and binds memory for it.">vmaCreateBuffer()</a>. <a href="group__group__alloc.html#ga02a94f25679275851a53e82eacbcfc73">More...</a><br /></td></tr>
<tr class="separator:ga02a94f25679275851a53e82eacbcfc73"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaebc4db1f94b53dba2338b4c0fd80d0dc"><td class="memItemLeft" align="right" valign="top">VkResult&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__alloc.html#gaebc4db1f94b53dba2338b4c0fd80d0dc">vmaCreateAliasingImage</a> (<a class="el" href="struct_vma_allocator.html">VmaAllocator</a> allocator, <a class="el" href="struct_vma_allocation.html">VmaAllocation</a> allocation, const VkImageCreateInfo *pImageCreateInfo, VkImage *pImage)</td></tr>
<tr class="memdesc:gaebc4db1f94b53dba2338b4c0fd80d0dc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function similar to <a class="el" href="group__group__alloc.html#ga60d5d4803e3c82505a2bfddb929adb03" title="Creates a new VkBuffer, binds already created memory for it.">vmaCreateAliasingBuffer()</a>. <a href="group__group__alloc.html#gaebc4db1f94b53dba2338b4c0fd80d0dc">More...</a><br /></td></tr>
<tr class="memdesc:gaebc4db1f94b53dba2338b4c0fd80d0dc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function similar to <a class="el" href="group__group__alloc.html#ga60d5d4803e3c82505a2bfddb929adb03" title="Creates a new VkBuffer, binds already created memory for it.">vmaCreateAliasingBuffer()</a> but for images. <a href="group__group__alloc.html#gaebc4db1f94b53dba2338b4c0fd80d0dc">More...</a><br /></td></tr>
<tr class="separator:gaebc4db1f94b53dba2338b4c0fd80d0dc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga69ac829f5bb0737449fa92c2d971f1bb"><td class="memItemLeft" align="right" valign="top">VkResult&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__alloc.html#ga69ac829f5bb0737449fa92c2d971f1bb">vmaCreateAliasingImage2</a> (<a class="el" href="struct_vma_allocator.html">VmaAllocator</a> allocator, <a class="el" href="struct_vma_allocation.html">VmaAllocation</a> allocation, VkDeviceSize allocationLocalOffset, const VkImageCreateInfo *pImageCreateInfo, VkImage *pImage)</td></tr>
<tr class="memdesc:ga69ac829f5bb0737449fa92c2d971f1bb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function similar to <a class="el" href="group__group__alloc.html#gaf0cf014344213e117bd9f9cf5f928122" title="Creates a new VkBuffer, binds already created memory for it.">vmaCreateAliasingBuffer2()</a> but for images. <a href="group__group__alloc.html#ga69ac829f5bb0737449fa92c2d971f1bb">More...</a><br /></td></tr>
<tr class="separator:ga69ac829f5bb0737449fa92c2d971f1bb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae50d2cb3b4a3bfd4dd40987234e50e7e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__alloc.html#gae50d2cb3b4a3bfd4dd40987234e50e7e">vmaDestroyImage</a> (<a class="el" href="struct_vma_allocator.html">VmaAllocator</a> allocator, VkImage image, <a class="el" href="struct_vma_allocation.html">VmaAllocation</a> allocation)</td></tr>
<tr class="memdesc:gae50d2cb3b4a3bfd4dd40987234e50e7e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destroys Vulkan image and frees allocated memory. <a href="group__group__alloc.html#gae50d2cb3b4a3bfd4dd40987234e50e7e">More...</a><br /></td></tr>
<tr class="separator:gae50d2cb3b4a3bfd4dd40987234e50e7e"><td class="memSeparator" colspan="2">&#160;</td></tr>
@ -659,7 +665,7 @@ Functions</h2></td></tr>
</td></tr>
<tr><td class="fieldname"><a id="ggad9889c10c798b040d59c92f257cae597a0729e932b7ea170e3a128cad96c5cf6d" name="ggad9889c10c798b040d59c92f257cae597a0729e932b7ea170e3a128cad96c5cf6d"></a>VMA_ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT&#160;</td><td class="fielddoc"><p >Allocation strategy that chooses first suitable free range for the allocation - not necessarily in terms of the smallest offset but the one that is easiest and fastest to find to minimize allocation time, possibly at the expense of allocation quality. </p>
</td></tr>
<tr><td class="fieldname"><a id="ggad9889c10c798b040d59c92f257cae597a8099acedc0d04cdccaaddcfe37fd227d" name="ggad9889c10c798b040d59c92f257cae597a8099acedc0d04cdccaaddcfe37fd227d"></a>VMA_ALLOCATION_CREATE_STRATEGY_MIN_OFFSET_BIT&#160;</td><td class="fielddoc"><p >Allocation strategy that chooses always the lowest offset in available space. This is not the most efficient strategy but achieves highly packed data. Used internally by defragmentation, not recomended in typical usage. </p>
<tr><td class="fieldname"><a id="ggad9889c10c798b040d59c92f257cae597a8099acedc0d04cdccaaddcfe37fd227d" name="ggad9889c10c798b040d59c92f257cae597a8099acedc0d04cdccaaddcfe37fd227d"></a>VMA_ALLOCATION_CREATE_STRATEGY_MIN_OFFSET_BIT&#160;</td><td class="fielddoc"><p >Allocation strategy that chooses always the lowest offset in available space. This is not the most efficient strategy but achieves highly packed data. Used internally by defragmentation, not recommended in typical usage. </p>
</td></tr>
<tr><td class="fieldname"><a id="ggad9889c10c798b040d59c92f257cae597a839826775c62319466441f86496f036d" name="ggad9889c10c798b040d59c92f257cae597a839826775c62319466441f86496f036d"></a>VMA_ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT&#160;</td><td class="fielddoc"><p >Alias to <a class="el" href="group__group__alloc.html#ggad9889c10c798b040d59c92f257cae597a8af1210cf591784afa026d94998f735d">VMA_ALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT</a>. </p>
</td></tr>
@ -1137,7 +1143,7 @@ Functions</h2></td></tr>
<table class="params">
<tr><td class="paramdir"></td><td class="paramname">allocator</td><td>Allocator object. </td></tr>
<tr><td class="paramdir"></td><td class="paramname">context</td><td>Context object that has been created by <a class="el" href="group__group__alloc.html#gac3335566858b45541fa9c0d7a6bbb57e" title="Begins defragmentation process.">vmaBeginDefragmentation()</a>. </td></tr>
<tr><td class="paramdir">[out]</td><td class="paramname">pPassInfo</td><td>Computed informations for current pass. </td></tr>
<tr><td class="paramdir">[out]</td><td class="paramname">pPassInfo</td><td>Computed information for current pass. </td></tr>
</table>
</dd>
</dl>
@ -1482,7 +1488,74 @@ Functions</h2></td></tr>
<li>Binds the buffer with the supplied memory.</li>
</ol>
<p >If any of these operations fail, buffer is not created, returned value is negative error code and <code>*pBuffer</code> is null.</p>
<p >If the function succeeded, you must destroy the buffer when you no longer need it using <code>vkDestroyBuffer()</code>. If you want to also destroy the corresponding allocation you can use convenience function <a class="el" href="group__group__alloc.html#ga0d9f4e4ba5bf9aab1f1c746387753d77" title="Destroys Vulkan buffer and frees allocated memory.">vmaDestroyBuffer()</a>. </p>
<p >If the function succeeded, you must destroy the buffer when you no longer need it using <code>vkDestroyBuffer()</code>. If you want to also destroy the corresponding allocation you can use convenience function <a class="el" href="group__group__alloc.html#ga0d9f4e4ba5bf9aab1f1c746387753d77" title="Destroys Vulkan buffer and frees allocated memory.">vmaDestroyBuffer()</a>.</p>
<dl class="section note"><dt>Note</dt><dd>There is a new version of this function augmented with parameter <code>allocationLocalOffset</code> - see <a class="el" href="group__group__alloc.html#gaf0cf014344213e117bd9f9cf5f928122" title="Creates a new VkBuffer, binds already created memory for it.">vmaCreateAliasingBuffer2()</a>. </dd></dl>
</div>
</div>
<a id="gaf0cf014344213e117bd9f9cf5f928122" name="gaf0cf014344213e117bd9f9cf5f928122"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf0cf014344213e117bd9f9cf5f928122">&#9670;&nbsp;</a></span>vmaCreateAliasingBuffer2()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">VkResult vmaCreateAliasingBuffer2 </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_vma_allocator.html">VmaAllocator</a>&#160;</td>
<td class="paramname"><em>allocator</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="struct_vma_allocation.html">VmaAllocation</a>&#160;</td>
<td class="paramname"><em>allocation</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">VkDeviceSize&#160;</td>
<td class="paramname"><em>allocationLocalOffset</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const VkBufferCreateInfo *&#160;</td>
<td class="paramname"><em>pBufferCreateInfo</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">VkBuffer *&#160;</td>
<td class="paramname"><em>pBuffer</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Creates a new <code>VkBuffer</code>, binds already created memory for it. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir"></td><td class="paramname">allocator</td><td></td></tr>
<tr><td class="paramdir"></td><td class="paramname">allocation</td><td>Allocation that provides memory to be used for binding new buffer to it. </td></tr>
<tr><td class="paramdir"></td><td class="paramname">allocationLocalOffset</td><td>Additional offset to be added while binding, relative to the beginning of the allocation. Normally it should be 0. </td></tr>
<tr><td class="paramdir"></td><td class="paramname">pBufferCreateInfo</td><td></td></tr>
<tr><td class="paramdir">[out]</td><td class="paramname">pBuffer</td><td>Buffer that was created.</td></tr>
</table>
</dd>
</dl>
<p>This function automatically:</p>
<ol type="1">
<li>Creates buffer.</li>
<li>Binds the buffer with the supplied memory.</li>
</ol>
<p >If any of these operations fail, buffer is not created, returned value is negative error code and <code>*pBuffer</code> is null.</p>
<p >If the function succeeded, you must destroy the buffer when you no longer need it using <code>vkDestroyBuffer()</code>. If you want to also destroy the corresponding allocation you can use convenience function <a class="el" href="group__group__alloc.html#ga0d9f4e4ba5bf9aab1f1c746387753d77" title="Destroys Vulkan buffer and frees allocated memory.">vmaDestroyBuffer()</a>.</p>
<dl class="section note"><dt>Note</dt><dd>This is a new version of the function augmented with parameter <code>allocationLocalOffset</code>. </dd></dl>
</div>
</div>
@ -1524,7 +1597,55 @@ Functions</h2></td></tr>
</table>
</div><div class="memdoc">
<p>Function similar to <a class="el" href="group__group__alloc.html#ga60d5d4803e3c82505a2bfddb929adb03" title="Creates a new VkBuffer, binds already created memory for it.">vmaCreateAliasingBuffer()</a>. </p>
<p>Function similar to <a class="el" href="group__group__alloc.html#ga60d5d4803e3c82505a2bfddb929adb03" title="Creates a new VkBuffer, binds already created memory for it.">vmaCreateAliasingBuffer()</a> but for images. </p>
</div>
</div>
<a id="ga69ac829f5bb0737449fa92c2d971f1bb" name="ga69ac829f5bb0737449fa92c2d971f1bb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga69ac829f5bb0737449fa92c2d971f1bb">&#9670;&nbsp;</a></span>vmaCreateAliasingImage2()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">VkResult vmaCreateAliasingImage2 </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_vma_allocator.html">VmaAllocator</a>&#160;</td>
<td class="paramname"><em>allocator</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="struct_vma_allocation.html">VmaAllocation</a>&#160;</td>
<td class="paramname"><em>allocation</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">VkDeviceSize&#160;</td>
<td class="paramname"><em>allocationLocalOffset</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const VkImageCreateInfo *&#160;</td>
<td class="paramname"><em>pImageCreateInfo</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">VkImage *&#160;</td>
<td class="paramname"><em>pImage</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Function similar to <a class="el" href="group__group__alloc.html#gaf0cf014344213e117bd9f9cf5f928122" title="Creates a new VkBuffer, binds already created memory for it.">vmaCreateAliasingBuffer2()</a> but for images. </p>
</div>
</div>
@ -1955,7 +2076,7 @@ Functions</h2></td></tr>
<table class="params">
<tr><td class="paramname">allocator</td><td>Allocator object. </td></tr>
<tr><td class="paramname">context</td><td>Context object that has been created by <a class="el" href="group__group__alloc.html#gac3335566858b45541fa9c0d7a6bbb57e" title="Begins defragmentation process.">vmaBeginDefragmentation()</a>. </td></tr>
<tr><td class="paramname">pPassInfo</td><td>Computed informations for current pass filled by <a class="el" href="group__group__alloc.html#ga980d7da2ce3b1fd5c8b8476bc362cc00" title="Starts single defragmentation pass.">vmaBeginDefragmentationPass()</a> and possibly modified by you.</td></tr>
<tr><td class="paramname">pPassInfo</td><td>Computed information for current pass filled by <a class="el" href="group__group__alloc.html#ga980d7da2ce3b1fd5c8b8476bc362cc00" title="Starts single defragmentation pass.">vmaBeginDefragmentationPass()</a> and possibly modified by you.</td></tr>
</table>
</dd>
</dl>
@ -2319,7 +2440,7 @@ Functions</h2></td></tr>
</div><div class="memdoc">
<p>Returns current information about specified allocation. </p>
<p >Current paramteres of given allocation are returned in <code>pAllocationInfo</code>.</p>
<p >Current parameters of given allocation are returned in <code>pAllocationInfo</code>.</p>
<p >Although this function doesn't lock any mutex, so it should be quite efficient, you should avoid calling it too often. You can retrieve same <a class="el" href="struct_vma_allocation_info.html" title="Parameters of VmaAllocation objects, that can be retrieved using function vmaGetAllocationInfo().">VmaAllocationInfo</a> structure while creating your resource, from function <a class="el" href="group__group__alloc.html#gac72ee55598617e8eecca384e746bab51" title="Creates a new VkBuffer, allocates and binds memory for it.">vmaCreateBuffer()</a>, <a class="el" href="group__group__alloc.html#ga02a94f25679275851a53e82eacbcfc73" title="Function similar to vmaCreateBuffer().">vmaCreateImage()</a>. You can remember it if you are sure parameters don't change (e.g. due to defragmentation). </p>
</div>