{-# language CPP #-}
module Vulkan.Extensions.VK_AMD_mixed_attachment_samples ( AttachmentSampleCountInfoAMD(..)
, AMD_MIXED_ATTACHMENT_SAMPLES_SPEC_VERSION
, pattern AMD_MIXED_ATTACHMENT_SAMPLES_SPEC_VERSION
, AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME
, pattern AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME
) where
import Foreign.Marshal.Alloc (allocaBytes)
import Foreign.Ptr (nullPtr)
import Foreign.Ptr (plusPtr)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
import Data.Vector (generateM)
import qualified Data.Vector (imapM_)
import qualified Data.Vector (length)
import Vulkan.CStruct (FromCStruct)
import Vulkan.CStruct (FromCStruct(..))
import Vulkan.CStruct (ToCStruct)
import Vulkan.CStruct (ToCStruct(..))
import Vulkan.Zero (Zero(..))
import Data.String (IsString)
import Data.Typeable (Typeable)
import Foreign.Storable (Storable(peek))
import Foreign.Storable (Storable(poke))
import GHC.Generics (Generic)
import Foreign.Ptr (Ptr)
import Data.Word (Word32)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Data.Vector (Vector)
import Vulkan.CStruct.Utils (advancePtrBytes)
import Vulkan.Core10.Enums.SampleCountFlagBits (SampleCountFlagBits)
import Vulkan.Core10.Enums.StructureType (StructureType)
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD))
data AttachmentSampleCountInfoAMD = AttachmentSampleCountInfoAMD
{
AttachmentSampleCountInfoAMD -> Vector SampleCountFlagBits
colorAttachmentSamples :: Vector SampleCountFlagBits
,
AttachmentSampleCountInfoAMD -> SampleCountFlagBits
depthStencilAttachmentSamples :: SampleCountFlagBits
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (AttachmentSampleCountInfoAMD)
#endif
deriving instance Show AttachmentSampleCountInfoAMD
instance ToCStruct AttachmentSampleCountInfoAMD where
withCStruct :: forall b.
AttachmentSampleCountInfoAMD
-> (Ptr AttachmentSampleCountInfoAMD -> IO b) -> IO b
withCStruct AttachmentSampleCountInfoAMD
x Ptr AttachmentSampleCountInfoAMD -> IO b
f = Int -> (Ptr AttachmentSampleCountInfoAMD -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
40 ((Ptr AttachmentSampleCountInfoAMD -> IO b) -> IO b)
-> (Ptr AttachmentSampleCountInfoAMD -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr AttachmentSampleCountInfoAMD
p -> Ptr AttachmentSampleCountInfoAMD
-> AttachmentSampleCountInfoAMD -> IO b -> IO b
forall b.
Ptr AttachmentSampleCountInfoAMD
-> AttachmentSampleCountInfoAMD -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr AttachmentSampleCountInfoAMD
p AttachmentSampleCountInfoAMD
x (Ptr AttachmentSampleCountInfoAMD -> IO b
f Ptr AttachmentSampleCountInfoAMD
p)
pokeCStruct :: forall b.
Ptr AttachmentSampleCountInfoAMD
-> AttachmentSampleCountInfoAMD -> IO b -> IO b
pokeCStruct Ptr AttachmentSampleCountInfoAMD
p AttachmentSampleCountInfoAMD{Vector SampleCountFlagBits
SampleCountFlagBits
colorAttachmentSamples :: AttachmentSampleCountInfoAMD -> Vector SampleCountFlagBits
depthStencilAttachmentSamples :: AttachmentSampleCountInfoAMD -> SampleCountFlagBits
colorAttachmentSamples :: Vector SampleCountFlagBits
depthStencilAttachmentSamples :: SampleCountFlagBits
..} IO b
f = ContT b IO b -> IO b
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT b IO b -> IO b) -> ContT b IO b -> IO b
forall a b. (a -> b) -> a -> b
$ do
IO () -> ContT b IO ()
forall (m :: * -> *) a. Monad m => m a -> ContT b m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AttachmentSampleCountInfoAMD
p Ptr AttachmentSampleCountInfoAMD -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD)
IO () -> ContT b IO ()
forall (m :: * -> *) a. Monad m => m a -> ContT b m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AttachmentSampleCountInfoAMD
p Ptr AttachmentSampleCountInfoAMD -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
IO () -> ContT b IO ()
forall (m :: * -> *) a. Monad m => m a -> ContT b m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AttachmentSampleCountInfoAMD
p Ptr AttachmentSampleCountInfoAMD -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32)) ((Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Vector SampleCountFlagBits -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector SampleCountFlagBits -> Int)
-> Vector SampleCountFlagBits -> Int
forall a b. (a -> b) -> a -> b
$ (Vector SampleCountFlagBits
colorAttachmentSamples)) :: Word32))
pPColorAttachmentSamples' <- ((Ptr SampleCountFlagBits -> IO b) -> IO b)
-> ContT b IO (Ptr SampleCountFlagBits)
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr SampleCountFlagBits -> IO b) -> IO b)
-> ContT b IO (Ptr SampleCountFlagBits))
-> ((Ptr SampleCountFlagBits -> IO b) -> IO b)
-> ContT b IO (Ptr SampleCountFlagBits)
forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @SampleCountFlagBits ((Vector SampleCountFlagBits -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector SampleCountFlagBits
colorAttachmentSamples)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
4)
lift $ Data.Vector.imapM_ (\Int
i SampleCountFlagBits
e -> Ptr SampleCountFlagBits -> SampleCountFlagBits -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr SampleCountFlagBits
pPColorAttachmentSamples' Ptr SampleCountFlagBits -> Int -> Ptr SampleCountFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
4 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr SampleCountFlagBits) (SampleCountFlagBits
e)) (colorAttachmentSamples)
lift $ poke ((p `plusPtr` 24 :: Ptr (Ptr SampleCountFlagBits))) (pPColorAttachmentSamples')
lift $ poke ((p `plusPtr` 32 :: Ptr SampleCountFlagBits)) (depthStencilAttachmentSamples)
lift $ f
cStructSize :: Int
cStructSize = Int
40
cStructAlignment :: Int
cStructAlignment = Int
8
pokeZeroCStruct :: forall b. Ptr AttachmentSampleCountInfoAMD -> IO b -> IO b
pokeZeroCStruct Ptr AttachmentSampleCountInfoAMD
p IO b
f = do
Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AttachmentSampleCountInfoAMD
p Ptr AttachmentSampleCountInfoAMD -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AttachmentSampleCountInfoAMD
p Ptr AttachmentSampleCountInfoAMD -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
IO b
f
instance FromCStruct AttachmentSampleCountInfoAMD where
peekCStruct :: Ptr AttachmentSampleCountInfoAMD -> IO AttachmentSampleCountInfoAMD
peekCStruct Ptr AttachmentSampleCountInfoAMD
p = do
colorAttachmentCount <- forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr AttachmentSampleCountInfoAMD
p Ptr AttachmentSampleCountInfoAMD -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32))
pColorAttachmentSamples <- peek @(Ptr SampleCountFlagBits) ((p `plusPtr` 24 :: Ptr (Ptr SampleCountFlagBits)))
pColorAttachmentSamples' <- generateM (fromIntegral colorAttachmentCount) (\Int
i -> forall a. Storable a => Ptr a -> IO a
peek @SampleCountFlagBits ((Ptr SampleCountFlagBits
pColorAttachmentSamples Ptr SampleCountFlagBits -> Int -> Ptr SampleCountFlagBits
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
4 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr SampleCountFlagBits)))
depthStencilAttachmentSamples <- peek @SampleCountFlagBits ((p `plusPtr` 32 :: Ptr SampleCountFlagBits))
pure $ AttachmentSampleCountInfoAMD
pColorAttachmentSamples' depthStencilAttachmentSamples
instance Zero AttachmentSampleCountInfoAMD where
zero :: AttachmentSampleCountInfoAMD
zero = Vector SampleCountFlagBits
-> SampleCountFlagBits -> AttachmentSampleCountInfoAMD
AttachmentSampleCountInfoAMD
Vector SampleCountFlagBits
forall a. Monoid a => a
mempty
SampleCountFlagBits
forall a. Zero a => a
zero
type AMD_MIXED_ATTACHMENT_SAMPLES_SPEC_VERSION = 1
pattern AMD_MIXED_ATTACHMENT_SAMPLES_SPEC_VERSION :: forall a . Integral a => a
pattern $mAMD_MIXED_ATTACHMENT_SAMPLES_SPEC_VERSION :: forall {r} {a}.
Integral a =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bAMD_MIXED_ATTACHMENT_SAMPLES_SPEC_VERSION :: forall a. Integral a => a
AMD_MIXED_ATTACHMENT_SAMPLES_SPEC_VERSION = 1
type AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME = "VK_AMD_mixed_attachment_samples"
pattern AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $mAMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bAMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME :: forall a. (Eq a, IsString a) => a
AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME = "VK_AMD_mixed_attachment_samples"