Commit Graph

181 Commits

Author SHA1 Message Date
Adam Sawicki
3fd264ae1d Added usage of vkGetDeviceBufferMemoryRequirements, vkGetDeviceImageMemoryRequirements from Vulkan 1.3
Used inside vmaFindMemoryTypeIndexForBufferInfo, vmaFindMemoryTypeIndexForImageInfo when available.
Added these 2 functions to VmaVulkanFunctions structure.
Regenerated the docs.
2022-02-17 17:34:48 +01:00
Adam Sawicki
aee61b1d25 Added new API for selecting preferred memory type: VMA_MEMORY_USAGE_AUTO, VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE, VMA_MEMORY_USAGE_AUTO_PREFER_HOST, VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT, VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT, VMA_ALLOCATION_CREATE_HOST_ACCESS_ALLOW_TRANSFER_INSTEAD_BIT
Old values like VMA_MEMORY_USAGE_GPU_ONLY still work as before, for backward compatibility.
Updated documentation accordingly.

Introduced a concept of mappable and non-mappable allocations - with VMA_MEMORY_USAGE_AUTO* an intent to map has to be specified using VMA_ALLOCATION_CREATE_HOST_ACCESS*.

Added mapping hysteresis logic (internal class VmaMappingHysteresis, config macro VMA_MAPPING_HYSTERESIS_ENABLED) that prevents too many calls vkMapMemory/vkUnmapMemory back and forth.

Internal improvement in VmaBlockVector::AllocatePage to try to keep mappable and non-mappable allocations separate.
2022-02-17 14:44:06 +01:00
Adam Sawicki
b41615cfce Added missing #include <intrin.h>
Fixes #237
2022-02-17 11:08:30 +01:00
Adam Sawicki
e51e4d3b40 Fix initialization order in VmaDefragmentationAlgorithm_Generic constructor
See #236
2022-02-15 11:26:29 +01:00
Adam Sawicki
cebd53ce67
Merge pull request #235 from RandomShaper/fix_nullability
Add missing nullability macros
2022-02-14 18:21:13 +01:00
Adam Sawicki
0a24d5a7f3 Fixes for 2 compiler warnings
Closes #236
2022-02-14 18:17:14 +01:00
Pedro J. Estébanez
32f74c51e0 Add missing nullability macros 2022-02-12 13:27:10 +01:00
Adam Sawicki
a1895bc765 Internal fix in VmaBlockVector::AllocatePage 2022-02-08 16:31:11 +01:00
Adam Sawicki
bb29254253 Fix for VmaBitScan functions in GCC and Clang. Fixed debug margin for generic algorithm.
Hopefully helps for #231.
Code by @medranSolus
2022-02-08 10:50:10 +01:00
Tiago Chaves
2d5df2d7a8
Include vulkan.h before #define VMA_VULKAN_VERSION 2022-02-07 14:56:49 -03:00
Adam Sawicki
4d65f7e113 Updated first chapter of the documentation "Quick start"
Rebuilt the docs.
Closes #228
2022-02-07 16:58:10 +01:00
Adam Sawicki
5c710e86a0 Added support for Vulkan 1.3
Fixes #228
2022-02-04 15:17:02 +01:00
Adam Sawicki
fd4ee1d5aa Fixed vmaVirtualFree legal to call with allocation == VK_NULL_HANDLE
Hopefully fixes #230
Fixes in internal validation.
Rebuilt the docs.
2022-02-04 14:32:45 +01:00
Adam Sawicki
22485a05f9 Improved behavior of vmaVirtualAllocate on failed allocation. Fixed VmaVirtualAllocation to distinguish VK_NULL_HANDLE from successful allocation.
Improved tests.
Rebult the docs.
2022-02-04 11:39:56 +01:00
Adam Sawicki
05d0c89f0b Minor fix in documentation 2022-02-02 15:45:33 +01:00
Adam Sawicki
ab16036dd5 Updated tests and documentation for VMA_DEBUG_MARGIN
Fixed type of VmaVirtualBlockCreateInfo::flags.
Rebuilt the docs.
2022-02-01 17:57:17 +01:00
Adam Sawicki
ab134958f5 Fixed algorithm in VmaBlockMetadata_TLSF::CreateAllocationRequest
Code by @medranSolus
2022-02-01 14:03:52 +01:00
Adam Sawicki
c161ba93d5 Minor fix in the documentation
Rebuilt the documentation
2022-01-31 18:07:58 +01:00
Adam Sawicki
2f478c8577
Merge pull request #227 from laurelkeys/user-includes-macro
Proposal: allow custom includes without having to edit vk_mem_alloc.h
2022-01-31 17:41:18 +01:00
Adam Sawicki
48d3cc46a0 Minor fixes after merging #226 2022-01-31 17:20:29 +01:00
Adam Sawicki
83d3571b7c
Merge pull request #226 from laurelkeys/master
Fix VMA_STATS_STRING_ENABLED 0 with VMA_DEBUG_LOG
2022-01-31 17:16:42 +01:00
Adam Sawicki
ff99bf7dea Fixed some calculations in TLSF.
Code by @medranSolus
2022-01-31 14:55:44 +01:00
Tiago Chaves
4c987c910d Add VMA_CONFIGURATION_USER_INCLUDES_H macro 2022-01-30 17:16:46 -03:00
Tiago Chaves
c0aa0ad54c
Fix VMA_STATS_STRING_ENABLED 0 with VMA_DEBUG_LOG 2022-01-30 16:40:32 -03:00
Adam Sawicki
08759cbec5 Changed value of VMA_ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT / VMA_ALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT.
Added support for VMA_DEBUG_MARGIN in TLSF algorithm.
Changed behavior of VMA_DEBUG_MARGIN to be included only after not before every allocation.
Bug fixes and improvements in TLSF algorithm.
Added benchmark for virtual allocator.

Code by @medranSolus
2022-01-28 13:07:58 +01:00
Adam Sawicki
aa823264ca Minor fix 2022-01-27 13:46:47 +01:00
Adam Sawicki
ed83ac24d2 Changes in ALLOCATION_CREATE_STRATEGY flags. COMPATIBILITY BREAKING!
Removed flags: VMA_ALLOCATION_CREATE_STRATEGY_MIN_FRAGMENTATION_BIT, VMA_ALLOCATION_CREATE_STRATEGY_WORST_FIT_BIT, VMA_VIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_FRAGMENTATION_BIT.
Regenerated documentation.
2022-01-26 17:47:11 +01:00
Adam Sawicki
6c1c16f05c Misc minor fixes 2022-01-26 17:46:38 +01:00
Adam Sawicki
5bd5975873 Fix for 32-bit compilation
Fixes #225
2022-01-26 13:51:12 +01:00
Adam Sawicki
a4d39851fd Fixed syntax errors 2022-01-24 15:16:13 +01:00
Adam Sawicki
cad2acc080 Merge remote-tracking branch 'origin/master' 2022-01-24 14:59:22 +01:00
Adam Sawicki
518907bbc5 Optimized bit functions, added intrinsics for GCC and Clang
Code by @medranSolus
2022-01-24 14:58:42 +01:00
Lava Block
5c08c6498f Fix build - 64 bit functions do not exist 2022-01-24 12:13:08 +01:00
Adam Sawicki
12d128d8f7 Added debug printing of unfreed allocation
Closes #130

Also made fixes for compilation errors on Android - see #223

Code by @medranSolus
2022-01-24 11:25:03 +01:00
Lava Block
b99c428aef Fix build - removed usage of DWORD type 2022-01-21 18:28:15 +01:00
Adam Sawicki
8da08d160a Minor internal fix - removed usage of DWORD type 2022-01-21 13:06:40 +01:00
Adam Sawicki
f451b94158 Fixed vmaBuildVirtualBlockStatsString, vmaFreeVirtualBlockStatsString to also be inside #if VMA_STATS_STRING_ENABLED
Updated copyright headers for to year 2022.

Change by @medranSolus
2022-01-21 12:56:18 +01:00
Adam Sawicki
2ae5466b2e Merge remote-tracking branch 'origin/master' 2022-01-20 17:02:00 +01:00
Adam Sawicki
d3a85f0dc3 Refactored virtual allocator. (COMPATIBILITY BREAKING!) Added TLSF algoritym.
Refactored virtual allocator: Added type VmaVirtualAllocation, member VmaVirtualAllocationInfo::offset, changed parameters of vmaVirtualAllocate, vmaVirtualFree, vmaSetVirtualAllocationUserData, vmaGetVirtualAllocationInfo.

Added TLSF algorithm: Added VMA_POOL_CREATE_TLSF_ALGORITHM_BIT, VMA_VIRTUAL_BLOCK_CREATE_TLSF_ALGORITHM_BIT.

Some internal refactoring.

Improved documentation: Grouped API elements into Doxygen modules.

Code mostly by @medranSolus.
2022-01-20 17:00:33 +01:00
Tiago Chaves
f333006465
Fix MSVC warning C4505 for VmaCreateStringCopy 2022-01-14 11:31:30 -03:00
Ellie Hermaszewska
15b16f88b9
Add missing length annotation to pBudgets parameter in vmaGetHeapBudgets 2022-01-14 16:40:40 +08:00
Adam Sawicki
992e545749 Fixed bugs after merge 2022-01-10 18:13:43 +01:00
Adam Sawicki
a8581fc96c Deleted the whole Record&Replay feature. COMPATIBILITY BREAKING!
Removed from the API: VmaAllocatorCreateInfo::pRecordSettings, VmaRecordSettings, VmaRecordFlagBits, VmaRecordFlags.
Regenerated documentation. Updated README.
2022-01-10 18:11:09 +01:00
Adam Sawicki
1e97603ab8 Deleted the whole feature of lost allocations. COMPATIBILITY BREAKING!
Removed from the interface: VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT, VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT, vmaCreateLostAllocation, vmaMakePoolAllocationsLost, vmaTouchAllocation, VmaAllocatorCreateInfo::frameInUseCount, VmaPoolCreateInfo::frameInUseCount.

Also fixed a bug with synchronization in VmaDedicatedAllocationList.
2022-01-10 17:57:11 +01:00
Adam Sawicki
6f73bc1b81 Removed VmaPoolStats::unusedRangeSizeMax. COMPATIBILITY BREAKING! 2022-01-07 14:23:05 +01:00
Adam Sawicki
204fcdc0a3 Minor fixes
Closes #217
2022-01-05 18:49:32 +01:00
Adam Sawicki
35bc050aa3 Fixed typo in code 2022-01-05 17:37:30 +01:00
Adam Sawicki
7c48285034 Removed VMA_USE_STL_CONTAINERS 2021-12-22 14:57:18 +01:00
Adam Sawicki
cbad11e039 Fixed vmaGetPoolStats for dedicated allocations
Added new tests: TestPoolsAndAllocationParameters.
2021-12-22 14:50:49 +01:00
Adam Sawicki
6fe7212e73 Improved documentation of vmaMapMemory function 2021-12-21 16:50:33 +01:00
Adam Sawicki
556834c0b4 Fixed creation and displaying of JSON memory dump for dedicated allocations in custom pools. 2021-12-21 16:23:13 +01:00
Adam Sawicki
9bb70bef1b Added comments documenting class VmaJsonWriter 2021-12-21 11:31:25 +01:00
Adam Sawicki
fbb465c2bc Fixed documentation about OpenGL interop
Added information about dedicated allocations now supported in custom pools.
2021-12-20 13:05:24 +01:00
Adam Sawicki
0109967554 Updated documentation regarding dedicated allocations in custom pools
Regenerated the documentation.
2021-12-17 16:39:47 +01:00
Adam Sawicki
e9c083b4d2 Added support for dedicated allocations in custom pools
A major refactoring.
JSON format changed!
2021-12-17 11:00:00 +01:00
Adam Sawicki
a8c1543723 Major refactoring - reordered sections in vk_mem_alloc.h
Added #ifndef _VMA_* for convenient folding in IDEs.
Regenerated docs.
2021-12-14 16:53:50 +01:00
Adam Sawicki
2ba419e8e4 Refactoring - created class VmaDedicatedAllocationList 2021-12-10 17:58:53 +01:00
yao.zhao
3dd4b203f9 fix crash in VmaAllocator_T::AllocateDedicatedMemory 2021-12-07 13:23:32 +08:00
Adam Sawicki
35eeb340a3 Renamed function vmaGetBudget to vmaGetHeapBudgets. COMPATIBILITY BREAKING!
Rebuilt the docs.
Closes #213
2021-12-06 17:36:18 +01:00
Adam Sawicki
4687f53764 Internal optimization in traversal of VmaBlockMetadata_Generic::m_Suballocations 2021-12-06 15:20:44 +01:00
Adam Sawicki
4cd813a8c6 Added flag VMA_ALLOCATION_CREATE_CAN_ALIAS_BIT 2021-12-06 12:14:13 +01:00
Adam Sawicki
e5c03604c9 Improvements in documentation 2021-12-03 18:04:34 +01:00
Adam Sawicki
b4d341de13 Internal optimization with m_pBlockVectors 2021-12-02 16:39:27 +01:00
Adam Sawicki
f529a86ab5 Added VmaVulkanFunctions::vkGetInstanceProcAddr, vkGetDeviceProcAddr
These are now required when using VMA_DYNAMIC_VULKAN_FUNCTIONS. Compatibility breaking!

Closes #211
2021-11-29 17:52:30 +01:00
Adam Sawicki
00d064e21e Added a comment after #207 2021-11-25 14:30:41 +01:00
Adam Sawicki
43d82a168f
Merge pull request #207 from scribam/sdk-compatibility
Compatibility fix with old sdks where VK_ERROR_UNKNOWN is not defined
2021-11-25 14:28:48 +01:00
Adam Sawicki
fac8ef44d2 Added convenience function vmaGetAllocationMemoryProperties
Regenerated documentation.
2021-11-23 13:35:19 +01:00
scribam
7e5a1d0859 Compatibility fix with old sdks where VK_ERROR_UNKNOWN is not defined 2021-11-16 23:07:57 +01:00
Adam Sawicki
c809ddca76 Documented some members of VmaVulkanFunctions to clarify which functions to fetch
Also a fix in documentation generation and rebuilt the docs.
2021-11-05 17:41:46 +01:00
Ellie Hermaszewska
38a632f9b3
Add typedefs for virtual allocation structs in ordinary identifier namespace 2021-11-03 10:12:24 +08:00
Adam Sawicki
cba6a2ba10 Fix for compilation on Linux 2021-10-30 23:36:24 +02:00
Adam Sawicki
e1813512c5 Made virtual allocations not applying VMA_DEBUG_MARGIN
Improved and regenerated documentation.
2021-10-30 23:29:01 +02:00
Adam Sawicki
bcd5f57deb Fixes to various bugs found during extensive testing 2021-10-30 23:03:20 +02:00
Adam Sawicki
3f19f8ae39 Optimized VmaBlockMetadata_Buddy - using VmaPoolAllocator to allocate nodes 2021-10-30 12:51:36 +02:00
Adam Sawicki
41296759b9 Refactoring: Added function VmaAddStatInfoAllocation, VmaAddStatInfoUnusedRange
Submitting improved tests.
2021-10-30 12:44:40 +02:00
Adam Sawicki
455823fcbf Improved VmaBlockMetadata_Buddy when used as a virtual allocator, to support allocation sizes down to 1 2021-10-30 12:26:09 +02:00
Adam Sawicki
fc23b9da1f Removed VMA_MIN_FREE_SUBALLOCATION_SIZE_TO_REGISTER to simplify the code
VmaBlockMetadata_Generic now aligns allocation sizes to a multiply of 16 instead, except when used as virtual allocator. This also allows to use virtual allocator with sizes smaller than 16.
2021-10-30 12:20:46 +02:00
Adam Sawicki
56f7b4c223 Added support for VMA_VIRTUAL_BLOCK_CREATE_BUDDY_ALGORITHM_BIT 2021-10-30 12:05:37 +02:00
Adam Sawicki
62a25b6b4c Changed behavior of buddy allocator to align allocation sizes to power of 2 instead of accounting the remaining space (internal fragmentation) as free
Also fixed major bug in VmaBlockMetadata_Buddy::CalcAllocationStatInfoNode.
2021-10-30 11:41:29 +02:00
Adam Sawicki
c24517fd92 Added support for VMA_VIRTUAL_BLOCK_CREATE_LINEAR_ALGORITHM_BIT
Fixed major bug in VmaBlockMetadata_Linear::CalcAllocationStatInfo. Necessary refactoring.
2021-10-30 11:12:15 +02:00
Adam Sawicki
0e37526f94 Implemented VmaBlockMetadata_Linear::Clear
A step towards enabling virtual allocator with linear algorithm.
2021-10-29 16:37:58 +02:00
Adam Sawicki
73ff8e07d1 Preparations for adding support for alternative algorithms in virtual blocks and tests for them 2021-10-28 19:20:12 +02:00
Adam Sawicki
01a0ba193a Added documentation chapter "Virtual allocator"
Regenerated the documentation.
2021-10-28 18:25:57 +02:00
Adam Sawicki
e93a581969 Written documentation for API of the virtual allocator
Regenerated the documentation.
2021-10-28 17:36:41 +02:00
Adam Sawicki
c6432507c5 Implemented vmaBuildVirtualBlockStatsString, vmaFreeVirtualBlockStatsString 2021-10-28 17:00:17 +02:00
Adam Sawicki
dfa2051cd2 Improvement in vmaCreateAllocator in case creation fails 2021-10-28 16:17:07 +02:00
Adam Sawicki
cc61fe10d8 Implemented vmaClearVirtualBlock 2021-10-28 16:03:09 +02:00
Adam Sawicki
9a091e8ccb Implemented vmaCalculateVirtualBlockStats 2021-10-28 15:00:24 +02:00
Adam Sawicki
e1812303d6 More coding and more tests. Basic functionality is working now. 2021-10-28 14:46:45 +02:00
Adam Sawicki
dc644281ac Essential refactoring that made the test not crashing. 2021-10-28 14:36:59 +02:00
Adam Sawicki
54b7eccc35 More implementation and first tests.
Crashing for now - need more refactoring.
2021-10-28 14:32:34 +02:00
Adam Sawicki
7acc6c0ca8 Defined interface for virtual allocator:
VmaVirtualBlockCreateFlagBits, VmaVirtualBlockCreateFlags, VmaVirtualBlockCreateInfo, VmaVirtualAllocationCreateInfo, VmaVirtualBlock, all necessary functions.
Implementation: added VmaVirtualBlock_T. Not working for now.
2021-10-28 13:51:12 +02:00
Adam Sawicki
3216bf6dc7 Necessary refactoring to prepare for virtual allocator 2021-10-27 16:45:08 +02:00
Adam Sawicki
e821342782 Fixing logic of VmaDefragmentationAlgorithm_Fast::PostprocessMetadata broken by #201
Closes #202
2021-10-21 13:37:10 +02:00
Adam Sawicki
2b9ee46c40
Merge pull request #201 from GermanAizek/patch
Code refactor (lower scope, local var, default constructor and destructor)
2021-10-19 17:13:53 +02:00
semenov_gv
666b38f11f Code refactor (lower scope, local var, default constructor and destructor) 2021-10-18 18:36:13 +03:00
Adam Sawicki
d2f0313d20 Fixes in comments
Regenerated documentation.
2021-10-18 17:32:40 +02:00
Daniel Krupiński
39106c64bb Replace tabs with spaces 2021-09-30 14:34:47 +02:00
Adam Sawicki
6bdc8e1bf8
Merge pull request #197 from danielkrupinski/master
Use forwarding references with std::forward()
2021-09-30 12:07:04 +02:00
Daniel Krupiński
c725ffd106 Use forwarding references with std::forward() 2021-09-29 14:37:30 +02:00