{-# language CPP #-}
module Graphics.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 Foreign.Ptr (Ptr)
import Data.Word (Word32)
import Data.Kind (Type)
import Graphics.Vulkan.Core10.BaseType (bool32ToBool)
import Graphics.Vulkan.Core10.BaseType (boolToBool32)
import Graphics.Vulkan.Core10.BaseType (Bool32)
import Graphics.Vulkan.CStruct (FromCStruct)
import Graphics.Vulkan.CStruct (FromCStruct(..))
import Graphics.Vulkan.Core10.Enums.ShaderStageFlagBits (ShaderStageFlags)
import Graphics.Vulkan.Core10.Enums.StructureType (StructureType)
import Graphics.Vulkan.Core11.Enums.SubgroupFeatureFlagBits (SubgroupFeatureFlags)
import Graphics.Vulkan.CStruct (ToCStruct)
import Graphics.Vulkan.CStruct (ToCStruct(..))
import Graphics.Vulkan.Zero (Zero(..))
import Graphics.Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES))
import Graphics.Vulkan.Core10.Enums.StructureType (StructureType(..))
import Graphics.Vulkan.Core11.Enums.SubgroupFeatureFlagBits (SubgroupFeatureFlagBits(..))
import Graphics.Vulkan.Core11.Enums.SubgroupFeatureFlagBits (SubgroupFeatureFlags)
data PhysicalDeviceSubgroupProperties = PhysicalDeviceSubgroupProperties
{
subgroupSize :: Word32
,
supportedStages :: ShaderStageFlags
,
supportedOperations :: SubgroupFeatureFlags
,
quadOperationsInAllStages :: Bool
}
deriving (Typeable)
deriving instance Show PhysicalDeviceSubgroupProperties
instance ToCStruct PhysicalDeviceSubgroupProperties where
withCStruct x f = allocaBytesAligned 32 8 $ \p -> pokeCStruct p x (f p)
pokeCStruct p PhysicalDeviceSubgroupProperties{..} f = do
poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES)
poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
poke ((p `plusPtr` 16 :: Ptr Word32)) (subgroupSize)
poke ((p `plusPtr` 20 :: Ptr ShaderStageFlags)) (supportedStages)
poke ((p `plusPtr` 24 :: Ptr SubgroupFeatureFlags)) (supportedOperations)
poke ((p `plusPtr` 28 :: Ptr Bool32)) (boolToBool32 (quadOperationsInAllStages))
f
cStructSize = 32
cStructAlignment = 8
pokeZeroCStruct p f = do
poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES)
poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
poke ((p `plusPtr` 16 :: Ptr Word32)) (zero)
poke ((p `plusPtr` 20 :: Ptr ShaderStageFlags)) (zero)
poke ((p `plusPtr` 24 :: Ptr SubgroupFeatureFlags)) (zero)
poke ((p `plusPtr` 28 :: Ptr Bool32)) (boolToBool32 (zero))
f
instance FromCStruct PhysicalDeviceSubgroupProperties where
peekCStruct p = do
subgroupSize <- peek @Word32 ((p `plusPtr` 16 :: Ptr Word32))
supportedStages <- peek @ShaderStageFlags ((p `plusPtr` 20 :: Ptr ShaderStageFlags))
supportedOperations <- peek @SubgroupFeatureFlags ((p `plusPtr` 24 :: Ptr SubgroupFeatureFlags))
quadOperationsInAllStages <- peek @Bool32 ((p `plusPtr` 28 :: Ptr Bool32))
pure $ PhysicalDeviceSubgroupProperties
subgroupSize supportedStages supportedOperations (bool32ToBool quadOperationsInAllStages)
instance Storable PhysicalDeviceSubgroupProperties where
sizeOf ~_ = 32
alignment ~_ = 8
peek = peekCStruct
poke ptr poked = pokeCStruct ptr poked (pure ())
instance Zero PhysicalDeviceSubgroupProperties where
zero = PhysicalDeviceSubgroupProperties
zero
zero
zero
zero