mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
synced 2024-11-22 15:04:34 +00:00
Version 2.0.0-alpha.6. Added VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT.
This commit is contained in:
parent
5268dbbce5
commit
c353ad0717
@ -41,10 +41,11 @@ Additional features:
|
||||
- Customization: Predefine appropriate macros to provide your own implementation of all external facilities used by the library, from assert, mutex, and atomic, to vector and linked list.
|
||||
- Support memory mapping, reference-counted internally. Support for for persistently mapped memory: Just allocate with appropriate flag and you get access to mapped pointer.
|
||||
- Custom memory pools: Create a pool with desired parameters (e.g. fixed or limited maximum size) and allocate memory out of it.
|
||||
- Support for VK_KHR_dedicated_allocation extension.
|
||||
- Support for VK_KHR_dedicated_allocation extension: Enable it and it will be used automatically by the library.
|
||||
- Defragmentation: Call one function and let the library move data around to free some memory blocks and make your allocations better compacted.
|
||||
- Lost allocations: Allocate memory with appropriate flags and let the library remove allocations that are not used for many frames to make room for new ones.
|
||||
- Statistics: Obtain detailed statistics about the amount of memory used, unused, number of allocated blocks, number of allocations etc. - globally, per memory heap, and per memory type.
|
||||
- Debug annotations: Associate string with name or opaque pointer to your own data with every allocation.
|
||||
- JSON dump: Obtain a string in JSON format with detailed map of internal state, including list of allocations and gaps between them.
|
||||
|
||||
# Prequisites
|
||||
|
Binary file not shown.
88
docs/html/allocation_annotation.html
Normal file
88
docs/html/allocation_annotation.html
Normal file
@ -0,0 +1,88 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://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.8.13"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>Vulkan Memory Allocator: Allocation names and user data</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.8.13 -->
|
||||
<script type="text/javascript">
|
||||
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
||||
</script>
|
||||
<script type="text/javascript" src="menudata.js"></script>
|
||||
<script type="text/javascript" src="menu.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
initMenu('',true,false,'search.php','Search');
|
||||
$(document).ready(function() { init_search(); });
|
||||
});
|
||||
</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 class="header">
|
||||
<div class="headertitle">
|
||||
<div class="title">Allocation names and user data </div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="textblock"><h1><a class="anchor" id="allocation_user_data"></a>
|
||||
Allocation user data</h1>
|
||||
<p>You can annotate allocations with your own information, e.g. for debugging purposes. To do that, fill <a class="el" href="struct_vma_allocation_create_info.html#a8259e85c272683434f4abb4ddddffe19" title="Custom general-purpose pointer that will be stored in VmaAllocation, can be read as VmaAllocationInfo...">VmaAllocationCreateInfo::pUserData</a> field when creating an allocation. It's an opaque <code>void*</code> pointer. You can use it e.g. as a pointer, some handle, index, key, ordinal number or any other value that would associate the allocation with your custom metadata.</p>
|
||||
<div class="fragment"><div class="line">VkBufferCreateInfo bufferInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };</div><div class="line"><span class="comment">// Fill bufferInfo...</span></div><div class="line"></div><div class="line">MyBufferMetadata* pMetadata = CreateBufferMetadata();</div><div class="line"></div><div class="line"><a class="code" href="struct_vma_allocation_create_info.html">VmaAllocationCreateInfo</a> allocCreateInfo = {};</div><div class="line">allocCreateInfo.<a class="code" href="struct_vma_allocation_create_info.html#accb8b06b1f677d858cb9af20705fa910">usage</a> = <a class="code" href="vk__mem__alloc_8h.html#aa5846affa1e9da3800e3e78fae2305ccac6b5dc1432d88647aa4cd456246eadf7">VMA_MEMORY_USAGE_GPU_ONLY</a>;</div><div class="line">allocCreateInfo.<a class="code" href="struct_vma_allocation_create_info.html#a8259e85c272683434f4abb4ddddffe19">pUserData</a> = pMetadata;</div><div class="line"></div><div class="line">VkBuffer buffer;</div><div class="line">VmaAllocation allocation;</div><div class="line"><a class="code" href="vk__mem__alloc_8h.html#ac72ee55598617e8eecca384e746bab51">vmaCreateBuffer</a>(allocator, &bufferInfo, &allocCreateInfo, &buffer, &allocation, <span class="keyword">nullptr</span>);</div></div><!-- fragment --><p>The pointer may be later retrieved as <a class="el" href="struct_vma_allocation_info.html#adc507656149c04de7ed95d0042ba2a13" title="Custom general-purpose pointer that was passed as VmaAllocationCreateInfo::pUserData or set using vma...">VmaAllocationInfo::pUserData</a>:</p>
|
||||
<div class="fragment"><div class="line"><a class="code" href="struct_vma_allocation_info.html">VmaAllocationInfo</a> allocInfo;</div><div class="line"><a class="code" href="vk__mem__alloc_8h.html#a86dd08aba8633bfa4ad0df2e76481d8b">vmaGetAllocationInfo</a>(allocator, allocation, &allocInfo);</div><div class="line">MyBufferMetadata* pMetadata = (MyBufferMetadata*)allocInfo.<a class="code" href="struct_vma_allocation_info.html#adc507656149c04de7ed95d0042ba2a13">pUserData</a>;</div></div><!-- fragment --><p>It can also be changed using function <a class="el" href="vk__mem__alloc_8h.html#af9147d31ffc11d62fc187bde283ed14f" title="Sets pUserData in given allocation to new value. ">vmaSetAllocationUserData()</a>.</p>
|
||||
<p>Values of (non-zero) allocations' <code>pUserData</code> are printed in JSON report created by <a class="el" href="vk__mem__alloc_8h.html#aa4fee7eb5253377599ef4fd38c93c2a0" title="Builds and returns statistics as string in JSON format. ">vmaBuildStatsString()</a>, in hexadecimal form.</p>
|
||||
<h1><a class="anchor" id="allocation_names"></a>
|
||||
Allocation names</h1>
|
||||
<p>There is alternative mode available where <code>pUserData</code> pointer is used to point to a null-terminated string, giving a name to the allocation. To use this mode, set <code>VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT</code> flag in <a class="el" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b" title="Use VmaAllocationCreateFlagBits enum. ">VmaAllocationCreateInfo::flags</a>. Then <code>pUserData</code> passed as <a class="el" href="struct_vma_allocation_create_info.html#a8259e85c272683434f4abb4ddddffe19" title="Custom general-purpose pointer that will be stored in VmaAllocation, can be read as VmaAllocationInfo...">VmaAllocationCreateInfo::pUserData</a> or argument to <a class="el" href="vk__mem__alloc_8h.html#af9147d31ffc11d62fc187bde283ed14f" title="Sets pUserData in given allocation to new value. ">vmaSetAllocationUserData()</a> must be either null or pointer to a null-terminated string. The library creates internal copy of the string, so the pointer you pass doesn't need to be valid for whole lifetime of the allocation. You can free it after the call.</p>
|
||||
<div class="fragment"><div class="line">VkImageCreateInfo imageInfo = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO };</div><div class="line"><span class="comment">// Fill imageInfo...</span></div><div class="line"></div><div class="line">std::string imageName = <span class="stringliteral">"Texture: "</span>;</div><div class="line">imageName += fileName;</div><div class="line"></div><div class="line"><a class="code" href="struct_vma_allocation_create_info.html">VmaAllocationCreateInfo</a> allocCreateInfo = {};</div><div class="line">allocCreateInfo.<a class="code" href="struct_vma_allocation_create_info.html#accb8b06b1f677d858cb9af20705fa910">usage</a> = <a class="code" href="vk__mem__alloc_8h.html#aa5846affa1e9da3800e3e78fae2305ccac6b5dc1432d88647aa4cd456246eadf7">VMA_MEMORY_USAGE_GPU_ONLY</a>;</div><div class="line">allocCreateInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> = <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597aa6f24f821cd6a7c5e4a443f7bf59c520">VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT</a>;</div><div class="line">allocCreateInfo.<a class="code" href="struct_vma_allocation_create_info.html#a8259e85c272683434f4abb4ddddffe19">pUserData</a> = imageName.c_str();</div><div class="line"></div><div class="line">VkImage image;</div><div class="line">VmaAllocation allocation;</div><div class="line"><a class="code" href="vk__mem__alloc_8h.html#a02a94f25679275851a53e82eacbcfc73">vmaCreateImage</a>(allocator, &imageInfo, &allocCreateInfo, &image, &allocation, <span class="keyword">nullptr</span>);</div></div><!-- fragment --><p>The value of <code>pUserData</code> pointer of the allocation will be different than the one you passed when setting allocation's name - pointing to a buffer managed internally that holds copy of the string.</p>
|
||||
<div class="fragment"><div class="line"><a class="code" href="struct_vma_allocation_info.html">VmaAllocationInfo</a> allocInfo;</div><div class="line"><a class="code" href="vk__mem__alloc_8h.html#a86dd08aba8633bfa4ad0df2e76481d8b">vmaGetAllocationInfo</a>(allocator, allocation, &allocInfo);</div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span>* imageName = (<span class="keyword">const</span> <span class="keywordtype">char</span>*)allocInfo.<a class="code" href="struct_vma_allocation_info.html#adc507656149c04de7ed95d0042ba2a13">pUserData</a>;</div><div class="line">printf(<span class="stringliteral">"Image name: %s\n"</span>, imageName);</div></div><!-- fragment --><p>That string is also printed in JSON report created by <a class="el" href="vk__mem__alloc_8h.html#aa4fee7eb5253377599ef4fd38c93c2a0" title="Builds and returns statistics as string in JSON format. ">vmaBuildStatsString()</a>. </p>
|
||||
</div></div><!-- contents -->
|
||||
<!-- start footer part -->
|
||||
<hr class="footer"/><address class="footer"><small>
|
||||
Generated by  <a href="http://www.doxygen.org/index.html">
|
||||
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
||||
</a> 1.8.13
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
@ -89,6 +89,9 @@ $(function() {
|
||||
<li>VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT
|
||||
: <a class="el" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a89759603401014eb325eb22a3839f2ff">vk_mem_alloc.h</a>
|
||||
</li>
|
||||
<li>VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT
|
||||
: <a class="el" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597aa6f24f821cd6a7c5e4a443f7bf59c520">vk_mem_alloc.h</a>
|
||||
</li>
|
||||
<li>VMA_ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT
|
||||
: <a class="el" href="vk__mem__alloc_8h.html#a4f87c9100d154a65a4ad495f7763cf7ca4816ddaed324ba110172ca608a20f29d">vk_mem_alloc.h</a>
|
||||
</li>
|
||||
|
@ -77,6 +77,9 @@ $(function() {
|
||||
<li>VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT
|
||||
: <a class="el" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a89759603401014eb325eb22a3839f2ff">vk_mem_alloc.h</a>
|
||||
</li>
|
||||
<li>VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT
|
||||
: <a class="el" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597aa6f24f821cd6a7c5e4a443f7bf59c520">vk_mem_alloc.h</a>
|
||||
</li>
|
||||
<li>VMA_ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT
|
||||
: <a class="el" href="vk__mem__alloc_8h.html#a4f87c9100d154a65a4ad495f7763cf7ca4816ddaed324ba110172ca608a20f29d">vk_mem_alloc.h</a>
|
||||
</li>
|
||||
|
@ -62,7 +62,7 @@ $(function() {
|
||||
<div class="title">Vulkan Memory Allocator </div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="textblock"><p><b>Version 2.0.0-alpha.5</b> (2017-11-08)</p>
|
||||
<div class="textblock"><p><b>Version 2.0.0-alpha.6</b> (2017-11-13)</p>
|
||||
<p>Copyright (c) 2017 Advanced Micro Devices, Inc. All rights reserved. <br />
|
||||
License: MIT</p>
|
||||
<p>Documentation of all members: <a class="el" href="vk__mem__alloc_8h.html">vk_mem_alloc.h</a></p>
|
||||
@ -74,6 +74,7 @@ License: MIT</p>
|
||||
<li><a class="el" href="custom_memory_pools.html">Custom memory pools</a></li>
|
||||
<li><a class="el" href="defragmentation.html">Defragmentation</a></li>
|
||||
<li><a class="el" href="lost_allocations.html">Lost allocations</a></li>
|
||||
<li><a class="el" href="allocation_annotation.html">Allocation names and user data</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="el" href="configuration.html">Configuration</a><ul>
|
||||
|
@ -1,5 +1,6 @@
|
||||
var searchData=
|
||||
[
|
||||
['allocation_20names_20and_20user_20data',['Allocation names and user data',['../allocation_annotation.html',1,'index']]],
|
||||
['allocationcount',['allocationCount',['../struct_vma_stat_info.html#a537741e4d5cdddc1c0ab95ec650afaff',1,'VmaStatInfo::allocationCount()'],['../struct_vma_pool_stats.html#ad1924eb54fffa45e9e0e65670c8fe5eb',1,'VmaPoolStats::allocationCount()']]],
|
||||
['allocationsizeavg',['allocationSizeAvg',['../struct_vma_stat_info.html#a1081a039964e566c672e7a2347f9e599',1,'VmaStatInfo']]],
|
||||
['allocationsizemax',['allocationSizeMax',['../struct_vma_stat_info.html#a17e9733a5ecd76287d4db6e66f71f50c',1,'VmaStatInfo']]],
|
||||
|
@ -25,6 +25,7 @@ var searchData=
|
||||
['vma_5fallocation_5fcreate_5fflag_5fbits_5fmax_5fenum',['VMA_ALLOCATION_CREATE_FLAG_BITS_MAX_ENUM',['../vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597ae5633ec569f4899cf8f29e7385b2f882',1,'vk_mem_alloc.h']]],
|
||||
['vma_5fallocation_5fcreate_5fmapped_5fbit',['VMA_ALLOCATION_CREATE_MAPPED_BIT',['../vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a11da372cc3a82931c5e5d6146cd9dd1f',1,'vk_mem_alloc.h']]],
|
||||
['vma_5fallocation_5fcreate_5fnever_5fallocate_5fbit',['VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT',['../vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a89759603401014eb325eb22a3839f2ff',1,'vk_mem_alloc.h']]],
|
||||
['vma_5fallocation_5fcreate_5fuser_5fdata_5fcopy_5fstring_5fbit',['VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT',['../vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597aa6f24f821cd6a7c5e4a443f7bf59c520',1,'vk_mem_alloc.h']]],
|
||||
['vma_5fallocator_5fcreate_5fexternally_5fsynchronized_5fbit',['VMA_ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT',['../vk__mem__alloc_8h.html#a4f87c9100d154a65a4ad495f7763cf7ca4816ddaed324ba110172ca608a20f29d',1,'vk_mem_alloc.h']]],
|
||||
['vma_5fallocator_5fcreate_5fflag_5fbits_5fmax_5fenum',['VMA_ALLOCATOR_CREATE_FLAG_BITS_MAX_ENUM',['../vk__mem__alloc_8h.html#a4f87c9100d154a65a4ad495f7763cf7cae4d5ad929caba5f23eb502b13bd5286c',1,'vk_mem_alloc.h']]],
|
||||
['vma_5fallocator_5fcreate_5fkhr_5fdedicated_5fallocation_5fbit',['VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT',['../vk__mem__alloc_8h.html#a4f87c9100d154a65a4ad495f7763cf7cace7da7cc6e71a625dfa763c55a597878',1,'vk_mem_alloc.h']]],
|
||||
|
@ -6,6 +6,7 @@ var searchData=
|
||||
['vma_5fallocation_5fcreate_5fflag_5fbits_5fmax_5fenum',['VMA_ALLOCATION_CREATE_FLAG_BITS_MAX_ENUM',['../vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597ae5633ec569f4899cf8f29e7385b2f882',1,'vk_mem_alloc.h']]],
|
||||
['vma_5fallocation_5fcreate_5fmapped_5fbit',['VMA_ALLOCATION_CREATE_MAPPED_BIT',['../vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a11da372cc3a82931c5e5d6146cd9dd1f',1,'vk_mem_alloc.h']]],
|
||||
['vma_5fallocation_5fcreate_5fnever_5fallocate_5fbit',['VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT',['../vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a89759603401014eb325eb22a3839f2ff',1,'vk_mem_alloc.h']]],
|
||||
['vma_5fallocation_5fcreate_5fuser_5fdata_5fcopy_5fstring_5fbit',['VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT',['../vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597aa6f24f821cd6a7c5e4a443f7bf59c520',1,'vk_mem_alloc.h']]],
|
||||
['vma_5fallocator_5fcreate_5fexternally_5fsynchronized_5fbit',['VMA_ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT',['../vk__mem__alloc_8h.html#a4f87c9100d154a65a4ad495f7763cf7ca4816ddaed324ba110172ca608a20f29d',1,'vk_mem_alloc.h']]],
|
||||
['vma_5fallocator_5fcreate_5fflag_5fbits_5fmax_5fenum',['VMA_ALLOCATOR_CREATE_FLAG_BITS_MAX_ENUM',['../vk__mem__alloc_8h.html#a4f87c9100d154a65a4ad495f7763cf7cae4d5ad929caba5f23eb502b13bd5286c',1,'vk_mem_alloc.h']]],
|
||||
['vma_5fallocator_5fcreate_5fkhr_5fdedicated_5fallocation_5fbit',['VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT',['../vk__mem__alloc_8h.html#a4f87c9100d154a65a4ad495f7763cf7cace7da7cc6e71a625dfa763c55a597878',1,'vk_mem_alloc.h']]],
|
||||
|
@ -1,5 +1,4 @@
|
||||
var searchData=
|
||||
[
|
||||
['configuration',['Configuration',['../configuration.html',1,'index']]],
|
||||
['custom_20memory_20pools',['Custom memory pools',['../custom_memory_pools.html',1,'index']]]
|
||||
['allocation_20names_20and_20user_20data',['Allocation names and user data',['../allocation_annotation.html',1,'index']]]
|
||||
];
|
||||
|
@ -1,4 +1,5 @@
|
||||
var searchData=
|
||||
[
|
||||
['defragmentation',['Defragmentation',['../defragmentation.html',1,'index']]]
|
||||
['configuration',['Configuration',['../configuration.html',1,'index']]],
|
||||
['custom_20memory_20pools',['Custom memory pools',['../custom_memory_pools.html',1,'index']]]
|
||||
];
|
||||
|
@ -1,4 +1,4 @@
|
||||
var searchData=
|
||||
[
|
||||
['lost_20allocations',['Lost allocations',['../lost_allocations.html',1,'index']]]
|
||||
['defragmentation',['Defragmentation',['../defragmentation.html',1,'index']]]
|
||||
];
|
||||
|
@ -1,4 +1,4 @@
|
||||
var searchData=
|
||||
[
|
||||
['memory_20mapping',['Memory mapping',['../memory_mapping.html',1,'index']]]
|
||||
['lost_20allocations',['Lost allocations',['../lost_allocations.html',1,'index']]]
|
||||
];
|
||||
|
@ -1,4 +1,4 @@
|
||||
var searchData=
|
||||
[
|
||||
['quick_20start',['Quick start',['../quick_start.html',1,'index']]]
|
||||
['memory_20mapping',['Memory mapping',['../memory_mapping.html',1,'index']]]
|
||||
];
|
||||
|
@ -1,4 +1,4 @@
|
||||
var searchData=
|
||||
[
|
||||
['thread_20safety',['Thread safety',['../thread_safety.html',1,'index']]]
|
||||
['quick_20start',['Quick start',['../quick_start.html',1,'index']]]
|
||||
];
|
||||
|
@ -1,5 +1,4 @@
|
||||
var searchData=
|
||||
[
|
||||
['vulkan_20memory_20allocator',['Vulkan Memory Allocator',['../index.html',1,'']]],
|
||||
['vk_5fkhr_5fdedicated_5fallocation',['VK_KHR_dedicated_allocation',['../vk_khr_dedicated_allocation.html',1,'index']]]
|
||||
['thread_20safety',['Thread safety',['../thread_safety.html',1,'index']]]
|
||||
];
|
||||
|
26
docs/html/search/pages_7.html
Normal file
26
docs/html/search/pages_7.html
Normal file
@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html><head><title></title>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta name="generator" content="Doxygen 1.8.13"/>
|
||||
<link rel="stylesheet" type="text/css" href="search.css"/>
|
||||
<script type="text/javascript" src="pages_7.js"></script>
|
||||
<script type="text/javascript" src="search.js"></script>
|
||||
</head>
|
||||
<body class="SRPage">
|
||||
<div id="SRIndex">
|
||||
<div class="SRStatus" id="Loading">Loading...</div>
|
||||
<div id="SRResults"></div>
|
||||
<script type="text/javascript"><!--
|
||||
createResults();
|
||||
--></script>
|
||||
<div class="SRStatus" id="Searching">Searching...</div>
|
||||
<div class="SRStatus" id="NoMatches">No Matches</div>
|
||||
<script type="text/javascript"><!--
|
||||
document.getElementById("Loading").style.display="none";
|
||||
document.getElementById("NoMatches").style.display="none";
|
||||
var searchResults = new SearchResults("searchResults");
|
||||
searchResults.Search();
|
||||
--></script>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
5
docs/html/search/pages_7.js
Normal file
5
docs/html/search/pages_7.js
Normal file
@ -0,0 +1,5 @@
|
||||
var searchData=
|
||||
[
|
||||
['vulkan_20memory_20allocator',['Vulkan Memory Allocator',['../index.html',1,'']]],
|
||||
['vk_5fkhr_5fdedicated_5fallocation',['VK_KHR_dedicated_allocation',['../vk_khr_dedicated_allocation.html',1,'index']]]
|
||||
];
|
@ -9,7 +9,7 @@ var indexSectionsWithContent =
|
||||
6: "v",
|
||||
7: "v",
|
||||
8: "v",
|
||||
9: "cdlmqtv"
|
||||
9: "acdlmqtv"
|
||||
};
|
||||
|
||||
var indexSectionNames =
|
||||
|
@ -196,6 +196,7 @@ Enumerations</h2></td></tr>
|
||||
<a class="el" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a5f436af6c8fe8540573a6d22627a6fd2">VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT</a> = 0x00000008,
|
||||
<br />
|
||||
  <a class="el" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a68686d0ce9beb0d4d1b9f2b8b1389a7e">VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT</a> = 0x00000010,
|
||||
<a class="el" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597aa6f24f821cd6a7c5e4a443f7bf59c520">VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT</a> = 0x00000020,
|
||||
<a class="el" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597ae5633ec569f4899cf8f29e7385b2f882">VMA_ALLOCATION_CREATE_FLAG_BITS_MAX_ENUM</a> = 0x7FFFFFFF
|
||||
<br />
|
||||
}<tr class="memdesc:ad9889c10c798b040d59c92f257cae597"><td class="mdescLeft"> </td><td class="mdescRight">Flags to be passed as <a class="el" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b" title="Use VmaAllocationCreateFlagBits enum. ">VmaAllocationCreateInfo::flags</a>. <a href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597">More...</a><br /></td></tr>
|
||||
@ -655,6 +656,8 @@ Functions</h2></td></tr>
|
||||
<tr><td class="fieldname"><a id="ad9889c10c798b040d59c92f257cae597a68686d0ce9beb0d4d1b9f2b8b1389a7e"></a>VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT </td><td class="fielddoc"><p>While creating allocation using this flag, other allocations that were created with flag <code>VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT</code> can become lost.</p>
|
||||
<p>For details about supporting lost allocations, see Lost Allocations chapter of User Guide on Main Page. </p>
|
||||
</td></tr>
|
||||
<tr><td class="fieldname"><a id="ad9889c10c798b040d59c92f257cae597aa6f24f821cd6a7c5e4a443f7bf59c520"></a>VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT </td><td class="fielddoc"><p>Set this flag to treat <a class="el" href="struct_vma_allocation_create_info.html#a8259e85c272683434f4abb4ddddffe19" title="Custom general-purpose pointer that will be stored in VmaAllocation, can be read as VmaAllocationInfo...">VmaAllocationCreateInfo::pUserData</a> as pointer to a null-terminated string. Instead of copying pointer value, a local copy of the string is made and stored in allocation's pUserData. The string is automatically freed together with the allocation. It is also used in <a class="el" href="vk__mem__alloc_8h.html#aa4fee7eb5253377599ef4fd38c93c2a0" title="Builds and returns statistics as string in JSON format. ">vmaBuildStatsString()</a>. </p>
|
||||
</td></tr>
|
||||
<tr><td class="fieldname"><a id="ad9889c10c798b040d59c92f257cae597ae5633ec569f4899cf8f29e7385b2f882"></a>VMA_ALLOCATION_CREATE_FLAG_BITS_MAX_ENUM </td><td class="fielddoc"></td></tr>
|
||||
</table>
|
||||
|
||||
@ -1815,6 +1818,8 @@ Functions</h2></td></tr>
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>Sets pUserData in given allocation to new value. </p>
|
||||
<p>If the allocation was created with VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT, pUserData must be either null, or pointer to a null-terminated string. The function makes local copy of the string and sets it as allocation's pUserData. String passed as pUserData doesn't need to be valid for whole lifetime of the allocation - you can free it after this call. String previously pointed by allocation's pUserData is freed from memory.</p>
|
||||
<p>If the flag was not used, the value of pointer pUserData is just copied to allocation's pUserData. It is opaque, so you can use it however you want - e.g. as a pointer, ordinal number or some handle to you own data. </p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
File diff suppressed because one or more lines are too long
@ -29,7 +29,7 @@ extern "C" {
|
||||
|
||||
/** \mainpage Vulkan Memory Allocator
|
||||
|
||||
<b>Version 2.0.0-alpha.5</b> (2017-11-08)
|
||||
<b>Version 2.0.0-alpha.6</b> (2017-11-13)
|
||||
|
||||
Copyright (c) 2017 Advanced Micro Devices, Inc. All rights reserved. \n
|
||||
License: MIT
|
||||
@ -44,6 +44,7 @@ Table of contents:
|
||||
- \subpage custom_memory_pools
|
||||
- \subpage defragmentation
|
||||
- \subpage lost_allocations
|
||||
- \subpage allocation_annotation
|
||||
- \subpage configuration
|
||||
- \subpage vk_khr_dedicated_allocation
|
||||
- \subpage thread_safety
|
||||
@ -382,6 +383,83 @@ The library uses following algorithm for allocation, in order:
|
||||
-# If failed, return `VK_ERROR_OUT_OF_DEVICE_MEMORY`.
|
||||
|
||||
|
||||
\page allocation_annotation Allocation names and user data
|
||||
|
||||
\section allocation_user_data Allocation user data
|
||||
|
||||
You can annotate allocations with your own information, e.g. for debugging purposes.
|
||||
To do that, fill VmaAllocationCreateInfo::pUserData field when creating
|
||||
an allocation. It's an opaque `void*` pointer. You can use it e.g. as a pointer,
|
||||
some handle, index, key, ordinal number or any other value that would associate
|
||||
the allocation with your custom metadata.
|
||||
|
||||
\code
|
||||
VkBufferCreateInfo bufferInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
|
||||
// Fill bufferInfo...
|
||||
|
||||
MyBufferMetadata* pMetadata = CreateBufferMetadata();
|
||||
|
||||
VmaAllocationCreateInfo allocCreateInfo = {};
|
||||
allocCreateInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY;
|
||||
allocCreateInfo.pUserData = pMetadata;
|
||||
|
||||
VkBuffer buffer;
|
||||
VmaAllocation allocation;
|
||||
vmaCreateBuffer(allocator, &bufferInfo, &allocCreateInfo, &buffer, &allocation, nullptr);
|
||||
\endcode
|
||||
|
||||
The pointer may be later retrieved as VmaAllocationInfo::pUserData:
|
||||
|
||||
\code
|
||||
VmaAllocationInfo allocInfo;
|
||||
vmaGetAllocationInfo(allocator, allocation, &allocInfo);
|
||||
MyBufferMetadata* pMetadata = (MyBufferMetadata*)allocInfo.pUserData;
|
||||
\endcode
|
||||
|
||||
It can also be changed using function vmaSetAllocationUserData().
|
||||
|
||||
Values of (non-zero) allocations' `pUserData` are printed in JSON report created by
|
||||
vmaBuildStatsString(), in hexadecimal form.
|
||||
|
||||
\section allocation_names Allocation names
|
||||
|
||||
There is alternative mode available where `pUserData` pointer is used to point to
|
||||
a null-terminated string, giving a name to the allocation. To use this mode,
|
||||
set `VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT` flag in VmaAllocationCreateInfo::flags.
|
||||
Then `pUserData` passed as VmaAllocationCreateInfo::pUserData or argument to
|
||||
vmaSetAllocationUserData() must be either null or pointer to a null-terminated string.
|
||||
The library creates internal copy of the string, so the pointer you pass doesn't need
|
||||
to be valid for whole lifetime of the allocation. You can free it after the call.
|
||||
|
||||
\code
|
||||
VkImageCreateInfo imageInfo = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO };
|
||||
// Fill imageInfo...
|
||||
|
||||
std::string imageName = "Texture: ";
|
||||
imageName += fileName;
|
||||
|
||||
VmaAllocationCreateInfo allocCreateInfo = {};
|
||||
allocCreateInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY;
|
||||
allocCreateInfo.flags = VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT;
|
||||
allocCreateInfo.pUserData = imageName.c_str();
|
||||
|
||||
VkImage image;
|
||||
VmaAllocation allocation;
|
||||
vmaCreateImage(allocator, &imageInfo, &allocCreateInfo, &image, &allocation, nullptr);
|
||||
\endcode
|
||||
|
||||
The value of `pUserData` pointer of the allocation will be different than the one
|
||||
you passed when setting allocation's name - pointing to a buffer managed
|
||||
internally that holds copy of the string.
|
||||
|
||||
\code
|
||||
VmaAllocationInfo allocInfo;
|
||||
vmaGetAllocationInfo(allocator, allocation, &allocInfo);
|
||||
const char* imageName = (const char*)allocInfo.pUserData;
|
||||
printf("Image name: %s\n", imageName);
|
||||
\endcode
|
||||
|
||||
That string is also printed in JSON report created by vmaBuildStatsString().
|
||||
|
||||
\page configuration Configuration
|
||||
|
||||
@ -851,6 +929,12 @@ typedef enum VmaAllocationCreateFlagBits {
|
||||
chapter of User Guide on Main Page.
|
||||
*/
|
||||
VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT = 0x00000010,
|
||||
/** Set this flag to treat VmaAllocationCreateInfo::pUserData as pointer to a
|
||||
null-terminated string. Instead of copying pointer value, a local copy of the
|
||||
string is made and stored in allocation's pUserData. The string is automatically
|
||||
freed together with the allocation. It is also used in vmaBuildStatsString().
|
||||
*/
|
||||
VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT = 0x00000020,
|
||||
|
||||
VMA_ALLOCATION_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} VmaAllocationCreateFlagBits;
|
||||
@ -1131,7 +1215,19 @@ void vmaGetAllocationInfo(
|
||||
VmaAllocation allocation,
|
||||
VmaAllocationInfo* pAllocationInfo);
|
||||
|
||||
/// Sets pUserData in given allocation to new value.
|
||||
/** \brief Sets pUserData in given allocation to new value.
|
||||
|
||||
If the allocation was created with VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT,
|
||||
pUserData must be either null, or pointer to a null-terminated string. The function
|
||||
makes local copy of the string and sets it as allocation's pUserData. String
|
||||
passed as pUserData doesn't need to be valid for whole lifetime of the allocation -
|
||||
you can free it after this call. String previously pointed by allocation's
|
||||
pUserData is freed from memory.
|
||||
|
||||
If the flag was not used, the value of pointer pUserData is just copied to
|
||||
allocation's pUserData. It is opaque, so you can use it however you want - e.g.
|
||||
as a pointer, ordinal number or some handle to you own data.
|
||||
*/
|
||||
void vmaSetAllocationUserData(
|
||||
VmaAllocator allocator,
|
||||
VmaAllocation allocation,
|
||||
@ -2946,6 +3042,11 @@ struct VmaAllocation_T
|
||||
private:
|
||||
static const uint8_t MAP_COUNT_FLAG_PERSISTENT_MAP = 0x80;
|
||||
|
||||
enum FLAGS
|
||||
{
|
||||
FLAG_USER_DATA_STRING = 0x01,
|
||||
};
|
||||
|
||||
public:
|
||||
enum ALLOCATION_TYPE
|
||||
{
|
||||
@ -2954,20 +3055,24 @@ public:
|
||||
ALLOCATION_TYPE_DEDICATED,
|
||||
};
|
||||
|
||||
VmaAllocation_T(uint32_t currentFrameIndex) :
|
||||
VmaAllocation_T(uint32_t currentFrameIndex, bool userDataString) :
|
||||
m_Alignment(1),
|
||||
m_Size(0),
|
||||
m_pUserData(VMA_NULL),
|
||||
m_LastUseFrameIndex(currentFrameIndex),
|
||||
m_Type((uint8_t)ALLOCATION_TYPE_NONE),
|
||||
m_SuballocationType((uint8_t)VMA_SUBALLOCATION_TYPE_UNKNOWN),
|
||||
m_MapCount(0)
|
||||
m_MapCount(0),
|
||||
m_Flags(userDataString ? (uint8_t)FLAG_USER_DATA_STRING : 0)
|
||||
{
|
||||
}
|
||||
|
||||
~VmaAllocation_T()
|
||||
{
|
||||
VMA_ASSERT((m_MapCount & ~MAP_COUNT_FLAG_PERSISTENT_MAP) == 0 && "Allocation was not unmapped before destruction.");
|
||||
|
||||
// Check if owned string was freed.
|
||||
VMA_ASSERT(m_pUserData == VMA_NULL);
|
||||
}
|
||||
|
||||
void InitBlockAllocation(
|
||||
@ -2978,7 +3083,6 @@ public:
|
||||
VkDeviceSize size,
|
||||
VmaSuballocationType suballocationType,
|
||||
bool mapped,
|
||||
void* pUserData,
|
||||
bool canBecomeLost)
|
||||
{
|
||||
VMA_ASSERT(m_Type == ALLOCATION_TYPE_NONE);
|
||||
@ -2986,7 +3090,6 @@ public:
|
||||
m_Type = (uint8_t)ALLOCATION_TYPE_BLOCK;
|
||||
m_Alignment = alignment;
|
||||
m_Size = size;
|
||||
m_pUserData = pUserData;
|
||||
m_MapCount = mapped ? MAP_COUNT_FLAG_PERSISTENT_MAP : 0;
|
||||
m_SuballocationType = (uint8_t)suballocationType;
|
||||
m_BlockAllocation.m_hPool = hPool;
|
||||
@ -3022,15 +3125,13 @@ public:
|
||||
VkDeviceMemory hMemory,
|
||||
VmaSuballocationType suballocationType,
|
||||
void* pMappedData,
|
||||
VkDeviceSize size,
|
||||
void* pUserData)
|
||||
VkDeviceSize size)
|
||||
{
|
||||
VMA_ASSERT(m_Type == ALLOCATION_TYPE_NONE);
|
||||
VMA_ASSERT(hMemory != VK_NULL_HANDLE);
|
||||
m_Type = (uint8_t)ALLOCATION_TYPE_DEDICATED;
|
||||
m_Alignment = 0;
|
||||
m_Size = size;
|
||||
m_pUserData = pUserData;
|
||||
m_SuballocationType = (uint8_t)suballocationType;
|
||||
m_MapCount = (pMappedData != VMA_NULL) ? MAP_COUNT_FLAG_PERSISTENT_MAP : 0;
|
||||
m_DedicatedAllocation.m_MemoryTypeIndex = memoryTypeIndex;
|
||||
@ -3041,8 +3142,9 @@ public:
|
||||
ALLOCATION_TYPE GetType() const { return (ALLOCATION_TYPE)m_Type; }
|
||||
VkDeviceSize GetAlignment() const { return m_Alignment; }
|
||||
VkDeviceSize GetSize() const { return m_Size; }
|
||||
bool IsUserDataString() const { return (m_Flags & FLAG_USER_DATA_STRING) != 0; }
|
||||
void* GetUserData() const { return m_pUserData; }
|
||||
void SetUserData(void* pUserData) { m_pUserData = pUserData; }
|
||||
void SetUserData(VmaAllocator hAllocator, void* pUserData);
|
||||
VmaSuballocationType GetSuballocationType() const { return (VmaSuballocationType)m_SuballocationType; }
|
||||
|
||||
VmaDeviceMemoryBlock* GetBlock() const
|
||||
@ -3102,6 +3204,7 @@ private:
|
||||
// Bit 0x80 is set when allocation was created with VMA_ALLOCATION_CREATE_MAPPED_BIT.
|
||||
// Bits with mask 0x7F, used only when ALLOCATION_TYPE_DEDICATED, are reference counter for vmaMapMemory()/vmaUnmapMemory().
|
||||
uint8_t m_MapCount;
|
||||
uint8_t m_Flags; // enum FLAGS
|
||||
|
||||
// Allocation out of VmaDeviceMemoryBlock.
|
||||
struct BlockAllocation
|
||||
@ -3127,6 +3230,8 @@ private:
|
||||
// Allocation for an object that has its own private VkDeviceMemory.
|
||||
DedicatedAllocation m_DedicatedAllocation;
|
||||
};
|
||||
|
||||
void FreeUserDataString(VmaAllocator hAllocator);
|
||||
};
|
||||
|
||||
/*
|
||||
@ -3722,6 +3827,7 @@ private:
|
||||
VmaSuballocationType suballocType,
|
||||
uint32_t memTypeIndex,
|
||||
bool map,
|
||||
bool isUserDataString,
|
||||
void* pUserData,
|
||||
VkBuffer dedicatedBuffer,
|
||||
VkImage dedicatedImage,
|
||||
@ -3856,6 +3962,7 @@ public:
|
||||
void ContinueString(const char* pStr);
|
||||
void ContinueString(uint32_t n);
|
||||
void ContinueString(uint64_t n);
|
||||
void ContinueString_Pointer(const void* ptr);
|
||||
void EndString(const char* pStr = VMA_NULL);
|
||||
|
||||
void WriteNumber(uint32_t n);
|
||||
@ -3992,6 +4099,12 @@ void VmaJsonWriter::ContinueString(const char* pStr)
|
||||
}
|
||||
else switch(ch)
|
||||
{
|
||||
case '\b':
|
||||
m_SB.Add("\\b");
|
||||
break;
|
||||
case '\f':
|
||||
m_SB.Add("\\f");
|
||||
break;
|
||||
case '\n':
|
||||
m_SB.Add("\\n");
|
||||
break;
|
||||
@ -4020,6 +4133,12 @@ void VmaJsonWriter::ContinueString(uint64_t n)
|
||||
m_SB.AddNumber(n);
|
||||
}
|
||||
|
||||
void VmaJsonWriter::ContinueString_Pointer(const void* ptr)
|
||||
{
|
||||
VMA_ASSERT(m_InsideString);
|
||||
m_SB.AddPointer(ptr);
|
||||
}
|
||||
|
||||
void VmaJsonWriter::EndString(const char* pStr)
|
||||
{
|
||||
VMA_ASSERT(m_InsideString);
|
||||
@ -4110,6 +4229,29 @@ void VmaJsonWriter::WriteIndent(bool oneLess)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void VmaAllocation_T::SetUserData(VmaAllocator hAllocator, void* pUserData)
|
||||
{
|
||||
if(IsUserDataString())
|
||||
{
|
||||
VMA_ASSERT(pUserData == VMA_NULL || pUserData != m_pUserData);
|
||||
|
||||
FreeUserDataString(hAllocator);
|
||||
|
||||
if(pUserData != VMA_NULL)
|
||||
{
|
||||
const char* const newStrSrc = (char*)pUserData;
|
||||
const size_t newStrLen = strlen(newStrSrc);
|
||||
char* const newStrDst = vma_new_array(hAllocator, char, newStrLen + 1);
|
||||
memcpy(newStrDst, newStrSrc, newStrLen + 1);
|
||||
m_pUserData = newStrDst;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pUserData = pUserData;
|
||||
}
|
||||
}
|
||||
|
||||
VkDeviceSize VmaAllocation_T::GetOffset() const
|
||||
{
|
||||
switch(m_Type)
|
||||
@ -4229,6 +4371,18 @@ bool VmaAllocation_T::MakeLost(uint32_t currentFrameIndex, uint32_t frameInUseCo
|
||||
}
|
||||
}
|
||||
|
||||
void VmaAllocation_T::FreeUserDataString(VmaAllocator hAllocator)
|
||||
{
|
||||
VMA_ASSERT(IsUserDataString());
|
||||
if(m_pUserData != VMA_NULL)
|
||||
{
|
||||
char* const oldStr = (char*)m_pUserData;
|
||||
const size_t oldStrLen = strlen(oldStr);
|
||||
vma_delete_array(hAllocator, oldStr, oldStrLen + 1);
|
||||
m_pUserData = VMA_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
VkResult VmaAllocation_T::DedicatedAllocMap(VmaAllocator hAllocator, void** ppData)
|
||||
{
|
||||
VMA_ASSERT(GetType() == ALLOCATION_TYPE_DEDICATED);
|
||||
@ -4588,6 +4742,25 @@ void VmaBlockMetadata::PrintDetailedMap(class VmaJsonWriter& json) const
|
||||
json.WriteString("Offset");
|
||||
json.WriteNumber(suballocItem->offset);
|
||||
|
||||
if(suballocItem->type != VMA_SUBALLOCATION_TYPE_FREE)
|
||||
{
|
||||
const void* pUserData = suballocItem->hAllocation->GetUserData();
|
||||
if(pUserData != VMA_NULL)
|
||||
{
|
||||
json.WriteString("UserData");
|
||||
if(suballocItem->hAllocation->IsUserDataString())
|
||||
{
|
||||
json.WriteString((const char*)pUserData);
|
||||
}
|
||||
else
|
||||
{
|
||||
json.BeginString();
|
||||
json.ContinueString_Pointer(pUserData);
|
||||
json.EndString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
json.EndObject();
|
||||
}
|
||||
json.EndArray();
|
||||
@ -5561,6 +5734,7 @@ VkResult VmaBlockVector::Allocate(
|
||||
VmaAllocation* pAllocation)
|
||||
{
|
||||
const bool mapped = (createInfo.flags & VMA_ALLOCATION_CREATE_MAPPED_BIT) != 0;
|
||||
const bool isUserDataString = (createInfo.flags & VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT) != 0;
|
||||
|
||||
VmaMutexLock lock(m_Mutex, m_hAllocator->m_UseMutex);
|
||||
|
||||
@ -5599,7 +5773,7 @@ VkResult VmaBlockVector::Allocate(
|
||||
m_HasEmptyBlock = false;
|
||||
}
|
||||
|
||||
*pAllocation = vma_new(m_hAllocator, VmaAllocation_T)(currentFrameIndex);
|
||||
*pAllocation = vma_new(m_hAllocator, VmaAllocation_T)(currentFrameIndex, isUserDataString);
|
||||
pCurrBlock->m_Metadata.Alloc(currRequest, suballocType, vkMemReq.size, *pAllocation);
|
||||
(*pAllocation)->InitBlockAllocation(
|
||||
hCurrentPool,
|
||||
@ -5609,10 +5783,10 @@ VkResult VmaBlockVector::Allocate(
|
||||
vkMemReq.size,
|
||||
suballocType,
|
||||
mapped,
|
||||
createInfo.pUserData,
|
||||
(createInfo.flags & VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT) != 0);
|
||||
VMA_HEAVY_ASSERT(pCurrBlock->Validate());
|
||||
VMA_DEBUG_LOG(" Returned from existing allocation #%u", (uint32_t)blockIndex);
|
||||
(*pAllocation)->SetUserData(m_hAllocator, createInfo.pUserData);
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
}
|
||||
@ -5665,7 +5839,7 @@ VkResult VmaBlockVector::Allocate(
|
||||
// Allocate from pBlock. Because it is empty, dstAllocRequest can be trivially filled.
|
||||
VmaAllocationRequest allocRequest;
|
||||
pBlock->m_Metadata.CreateFirstAllocationRequest(&allocRequest);
|
||||
*pAllocation = vma_new(m_hAllocator, VmaAllocation_T)(currentFrameIndex);
|
||||
*pAllocation = vma_new(m_hAllocator, VmaAllocation_T)(currentFrameIndex, isUserDataString);
|
||||
pBlock->m_Metadata.Alloc(allocRequest, suballocType, vkMemReq.size, *pAllocation);
|
||||
(*pAllocation)->InitBlockAllocation(
|
||||
hCurrentPool,
|
||||
@ -5675,11 +5849,10 @@ VkResult VmaBlockVector::Allocate(
|
||||
vkMemReq.size,
|
||||
suballocType,
|
||||
mapped,
|
||||
createInfo.pUserData,
|
||||
(createInfo.flags & VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT) != 0);
|
||||
VMA_HEAVY_ASSERT(pBlock->Validate());
|
||||
VMA_DEBUG_LOG(" Created new allocation Size=%llu", allocInfo.allocationSize);
|
||||
|
||||
(*pAllocation)->SetUserData(m_hAllocator, createInfo.pUserData);
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
}
|
||||
@ -5751,7 +5924,7 @@ VkResult VmaBlockVector::Allocate(
|
||||
m_HasEmptyBlock = false;
|
||||
}
|
||||
// Allocate from this pBlock.
|
||||
*pAllocation = vma_new(m_hAllocator, VmaAllocation_T)(currentFrameIndex);
|
||||
*pAllocation = vma_new(m_hAllocator, VmaAllocation_T)(currentFrameIndex, isUserDataString);
|
||||
pBestRequestBlock->m_Metadata.Alloc(bestRequest, suballocType, vkMemReq.size, *pAllocation);
|
||||
(*pAllocation)->InitBlockAllocation(
|
||||
hCurrentPool,
|
||||
@ -5761,10 +5934,10 @@ VkResult VmaBlockVector::Allocate(
|
||||
vkMemReq.size,
|
||||
suballocType,
|
||||
mapped,
|
||||
createInfo.pUserData,
|
||||
(createInfo.flags & VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT) != 0);
|
||||
VMA_HEAVY_ASSERT(pBlock->Validate());
|
||||
VMA_DEBUG_LOG(" Returned from existing allocation #%u", (uint32_t)blockIndex);
|
||||
(*pAllocation)->SetUserData(m_hAllocator, createInfo.pUserData);
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
// else: Some allocations must have been touched while we are here. Next try.
|
||||
@ -6579,6 +6752,7 @@ VkResult VmaAllocator_T::AllocateMemoryOfType(
|
||||
suballocType,
|
||||
memTypeIndex,
|
||||
(finalCreateInfo.flags & VMA_ALLOCATION_CREATE_MAPPED_BIT) != 0,
|
||||
(finalCreateInfo.flags & VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT) != 0,
|
||||
finalCreateInfo.pUserData,
|
||||
dedicatedBuffer,
|
||||
dedicatedImage,
|
||||
@ -6611,6 +6785,7 @@ VkResult VmaAllocator_T::AllocateMemoryOfType(
|
||||
suballocType,
|
||||
memTypeIndex,
|
||||
(finalCreateInfo.flags & VMA_ALLOCATION_CREATE_MAPPED_BIT) != 0,
|
||||
(finalCreateInfo.flags & VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT) != 0,
|
||||
finalCreateInfo.pUserData,
|
||||
dedicatedBuffer,
|
||||
dedicatedImage,
|
||||
@ -6636,6 +6811,7 @@ VkResult VmaAllocator_T::AllocateDedicatedMemory(
|
||||
VmaSuballocationType suballocType,
|
||||
uint32_t memTypeIndex,
|
||||
bool map,
|
||||
bool isUserDataString,
|
||||
void* pUserData,
|
||||
VkBuffer dedicatedBuffer,
|
||||
VkImage dedicatedImage,
|
||||
@ -6690,8 +6866,9 @@ VkResult VmaAllocator_T::AllocateDedicatedMemory(
|
||||
}
|
||||
}
|
||||
|
||||
*pAllocation = vma_new(this, VmaAllocation_T)(m_CurrentFrameIndex.load());
|
||||
(*pAllocation)->InitDedicatedAllocation(memTypeIndex, hMemory, suballocType, pMappedData, size, pUserData);
|
||||
*pAllocation = vma_new(this, VmaAllocation_T)(m_CurrentFrameIndex.load(), isUserDataString);
|
||||
(*pAllocation)->InitDedicatedAllocation(memTypeIndex, hMemory, suballocType, pMappedData, size);
|
||||
(*pAllocation)->SetUserData(this, pUserData);
|
||||
|
||||
// Register it in m_pDedicatedAllocations.
|
||||
{
|
||||
@ -6915,6 +7092,7 @@ void VmaAllocator_T::FreeMemory(const VmaAllocation allocation)
|
||||
}
|
||||
}
|
||||
|
||||
allocation->SetUserData(this, VMA_NULL);
|
||||
vma_delete(this, allocation);
|
||||
}
|
||||
|
||||
@ -7204,7 +7382,7 @@ void VmaAllocator_T::MakePoolAllocationsLost(
|
||||
|
||||
void VmaAllocator_T::CreateLostAllocation(VmaAllocation* pAllocation)
|
||||
{
|
||||
*pAllocation = vma_new(this, VmaAllocation_T)(VMA_FRAME_INDEX_LOST);
|
||||
*pAllocation = vma_new(this, VmaAllocation_T)(VMA_FRAME_INDEX_LOST, false);
|
||||
(*pAllocation)->InitLost();
|
||||
}
|
||||
|
||||
@ -7905,7 +8083,7 @@ void vmaSetAllocationUserData(
|
||||
|
||||
VMA_DEBUG_GLOBAL_MUTEX_LOCK
|
||||
|
||||
allocation->SetUserData(pUserData);
|
||||
allocation->SetUserData(allocator, pUserData);
|
||||
}
|
||||
|
||||
void vmaCreateLostAllocation(
|
||||
|
Loading…
Reference in New Issue
Block a user