VulkanMemoryAllocator 0.7.4 → 0.7.5
raw patch · 5 files changed
+67/−10 lines, 5 filesdep ~vulkanPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: vulkan
API changes (from Hackage documentation)
+ VulkanMemoryAllocator: getAllocationMemoryProperties :: forall io. MonadIO io => Allocator -> Allocation -> io MemoryPropertyFlags
Files
- VulkanMemoryAllocator.cabal +3/−3
- VulkanMemoryAllocator/include/vk_mem_alloc.h +32/−5
- changelog.md +4/−0
- package.yaml +2/−2
- src/VulkanMemoryAllocator.hs +26/−0
VulkanMemoryAllocator.cabal view
@@ -1,11 +1,11 @@ cabal-version: 2.2 --- This file has been generated from package.yaml by hpack version 0.34.4.+-- This file has been generated from package.yaml by hpack version 0.34.5. -- -- see: https://github.com/sol/hpack name: VulkanMemoryAllocator-version: 0.7.4+version: 0.7.5 synopsis: Bindings to the VulkanMemoryAllocator library category: Graphics homepage: https://github.com/expipiplus1/vulkan#readme@@ -96,7 +96,7 @@ , bytestring , transformers , vector- , vulkan >=3.6 && <3.14+ , vulkan >=3.6 && <3.15 if flag(safe-foreign-calls) cpp-options: -DSAFE_FOREIGN_CALLS if flag(vma-ndebug)
VulkanMemoryAllocator/include/vk_mem_alloc.h view
@@ -150,6 +150,13 @@ #include <vulkan/vulkan.h> #endif +#if !defined(VK_VERSION_1_2) + // This one is tricky. Vulkan specification defines this code as available since + // Vulkan 1.0, but doesn't actually define it in Vulkan SDK earlier than 1.2.131. + // See pull request #207. + #define VK_ERROR_UNKNOWN ((VkResult)-13) +#endif + // Define this macro to declare maximum supported Vulkan version in format AAABBBCCC, // where AAA = major, BBB = minor, CCC = patch. // If you want to use version > 1.0, it still needs to be enabled via VmaAllocatorCreateInfo::vulkanApiVersion. @@ -1571,6 +1578,17 @@ VmaAllocator VMA_NOT_NULL allocator, VmaAllocation VMA_NULLABLE * VMA_NOT_NULL pAllocation); +/** +\brief Given an allocation, returns Property Flags of its memory type. + +This is just a convenience function. Same information can be obtained using +vmaGetAllocationInfo() + vmaGetMemoryProperties(). +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaGetAllocationMemoryProperties( + VmaAllocator VMA_NOT_NULL allocator, + VmaAllocation VMA_NOT_NULL allocation, + VkMemoryPropertyFlags* VMA_NOT_NULL pFlags); + /** \brief Maps memory represented by given allocation and returns pointer to it. Maps memory represented by given allocation to make it accessible to CPU code. @@ -17665,6 +17683,16 @@ #endif } +VMA_CALL_PRE void VMA_CALL_POST vmaGetAllocationMemoryProperties( + VmaAllocator VMA_NOT_NULL allocator, + VmaAllocation VMA_NOT_NULL allocation, + VkMemoryPropertyFlags* VMA_NOT_NULL pFlags) +{ + VMA_ASSERT(allocator && allocation && pFlags); + const uint32_t memTypeIndex = allocation->GetMemoryTypeIndex(); + *pFlags = allocator->m_MemProps.memoryTypes[memTypeIndex].propertyFlags; +} + VMA_CALL_PRE VkResult VMA_CALL_POST vmaMapMemory( VmaAllocator allocator, VmaAllocation allocation, @@ -18893,8 +18921,8 @@ You can detect this case and map such allocation to access its memory on CPU directly, instead of launching a transfer operation. -In order to do that: inspect `allocInfo.memoryType`, call vmaGetMemoryTypeProperties(), -and look for `VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT` flag in properties of that memory type. +In order to do that: call vmaGetAllocationMemoryProperties() +and look for `VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT` flag. \code VkBufferCreateInfo bufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO }; @@ -18907,11 +18935,10 @@ VkBuffer buf; VmaAllocation alloc; -VmaAllocationInfo allocInfo; -vmaCreateBuffer(allocator, &bufCreateInfo, &allocCreateInfo, &buf, &alloc, &allocInfo); +vmaCreateBuffer(allocator, &bufCreateInfo, &allocCreateInfo, &buf, &alloc, nullptr); VkMemoryPropertyFlags memFlags; -vmaGetMemoryTypeProperties(allocator, allocInfo.memoryType, &memFlags); +vmaGetAllocationMemoryProperties(allocator, alloc, &memFlags); if((memFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0) { // Allocation ended up in mappable memory. You can map it and access it directly.
changelog.md view
@@ -2,6 +2,10 @@ ## WIP +## [0.7.5] - 2021-11-25+- Bump VMA, adds `getAllocationMemoryProperties`+- Raise upper bound on `vulkan`+ ## [0.7.4] - 2021-11-08 - Bump VMA, documentation changes
package.yaml view
@@ -1,5 +1,5 @@ name: VulkanMemoryAllocator-version: "0.7.4"+version: "0.7.5" synopsis: Bindings to the VulkanMemoryAllocator library category: Graphics maintainer: Ellie Hermaszewska <live.long.and.prosper@monoid.al>@@ -20,7 +20,7 @@ src/lib.cpp dependencies: - base <5- - vulkan >= 3.6 && < 3.14+ - vulkan >= 3.6 && < 3.15 - bytestring - transformers - vector
src/VulkanMemoryAllocator.hs view
@@ -38,6 +38,7 @@ , setAllocationUserData , createLostAllocation , withLostAllocation+ , getAllocationMemoryProperties , mapMemory , withMappedMemory , unmapMemory@@ -1396,6 +1397,31 @@ withLostAllocation allocator b = b (createLostAllocation allocator) (\(o0) -> freeMemory allocator o0)+++foreign import ccall+#if !defined(SAFE_FOREIGN_CALLS)+ unsafe+#endif+ "vmaGetAllocationMemoryProperties" ffiVmaGetAllocationMemoryProperties+ :: Allocator -> Allocation -> Ptr MemoryPropertyFlags -> IO ()++-- | Given an allocation, returns Property Flags of its memory type.+--+-- This is just a convenience function. Same information can be obtained+-- using 'getAllocationInfo' + 'getMemoryProperties'.+getAllocationMemoryProperties :: forall io+ . (MonadIO io)+ => -- No documentation found for Nested "vmaGetAllocationMemoryProperties" "allocator"+ Allocator+ -> -- No documentation found for Nested "vmaGetAllocationMemoryProperties" "allocation"+ Allocation+ -> io (MemoryPropertyFlags)+getAllocationMemoryProperties allocator allocation = liftIO . evalContT $ do+ pPFlags <- ContT $ bracket (callocBytes @MemoryPropertyFlags 4) free+ lift $ traceAroundEvent "vmaGetAllocationMemoryProperties" ((ffiVmaGetAllocationMemoryProperties) (allocator) (allocation) (pPFlags))+ pFlags <- lift $ peek @MemoryPropertyFlags pPFlags+ pure $ (pFlags) foreign import ccall