Commit Graph

234 Commits

Author SHA1 Message Date
Adam Sawicki
1022be64cf Added missing mutex when unmapping memory.
Hopefully fixes #267. Code by @medranSolus
2022-06-22 12:48:27 +02:00
Adam Sawicki
b51fea7a53 Improved documentation regarding selecting Vulkan version
See #256
Updated to Doxygen 1.9.4.
2022-06-14 16:43:27 +02:00
Rémi Verschelde
9eab57ea44 Strip trailing whitespace in code files 2022-06-14 13:41:15 +02:00
Rémi Verschelde
e20c24c4c8 Convert VMA line endings to Unix style (LF)
This makes it consistent with other files in the repository,
and is typically the norm for cross-platform Git repos.
2022-06-14 12:00:24 +02:00
Alex
825d3d850a fix typos 2022-06-10 09:36:31 +08:00
Adam Sawicki
a6bfc23725 Releasing version 3.0.1
Some fixes in tests for Nvidia cards.
2022-05-26 11:51:12 +02:00
Adam Sawicki
b77238c92c Refactored VmaBlockVector::SortByFreeSize to fix compilation on XCode 13.4
Fixes #269. Thanks @richard-lunarg !
2022-05-26 11:11:32 +02:00
Adam Sawicki
0bbde1750e Removed unused functions VmaQuickSort, VmaQuickSortPartition
Closes #262. Thanks @laurelkeys !
2022-05-11 12:37:14 +02:00
Artem Kharytoniuk
fe38c8f13e
Fix minor typo 2022-05-11 11:23:16 +02:00
Adam Sawicki
5ab8c1752a Fix assert when VMA_DEBUG_INITIALIZE_ALLOCATIONS is used with new memory usage flags
Only mappable allocations are filled with bit pattern.

See #260
2022-04-27 16:58:56 +02:00
Brian Osman
8a7f80743a
Fix return type of GetAllocationNextPtr
Returning `void* const` doesn't mean anything (produces a warning with -Wignored-qualifiers). Based on usage, it looks like the returned pointer is expected to point at const data, so I've fixed the declaration to reflect that.
2022-04-19 10:55:48 -04:00
Tiago Chaves
ebefe58623
Remove unused VmaAlgorithmToStr function 2022-04-09 21:23:17 -03:00
Adam Sawicki
0c7ad4e859 Optimized VmaCountBitsSets to use std::popcount when C++20 is enabled
Closes #251
2022-03-29 18:07:09 +02:00
Adam Sawicki
2d2a9e3df3 Fixed bug with assert failure when JSON dump is created while a custom pool exist with specified string name 2022-03-29 17:24:48 +02:00
Adam Sawicki
5b598e0a35 Clarified documentation about required C++14 version
Fixes #252
2022-03-28 16:36:24 +02:00
Adam Sawicki
3ed40d8321 Updated version number 2022-03-28 13:22:36 +02:00
Adam Sawicki
3f9f66740a Fix for compilation on AppleClang 13.1
Fixes #253
2022-03-28 13:21:46 +02:00
Adam Sawicki
35e1539161 Fix for out-of-bound accessing last free block in EXTENSIVE defragmentation algorithm.
Code by @medranSolus
See #232
2022-03-28 13:19:34 +02:00
Menno Vink
11cbcfcfc5 Simplify the code to keep xcode happy 2022-03-27 18:34:29 +02:00
Menno Vink
54d356e2f3 C4062 fix 2022-03-27 17:48:07 +02:00
Adam Sawicki
67fda02b4b Updated version number and CHANGELOG.md
Regenerated documentation and executable.
2022-03-25 12:39:55 +01:00
Adam Sawicki
3c6470cf45 New JSON dump format
Unified across VMA and D3D12MA.
Updated Python script for visualization - now called GpuMemDumpVis.py.

Also a fix for bug in EXTENSIVE defragmentation algorithm - see #232

Code by @medranSolus
2022-03-24 11:50:34 +01:00
Adam Sawicki
6b098e457e Small but important fix in the documentation 2022-03-14 18:05:55 +01:00
Adam Sawicki
fadfc3fd13 Added convenience functions vmaCreateAliasingBuffer, vmaCreateAliasingImage
Code by @medranSolus
2022-03-14 16:56:30 +01:00
Adam Sawicki
c317c7b3e8 Internal improvement: moved setting of incremental sort in block vector to separate variable.
Code by @medranSolus
2022-03-10 15:17:22 +01:00
Adam Sawicki
31910c8b08 Fix in defragmentation versus mapping
by @medranSolus

Added TestDefragmentationVsMapping.
2022-03-09 13:24:06 +01:00
Adam Sawicki
e4dd120c2f Fixed line endings to LF again
See #195
2022-03-08 13:50:37 +01:00
Adam Sawicki
85a49729c3 Improvements in documentation regarding defragmentation 2022-03-08 13:46:58 +01:00
Adam Sawicki
e1879e9f10 Removed VMA_ALLOCATION_CREATE_RESERVED_1_BIT, VMA_ALLOCATION_CREATE_RESERVED_2_BIT
Improvements in documentation.
2022-03-08 12:25:24 +01:00
Adam Sawicki
b644e72765 Renamed VMA_VIRTUAL_ALLOCATION_CREATE_STRATEGY_PACKED_BIT to VMA_VIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_OFFSET_BIT for consistency. Compatibility breaking. 2022-03-07 17:16:49 +01:00
Adam Sawicki
7d182e2c5a Change in the defragmentation API. Compatibility breaking!
Removed VmaDefragmentationMove::dstMemory, dstOffset, internalData, added dstTmpAllocation.
Code by @medranSolus
2022-03-07 17:00:12 +01:00
Adam Sawicki
80a07979f5 Improvements in documentation, especially regarding defragmentation 2022-03-04 16:33:16 +01:00
Adam Sawicki
f828262f43 Changed vmaEndDefragmentation to return void (somewhat compatibility breaking)
It couldn't fail anyway.
2022-03-04 14:24:29 +01:00
Adam Sawicki
b1427085f3 Fixed accounting of statistics in defragmentation.
Code by @medranSolus
See #232
2022-03-04 13:26:42 +01:00
Adam Sawicki
ea759b65d4 Added missing mutexes for DefragmentPassEnd().
Code by @medranSolus
2022-03-04 10:34:26 +01:00
Sidney Just
7b9c21f1fe Fixed defragmenter not acquiring a lock before touching blocks 2022-03-03 17:05:05 -08:00
Sidney Just
44a5aea4ef Fixed loop termination when ending defragment passes 2022-03-03 17:04:20 -08:00
Adam Sawicki
46776a4c37 Fixed merge error 2022-03-03 11:33:39 +01:00
Adam Sawicki
caf27e0428 Made allocation Name and UserData separate. COMPATIBILITY BREAKING!
Added function vmaSetAllocationName. Added member VmaAllocationInfo::pName.
VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT is now deprecated but still works.

Code mostly by @medranSolus
2022-03-03 11:23:14 +01:00
Adam Sawicki
bd39bed5e6 Fixes in defragmentation
Implemented VMA_DEFRAGMENTATION_FLAG_ALGORITHM_BALANCED_BIT. Fixed allocation mapping after defragmentation.
Also fixed tests - hopefully fixes #248
Code by @medranSolus
2022-03-02 16:10:41 +01:00
Adam Sawicki
01364c7970 Added documentation chapter "VK_EXT_memory_priority"
Other fixes in documentation
2022-02-28 12:10:18 +01:00
Adam Sawicki
f02c8a46d8 Improvement in documentation 2022-02-28 10:57:04 +01:00
Adam Sawicki
4039e45a19 Added documentation chapter "Versioning and compatibility"
Many improvements in documentation and README.
2022-02-26 13:26:20 +01:00
Adam Sawicki
86c124c772 VMA_MEMORY_USAGE_AUTO* flags: Added support for rare case when a resource used on the device, not used on the host, may still be preferred in host memory
An update in the documentation.
2022-02-26 11:49:51 +01:00
Adam Sawicki
88bf8cb9a8 Removed usage of __popcnt
Apparently some old processors don't support this instruction. It's up to the user to provide optimized implementation by defining macro VMA_COUNT_BITS_SET.

Fixes #245
2022-02-25 13:51:13 +01:00
Pedro J. Estébanez
d8a9c7fa42 Add missing nullability qualifier 2022-02-24 11:42:44 +01:00
Adam Sawicki
20b9bc5334 Minor fixes in documentation of defragmentation 2022-02-23 16:21:16 +01:00
Adam Sawicki
6a63f2cb4e Fixed incorrect accounting of memory budget.
Code by @medranSolus
Fixes #241
2022-02-23 13:44:51 +01:00
Adam Sawicki
ab75719ee0 Fix for failing CI job on linux.
Code by @medranSolus
2022-02-23 10:39:40 +01:00
Adam Sawicki
88510e9801 New API for defragmentation. COMPATIBILITY BREAKING!
See structure VmaDefragmentationInfo, VmaDefragmentationMove, VmaDefragmentationPassMoveInfo, VmaDefragmentationStats, function vmaBeginDefragmentation, vmaEndDefragmentation, vmaBeginDefragmentationPass, vmaEndDefragmentationPass.

Switched to TLSF as the default algorithm - in default pools, custom pools, virtual blocks. Removed generic and buddy algorithm. Removed flags: VMA_POOL_CREATE_BUDDY_ALGORITHM_BIT, VMA_POOL_CREATE_TLSF_ALGORITHM_BIT, VMA_VIRTUAL_BLOCK_CREATE_BUDDY_ALGORITHM_BIT, VMA_VIRTUAL_BLOCK_CREATE_TLSF_ALGORITHM_BIT.

Updated and regenerated documentation.
2022-02-22 23:38:19 +01:00
Adam Sawicki
9104ef3d45 Merge branch 'master' of https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator 2022-02-22 15:19:47 +01:00
Adam Sawicki
226bd5a6ad New API for statistics. COMPATIBILITY BREAKING!
New structure VmaStatistics, VmaDetailedStatistics, VmaTotalStatistics. Modified structure VmaBudget.
New function vmaCalculateStatistics, vmaGetPoolStatistics, vmaCalculatePoolStatistics, vmaGetVirtualBlockStatistics, vmaCalculateVirtualBlockStatistics. vmaGetHeapBudgets function unchanged.

Updated and rebuilt the docs.
2022-02-22 15:19:35 +01:00
Matus Fedorko
cf5e9899fb Fix VmaSmallVector::push_back 2022-02-18 13:27:52 +01:00
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