{-# language CPP #-}
module Vulkan.Core11.Originally_Based_On_VK_KHR_subgroup  ( PhysicalDeviceSubgroupProperties(..)
                                                          , StructureType(..)
                                                          , SubgroupFeatureFlagBits(..)
                                                          , SubgroupFeatureFlags
                                                          ) where

import Foreign.Marshal.Alloc (allocaBytesAligned)
import Foreign.Ptr (nullPtr)
import Foreign.Ptr (plusPtr)
import Data.Typeable (Typeable)
import Foreign.Storable (Storable)
import Foreign.Storable (Storable(peek))
import Foreign.Storable (Storable(poke))
import qualified Foreign.Storable (Storable(..))
import GHC.Generics (Generic)
import Foreign.Ptr (Ptr)
import Data.Word (Word32)
import Data.Kind (Type)
import Vulkan.Core10.BaseType (bool32ToBool)
import Vulkan.Core10.BaseType (boolToBool32)
import Vulkan.Core10.BaseType (Bool32)
import Vulkan.CStruct (FromCStruct)
import Vulkan.CStruct (FromCStruct(..))
import Vulkan.Core10.Enums.ShaderStageFlagBits (ShaderStageFlags)
import Vulkan.Core10.Enums.StructureType (StructureType)
import Vulkan.Core11.Enums.SubgroupFeatureFlagBits (SubgroupFeatureFlags)
import Vulkan.CStruct (ToCStruct)
import Vulkan.CStruct (ToCStruct(..))
import Vulkan.Zero (Zero(..))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES))
import Vulkan.Core10.Enums.StructureType (StructureType(..))
import Vulkan.Core11.Enums.SubgroupFeatureFlagBits (SubgroupFeatureFlagBits(..))
import Vulkan.Core11.Enums.SubgroupFeatureFlagBits (SubgroupFeatureFlags)
-- | VkPhysicalDeviceSubgroupProperties - Structure describing subgroup
-- support for an implementation
--
-- = Members
--
-- The members of the 'PhysicalDeviceSubgroupProperties' structure describe
-- the following implementation-dependent limits:
--
-- = Description
--
-- If the 'PhysicalDeviceSubgroupProperties' structure is included in the
-- @pNext@ chain of
-- 'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.PhysicalDeviceProperties2',
-- it is filled with the implementation-dependent limits.
--
-- If @supportedOperations@ includes
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#features-subgroup-quad >,
-- @subgroupSize@ /must/ be greater than or equal to 4.
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- 'Vulkan.Core10.BaseType.Bool32',
-- 'Vulkan.Core10.Enums.ShaderStageFlagBits.ShaderStageFlags',
-- 'Vulkan.Core10.Enums.StructureType.StructureType',
-- 'Vulkan.Core11.Enums.SubgroupFeatureFlagBits.SubgroupFeatureFlags'
data PhysicalDeviceSubgroupProperties = PhysicalDeviceSubgroupProperties
  { -- | @subgroupSize@ is the default number of invocations in each subgroup.
    -- @subgroupSize@ is at least 1 if any of the physical device’s queues
    -- support 'Vulkan.Core10.Enums.QueueFlagBits.QUEUE_GRAPHICS_BIT' or
    -- 'Vulkan.Core10.Enums.QueueFlagBits.QUEUE_COMPUTE_BIT'. @subgroupSize@ is
    -- a power-of-two.
    PhysicalDeviceSubgroupProperties -> Word32
subgroupSize :: Word32
  , -- | @supportedStages@ is a bitfield of
    -- 'Vulkan.Core10.Enums.ShaderStageFlagBits.ShaderStageFlagBits' describing
    -- the shader stages that
    -- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#shaders-group-operations group operations>
    -- with
    -- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#shaders-scope-subgroup subgroup scope>
    -- are supported in. @supportedStages@ will have the
    -- 'Vulkan.Core10.Enums.ShaderStageFlagBits.SHADER_STAGE_COMPUTE_BIT' bit
    -- set if any of the physical device’s queues support
    -- 'Vulkan.Core10.Enums.QueueFlagBits.QUEUE_COMPUTE_BIT'.
    PhysicalDeviceSubgroupProperties -> ShaderStageFlags
supportedStages :: ShaderStageFlags
  , -- | @supportedOperations@ is a bitmask of
    -- 'Vulkan.Core11.Enums.SubgroupFeatureFlagBits.SubgroupFeatureFlagBits'
    -- specifying the sets of
    -- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#shaders-group-operations group operations>
    -- with
    -- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#shaders-scope-subgroup subgroup scope>
    -- supported on this device. @supportedOperations@ will have the
    -- 'Vulkan.Core11.Enums.SubgroupFeatureFlagBits.SUBGROUP_FEATURE_BASIC_BIT'
    -- bit set if any of the physical device’s queues support
    -- 'Vulkan.Core10.Enums.QueueFlagBits.QUEUE_GRAPHICS_BIT' or
    -- 'Vulkan.Core10.Enums.QueueFlagBits.QUEUE_COMPUTE_BIT'.
    PhysicalDeviceSubgroupProperties -> SubgroupFeatureFlags
supportedOperations :: SubgroupFeatureFlags
  , -- | @quadOperationsInAllStages@ is a boolean specifying whether
    -- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#shaders-quad-operations quad group operations>
    -- are available in all stages, or are restricted to fragment and compute
    -- stages.
    PhysicalDeviceSubgroupProperties -> Bool
quadOperationsInAllStages :: Bool
  }
  deriving (Typeable, PhysicalDeviceSubgroupProperties
-> PhysicalDeviceSubgroupProperties -> Bool
(PhysicalDeviceSubgroupProperties
 -> PhysicalDeviceSubgroupProperties -> Bool)
-> (PhysicalDeviceSubgroupProperties
    -> PhysicalDeviceSubgroupProperties -> Bool)
-> Eq PhysicalDeviceSubgroupProperties
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhysicalDeviceSubgroupProperties
-> PhysicalDeviceSubgroupProperties -> Bool
$c/= :: PhysicalDeviceSubgroupProperties
-> PhysicalDeviceSubgroupProperties -> Bool
== :: PhysicalDeviceSubgroupProperties
-> PhysicalDeviceSubgroupProperties -> Bool
$c== :: PhysicalDeviceSubgroupProperties
-> PhysicalDeviceSubgroupProperties -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (PhysicalDeviceSubgroupProperties)
#endif
deriving instance Show PhysicalDeviceSubgroupProperties

instance ToCStruct PhysicalDeviceSubgroupProperties where
  withCStruct :: PhysicalDeviceSubgroupProperties
-> (Ptr PhysicalDeviceSubgroupProperties -> IO b) -> IO b
withCStruct x :: PhysicalDeviceSubgroupProperties
x f :: Ptr PhysicalDeviceSubgroupProperties -> IO b
f = Int
-> Int -> (Ptr PhysicalDeviceSubgroupProperties -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 32 8 ((Ptr PhysicalDeviceSubgroupProperties -> IO b) -> IO b)
-> (Ptr PhysicalDeviceSubgroupProperties -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr PhysicalDeviceSubgroupProperties
p -> Ptr PhysicalDeviceSubgroupProperties
-> PhysicalDeviceSubgroupProperties -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PhysicalDeviceSubgroupProperties
p PhysicalDeviceSubgroupProperties
x (Ptr PhysicalDeviceSubgroupProperties -> IO b
f Ptr PhysicalDeviceSubgroupProperties
p)
  pokeCStruct :: Ptr PhysicalDeviceSubgroupProperties
-> PhysicalDeviceSubgroupProperties -> IO b -> IO b
pokeCStruct p :: Ptr PhysicalDeviceSubgroupProperties
p PhysicalDeviceSubgroupProperties{..} f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceSubgroupProperties
p Ptr PhysicalDeviceSubgroupProperties -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceSubgroupProperties
p Ptr PhysicalDeviceSubgroupProperties -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceSubgroupProperties
p Ptr PhysicalDeviceSubgroupProperties -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Word32)) (Word32
subgroupSize)
    Ptr ShaderStageFlags -> ShaderStageFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceSubgroupProperties
p Ptr PhysicalDeviceSubgroupProperties -> Int -> Ptr ShaderStageFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr ShaderStageFlags)) (ShaderStageFlags
supportedStages)
    Ptr SubgroupFeatureFlags -> SubgroupFeatureFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceSubgroupProperties
p Ptr PhysicalDeviceSubgroupProperties
-> Int -> Ptr SubgroupFeatureFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr SubgroupFeatureFlags)) (SubgroupFeatureFlags
supportedOperations)
    Ptr Bool32 -> Bool32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceSubgroupProperties
p Ptr PhysicalDeviceSubgroupProperties -> Int -> Ptr Bool32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 28 :: Ptr Bool32)) (Bool -> Bool32
boolToBool32 (Bool
quadOperationsInAllStages))
    IO b
f
  cStructSize :: Int
cStructSize = 32
  cStructAlignment :: Int
cStructAlignment = 8
  pokeZeroCStruct :: Ptr PhysicalDeviceSubgroupProperties -> IO b -> IO b
pokeZeroCStruct p :: Ptr PhysicalDeviceSubgroupProperties
p f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceSubgroupProperties
p Ptr PhysicalDeviceSubgroupProperties -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceSubgroupProperties
p Ptr PhysicalDeviceSubgroupProperties -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceSubgroupProperties
p Ptr PhysicalDeviceSubgroupProperties -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Word32)) (Word32
forall a. Zero a => a
zero)
    Ptr ShaderStageFlags -> ShaderStageFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceSubgroupProperties
p Ptr PhysicalDeviceSubgroupProperties -> Int -> Ptr ShaderStageFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr ShaderStageFlags)) (ShaderStageFlags
forall a. Zero a => a
zero)
    Ptr SubgroupFeatureFlags -> SubgroupFeatureFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceSubgroupProperties
p Ptr PhysicalDeviceSubgroupProperties
-> Int -> Ptr SubgroupFeatureFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr SubgroupFeatureFlags)) (SubgroupFeatureFlags
forall a. Zero a => a
zero)
    Ptr Bool32 -> Bool32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceSubgroupProperties
p Ptr PhysicalDeviceSubgroupProperties -> Int -> Ptr Bool32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 28 :: Ptr Bool32)) (Bool -> Bool32
boolToBool32 (Bool
forall a. Zero a => a
zero))
    IO b
f

instance FromCStruct PhysicalDeviceSubgroupProperties where
  peekCStruct :: Ptr PhysicalDeviceSubgroupProperties
-> IO PhysicalDeviceSubgroupProperties
peekCStruct p :: Ptr PhysicalDeviceSubgroupProperties
p = do
    Word32
subgroupSize <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr PhysicalDeviceSubgroupProperties
p Ptr PhysicalDeviceSubgroupProperties -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Word32))
    ShaderStageFlags
supportedStages <- Ptr ShaderStageFlags -> IO ShaderStageFlags
forall a. Storable a => Ptr a -> IO a
peek @ShaderStageFlags ((Ptr PhysicalDeviceSubgroupProperties
p Ptr PhysicalDeviceSubgroupProperties -> Int -> Ptr ShaderStageFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr ShaderStageFlags))
    SubgroupFeatureFlags
supportedOperations <- Ptr SubgroupFeatureFlags -> IO SubgroupFeatureFlags
forall a. Storable a => Ptr a -> IO a
peek @SubgroupFeatureFlags ((Ptr PhysicalDeviceSubgroupProperties
p Ptr PhysicalDeviceSubgroupProperties
-> Int -> Ptr SubgroupFeatureFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr SubgroupFeatureFlags))
    Bool32
quadOperationsInAllStages <- Ptr Bool32 -> IO Bool32
forall a. Storable a => Ptr a -> IO a
peek @Bool32 ((Ptr PhysicalDeviceSubgroupProperties
p Ptr PhysicalDeviceSubgroupProperties -> Int -> Ptr Bool32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 28 :: Ptr Bool32))
    PhysicalDeviceSubgroupProperties
-> IO PhysicalDeviceSubgroupProperties
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PhysicalDeviceSubgroupProperties
 -> IO PhysicalDeviceSubgroupProperties)
-> PhysicalDeviceSubgroupProperties
-> IO PhysicalDeviceSubgroupProperties
forall a b. (a -> b) -> a -> b
$ Word32
-> ShaderStageFlags
-> SubgroupFeatureFlags
-> Bool
-> PhysicalDeviceSubgroupProperties
PhysicalDeviceSubgroupProperties
             Word32
subgroupSize ShaderStageFlags
supportedStages SubgroupFeatureFlags
supportedOperations (Bool32 -> Bool
bool32ToBool Bool32
quadOperationsInAllStages)

instance Storable PhysicalDeviceSubgroupProperties where
  sizeOf :: PhysicalDeviceSubgroupProperties -> Int
sizeOf ~PhysicalDeviceSubgroupProperties
_ = 32
  alignment :: PhysicalDeviceSubgroupProperties -> Int
alignment ~PhysicalDeviceSubgroupProperties
_ = 8
  peek :: Ptr PhysicalDeviceSubgroupProperties
-> IO PhysicalDeviceSubgroupProperties
peek = Ptr PhysicalDeviceSubgroupProperties
-> IO PhysicalDeviceSubgroupProperties
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr PhysicalDeviceSubgroupProperties
-> PhysicalDeviceSubgroupProperties -> IO ()
poke ptr :: Ptr PhysicalDeviceSubgroupProperties
ptr poked :: PhysicalDeviceSubgroupProperties
poked = Ptr PhysicalDeviceSubgroupProperties
-> PhysicalDeviceSubgroupProperties -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PhysicalDeviceSubgroupProperties
ptr PhysicalDeviceSubgroupProperties
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero PhysicalDeviceSubgroupProperties where
  zero :: PhysicalDeviceSubgroupProperties
zero = Word32
-> ShaderStageFlags
-> SubgroupFeatureFlags
-> Bool
-> PhysicalDeviceSubgroupProperties
PhysicalDeviceSubgroupProperties
           Word32
forall a. Zero a => a
zero
           ShaderStageFlags
forall a. Zero a => a
zero
           SubgroupFeatureFlags
forall a. Zero a => a
zero
           Bool
forall a. Zero a => a
zero