HORIZON HASKELLDocslts/ghc-9.14.x3e2d5682026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 3e2d568 · 2026-10-11

Modulevulkan-utils-0.5.11.0Haskell2010

Vulkan.Utils.Swapchain

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.

  • 2 types
  • 6 values
datadata Swapchain
#

Constructors

Instances2Generic, Rep
datadata SwapchainConfig
#

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

Constructors

  • SwapchainConfig
    • 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: [].

Instances2Generic, Rep

Does presenting through this surface format sRGB-encode written linear values?

selectSurfaceFormat is first-fit and the platforms disagree — Mesa's surface list leads with sRGB formats, MoltenVK's with UNORM — so unpinned output is only correct on the platform whose pick matches what the app writes. Pin via scSurfaceFormatPreferences: srgbEncoding when passes produce linear colour (the hardware encodes on write), unormEncoding when they produce display-referred (already-encoded) colour that must pass through untouched. A preference is best-effort — a surface offering no match falls back — so callers that can adapt should check the picked sFormat.