| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Vulkan.Utils.DynamicState
Description
The Vulkan-1.3-core "always-on" dynamic state: the set of pipeline state
that can be made dynamic without any vendor or experimental extension, so a
single pipeline object serves every combination instead of permuting into one
Pipeline per variation. See allocatePipeline
and allocatePipeline.
Because these states are declared dynamic, the matching cmdSet* MUST be issued
before each draw (an unset dynamic state is undefined behaviour). The
DynamicState record carries the whole set with safe defaults; amend it with
the per-frame situation (the swapchain extent via dynamicStateFor) and emit
the lot in one go with applyDynamicStates over allDynamicStates.
Defaults mirror Vulkan's zero-initialized values, deviating only where a
non-zero is required for validity (lineWidth = 1) or to match the pipeline's
baked topology class (topology = TRIANGLE_LIST). They are feature-free
(no wideLines, no depthBounds) and valid with a colour-only attachment (all
depth/stencil tests disabled).
Synopsis
- data DynamicState = DynamicState {
- viewports :: Vector Viewport
- scissors :: Vector Rect2D
- topology :: PrimitiveTopology
- primitiveRestart :: Bool
- cullMode :: CullModeFlags
- frontFace :: FrontFace
- rasterizerDiscard :: Bool
- lineWidth :: Float
- depthBiasEnable :: Bool
- depthBias :: (Float, Float, Float)
- depthTest :: Bool
- depthWrite :: Bool
- depthCompareOp :: CompareOp
- depthBoundsTest :: Bool
- depthBounds :: (Float, Float)
- stencilTest :: Bool
- stencilFailOp :: StencilOp
- stencilPassOp :: StencilOp
- stencilDepthFailOp :: StencilOp
- stencilCompareOp :: CompareOp
- stencilCompareMask :: Word32
- stencilWriteMask :: Word32
- stencilReference :: Word32
- blendConstants :: (Float, Float, Float, Float)
- defaultDynamicState :: DynamicState
- dynamicStateFor :: Extent2D -> DynamicState
- applyDynamicStates :: MonadIO m => Vector DynamicState -> CommandBuffer -> DynamicState -> m ()
- allDynamicStates :: Vector DynamicState
- depthOnlyDynamicStates :: Vector DynamicState
- defaultDynamicStatesFor :: Bool -> Vector DynamicState
- minimalDynamicStates :: Vector DynamicState
- noDynamicStates :: Maybe (Vector DynamicState)
- preRasterizationStates :: Vector DynamicState
- fragmentTestStates :: Vector DynamicState
- fragmentOutputStates :: Vector DynamicState
- fullViewport :: Extent2D -> Viewport
- fullScissor :: Extent2D -> Rect2D
The dynamic-state record
data DynamicState Source #
Every Vulkan-1.3-core always-on dynamic state, as plain values. Field types
match the cmdSet* argument shapes. The stencil ops apply to
STENCIL_FACE_FRONT_AND_BACK.
Constructors
| DynamicState | |
Fields
| |
defaultDynamicState :: DynamicState Source #
Safe, feature-free defaults (see module header). viewports and scissors
are empty — supply them with dynamicStateFor or by record update before
applying.
dynamicStateFor :: Extent2D -> DynamicState Source #
defaultDynamicState with the whole-extent viewport and scissor filled in.
The common entry point; amend further by record update, e.g.
applyDynamicStatesallDynamicStatescb (dynamicStateForext){cullMode= Vk.CULL_MODE_BACK_BIT }
Applying it
applyDynamicStates :: MonadIO m => Vector DynamicState -> CommandBuffer -> DynamicState -> m () Source #
Issue the cmdSet* for exactly the given states, pulling values from the
record. Use the same set passed to the pipeline builder for exact lockstep.
States not modelled by DynamicState are skipped (the caller must set those
themselves).
The state set (pipeline dynamicStates ⇆ apply, single source of truth)
allDynamicStates :: Vector DynamicState Source #
The whole always-on set: pass this (or Nothing, which resolves to it) to a
full-dynamic pipeline builder, and feed the same set to applyDynamicStates so
the pipeline's dynamicStates and the per-frame applies stay in lockstep.
depthOnlyDynamicStates :: Vector DynamicState Source #
The set for a depth-only pipeline (no colour attachment): everything in
allDynamicStates except fragmentOutputStates (DYNAMIC_STATE_BLEND_CONSTANTS),
which has no colour attachment to act on. Pair it with a depth-only pipeline and
feed the same set to applyDynamicStates.
defaultDynamicStatesFor Source #
The default dynamic-state set for an attachment shape: allDynamicStates when
there is at least one colour attachment, otherwise depthOnlyDynamicStates. The
default a pipeline builder resolves Nothing to.
minimalDynamicStates :: Vector DynamicState Source #
Just the (fixed-count) viewport and scissor. For pipelines that want only
those dynamic and set them with cmdSetViewport / cmdSetScissor (not the
with-count variants applyDynamicStates issues for allDynamicStates).
noDynamicStates :: Maybe (Vector DynamicState) Source #
Declare nothing dynamic: every state is baked into the pipeline, so no
cmdSet* need be issued (skip applyDynamicStates entirely). Pass it where a
builder takes Maybe (Vector Vk.DynamicState).
The pipeline must then carry a complete static state — crucially a baked viewport
and scissor — so this suits a builder that bakes those (typically a fixed-size
offscreen target). The colour-pipeline builders here instead leave viewport and
scissor dynamic, so they pair with Nothing / allDynamicStates, not this.
preRasterizationStates :: Vector DynamicState Source #
fragmentTestStates :: Vector DynamicState Source #
Fragment-shader depth/stencil dynamic states.
fragmentOutputStates :: Vector DynamicState Source #
Whole-extent viewport/scissor
fullViewport :: Extent2D -> Viewport Source #
A viewport covering the whole extent, with depth range 0 to 1.
fullScissor :: Extent2D -> Rect2D Source #
A scissor rectangle covering the whole extent (offset at the origin).