From dedab850e9150093c65e8473ae3c8356a24f2638 Mon Sep 17 00:00:00 2001 From: Adam Sawicki Date: Thu, 23 Aug 2018 15:00:58 +0200 Subject: [PATCH] Documented linear allocation algorithm. Added "Linear allocation algorithm" documentation chapter. --- docs/gfx/Linear_allocator_1_algo_default.png | Bin 0 -> 1264 bytes docs/gfx/Linear_allocator_2_algo_linear.png | Bin 0 -> 1989 bytes docs/gfx/Linear_allocator_3_free_at_once.png | Bin 0 -> 5205 bytes docs/gfx/Linear_allocator_4_stack.png | Bin 0 -> 3356 bytes docs/gfx/Linear_allocator_5_ring_buffer.png | Bin 0 -> 2246 bytes .../Linear_allocator_6_ring_buffer_lost.png | Bin 0 -> 2666 bytes docs/gfx/Linear_allocator_7_double_stack.png | Bin 0 -> 1595 bytes docs/html/custom_memory_pools.html | 52 +++- docs/html/debugging_memory_usage.html | 4 +- docs/html/globals.html | 6 + docs/html/globals_eval.html | 6 + docs/html/index.html | 9 +- docs/html/search/all_f.js | 2 + docs/html/search/enumvalues_0.js | 2 + docs/html/struct_vma_pool_create_info.html | 6 +- docs/html/usage_patterns.html | 6 +- docs/html/vk__mem__alloc_8h.html | 21 +- docs/html/vk__mem__alloc_8h_source.html | 238 +++++++++--------- src/vk_mem_alloc.h | 111 +++++++- 19 files changed, 320 insertions(+), 143 deletions(-) create mode 100644 docs/gfx/Linear_allocator_1_algo_default.png create mode 100644 docs/gfx/Linear_allocator_2_algo_linear.png create mode 100644 docs/gfx/Linear_allocator_3_free_at_once.png create mode 100644 docs/gfx/Linear_allocator_4_stack.png create mode 100644 docs/gfx/Linear_allocator_5_ring_buffer.png create mode 100644 docs/gfx/Linear_allocator_6_ring_buffer_lost.png create mode 100644 docs/gfx/Linear_allocator_7_double_stack.png diff --git a/docs/gfx/Linear_allocator_1_algo_default.png b/docs/gfx/Linear_allocator_1_algo_default.png new file mode 100644 index 0000000000000000000000000000000000000000..e3e8f47c1b4730e6bac2778016fe1030e656c771 GIT binary patch literal 1264 zcmeAS@N?(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2_algo_linear.png new file mode 100644 index 0000000000000000000000000000000000000000..c2a38b2e8140e12baf9e4706259d3259737553bd GIT binary patch literal 1989 zcmb_d`#0O!7C#{+R7DvSt?1OFWtwU+^yO8-x2TqSR*6y6V@iWYMU!Cka;K4^W2zLb zN5>#}R zRbLeVumf^;@c{tlD39Y2N^)2q{V`J+N_-}q}MmdZ=dtnamBS}FT;FuzsU#pY(V?uV9p z;aip%Sp?=-P2easxh82>$-Bmzna%uC-4vC_L8Mwx)!Ere+qP|6?OSRXVLlKVdQ@IyQbv@v3i#R2Wseib;+i%j za~tbhqV<=;R$uXJUx#OsPxYkYxJ9kSXKN$V4YKr0sP>q={x-d@PT%x}g8Qo!cTZF08v8a}L*|wBzLRt+nin0o8}PDl#{T z7t=RV1QJYVXRGvcxJfxFG@ldAevT|Gtbff9Xj+-`o?Cq{usPCWRxS(9%CdRaDtz*A zXpqwXYHWk7se)$y*!=R}z{78U{@KWgN>{@)_e!MwY!JQx@|%BGeJQ2w=BjArIb&XO zF^MvBAioh!6VATMwiVpDa8`qP81!cWDF-jB`J*q>PKj(`L~fb-rn^X|ItP{b=RR_f z^QluEtfsotDig{fD+p}SY!7maBqoS4a*XLp@Cc5-w0?~uAa&1(ODES@y4&;03q4O; z=uYnfIHoqXsCiwqe4>adp~)l>+GSSDZ;vyg;E9G`a>CAeQ~S!&eQG~_0%ri$UWPdF zk91a3SDT+Ma*vN`vD(Bg@bQIq1=8#nRePeDH_@QGmRpkbAB}dkcg(LX$O*!#h6BS= z;cm7Bc5N>?s1LtrN+e@awTwMJu?=iw^DQ5;PcR3sb{yPyJ0S!XRlHo}59@8hVjZ)~ zOFA~RuvQAG+f0> zed7ib`8xvEewY|TX7g#Uj!((qYH)}$? zSFe!9k@6L^AMiR5Kha93Cz%awNimVr5Bk}ZN@CnJjg}IDA4?J8PW52AR|?wOFIZUw z)Z9c7=5Gn4ZEjS59h5_;%@fj=KsNI9=~DwUGcyZa`;$7}5X z@!IZ3{=66{!Zhl3m8a>XXtZM)S+lAP0K;$guJK}%HjHtE9>lAv65KO{gQbPFf)I#g za}oijhE<_xYb^#0;+O1E21_#m1+H=!0};4+ir~w#8JD?8B5lT8+YLC>Iph2MHN{=O zCfC0x21bX1jZIcIKxct^$!=A!^jB4vILTzg!-q2-0yKUzhjgbr&D%!j^W3yb7W4sZ&yU?|A?V z{23_xt^L5@qL($wpr|1E*t4FirT)W7?rCAXLte<{(VdQr zoy}%T%@p&hu%%&Z`-+EgA{pgW&_5X|H|GH?4_%whOUQM20 wCfr)EKited+};t1FdDC<(_c)j!Y#cw746Lp`q6s@EnhnTVa~WTI%6~c22CrUt^fc4 literal 0 HcmV?d00001 diff --git a/docs/gfx/Linear_allocator_3_free_at_once.png b/docs/gfx/Linear_allocator_3_free_at_once.png new file mode 100644 index 0000000000000000000000000000000000000000..a000ad569aa8f08d89ceec469be7d2355e6d93b0 GIT binary patch literal 5205 zcmc&%cTiK`wmuXA3j#kynvfWpg2I(z=me>usdQ;UK@gB4MS92&!~)U+QUnr85CI8I zqoDv=KC=p@m5@8?W8xeIa>;@1O6{X@I92o9>E%b&;NSI&IlAa_093#U`j2xni=@W6$ z4(lbojDf;J7z}doo|PS!@@db`NRa8!9m@0szIK4%7NK3OTcZ2e>G z)k+hXms=o3sxFh@$h;!P{G#G`R%MdAsr<+(F&hg3;-}&rZ#89KUvPeS{~v4QAIj=7 zpq&%m;ind(UKrm0!@<#!$lYKVwY4@srJ>Ku7R$kr$#f;QFj#WK!|73S?ZG|(uaW}%#tl%w*o#D{S||1MoRSO{2hX{1 zb8+;uneS+OT++Uy$OZdUGu`x0m+jTBNJ}TDCrEG5rE1Q(J*5RA;w~wctUb?`m_%+v zhKH;N8+$uynwpsDpO$;1@@w$HZP`Jx(IQ`Y0MwbEM}9cL|FB-~PFV$LzYp@vTT8h# z9wo0o^R=aY2r@5ZfKSZ91sUK$S`R|`LW#KM+$}!Fn5z6vJI+w%#|1bXYN_KqX+HQ^ z;}ZEK92?yhT)$&PPC+AQ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!*>Xg(B_RlYQaNmP+;uKYF#` zVwSNsWW^o@9sp}Izrm!VkLq`Z0pbk=S}m7}MG95Aj0=2|R~YqD01O0*zzEg1PjXo8SZ~pd!=dKu>jbb!{G_-47XE6GZNGty5eeT z+HIYqJ_`2TUv#JFTZi?4Zg(kot1o_!c|Jbr>Ee3}NE3#ElWUs?kfWm`*w}>=uiAG) zy~kf2ta=0d+p+y`&~;l20e8P(^ecM^^p^9zqdn)0fxnMrV4|n}eEDHu0dND>LT)9O z*5YO}@Uvy<=vVdsQtxIVilue$9PtkfEb`hHi|g~cI(of)d+`25lETgN{{rbhk6bj( ztU~wL!!Dku{9OA%gW0zEFS^!*0k5}dXoJVU3S@YJB!|=0W_GPO(s{kZ0PliQ<@B6o z?8x$2K=>InH#v8`Hz7pQ<(W`GL5ulf5yMYr^PU z3%OleyVJg0UiS;+5_V`(k&BJ>5)!2y$mf&stAELk^Lf20kQ0;|DP37%9!dWpIi>=P z-|G!OWCu{UHqhg&}lrJt(T6yDcHk})0jb2#Dxa=_@a?hM|wmYEGFd`PE SZjiDs6S%3Z3I3v2(tiLI*O~eN literal 0 HcmV?d00001 diff --git a/docs/gfx/Linear_allocator_4_stack.png b/docs/gfx/Linear_allocator_4_stack.png new file mode 100644 index 0000000000000000000000000000000000000000..4dba064b48c12f9b08ff9b568b1acd70304b573a GIT binary patch literal 3356 zcmcInXIK;I7ETBRkm5=UML;A(1%pVjAT5Ys6c8zk7$G1fQbP$uN+6(ubd(|p7+jGe zQWT_zD$>gm6zNDuN+`xeA#lfi?vMR(_s@Oqoo8mgnKNh3eC53FdnVe<)JWifVQ9w=~b*3Q!h8csibv?UL)h445%1nzmgFWdNmK>T9A4)9vXpYwoG zf^g{u!2<6>AUgOugNQ_;va6T7pQD4fvohWnm$|Mb33z9q4N#VMv(_eTJyQLjHEq(* zi@esu#a3LpBYx+BY9vp|@zn>}k~kPHGu=PnIw#ap{IjjZLKojLcYauj;VBgxe*$xQ z)#EGQS50udQlvt1{JDF_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_5_ring_buffer.png new file mode 100644 index 0000000000000000000000000000000000000000..0686702ac2ceb6991eed14955c709200d5c0d41b GIT binary patch literal 2246 zcmbuBhgXxy7Qnxdm_+KLAQA-BL;{FN53GbJEd(%P1OYJyAEMz<66wtt*aa*sU|2wU zk@7^E2!>wdf$%^gy+l})fcQiclup3+`Tm4`bI#1%x#ynW%)K*nXYMIK~3)A%p@D1|1&h*x01m4R2YK{T`q!r2foO5{2ml=j1)myb=Md;r= ze842Px$d)pNv{b;V#M0c!D+c?cq>8iidAV>!OK+2`MJ3JLrTkvEqZevslzFUX+AF> z-;>H8Gjya6V=1#8ZjG zXSM2PI{FO!qu}99j{GVKxRaz7LX6xrC`q1^u8~=SCS`>4U0wn9$HpXhkTOkwSWpKy zh5+S39USUrw7r0mw^?i@O)99~#k`M_Z&)$lx^_z!IPV`!oO5khMINGUDYu*HvneH- zwjvA(c7ZAoD$R4FLeKOFe;BYSC$wytv4Y_6DtU7p3zz2IR1PxjN2~+4f1N-svW1>v z-55v(v+-(DSAtxE8ancOn>vVoohz#}zj35Tc;Ik{WJdo&gRpI9vd-sVGGWgY6a$tX z6&V>CcD?lHFD)(2-N)uV&fj%1SGDNeLes^%*&uOkZOvRP>Pk#Z)YH@JpoY!ZgoWYG zgnh+izlm2njdHzud!HPB^%r8Y+Cm>TU+}eASlZm2O>GX<$K$DOaoMB~p*b(m;Q`_R z-M^4y1As0-rBaJWe1Ig?Gd(d-#N=}?L^h65T2_|O8nrb} zypEVM*+jL7-;ro9ro`&DZSAhEuFmoNtgNOvUhS05R&?H-o%NyF z*=u8v=!G;_(?Ee;%^D$q;CTN0Bi_fp8wP%pHHCE$m|f~S{)UPto=Nq=siQ#_pUaSY z8LFFsPVLjvzr7CiQaXKYpw_#e?(6%6%gy*)^=uFQAqJs_{AuJxr!Tea9LpsK@%_0& ze189b#-8=pn7)OI?+d7EgrjDvtV0dutNq=tz_4aI#vjCzfg1YI@vQ7@_ZK&1z`4rm z>(jDOrxykj@KNhx24Qq!Vq|pmU(@xzpT2x4sjU3NS=%Kq?%~RgYF{fWA8WQd!St7OI8*J@FT@$vBS3iqz@N{^{pZ-=c7tGwhM zxxqFKI_z{Ncx0yh(n0&CrY3qofGnO|2L^0rW+pf!WN38Mi16^5Cd;OOOD~qTFRv4M z4Fh$1527PPod~OB`PQBu+wJY`MMmd8#CeP2m6Has8Ql+wloG8TA-6-lfhm5F&f9Ch z$U*LvRgAbOLN#4D5~4et%`fnP%z0rYZ10|YiyhplTwz~<`lhjxQhSjhdehjmws^$l z1ZW)l;bgnRAGC}5u|G5-PS9b5bjY8UCwqjhn2B$?#w;6K=Ad+e!f@kCbGl>;5&E$>8_lX)=KAz0 zRXYR%3Yd=M3_t-32^Y4y3=E7SGOtHYdweu*pJnYtQl3WFtd*5jONI_yaMVF?ya-pr z(j`(*M~s$KjzZeAm?s#B7%}UirFHy_oyE&i zAO~g=r%L23@_aEXCt14|%cdM7f(5jtYYHO9vb29IMv7x!%)0`!h&Cmr21&aaHTR3U zjAx9X`W45y-UNCuhrlMrD89E%HBzcCM7VXp*@xzkA{<8!E0z*L-a3AJAAcI2P3HWY zjuUlH-KCMfmCJE1%`+t0rS<>Byx|%`HGN`4R4Go8H*mtHAFzJ_ZlA&_sHWBxxD%yL zx}cb@e3mq1!2UZ1EM2CLAm%OvVFkv4gCRAgI4?o8J18IyIP|8w?TH#_1G^^DDtAPCFp1`ty?M%l^3y?a4bE& z=q7M$Y-~Xie4An`a(PiWjzTOk@Bdlv-}d-274)lnM~EB0VXy(ef>)$dwF2PG@lPW% jPbaQ@M&jd(BUWiGu{N-^#z)rRp93J-kgcmMJ!Ah1p&A;> literal 0 HcmV?d00001 diff --git a/docs/gfx/Linear_allocator_6_ring_buffer_lost.png b/docs/gfx/Linear_allocator_6_ring_buffer_lost.png new file mode 100644 index 0000000000000000000000000000000000000000..9a2338cd33056fa66f4713ba7a9bc5938fb2f6ef GIT binary patch literal 2666 zcmcgui96JL7yk`nFv?6O`!X{UnJn3*h{;x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56JG7nclz#*U6iFbWiXRbs}UkF%SvBFdv HyA%HdL^aSq literal 0 HcmV?d00001 diff --git a/docs/gfx/Linear_allocator_7_double_stack.png b/docs/gfx/Linear_allocator_7_double_stack.png new file mode 100644 index 0000000000000000000000000000000000000000..77d1468b7f7ffb8c48b29726e75cca04645fc48b GIT binary patch literal 1595 zcma)6iBr;f6#t&-fR@frg`@`c90r4%6TE{H zj!{Snw6HiLK%>!Yqhij-hlf##wv@QY(pl#%0HF5F*UN*DTsAW#_bW(2!RD9BNAI5e zQ!_GVih&>T-(kbAIO8>TO3S8JQ@8s?k?HEr=QW-U*_O=E_M~t`{X#}eb?#t#5O(uq z#vf0Vs8@T0W3joCy2WYfOYgEYB;)2IXW3W!nc{f58)k8McotUra_s9r9?W#<1$14GxFI)&utUvWmNWqw~;iF??dRppX0x4J~cXl?0Kp@!PIB^*2(KbGAIV*3? zBUoi69MCT4$z-$jF1&w|Gg0l5vKTry+?;)|BKiBu-mb2$P=S=Xwj7&4qg6CDl}$L? z+*GkP<+)z&Xiiz8e(ut?wzKm@Ku6;0JLJM>*)ubHmb`>ox zXz(?-OxML}YF2Ifh}=%<#||}rJpR-7)g>`WAa5ET>*wjgq5C3Wfygj>qsL&zXZ{>> zYa5%esHhDA<<9LzHYcg$uT0CF;?)Za3ytd-91@8{U0=I6@0|DM&6^*6?Q=^Mu})8f zK9NYwC)QI#EDCmvAacA2JXJp>g%9=NKz%v+{hQ_}Z{tv~8+cej&+Ye-7>>C?`GmoF zLsWO#XUCF0(x_ego9uE(QEE|<;qvz@^yPVoFy=$YyLU!Vk5o(M6dD|;US$C9+5kDC zMKmK5wyq>d$qxL6hApcv{|yNplCPs;b~wI1mUZB;BOCv3!91 zT%jd1r?hUlaF)vIm?uvly38~v9BtaON4EOZ(R9r;AtvRjQ z|J9K;i)v_SC}~;aa=GoVUn92|8^?}_^~xM$RSa{pq~Gqmh!KV-CmV@GqLT7*+Y$TS zyVF@Lox4u{0Rb6f7ajKP<5yK_UcP);iI(f~RS0RLqoh+!$$HWYhItsbgZoN}D{Zod z#GSK4^{SPFJ=6Ys&qYPG-|;Kfa1z(OaDe4@rZ>{&_%$^wDfibyYWK`8HKQ527}Ay5 zmp8Cn-hGmBp{V9`V+rqm;^f*h76R9z`u~4@5gO3XQFl&REH%?KFIWIlgQriF_|GAw z9-NjnPR&uF2YbCvKd^Q`1;zXzAB@5Rp;y);Zy%M=8@IE`05A?xfXf;)^FMe}arR}n VRb}Em0UacIz}Fk^Rf7vn{}=d`=^Ow6 literal 0 HcmV?d00001 diff --git a/docs/html/custom_memory_pools.html b/docs/html/custom_memory_pools.html index fed21c8..9f72b3f 100644 --- a/docs/html/custom_memory_pools.html +++ b/docs/html/custom_memory_pools.html @@ -78,7 +78,7 @@ $(function() {
  1. Fill VmaPoolCreateInfo structure.
  2. Call vmaCreatePool() to obtain VmaPool handle.
  3. -
  4. When making an allocation, set VmaAllocationCreateInfo::pool to this handle. You don't need to specify any other parameters of this structure, like usage.
  5. +
  6. When making an allocation, set VmaAllocationCreateInfo::pool to this handle. You don't need to specify any other parameters of this structure, like usage.

Example:

// Create a pool that can have at most 2 blocks, 128 MiB each.
VmaPoolCreateInfo poolCreateInfo = {};
poolCreateInfo.memoryTypeIndex = ...
poolCreateInfo.blockSize = 128ull * 1024 * 1024;
poolCreateInfo.maxBlockCount = 2;
VmaPool pool;
vmaCreatePool(allocator, &poolCreateInfo, &pool);
// Allocate a buffer out of it.
VkBufferCreateInfo bufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
bufCreateInfo.size = 1024;
bufCreateInfo.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
VmaAllocationCreateInfo allocCreateInfo = {};
allocCreateInfo.pool = pool;
VkBuffer buf;
vmaCreateBuffer(allocator, &bufCreateInfo, &allocCreateInfo, &buf, &alloc, &allocInfo);

You have to free all allocations made from this pool before destroying it.

@@ -88,9 +88,55 @@ Choosing memory type index
VkBufferCreateInfo exampleBufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
exampleBufCreateInfo.size = 1024; // Whatever.
exampleBufCreateInfo.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT; // Change if needed.
VmaAllocationCreateInfo allocCreateInfo = {};
allocCreateInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY; // Change if needed.
uint32_t memTypeIndex;
vmaFindMemoryTypeIndexForBufferInfo(allocator, &exampleBufCreateInfo, &allocCreateInfo, &memTypeIndex);
VmaPoolCreateInfo poolCreateInfo = {};
poolCreateInfo.memoryTypeIndex = memTypeIndex;
// ...

When creating buffers/images allocated in that pool, provide following parameters:

  • VkBufferCreateInfo: Prefer to pass same parameters as above. Otherwise you risk creating resources in a memory type that is not suitable for them, which may result in undefined behavior. Using different VK_BUFFER_USAGE_ flags may work, but you shouldn't create images in a pool intended for buffers or the other way around.
  • -
  • VmaAllocationCreateInfo: You don't need to pass same parameters. Fill only pool member. Other members are ignored anyway.
  • +
  • VmaAllocationCreateInfo: You don't need to pass same parameters. Fill only pool member. Other members are ignored anyway.
- +

+Linear allocation algorithm

+

Each Vulkan memory block managed by this library has accompanying metadata that keeps track of used and unused regions. By default, the metadata structure and algorithm tries to find best place for new allocations among free regions to optimize memory usage. This way you can allocate and free objects in any order.

+
+Default allocation algorithm +
+

Sometimes there is a need to use simpler, linear allocation algorithm. You can create custom pool that uses such algorithm by adding flag VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT to VmaPoolCreateInfo::flags while creating VmaPool object. Then an alternative metadata management is used. It always creates new allocations after last one and doesn't reuse free regions after allocations freed in the middle. It results in better allocation performance and less memory consumed by metadata.

+
+Linear allocation algorithm +
+

With this one flag, you can create a custom pool that can be used in many ways: free-at-once, stack, double stack, and ring buffer. See below for details.

+

Pools with linear algorithm must have only one memory block - VmaPoolCreateInfo::maxBlockCount must be 1.

+

+Free-at-once

+

In a pool that uses linear algorithm, you still need to free all the allocations individually, e.g. by using vmaFreeMemory() or vmaDestroyBuffer(). You can free them in any order. New allocations are always made after last one - free space in the middle is not reused. However, when you release all the allocation and the pool becomes empty, allocation starts from the beginning again. This way you can use linear algorithm to speed up creation of allocations that you are going to release all at once.

+
+Free-at-once +
+

+Stack

+

When you free an allocation that was created last, its space can be reused. Thanks to this, if you always release allocations in the order opposite to their creation (LIFO - Last In First Out), you can achieve behavior of a stack.

+
+Stack +
+

+Double stack

+

The space reserved by a custom pool with linear algorithm may be used by two stacks:

+
    +
  • First, default one, growing up from offset 0.
  • +
  • Second, "upper" one, growing down from the end towards lower offsets.
  • +
+

To make allocation from upper stack, add flag VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT to VmaAllocationCreateInfo::flags.

+

When the two stacks' ends meet so there is not enough space between them for a new allocation, such allocation fails with usual VK_ERROR_OUT_OF_DEVICE_MEMORY error.

+
+Double stack +
+

+Ring buffer

+

When you free some allocations from the beginning and there is not enough free space for a new one at the end of a pool, allocator's "cursor" wraps around to the beginning and starts allocation there. Thanks to this, if you always release allocations in the same order as you created them (FIFO - First In First Out), you can achieve behavior of a ring buffer / queue.

+
+Ring buffer +
+

Pools with linear algorithm support lost allocations when used as ring buffer. If there is not enough free space for a new allocation, but existing allocations from the front of the queue can become lost, they become lost and the allocation succeeds.

+
+Ring buffer with lost allocations +
+