Skip to content

Commit

Permalink
Merge pull request #319 from expipiplus1/vma-bump
Browse files Browse the repository at this point in the history
Bump VMA
  • Loading branch information
expipiplus1 authored Jul 23, 2021
2 parents 4037bd4 + d3c347c commit 8456e89
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 6 deletions.
2 changes: 1 addition & 1 deletion VulkanMemoryAllocator/VulkanMemoryAllocator
Submodule VulkanMemoryAllocator updated 59 files
+2 −1 Doxyfile
+8 −8 docs/html/allocation_annotation.html
+8 −8 docs/html/choosing_memory_type.html
+8 −8 docs/html/custom_memory_pools.html
+10 −10 docs/html/defragmentation.html
+3 −0 docs/html/functions.html
+3 −0 docs/html/functions_vars.html
+3 −0 docs/html/globals.html
+3 −0 docs/html/globals_func.html
+6 −6 docs/html/lost_allocations.html
+10 −10 docs/html/memory_mapping.html
+8 −8 docs/html/quick_start.html
+3 −3 docs/html/resource_aliasing.html
+8 −8 docs/html/search/all_10.js
+156 −155 docs/html/search/all_11.js
+3 −2 docs/html/search/all_b.js
+1 −1 docs/html/search/all_c.js
+4 −4 docs/html/search/all_d.js
+3 −3 docs/html/search/all_e.js
+1 −1 docs/html/search/all_f.js
+21 −21 docs/html/search/classes_0.js
+8 −8 docs/html/search/defines_0.js
+6 −6 docs/html/search/enums_0.js
+42 −42 docs/html/search/enumvalues_0.js
+1 −1 docs/html/search/files_0.js
+52 −51 docs/html/search/functions_0.js
+1 −1 docs/html/search/pages_0.js
+3 −3 docs/html/search/pages_1.js
+3 −3 docs/html/search/pages_2.js
+1 −1 docs/html/search/pages_3.js
+1 −1 docs/html/search/pages_4.js
+1 −1 docs/html/search/pages_5.js
+1 −1 docs/html/search/pages_6.js
+1 −1 docs/html/search/pages_7.js
+3 −3 docs/html/search/pages_8.js
+2 −2 docs/html/search/pages_9.js
+3 −3 docs/html/search/pages_a.js
+2 −2 docs/html/search/typedefs_0.js
+28 −28 docs/html/search/typedefs_1.js
+7 −7 docs/html/search/variables_0.js
+6 −6 docs/html/search/variables_1.js
+1 −1 docs/html/search/variables_2.js
+3 −3 docs/html/search/variables_3.js
+2 −2 docs/html/search/variables_4.js
+1 −1 docs/html/search/variables_5.js
+15 −15 docs/html/search/variables_6.js
+1 −1 docs/html/search/variables_7.js
+22 −21 docs/html/search/variables_8.js
+1 −1 docs/html/search/variables_9.js
+1 −1 docs/html/search/variables_a.js
+1 −1 docs/html/search/variables_b.js
+8 −8 docs/html/search/variables_c.js
+18 −18 docs/html/search/variables_d.js
+3 −2 docs/html/struct_vma_allocator_create_info-members.html
+21 −0 docs/html/struct_vma_allocator_create_info.html
+64 −0 docs/html/vk__mem__alloc_8h.html
+16,154 −15,994 docs/html/vk__mem__alloc_8h_source.html
+1 −1 docs/html/vk_khr_dedicated_allocation.html
+192 −12 include/vk_mem_alloc.h
2 changes: 1 addition & 1 deletion VulkanMemoryAllocator/VulkanMemoryAllocator.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 2.2
-- see: https://github.com/sol/hpack

name: VulkanMemoryAllocator
version: 0.6.0.1
version: 0.7
synopsis: Bindings to the VulkanMemoryAllocator library
category: Graphics
homepage: https://github.com/expipiplus1/vulkan#readme
Expand Down
3 changes: 3 additions & 0 deletions VulkanMemoryAllocator/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## WIP

## [0.7] - 2021-07-23
- Bump VMA, adds vkaCreateBufferWithAlignment and fixes aligned_alloc on OS X.

## [0.6.0.1] - 2021-06-26
- Bump VMA, no functional change
- Use allocaBytes over allocaBytesAligned where possible
Expand Down
2 changes: 1 addition & 1 deletion VulkanMemoryAllocator/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: VulkanMemoryAllocator
version: "0.6.0.1"
version: "0.7"
synopsis: Bindings to the VulkanMemoryAllocator library
category: Graphics
maintainer: Joe Hermaszewski <[email protected]>
Expand Down
61 changes: 58 additions & 3 deletions VulkanMemoryAllocator/src/VulkanMemoryAllocator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ module VulkanMemoryAllocator ( createAllocator
, bindImageMemory2
, createBuffer
, withBuffer
, createBufferWithAlignment
, destroyBuffer
, createImage
, withImage
Expand Down Expand Up @@ -155,6 +156,7 @@ import Vulkan (CommandBuffer_T)
import Vulkan (DeviceMemory)
import Vulkan (DeviceSize)
import Vulkan (Device_T)
import Vulkan (ExternalMemoryHandleTypeFlagsKHR)
import Vulkan (Flags)
import Vulkan (Image)
import Vulkan (ImageCreateInfo)
Expand Down Expand Up @@ -2261,6 +2263,44 @@ withBuffer allocator pBufferCreateInfo pAllocationCreateInfo b =
(\(o0, o1, _) -> destroyBuffer allocator o0 o1)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"vmaCreateBufferWithAlignment" ffiVmaCreateBufferWithAlignment
:: Allocator -> Ptr (SomeStruct BufferCreateInfo) -> Ptr AllocationCreateInfo -> DeviceSize -> Ptr Buffer -> Ptr Allocation -> Ptr AllocationInfo -> IO Result

-- | Creates a buffer with additional minimum alignment.
--
-- Similar to 'createBuffer' but provides additional parameter
-- @minAlignment@ which allows to specify custom, minimum alignment to be
-- used when placing the buffer inside a larger memory block, which may be
-- needed e.g. for interop with OpenGL.
createBufferWithAlignment :: forall a io
. (Extendss BufferCreateInfo a, PokeChain a, MonadIO io)
=> -- No documentation found for Nested "vmaCreateBufferWithAlignment" "allocator"
Allocator
-> -- No documentation found for Nested "vmaCreateBufferWithAlignment" "pBufferCreateInfo"
(BufferCreateInfo a)
-> -- No documentation found for Nested "vmaCreateBufferWithAlignment" "pAllocationCreateInfo"
AllocationCreateInfo
-> -- No documentation found for Nested "vmaCreateBufferWithAlignment" "minAlignment"
("minAlignment" ::: DeviceSize)
-> io (Buffer, Allocation, AllocationInfo)
createBufferWithAlignment allocator bufferCreateInfo allocationCreateInfo minAlignment = liftIO . evalContT $ do
pBufferCreateInfo <- ContT $ withCStruct (bufferCreateInfo)
pAllocationCreateInfo <- ContT $ withCStruct (allocationCreateInfo)
pPBuffer <- ContT $ bracket (callocBytes @Buffer 8) free
pPAllocation <- ContT $ bracket (callocBytes @Allocation 8) free
pPAllocationInfo <- ContT (withZeroCStruct @AllocationInfo)
r <- lift $ traceAroundEvent "vmaCreateBufferWithAlignment" ((ffiVmaCreateBufferWithAlignment) (allocator) (forgetExtensions pBufferCreateInfo) pAllocationCreateInfo (minAlignment) (pPBuffer) (pPAllocation) (pPAllocationInfo))
lift $ when (r < SUCCESS) (throwIO (VulkanException r))
pBuffer <- lift $ peek @Buffer pPBuffer
pAllocation <- lift $ peek @Allocation pPAllocation
pAllocationInfo <- lift $ peekCStruct @AllocationInfo pPAllocationInfo
pure $ (pBuffer, pAllocation, pAllocationInfo)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
Expand Down Expand Up @@ -3052,6 +3092,18 @@ data AllocatorCreateInfo = AllocatorCreateInfo
-- supported by the current implementation. Leaving it initialized to zero
-- is equivalent to @VK_API_VERSION_1_0@.
vulkanApiVersion :: Word32
, -- | Either null or a pointer to an array of external memory handle types for
-- each Vulkan memory type.
--
-- If not NULL, it must be a pointer to an array of
-- @VkPhysicalDeviceMemoryProperties::memoryTypeCount@ elements, defining
-- external memory handle types of particular Vulkan memory type, to be
-- passed using @VkExportMemoryAllocateInfoKHR@.
--
-- Any of the elements may be equal to 0, which means not to use
-- @VkExportMemoryAllocateInfoKHR@ on this memory type. This is also the
-- default in case of @pTypeExternalMemoryHandleTypes@ = NULL.
typeExternalMemoryHandleTypes :: Ptr ExternalMemoryHandleTypeFlagsKHR
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
Expand All @@ -3060,7 +3112,7 @@ deriving instance Generic (AllocatorCreateInfo)
deriving instance Show AllocatorCreateInfo

instance ToCStruct AllocatorCreateInfo where
withCStruct x f = allocaBytes 96 $ \p -> pokeCStruct p x (f p)
withCStruct x f = allocaBytes 104 $ \p -> pokeCStruct p x (f p)
pokeCStruct p AllocatorCreateInfo{..} f = evalContT $ do
lift $ poke ((p `plusPtr` 0 :: Ptr AllocatorCreateFlags)) (flags)
lift $ poke ((p `plusPtr` 8 :: Ptr (Ptr PhysicalDevice_T))) (physicalDevice)
Expand All @@ -3086,8 +3138,9 @@ instance ToCStruct AllocatorCreateInfo where
lift $ poke ((p `plusPtr` 72 :: Ptr (Ptr RecordSettings))) pRecordSettings''
lift $ poke ((p `plusPtr` 80 :: Ptr (Ptr Instance_T))) (instance')
lift $ poke ((p `plusPtr` 88 :: Ptr Word32)) (vulkanApiVersion)
lift $ poke ((p `plusPtr` 96 :: Ptr (Ptr ExternalMemoryHandleTypeFlagsKHR))) (typeExternalMemoryHandleTypes)
lift $ f
cStructSize = 96
cStructSize = 104
cStructAlignment = 8
pokeZeroCStruct p f = do
poke ((p `plusPtr` 0 :: Ptr AllocatorCreateFlags)) (zero)
Expand Down Expand Up @@ -3117,8 +3170,9 @@ instance FromCStruct AllocatorCreateInfo where
pRecordSettings' <- maybePeek (\j -> peekCStruct @RecordSettings (j)) pRecordSettings
instance' <- peek @(Ptr Instance_T) ((p `plusPtr` 80 :: Ptr (Ptr Instance_T)))
vulkanApiVersion <- peek @Word32 ((p `plusPtr` 88 :: Ptr Word32))
pTypeExternalMemoryHandleTypes <- peek @(Ptr ExternalMemoryHandleTypeFlagsKHR) ((p `plusPtr` 96 :: Ptr (Ptr ExternalMemoryHandleTypeFlagsKHR)))
pure $ AllocatorCreateInfo
flags physicalDevice device preferredLargeHeapBlockSize pAllocationCallbacks' pDeviceMemoryCallbacks' frameInUseCount pHeapSizeLimit pVulkanFunctions' pRecordSettings' instance' vulkanApiVersion
flags physicalDevice device preferredLargeHeapBlockSize pAllocationCallbacks' pDeviceMemoryCallbacks' frameInUseCount pHeapSizeLimit pVulkanFunctions' pRecordSettings' instance' vulkanApiVersion pTypeExternalMemoryHandleTypes

instance Zero AllocatorCreateInfo where
zero = AllocatorCreateInfo
Expand All @@ -3134,6 +3188,7 @@ instance Zero AllocatorCreateInfo where
Nothing
zero
zero
zero


-- | VmaAllocatorInfo
Expand Down
8 changes: 8 additions & 0 deletions VulkanMemoryAllocator/src/lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
#pragma clang diagnostic ignored "-Wnullability-completeness"
#endif

// To match the vulkan headers this is generated against
#define VMA_DEDICATED_ALLOCATION 1
#define VMA_BIND_MEMORY2 1
#define VMA_MEMORY_BUDGET 1
#define VMA_BUFFER_DEVICE_ADDRESS 1
#define VMA_MEMORY_PRIORITY 1
#define VMA_EXTERNAL_MEMORY 1

#include <vk_mem_alloc.h>

#ifdef __clang__
Expand Down
1 change: 1 addition & 0 deletions generate-new/vma/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ marshalParams handles =
getBespokeScheme :: Marshalable a => CName -> a -> Maybe (MarshalScheme a)
getBespokeScheme p a = case (p, name a) of
("VmaAllocatorCreateInfo", "pHeapSizeLimit") -> Just $ Preserve (type' a)
("VmaAllocatorCreateInfo", "pTypeExternalMemoryHandleTypes") -> Just $ Preserve (type' a)
("vmaBuildStatsString", "ppStatsString") | Ptr _ p <- type' a ->
Just $ Returned (Preserve p)
("vmaGetPoolName", "ppName") | Ptr _ p <- type' a ->
Expand Down
1 change: 1 addition & 0 deletions generate-new/vma/VMA/RenderParams.hs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ vulkanManifest getVar structStyle RenderParams {..} =
, "VkDeviceMemory"
, "VkDeviceSize"
, "VkDevice_T"
, "VkExternalMemoryHandleTypeFlagsKHR"
, "VkInstance_T"
, "VkMemoryPropertyFlags"
, "VkPhysicalDevice_T"
Expand Down

0 comments on commit 8456e89

Please sign in to comment.