| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Vulkan.Utils.Pipeline.Specialization
Description
Specialization constants, normalized to stacks of 32-bit units.
data MySpec = MySpec { width :: Word32, height :: Word32, scale :: Float }
instance Specialization MySpec where -- ... pack the fields
withSpecialization sp \mSpec ->
-- build a PipelineShaderStageCreateInfo with
-- specializationInfo = mSpec
...
Synopsis
- withSpecialization :: (Specialization spec, MonadUnliftIO m) => spec -> (Maybe SpecializationInfo -> m a) -> m a
- allocateSpecialization :: (Specialization spec, MonadResource m) => spec -> m (Maybe SpecializationInfo)
- class Specialization a where
- specializationData :: a -> [Word32]
- class SpecializationConst a where
- packConstData :: a -> Word32
Documentation
withSpecialization :: (Specialization spec, MonadUnliftIO m) => spec -> (Maybe SpecializationInfo -> m a) -> m a Source #
Provide a SpecializationInfo describing spec to the callback.
The info (and the buffer its data' pointer references) is valid only for the
duration of the callback, which is exactly the window in which it needs to live:
pipeline creation copies the constant values out. Build and create the pipeline
inside the continuation.
An empty specialization (e.g. () or an empty list) yields Nothing, so the
shader stage's specializationInfo stays unset.
allocateSpecialization :: (Specialization spec, MonadResource m) => spec -> m (Maybe SpecializationInfo) Source #
Pack a specialization into a buffer tied to the current resource scope,
yielding the SpecializationInfo to embed in a shader stage's
specializationInfo.
Unlike withSpecialization this is not continuation-scoped: the backing buffer
lives until the surrounding ResourceT block ends,
so it survives a later pipeline creation. An empty specialization (e.g. ())
yields Nothing.
class Specialization a where Source #
A value that flattens to a stack of 32-bit specialization constants, in
constant_id order starting from zero.
Methods
specializationData :: a -> [Word32] Source #
Instances
class SpecializationConst a where Source #
A single scalar specialization constant, reinterpreted into its 32-bit representation.
Per the GL_KHR_vulkan_glsl spec a constant_id may only decorate a scalar
int, float or bool; uint works in practice too. All of these are 32 bits
wide.
Methods
packConstData :: a -> Word32 Source #
Instances
| SpecializationConst Int32 Source # | Two's-complement bit pattern, preserved by |
Defined in Vulkan.Utils.Pipeline.Specialization Methods packConstData :: Int32 -> Word32 Source # | |
| SpecializationConst Word32 Source # | |
Defined in Vulkan.Utils.Pipeline.Specialization Methods packConstData :: Word32 -> Word32 Source # | |
| SpecializationConst Bool Source # | |
Defined in Vulkan.Utils.Pipeline.Specialization Methods packConstData :: Bool -> Word32 Source # | |
| SpecializationConst Float Source # | |
Defined in Vulkan.Utils.Pipeline.Specialization Methods packConstData :: Float -> Word32 Source # | |