vulkan-utils-0.5.11.0: Utils for the vulkan package
Safe HaskellNone
LanguageHaskell2010

Vulkan.Utils.Swapchain

Description

Swapchain creation, recreation, and the small helper for catching swapchain-out-of-date exceptions thrown elsewhere.

Opinionated choices (storage-image usage, FIFO_RELAXED preference, surface format selection) are exposed via SwapchainConfig. defaultSwapchainConfig gives a color-attachment-only swapchain prefering FIFO_RELAXED then FIFO; compute-shader callers add IMAGE_USAGE_STORAGE_BIT etc.

Synopsis

Documentation

data Swapchain Source #

Constructors

Swapchain 

Fields

Instances

Instances details
Generic Swapchain Source # 
Instance details

Defined in Vulkan.Utils.Swapchain

Associated Types

type Rep Swapchain 
Instance details

Defined in Vulkan.Utils.Swapchain

type Rep Swapchain = D1 ('MetaData "Swapchain" "Vulkan.Utils.Swapchain" "vulkan-utils-0.5.11.0-inplace" 'False) (C1 ('MetaCons "Swapchain" 'PrefixI 'True) (((S1 ('MetaSel ('Just "sSwapchain") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SwapchainKHR) :*: S1 ('MetaSel ('Just "sSurface") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SurfaceKHR)) :*: (S1 ('MetaSel ('Just "sFormat") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SurfaceFormatKHR) :*: (S1 ('MetaSel ('Just "sExtent") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Extent2D) :*: S1 ('MetaSel ('Just "sPresentMode") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 PresentModeKHR)))) :*: ((S1 ('MetaSel ('Just "sImages") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Vector Image)) :*: S1 ('MetaSel ('Just "sImageViews") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Vector ImageView))) :*: (S1 ('MetaSel ('Just "sRenderFinished") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Vector Semaphore)) :*: (S1 ('MetaSel ('Just "sRelease") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 RefCounted) :*: S1 ('MetaSel ('Just "sConfig") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SwapchainConfig))))))
type Rep Swapchain Source # 
Instance details

Defined in Vulkan.Utils.Swapchain

type Rep Swapchain = D1 ('MetaData "Swapchain" "Vulkan.Utils.Swapchain" "vulkan-utils-0.5.11.0-inplace" 'False) (C1 ('MetaCons "Swapchain" 'PrefixI 'True) (((S1 ('MetaSel ('Just "sSwapchain") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SwapchainKHR) :*: S1 ('MetaSel ('Just "sSurface") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SurfaceKHR)) :*: (S1 ('MetaSel ('Just "sFormat") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SurfaceFormatKHR) :*: (S1 ('MetaSel ('Just "sExtent") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Extent2D) :*: S1 ('MetaSel ('Just "sPresentMode") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 PresentModeKHR)))) :*: ((S1 ('MetaSel ('Just "sImages") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Vector Image)) :*: S1 ('MetaSel ('Just "sImageViews") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Vector ImageView))) :*: (S1 ('MetaSel ('Just "sRenderFinished") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Vector Semaphore)) :*: (S1 ('MetaSel ('Just "sRelease") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 RefCounted) :*: S1 ('MetaSel ('Just "sConfig") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SwapchainConfig))))))

data SwapchainConfig Source #

Opinionated knobs for swapchain creation. Use defaultSwapchainConfig as a starting point and override the bits you care about.

Constructors

SwapchainConfig 

Fields

  • scRequiredUsageFlags :: [ImageUsageFlagBits]

    Image usages every swapchain image must support. Default: [IMAGE_USAGE_COLOR_ATTACHMENT_BIT]. Compute-shader callers add IMAGE_USAGE_STORAGE_BIT.

  • scRequiredFormatFeatures :: [FormatFeatureFlagBits]

    Format-feature flags the chosen surface format's optimal tiling must satisfy. Default: []. Set FORMAT_FEATURE_STORAGE_IMAGE_BIT if using IMAGE_USAGE_STORAGE_BIT — SRGB formats typically omit it.

  • scDesiredPresentModes :: [PresentModeKHR]

    Present-mode preference, best first. Default: [FIFO_RELAXED, FIFO]. The driver-guaranteed FIFO is the safe fallback. Add IMMEDIATE or MAILBOX if your scheduler can tolerate them.

  • scSurfaceFormatPreferences :: [SurfaceFormatKHR -> Bool]

    Surface-format preference predicates, best first. For each predicate in order, the first format that matches both the predicate AND the feature requirements wins. If no preference matches, falls back to the first feature-satisfying format, then to the head. Default: [].

Instances

Instances details
Generic SwapchainConfig Source # 
Instance details

Defined in Vulkan.Utils.Swapchain

Associated Types

type Rep SwapchainConfig 
Instance details

Defined in Vulkan.Utils.Swapchain

type Rep SwapchainConfig = D1 ('MetaData "SwapchainConfig" "Vulkan.Utils.Swapchain" "vulkan-utils-0.5.11.0-inplace" 'False) (C1 ('MetaCons "SwapchainConfig" 'PrefixI 'True) ((S1 ('MetaSel ('Just "scRequiredUsageFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [ImageUsageFlagBits]) :*: S1 ('MetaSel ('Just "scRequiredFormatFeatures") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [FormatFeatureFlagBits])) :*: (S1 ('MetaSel ('Just "scDesiredPresentModes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [PresentModeKHR]) :*: S1 ('MetaSel ('Just "scSurfaceFormatPreferences") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [SurfaceFormatKHR -> Bool]))))
type Rep SwapchainConfig Source # 
Instance details

Defined in Vulkan.Utils.Swapchain

type Rep SwapchainConfig = D1 ('MetaData "SwapchainConfig" "Vulkan.Utils.Swapchain" "vulkan-utils-0.5.11.0-inplace" 'False) (C1 ('MetaCons "SwapchainConfig" 'PrefixI 'True) ((S1 ('MetaSel ('Just "scRequiredUsageFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [ImageUsageFlagBits]) :*: S1 ('MetaSel ('Just "scRequiredFormatFeatures") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [FormatFeatureFlagBits])) :*: (S1 ('MetaSel ('Just "scDesiredPresentModes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [PresentModeKHR]) :*: S1 ('MetaSel ('Just "scSurfaceFormatPreferences") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [SurfaceFormatKHR -> Bool]))))

allocateSwapchain Source #

Arguments

:: MonadResource m 
=> PhysicalDevice 
-> Device 
-> SwapchainConfig 
-> SwapchainKHR

Previous swapchain (NULL_HANDLE for first)

-> Extent2D

Fallback size when the surface lets us pick

-> SurfaceKHR 
-> m Swapchain 

Allocate a new swapchain plus its image views.

recreateSwapchain Source #

Arguments

:: MonadResource m 
=> PhysicalDevice 
-> Device 
-> Extent2D

New window size

-> Swapchain 
-> m Swapchain 

Build a new swapchain at a new size, dropping the reference to the old one so its resources can be released once in-flight frames complete.

threwSwapchainError :: IO b -> IO Bool Source #

Catch an ERROR_OUT_OF_DATE_KHR exception and return True when caught.