Skip to content

Commit

Permalink
Merge pull request #264 from expipiplus1/bump-vma
Browse files Browse the repository at this point in the history
Bump VMA version
  • Loading branch information
expipiplus1 authored Feb 19, 2021
2 parents bd07ea3 + 4378d18 commit 4f163a3
Show file tree
Hide file tree
Showing 61 changed files with 7,485 additions and 402 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ jobs:
run: |
brew install pkg-config sdl2
brew tap apenngrace/homebrew-vulkan
brew cask install vulkan-sdk --verbose ||
brew cask install vulkan-sdk --verbose ||
brew cask install vulkan-sdk --verbose
brew install --cask vulkan-sdk --verbose ||
brew install --cask vulkan-sdk --verbose ||
brew install --cask vulkan-sdk --verbose
- name: Install system dependencies Windows
if: matrix.os == 'windows-latest'
Expand Down Expand Up @@ -230,9 +230,9 @@ jobs:
run: |
brew install pkg-config sdl2
brew tap apenngrace/homebrew-vulkan --verbose
brew cask install vulkan-sdk --verbose ||
brew cask install vulkan-sdk --verbose ||
brew cask install vulkan-sdk --verbose
brew install --cask vulkan-sdk --verbose ||
brew install --cask vulkan-sdk --verbose ||
brew install --cask vulkan-sdk --verbose
- name: Remove openxr
run: |
Expand Down
2 changes: 1 addition & 1 deletion VulkanMemoryAllocator/VulkanMemoryAllocator
41 changes: 37 additions & 4 deletions VulkanMemoryAllocator/VulkanMemoryAllocator.cabal
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
cabal-version: 2.2

-- This file has been generated from package.yaml by hpack version 0.34.3.
-- This file has been generated from package.yaml by hpack version 0.34.4.
--
-- see: https://github.com/sol/hpack

name: VulkanMemoryAllocator
version: 0.3.12
version: 0.4
synopsis: Bindings to the VulkanMemoryAllocator library
category: Graphics
homepage: https://github.com/expipiplus1/vulkan#readme
Expand Down Expand Up @@ -49,7 +49,40 @@ library
VulkanMemoryAllocator
hs-source-dirs:
src
default-extensions: AllowAmbiguousTypes CPP DataKinds DefaultSignatures DeriveAnyClass DeriveGeneric DerivingStrategies DuplicateRecordFields FlexibleContexts FlexibleInstances GADTs GeneralizedNewtypeDeriving InstanceSigs LambdaCase MagicHash NoMonomorphismRestriction OverloadedStrings PartialTypeSignatures PatternSynonyms PolyKinds QuantifiedConstraints RankNTypes RecordWildCards RoleAnnotations ScopedTypeVariables StandaloneDeriving Strict TypeApplications TypeFamilyDependencies TypeOperators TypeSynonymInstances UndecidableInstances ViewPatterns
default-extensions:
AllowAmbiguousTypes
CPP
DataKinds
DefaultSignatures
DeriveAnyClass
DeriveGeneric
DerivingStrategies
DuplicateRecordFields
FlexibleContexts
FlexibleInstances
GADTs
GeneralizedNewtypeDeriving
InstanceSigs
LambdaCase
MagicHash
NoMonomorphismRestriction
OverloadedStrings
PartialTypeSignatures
PatternSynonyms
PolyKinds
QuantifiedConstraints
RankNTypes
RecordWildCards
RoleAnnotations
ScopedTypeVariables
StandaloneDeriving
Strict
TypeApplications
TypeFamilyDependencies
TypeOperators
TypeSynonymInstances
UndecidableInstances
ViewPatterns
ghc-options: -Wall -Wno-unticked-promoted-constructors -Wno-missing-pattern-synonym-signatures -Wno-unused-imports -Wno-missing-signatures -Wno-partial-type-signatures
cxx-options: -std=c++11
include-dirs:
Expand All @@ -63,7 +96,7 @@ library
, bytestring
, transformers
, vector
, vulkan >=3.6 && <3.10
, vulkan >=3.6 && <3.11
if flag(safe-foreign-calls)
cpp-options: -DSAFE_FOREIGN_CALLS
if flag(vma-ndebug)
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.4] - 2021-02-18
- Bump VMA, support for VK_EXT_memory_priority

## [0.3.12] - 2021-01-09

- Calling traceEventIO before and after every VulkanMemoryAllocator command if
Expand Down
4 changes: 2 additions & 2 deletions VulkanMemoryAllocator/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: VulkanMemoryAllocator
version: "0.3.12"
version: "0.4"
synopsis: Bindings to the VulkanMemoryAllocator library
category: Graphics
maintainer: Joe Hermaszewski <[email protected]>
Expand All @@ -20,7 +20,7 @@ library:
src/lib.cpp
dependencies:
- base <5
- vulkan >= 3.6 && < 3.10
- vulkan >= 3.6 && < 3.11
- bytestring
- transformers
- vector
Expand Down
63 changes: 56 additions & 7 deletions VulkanMemoryAllocator/src/VulkanMemoryAllocator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ module VulkanMemoryAllocator ( createAllocator
, ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT
, ALLOCATOR_CREATE_AMD_DEVICE_COHERENT_MEMORY_BIT
, ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT
, ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT
, ..
)
, VulkanFunctions(..)
Expand Down Expand Up @@ -233,6 +234,9 @@ import Data.Bits (Bits)
import Data.Bits (FiniteBits)
import Data.Typeable (Typeable)
import Foreign.C.Types (CChar)
import Foreign.C.Types (CFloat)
import Foreign.C.Types (CFloat(..))
import Foreign.C.Types (CFloat(CFloat))
import Foreign.C.Types (CSize)
import Foreign.C.Types (CSize(..))
import Foreign.C.Types (CSize(CSize))
Expand Down Expand Up @@ -1012,8 +1016,8 @@ allocateMemoryPages :: forall io
allocateMemoryPages allocator vkMemoryRequirements createInfo = liftIO . evalContT $ do
pPVkMemoryRequirements <- ContT $ allocaBytesAligned @MemoryRequirements ((Data.Vector.length (vkMemoryRequirements)) * 24) 8
Data.Vector.imapM_ (\i e -> ContT $ pokeCStruct (pPVkMemoryRequirements `plusPtr` (24 * (i)) :: Ptr MemoryRequirements) (e) . ($ ())) (vkMemoryRequirements)
pPCreateInfo <- ContT $ allocaBytesAligned @AllocationCreateInfo ((Data.Vector.length (createInfo)) * 40) 8
lift $ Data.Vector.imapM_ (\i e -> poke (pPCreateInfo `plusPtr` (40 * (i)) :: Ptr AllocationCreateInfo) (e)) (createInfo)
pPCreateInfo <- ContT $ allocaBytesAligned @AllocationCreateInfo ((Data.Vector.length (createInfo)) * 48) 8
lift $ Data.Vector.imapM_ (\i e -> poke (pPCreateInfo `plusPtr` (48 * (i)) :: Ptr AllocationCreateInfo) (e)) (createInfo)
let pVkMemoryRequirementsLength = Data.Vector.length $ (vkMemoryRequirements)
lift $ unless ((Data.Vector.length $ (createInfo)) == pVkMemoryRequirementsLength) $
throwIO $ IOError Nothing InvalidArgument "" "pCreateInfo and pVkMemoryRequirements must have the same length" Nothing Nothing
Expand Down Expand Up @@ -2698,6 +2702,26 @@ pattern ALLOCATOR_CREATE_AMD_DEVICE_COHERENT_MEMORY_BIT = AllocatorCreateFlagBit
-- For more information, see documentation chapter /Enabling buffer device
-- address/.
pattern ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT = AllocatorCreateFlagBits 0x00000020
-- | Enables usage of VK_EXT_memory_priority extension in the library.
--
-- You may set this flag only if you found available and enabled this
-- device extension, along with
-- @VkPhysicalDeviceMemoryPriorityFeaturesEXT::memoryPriority == VK_TRUE@,
-- while creating Vulkan device passed as /VmaAllocatorCreateInfo::device/.
--
-- When this flag is used, /VmaAllocationCreateInfo::priority/ and
-- /VmaPoolCreateInfo::priority/ are used to set priorities of allocated
-- Vulkan memory. Without it, these variables are ignored.
--
-- A priority must be a floating-point value between 0 and 1, indicating
-- the priority of the allocation relative to other memory allocations.
-- Larger values are higher priority. The granularity of the priorities is
-- implementation-dependent. It is automatically passed to every call to
-- @vkAllocateMemory@ done by the library using structure
-- @VkMemoryPriorityAllocateInfoEXT@. The value to be used for default
-- priority is 0.5. For more details, see the documentation of the
-- VK_EXT_memory_priority extension.
pattern ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT = AllocatorCreateFlagBits 0x00000040

conNameAllocatorCreateFlagBits :: String
conNameAllocatorCreateFlagBits = "AllocatorCreateFlagBits"
Expand All @@ -2713,6 +2737,7 @@ showTableAllocatorCreateFlagBits =
, (ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT , "EXT_MEMORY_BUDGET_BIT")
, (ALLOCATOR_CREATE_AMD_DEVICE_COHERENT_MEMORY_BIT, "AMD_DEVICE_COHERENT_MEMORY_BIT")
, (ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT , "BUFFER_DEVICE_ADDRESS_BIT")
, (ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT , "EXT_MEMORY_PRIORITY_BIT")
]

instance Show AllocatorCreateFlagBits where
Expand Down Expand Up @@ -3788,6 +3813,15 @@ data AllocationCreateInfo = AllocationCreateInfo
-- then copied to internal buffer, so it doesn\'t need to be valid after
-- allocation call.
userData :: Ptr ()
, -- | A floating-point value between 0 and 1, indicating the priority of the
-- allocation relative to other memory allocations.
--
-- It is used only when 'ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT' flag was
-- used during creation of the 'Allocator' object and this allocation ends
-- up as dedicated or is explicitly forced as dedicated using
-- 'ALLOCATION_CREATE_DEDICATED_MEMORY_BIT'. Otherwise, it has the priority
-- of a memory block where it is placed and this variable is ignored.
priority :: Float
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
Expand All @@ -3796,7 +3830,7 @@ deriving instance Generic (AllocationCreateInfo)
deriving instance Show AllocationCreateInfo

instance ToCStruct AllocationCreateInfo where
withCStruct x f = allocaBytesAligned 40 8 $ \p -> pokeCStruct p x (f p)
withCStruct x f = allocaBytesAligned 48 8 $ \p -> pokeCStruct p x (f p)
pokeCStruct p AllocationCreateInfo{..} f = do
poke ((p `plusPtr` 0 :: Ptr AllocationCreateFlags)) (flags)
poke ((p `plusPtr` 4 :: Ptr MemoryUsage)) (usage)
Expand All @@ -3805,15 +3839,17 @@ instance ToCStruct AllocationCreateInfo where
poke ((p `plusPtr` 16 :: Ptr Word32)) (memoryTypeBits)
poke ((p `plusPtr` 24 :: Ptr Pool)) (pool)
poke ((p `plusPtr` 32 :: Ptr (Ptr ()))) (userData)
poke ((p `plusPtr` 40 :: Ptr CFloat)) (CFloat (priority))
f
cStructSize = 40
cStructSize = 48
cStructAlignment = 8
pokeZeroCStruct p f = do
poke ((p `plusPtr` 0 :: Ptr AllocationCreateFlags)) (zero)
poke ((p `plusPtr` 4 :: Ptr MemoryUsage)) (zero)
poke ((p `plusPtr` 8 :: Ptr MemoryPropertyFlags)) (zero)
poke ((p `plusPtr` 12 :: Ptr MemoryPropertyFlags)) (zero)
poke ((p `plusPtr` 16 :: Ptr Word32)) (zero)
poke ((p `plusPtr` 40 :: Ptr CFloat)) (CFloat (zero))
f

instance FromCStruct AllocationCreateInfo where
Expand All @@ -3825,11 +3861,12 @@ instance FromCStruct AllocationCreateInfo where
memoryTypeBits <- peek @Word32 ((p `plusPtr` 16 :: Ptr Word32))
pool <- peek @Pool ((p `plusPtr` 24 :: Ptr Pool))
pUserData <- peek @(Ptr ()) ((p `plusPtr` 32 :: Ptr (Ptr ())))
priority <- peek @CFloat ((p `plusPtr` 40 :: Ptr CFloat))
pure $ AllocationCreateInfo
flags usage requiredFlags preferredFlags memoryTypeBits pool pUserData
flags usage requiredFlags preferredFlags memoryTypeBits pool pUserData (coerce @CFloat @Float priority)

instance Storable AllocationCreateInfo where
sizeOf ~_ = 40
sizeOf ~_ = 48
alignment ~_ = 8
peek = peekCStruct
poke ptr poked = pokeCStruct ptr poked (pure ())
Expand All @@ -3843,6 +3880,7 @@ instance Zero AllocationCreateInfo where
zero
zero
zero
zero


type PoolCreateFlags = PoolCreateFlagBits
Expand Down Expand Up @@ -3973,6 +4011,13 @@ data PoolCreateInfo = PoolCreateInfo
-- If you want to allow any allocations other than used in the current
-- frame to become lost, set this value to 0.
frameInUseCount :: Word32
, -- | A floating-point value between 0 and 1, indicating the priority of the
-- allocations in this pool relative to other memory allocations.
--
-- It is used only when 'ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT' flag was
-- used during creation of the 'Allocator' object. Otherwise, this variable
-- is ignored.
priority :: Float
}
deriving (Typeable, Eq)
#if defined(GENERIC_INSTANCES)
Expand All @@ -3989,6 +4034,7 @@ instance ToCStruct PoolCreateInfo where
poke ((p `plusPtr` 16 :: Ptr CSize)) (CSize (minBlockCount))
poke ((p `plusPtr` 24 :: Ptr CSize)) (CSize (maxBlockCount))
poke ((p `plusPtr` 32 :: Ptr Word32)) (frameInUseCount)
poke ((p `plusPtr` 36 :: Ptr CFloat)) (CFloat (priority))
f
cStructSize = 40
cStructAlignment = 8
Expand All @@ -3999,6 +4045,7 @@ instance ToCStruct PoolCreateInfo where
poke ((p `plusPtr` 16 :: Ptr CSize)) (CSize (zero))
poke ((p `plusPtr` 24 :: Ptr CSize)) (CSize (zero))
poke ((p `plusPtr` 32 :: Ptr Word32)) (zero)
poke ((p `plusPtr` 36 :: Ptr CFloat)) (CFloat (zero))
f

instance FromCStruct PoolCreateInfo where
Expand All @@ -4009,8 +4056,9 @@ instance FromCStruct PoolCreateInfo where
minBlockCount <- peek @CSize ((p `plusPtr` 16 :: Ptr CSize))
maxBlockCount <- peek @CSize ((p `plusPtr` 24 :: Ptr CSize))
frameInUseCount <- peek @Word32 ((p `plusPtr` 32 :: Ptr Word32))
priority <- peek @CFloat ((p `plusPtr` 36 :: Ptr CFloat))
pure $ PoolCreateInfo
memoryTypeIndex flags blockSize (coerce @CSize @Word64 minBlockCount) (coerce @CSize @Word64 maxBlockCount) frameInUseCount
memoryTypeIndex flags blockSize (coerce @CSize @Word64 minBlockCount) (coerce @CSize @Word64 maxBlockCount) frameInUseCount (coerce @CFloat @Float priority)

instance Storable PoolCreateInfo where
sizeOf ~_ = 40
Expand All @@ -4026,6 +4074,7 @@ instance Zero PoolCreateInfo where
zero
zero
zero
zero


-- | VmaPoolStats
Expand Down
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## WIP

## [3.10] - 2021-02-18
- Bump API version to v1.2.170

## [3.9.1] - 2021-02-06
- Bump API version to v1.2.169
- Add `COMPLETE` pragma to `MAKE_VERSION` pattern
Expand Down
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let
packages = p:
with p;
[ vulkan vulkan-utils VulkanMemoryAllocator vulkan-examples openxr ]
++ pkgs.lib.optional (p.ghc.version == "8.10.3") generate-new;
++ pkgs.lib.optional (p.ghc.version == "8.10.4") generate-new;

in if forShell then
haskellPackages.shellFor {
Expand Down
Loading

0 comments on commit 4f163a3

Please sign in to comment.