Skip to content

Commit

Permalink
Fix for 9.6
Browse files Browse the repository at this point in the history
  • Loading branch information
dpwiz committed Apr 13, 2024
1 parent 2007a6e commit d2d3af4
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 38 deletions.
3 changes: 2 additions & 1 deletion examples/compute/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import Vulkan.Core10 as Vk
hiding ( withBuffer
, withImage
)
import qualified Vulkan.Core10.DeviceInitialization as DI
import Vulkan.Dynamic ( DeviceCmds
( DeviceCmds
, pVkGetDeviceProcAddr
Expand Down Expand Up @@ -505,7 +506,7 @@ physicalDeviceInfo
physicalDeviceInfo phys = runMaybeT $ do
pdiTotalMemory <- do
heaps <- memoryHeaps <$> getPhysicalDeviceMemoryProperties phys
pure $ sum ((size :: MemoryHeap -> DeviceSize) <$> heaps)
pure $ sum (DI.size <$> heaps)
pdiComputeQueueFamilyIndex <- do
queueFamilyProperties <- getPhysicalDeviceQueueFamilyProperties phys
let isComputeQueue q =
Expand Down
6 changes: 4 additions & 2 deletions examples/offscreen/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ import qualified Language.C.Types as C
import Vulkan.CStruct.Extends
import Vulkan.Core10 as Vk
hiding ( withImage )
import qualified Vulkan.Core10.DeviceInitialization as DI
import qualified Vulkan.Core10.Image as SL
import Vulkan.Dynamic ( DeviceCmds
( DeviceCmds
, pVkGetDeviceProcAddr
Expand Down Expand Up @@ -571,7 +573,7 @@ render = do
let pixelAddr :: Int -> Int -> Ptr Word32
pixelAddr x y = plusPtr
(mappedData cpuImageAllocationInfo)
( fromIntegral (offset (cpuImageLayout :: SubresourceLayout))
( fromIntegral (SL.offset cpuImageLayout)
+ (y * fromIntegral (rowPitch cpuImageLayout))
+ (x * sizeOf (0 :: Word32))
)
Expand Down Expand Up @@ -738,7 +740,7 @@ physicalDeviceInfo
physicalDeviceInfo phys = runMaybeT $ do
pdiTotalMemory <- do
heaps <- memoryHeaps <$> getPhysicalDeviceMemoryProperties phys
pure $ sum ((size :: MemoryHeap -> DeviceSize) <$> heaps)
pure $ sum (DI.size <$> heaps)
pdiGraphicsQueueFamilyIndex <- do
queueFamilyProperties <- getPhysicalDeviceQueueFamilyProperties phys
let isGraphicsQueue q =
Expand Down
34 changes: 17 additions & 17 deletions examples/sdl-triangle/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ import Say
import System.Exit
import Vulkan.CStruct.Extends
import Vulkan.Core10
import qualified Vulkan.Core10.DeviceInitialization as DI
import Vulkan.Extensions.VK_EXT_debug_utils
import Vulkan.Extensions.VK_EXT_validation_features
import Vulkan.Extensions.VK_KHR_surface
import qualified Vulkan.Extensions.VK_KHR_surface as SF
import Vulkan.Extensions.VK_KHR_swapchain
import qualified Vulkan.Extensions.VK_KHR_swapchain as SW
import Vulkan.Utils.Debug
import Vulkan.Utils.ShaderQQ.GLSL.Glslang ( vert
, frag )
Expand Down Expand Up @@ -267,6 +270,7 @@ createGraphicsPipeline dev renderPass swapchainExtent _swapchainImageFormat = do
shaderStages <- createShaders dev
pipelineLayout <- withPipelineLayout dev zero Nothing allocate
let
Extent2D {width = swapchainWidth, height = swapchainHeight} = swapchainExtent
pipelineCreateInfo :: GraphicsPipelineCreateInfo '[]
pipelineCreateInfo = zero
{ stages = shaderStages
Expand All @@ -280,8 +284,8 @@ createGraphicsPipeline dev renderPass swapchainExtent _swapchainImageFormat = do
[ Viewport
{ x = 0
, y = 0
, width = realToFrac (width (swapchainExtent :: Extent2D))
, height = realToFrac (height (swapchainExtent :: Extent2D))
, width = realToFrac swapchainWidth
, height = realToFrac swapchainHeight
, minDepth = 0
, maxDepth = 1
}
Expand Down Expand Up @@ -333,14 +337,14 @@ createFramebuffers
-> RenderPass
-> Extent2D
-> Managed (V.Vector Framebuffer)
createFramebuffers dev imageViews renderPass swapchainExtent =
createFramebuffers dev imageViews renderPass Extent2D {width, height} =
for imageViews $ \imageView -> do
let framebufferCreateInfo :: FramebufferCreateInfo '[]
framebufferCreateInfo = zero
{ renderPass = renderPass
, attachments = [imageView]
, width = width (swapchainExtent :: Extent2D)
, height = height (swapchainExtent :: Extent2D)
, width
, height
, layers = 1
}
withFramebuffer dev framebufferCreateInfo Nothing allocate
Expand Down Expand Up @@ -493,11 +497,9 @@ createGraphicalDevice inst surface = do
in
zero
{ surface = surface
, minImageCount = minImageCount
(surfaceCaps :: SurfaceCapabilitiesKHR)
+ 1
, imageFormat = (format :: SurfaceFormatKHR -> Format) surfaceFormat
, imageColorSpace = colorSpace surfaceFormat
, minImageCount = SF.minImageCount surfaceCaps + 1
, imageFormat = SF.format surfaceFormat
, imageColorSpace = SF.colorSpace surfaceFormat
, imageExtent = case
currentExtent
(surfaceCaps :: SurfaceCapabilitiesKHR)
Expand All @@ -522,8 +524,8 @@ createGraphicalDevice inst surface = do
, graphicsQueue
, graphicsQueueFamilyIndex
, presentQueue
, format (surfaceFormat :: SurfaceFormatKHR)
, imageExtent (swapchainCreateInfo :: SwapchainCreateInfoKHR '[])
, SF.format surfaceFormat
, SW.imageExtent swapchainCreateInfo
, swapchain
)

Expand Down Expand Up @@ -571,7 +573,7 @@ pickGraphicalPhysicalDevice inst surface _requiredExtensions desiredFormat = do
deviceScore :: MonadIO m => PhysicalDevice -> m Word64
deviceScore dev = do
heaps <- memoryHeaps <$> getPhysicalDeviceMemoryProperties dev
let totalSize = sum $ (size :: MemoryHeap -> DeviceSize) <$> heaps
let totalSize = sum $ DI.size <$> heaps
pure totalSize

deviceHasSwapchain :: MonadIO m => PhysicalDevice -> m Bool
Expand Down Expand Up @@ -606,10 +608,8 @@ pickGraphicalPhysicalDevice inst surface _requiredExtensions desiredFormat = do
_
| V.any
(\f ->
format (f :: SurfaceFormatKHR)
== format (desiredFormat :: SurfaceFormatKHR)
&& colorSpace (f :: SurfaceFormatKHR)
== colorSpace (desiredFormat :: SurfaceFormatKHR)
SF.format f == SF.format desiredFormat
&& SF.colorSpace f == SF.colorSpace desiredFormat
)
formats
-> desiredFormat
Expand Down
4 changes: 2 additions & 2 deletions examples/timeline-semaphore/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import UnliftIO ( Exception(displayException)
)
import Vulkan.CStruct.Extends
import Vulkan.Core10
import Vulkan.Core12
import qualified Vulkan.Core10.DeviceInitialization as DI
import Vulkan.Core12.Promoted_From_VK_KHR_timeline_semaphore
as Timeline
import Vulkan.Exception
Expand Down Expand Up @@ -160,7 +160,7 @@ physicalDeviceInfo phys = runMaybeT $ do
empty
pdiTotalMemory <- do
heaps <- memoryHeaps <$> getPhysicalDeviceMemoryProperties phys
pure $ sum ((size :: MemoryHeap -> DeviceSize) <$> heaps)
pure $ sum (DI.size <$> heaps)
(pdiQueueCreateInfos, getQueues) <- MaybeT $ assignQueues
phys
(MyQueues (QueueSpec 1 (const (pure . isComputeQueueFamily))))
Expand Down
35 changes: 20 additions & 15 deletions generate-new/generate-new.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ library
BlockArguments
ConstraintKinds
DataKinds
DeriveFunctor
DeepSubsumption
DeriveFoldable
DeriveTraversable
DeriveFunctor
DeriveGeneric
DeriveTraversable
DerivingVia
DisambiguateRecordFields
DuplicateRecordFields
Expand Down Expand Up @@ -152,7 +153,7 @@ library
, pandoc
, parsec
, parsers
, polysemy >=1.4 && <1.8
, polysemy >=1.4 && <2
, pretty-show
, prettyprinter
, regex-applicative
Expand Down Expand Up @@ -199,10 +200,11 @@ library khronos-spec
BlockArguments
ConstraintKinds
DataKinds
DeriveFunctor
DeepSubsumption
DeriveFoldable
DeriveTraversable
DeriveFunctor
DeriveGeneric
DeriveTraversable
DerivingVia
DisambiguateRecordFields
DuplicateRecordFields
Expand Down Expand Up @@ -260,7 +262,7 @@ library khronos-spec
, pandoc
, parsec
, parsers
, polysemy >=1.4 && <1.8
, polysemy >=1.4 && <2
, pretty-show
, prettyprinter
, regex-applicative
Expand Down Expand Up @@ -302,10 +304,11 @@ executable vk
BlockArguments
ConstraintKinds
DataKinds
DeriveFunctor
DeepSubsumption
DeriveFoldable
DeriveTraversable
DeriveFunctor
DeriveGeneric
DeriveTraversable
DerivingVia
DisambiguateRecordFields
DuplicateRecordFields
Expand Down Expand Up @@ -364,7 +367,7 @@ executable vk
, pandoc
, parsec
, parsers
, polysemy >=1.4 && <1.8
, polysemy >=1.4 && <2
, pretty-show
, prettyprinter
, regex-applicative
Expand Down Expand Up @@ -409,10 +412,11 @@ executable vma
BlockArguments
ConstraintKinds
DataKinds
DeriveFunctor
DeepSubsumption
DeriveFoldable
DeriveTraversable
DeriveFunctor
DeriveGeneric
DeriveTraversable
DerivingVia
DisambiguateRecordFields
DuplicateRecordFields
Expand Down Expand Up @@ -471,7 +475,7 @@ executable vma
, pandoc
, parsec
, parsers
, polysemy >=1.4 && <1.8
, polysemy >=1.4 && <2
, pretty-show
, prettyprinter
, regex-applicative
Expand Down Expand Up @@ -514,10 +518,11 @@ executable xr
BlockArguments
ConstraintKinds
DataKinds
DeriveFunctor
DeepSubsumption
DeriveFoldable
DeriveTraversable
DeriveFunctor
DeriveGeneric
DeriveTraversable
DerivingVia
DisambiguateRecordFields
DuplicateRecordFields
Expand Down Expand Up @@ -576,7 +581,7 @@ executable xr
, pandoc
, parsec
, parsers
, polysemy >=1.4 && <1.8
, polysemy >=1.4 && <2
, pretty-show
, prettyprinter
, regex-applicative
Expand Down
2 changes: 1 addition & 1 deletion generate-new/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ dependencies:
- pandoc
- parsec
- parsers
- polysemy >= 1.4 && < 1.8
- polysemy >= 1.4 && < 2
- pretty-show
- prettyprinter
- regex-applicative
Expand Down

0 comments on commit d2d3af4

Please sign in to comment.