{-# language CPP #-}
-- | = Name
--
-- VK_AMD_mixed_attachment_samples - device extension
--
-- = VK_AMD_mixed_attachment_samples
--
-- [__Name String__]
--     @VK_AMD_mixed_attachment_samples@
--
-- [__Extension Type__]
--     Device extension
--
-- [__Registered Extension Number__]
--     137
--
-- [__Revision__]
--     1
--
-- [__Ratification Status__]
--     Not ratified
--
-- [__Extension and Version Dependencies__]
--     None
--
-- [__API Interactions__]
--
--     -   Interacts with VK_VERSION_1_3
--
--     -   Interacts with VK_KHR_dynamic_rendering
--
-- [__Contact__]
--
--     -   Matthaeus G. Chajdas
--         <https://github.com/KhronosGroup/Vulkan-Docs/issues/new?body=[VK_AMD_mixed_attachment_samples] @anteru%0A*Here describe the issue or question you have about the VK_AMD_mixed_attachment_samples extension* >
--
-- == Other Extension Metadata
--
-- [__Last Modified Date__]
--     2017-07-24
--
-- [__Contributors__]
--
--     -   Mais Alnasser, AMD
--
--     -   Matthaeus G. Chajdas, AMD
--
--     -   Maciej Jesionowski, AMD
--
--     -   Daniel Rakos, AMD
--
-- == Description
--
-- This extension enables applications to use multisampled rendering with a
-- depth\/stencil sample count that is larger than the color sample count.
-- Having a depth\/stencil sample count larger than the color sample count
-- allows maintaining geometry and coverage information at a higher sample
-- rate than color information. All samples are depth\/stencil tested, but
-- only the first color sample count number of samples get a corresponding
-- color output.
--
-- == New Structures
--
-- If
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#versions-1.3 Vulkan Version 1.3>
-- or
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_dynamic_rendering VK_KHR_dynamic_rendering>
-- is supported:
--
-- -   Extending
--     'Vulkan.Core10.CommandBuffer.CommandBufferInheritanceInfo',
--     'Vulkan.Core10.GraphicsPipeline.GraphicsPipelineCreateInfo':
--
--     -   'AttachmentSampleCountInfoAMD'
--
-- == New Enum Constants
--
-- -   'AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME'
--
-- -   'AMD_MIXED_ATTACHMENT_SAMPLES_SPEC_VERSION'
--
-- If
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#versions-1.3 Vulkan Version 1.3>
-- or
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_dynamic_rendering VK_KHR_dynamic_rendering>
-- is supported:
--
-- -   Extending 'Vulkan.Core10.Enums.StructureType.StructureType':
--
--     -   'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD'
--
-- == Issues
--
-- None.
--
-- == Version History
--
-- -   Revision 1, 2017-07-24 (Daniel Rakos)
--
--     -   Internal revisions
--
-- == See Also
--
-- No cross-references are available
--
-- == Document Notes
--
-- For more information, see the
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#VK_AMD_mixed_attachment_samples Vulkan Specification>.
--
-- This page is a generated document. Fixes and changes should be made to
-- the generator scripts, not directly.
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))
-- | VkAttachmentSampleCountInfoAMD - Structure specifying command buffer
-- inheritance info for dynamic render pass instances
--
-- = Description
--
-- If
-- 'Vulkan.Core10.CommandBuffer.CommandBufferInheritanceInfo'::@renderPass@
-- is 'Vulkan.Core10.APIConstants.NULL_HANDLE',
-- 'Vulkan.Core10.Enums.CommandBufferUsageFlagBits.COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT'
-- is specified in
-- 'Vulkan.Core10.CommandBuffer.CommandBufferBeginInfo'::@flags@, and the
-- @pNext@ chain of
-- 'Vulkan.Core10.CommandBuffer.CommandBufferInheritanceInfo' includes
-- 'AttachmentSampleCountInfoAMD', then this structure defines the sample
-- counts of each attachment within the render pass instance. If
-- 'AttachmentSampleCountInfoAMD' is not included, the value of
-- 'Vulkan.Core13.Promoted_From_VK_KHR_dynamic_rendering.CommandBufferInheritanceRenderingInfo'::@rasterizationSamples@
-- is used as the sample count for each attachment. If
-- 'Vulkan.Core10.CommandBuffer.CommandBufferInheritanceInfo'::@renderPass@
-- is not 'Vulkan.Core10.APIConstants.NULL_HANDLE', or
-- 'Vulkan.Core10.Enums.CommandBufferUsageFlagBits.COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT'
-- is not specified in
-- 'Vulkan.Core10.CommandBuffer.CommandBufferBeginInfo'::@flags@,
-- parameters of this structure are ignored.
--
-- 'AttachmentSampleCountInfoAMD' /can/ also be included in the @pNext@
-- chain of 'Vulkan.Core10.GraphicsPipeline.GraphicsPipelineCreateInfo'.
-- When a graphics pipeline is created without a
-- 'Vulkan.Core10.Handles.RenderPass', if this structure is included in the
-- @pNext@ chain of
-- 'Vulkan.Core10.GraphicsPipeline.GraphicsPipelineCreateInfo', it
-- specifies the sample count of attachments used for rendering. If this
-- structure is not specified, and the pipeline does not include a
-- 'Vulkan.Core10.Handles.RenderPass', the value of
-- 'Vulkan.Core10.GraphicsPipeline.PipelineMultisampleStateCreateInfo'::@rasterizationSamples@
-- is used as the sample count for each attachment. If a graphics pipeline
-- is created with a valid 'Vulkan.Core10.Handles.RenderPass', parameters
-- of this structure are ignored.
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_AMD_mixed_attachment_samples VK_AMD_mixed_attachment_samples>,
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_dynamic_rendering VK_KHR_dynamic_rendering>,
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_NV_framebuffer_mixed_samples VK_NV_framebuffer_mixed_samples>,
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_3 VK_VERSION_1_3>,
-- 'Vulkan.Core10.Enums.SampleCountFlagBits.SampleCountFlagBits',
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data AttachmentSampleCountInfoAMD = AttachmentSampleCountInfoAMD
  { -- | @pColorAttachmentSamples@ is a pointer to an array of
    -- 'Vulkan.Core10.Enums.SampleCountFlagBits.SampleCountFlagBits' values
    -- defining the sample count of color attachments.
    AttachmentSampleCountInfoAMD -> Vector SampleCountFlagBits
colorAttachmentSamples :: Vector SampleCountFlagBits
  , -- | @depthStencilAttachmentSamples@ is a
    -- 'Vulkan.Core10.Enums.SampleCountFlagBits.SampleCountFlagBits' value
    -- defining the sample count of a depth\/stencil attachment.
    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

-- No documentation found for TopLevel "VK_AMD_MIXED_ATTACHMENT_SAMPLES_SPEC_VERSION"
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"

-- No documentation found for TopLevel "VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME"
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"