Pyrogenesis  trunk
General considerations

Thread safety

Versioning and compatibility

The library uses Semantic Versioning, which means version numbers follow convention: Major.Minor.Patch (e.g. 2.3.0), where:

All changes between official releases are documented in file "CHANGELOG.md".

Warning
Backward compatiblity is considered on the level of C++ source code, not binary linkage. Adding new members to existing structures is treated as backward compatible if initializing the new members to binary zero results in the old behavior. You should always fully initialize all library structures to zeros and not rely on their exact binary size.

Validation layer warnings

When using this library, you can meet following types of warnings issued by Vulkan validation layer. They don't necessarily indicate a bug, so you may need to just ignore them.

Allocation algorithm

The library uses following algorithm for allocation, in order:

  1. Try to find free range of memory in existing blocks.
  2. If failed, try to create a new block of VkDeviceMemory, with preferred block size.
  3. If failed, try to create such block with size / 2, size / 4, size / 8.
  4. If failed, try to allocate separate VkDeviceMemory for this allocation, just like when you use VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT.
  5. If failed, choose other memory type that meets the requirements specified in VmaAllocationCreateInfo and go to point 1.
  6. If failed, return VK_ERROR_OUT_OF_DEVICE_MEMORY.

Features not supported

Features deliberately excluded from the scope of this library:

  1. Data transfer. Uploading (streaming) and downloading data of buffers and images between CPU and GPU memory and related synchronization is responsibility of the user. Defining some "texture" object that would automatically stream its data from a staging copy in CPU memory to GPU memory would rather be a feature of another, higher-level library implemented on top of VMA. VMA doesn't record any commands to a VkCommandBuffer. It just allocates memory.
  2. Recreation of buffers and images. Although the library has functions for buffer and image creation: vmaCreateBuffer(), vmaCreateImage(), you need to recreate these objects yourself after defragmentation. That is because the big structures VkBufferCreateInfo, VkImageCreateInfo are not stored in VmaAllocation object.
  3. Handling CPU memory allocation failures. When dynamically creating small C++ objects in CPU memory (not Vulkan memory), allocation failures are not checked and handled gracefully, because that would complicate code significantly and is usually not needed in desktop PC applications anyway. Success of an allocation is just checked with an assert.
  4. Code free of any compiler warnings. Maintaining the library to compile and work correctly on so many different platforms is hard enough. Being free of any warnings, on any version of any compiler, is simply not feasible. There are many preprocessor macros that make some variables unused, function parameters unreferenced, or conditional expressions constant in some configurations. The code of this library should not be bigger or more complicated just to silence these warnings. It is recommended to disable such warnings instead.
  5. This is a C++ library with C interface. Bindings or ports to any other programming languages are welcome as external projects but are not going to be included into this repository.