-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Utils for the vulkan package -- -- Utils for the vulkan package @package vulkan-utils @version 0.3 module Vulkan.Utils.CommandCheck -- | Create an expression which checks the function pointers for all the -- Vulkan commands depended upon by the specified list of function names. -- -- It returns a list of function names corresponding to those functions -- with null pointers. -- -- Your program can use this function to fail early if a command couldn't -- be loaded for some reason (missing extension or layer for example). -- -- One can create a function called checkCommands with the -- following: [d| checkCommands = $(checkCommandsExp ['withInstance, -- 'cmdDraw, ...]) |] -- -- It has the type IsString a => Instance -> Device -> -- [a] -- -- It looks basically like -- --
--   inst dev ->
--     [ name
--     | True <- [ nullFunPtr == pVkCreateDevice inst
--               , nullFunPtr == pVkCreateFence dev
--                 ..
--               ]
--     | name <- [ "vkCreateDevice"
--               , "vkCreateFence"
--                 ..
--               ]
--     ]
--   
checkCommandsExp :: [Name] -> Q Exp instance GHC.Show.Show Vulkan.Utils.CommandCheck.DeviceOrInstanceCommand instance GHC.Classes.Eq Vulkan.Utils.CommandCheck.DeviceOrInstanceCommand module Vulkan.Utils.Debug -- | A debug callback which prints the message prefixed with "Validation: " -- to stderr. debugCallbackPtr :: PFN_vkDebugUtilsMessengerCallbackEXT -- | A debug callback the same as debugCallbackPtr except it will -- call abort when -- VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT is set. debugCallbackFatalPtr :: PFN_vkDebugUtilsMessengerCallbackEXT -- | Assign a name to a handle using setDebugUtilsObjectNameEXT, -- note that the VK_EXT_debug_utils extension must be enabled. nameObject :: (HasObjectType a, MonadIO m) => Device -> a -> ByteString -> m () module Vulkan.Utils.FromGL -- | Convert an OpenGL format enum into a Format -- --
--   >>> internalFormat 0x8051
--   Just FORMAT_R8G8B8_UNORM
--   
internalFormat :: (Eq a, Num a) => a -> Maybe Format module Vulkan.Utils.Misc -- | From a list of things, take all the required things and as many -- optional things as possible. partitionOptReq :: Eq a => [a] -> [a] -> [a] -> ([a], Either [a] [a]) -- | Like partitionOptReq. -- -- Will throw an 'IOError in the case of missing things. Details on -- missing things will be reported in stderr. -- -- This is useful in dealing with layers and extensions. partitionOptReqIO :: (Show a, Eq a, MonadIO m) => String -> [a] -> [a] -> [a] -> m [a] -- | Show valies as a union of their individual bits -- --
--   >>> showBits @Int 5
--   "1 .|. 4"
--   
-- --
--   >>> showBits @Int 0
--   "zeroBits"
--   
-- --
--   >>> import Vulkan.Core10.Enums.QueueFlagBits
--   
--   >>> showBits (QUEUE_COMPUTE_BIT .|. QUEUE_GRAPHICS_BIT)
--   "QUEUE_GRAPHICS_BIT .|. QUEUE_COMPUTE_BIT"
--   
showBits :: forall a. (Show a, FiniteBits a) => a -> String -- | Check if the intersection of bits is non-zero (.&&.) :: Bits a => a -> a -> Bool module Vulkan.Utils.Initialization -- | Like createInstanceWithExtensions except it will create a debug -- utils messenger (from the VK_EXT_debug_utils extension). -- -- If the VK_EXT_validation_features extension (from the -- VK_LAYER_KHRONOS_validation layer) is available is it will be -- enabled and best practices messages enabled. createDebugInstanceWithExtensions :: forall es m. (Extendss InstanceCreateInfo es, PokeChain es, MonadResource m) => [ByteString] -> [ByteString] -> [ByteString] -> [ByteString] -> InstanceCreateInfo es -> m Instance -- | Create an Instance with some layers and extensions, the layers -- and extensions will be added to the provided -- InstanceCreateInfo. -- -- Will throw an 'IOError in the case of missing layers or extensions. -- Details on missing layers and extensions will be reported in stderr. createInstanceWithExtensions :: forall es m. (Extendss InstanceCreateInfo es, PokeChain es, MonadResource m) => [ByteString] -> [ByteString] -> [ByteString] -> [ByteString] -> InstanceCreateInfo es -> m Instance -- | Get a single PhysicalDevice deciding with a scoring function -- -- Pass a function which will extract any required values from a device -- in the spirit of parse-don't-validate. Also provide a function to -- compare these results for sorting multiple suitable devices. -- -- As an example, the suitability function could return a tuple of device -- memory and the compute queue family index, and the scoring function -- could be fst to select devices based on their memory capacity. -- Consider using assignQueues to find your desired queues in the -- suitability function. -- -- If no devices are deemed suitable then a NoSuchThing -- IOError is thrown. pickPhysicalDevice :: (MonadIO m, Ord b) => Instance -> (PhysicalDevice -> m (Maybe a)) -> (a -> b) -> m (Maybe (a, PhysicalDevice)) -- | Extract the name of a PhysicalDevice with -- getPhysicalDeviceProperties physicalDeviceName :: MonadIO m => PhysicalDevice -> m Text -- | Create a Device with some extensions, the extensions will be -- added to the provided DeviceCreateInfo. -- -- Will throw an 'IOError in the case of missing extensions. Missing -- extensions will be listed on stderr. createDeviceWithExtensions :: forall es m. (Extendss DeviceCreateInfo es, PokeChain es, MonadResource m) => PhysicalDevice -> [ByteString] -> [ByteString] -> DeviceCreateInfo es -> m Device module Vulkan.Utils.QueueAssignment -- | Given a PhysicalDevice and a set of requirements for queues, -- calculate an assignment of queues to queue families and return -- information with which to create a Device and also a function -- to extract the requested Queues from the device. -- -- You may want to create a custom type with a Traversable -- instance to store your queues like: -- --
--   data MyQueues q = MyQueues
--     { computeQueue            :: q
--     , graphicsAndPresentQueue :: q
--     , transferQueue           :: q
--     }
--   
--   myQueueSpecs :: MyQueues QueueSpec
--   myQueueSpecs = MyQueues
--     { computeQueue            = QueueSpec 0.5 isComputeQueueFamily
--     , graphicsAndPresentQueue = QueueSpec 1   isPresentQueueFamily
--     , transferQueue           = QueueSpec 1   isTransferOnlyQueueFamily
--     }
--   
-- -- Note, this doesn't permit differentiating queue family assignment -- based on whether or not the queue is protected. assignQueues :: forall f m n. (Traversable f, MonadIO m, MonadIO n) => PhysicalDevice -> f (QueueSpec m) -> m (Maybe (Vector (DeviceQueueCreateInfo '[]), Device -> n (f (QueueFamilyIndex, Queue)))) -- | Requirements for a Queue to be assigned a family by -- assignQueues. -- -- To assign to a specific queue family index f: -- --
--   queueSpecFamilyPredicate = i _ -> i == f
--   
-- -- To assign to any queue family which supports compute operations: -- --
--   let isComputeQueue q = QUEUE_COMPUTE_BIT .&&. queueFlags q
--   in QueueSpec priority (_index q -> pure (isComputeQueue q))
--   
data QueueSpec m QueueSpec :: Float -> (QueueFamilyIndex -> QueueFamilyProperties -> m Bool) -> QueueSpec m [$sel:queueSpecQueuePriority:QueueSpec] :: QueueSpec m -> Float [$sel:queueSpecFamilyPredicate:QueueSpec] :: QueueSpec m -> QueueFamilyIndex -> QueueFamilyProperties -> m Bool newtype QueueFamilyIndex QueueFamilyIndex :: Word32 -> QueueFamilyIndex [$sel:unQueueFamilyIndex:QueueFamilyIndex] :: QueueFamilyIndex -> Word32 newtype QueueIndex QueueIndex :: Word32 -> QueueIndex [$sel:unQueueIndex:QueueIndex] :: QueueIndex -> Word32 isComputeQueueFamily :: QueueFamilyProperties -> Bool isGraphicsQueueFamily :: QueueFamilyProperties -> Bool isTransferQueueFamily :: QueueFamilyProperties -> Bool -- | Does this queue have QUEUE_TRANSFER_BIT set and not -- QUEUE_COMPUTE_BIT or QUEUE_GRAPHICS_BIT isTransferOnlyQueueFamily :: QueueFamilyProperties -> Bool -- | Can this queue family present to this surface on this device isPresentQueueFamily :: MonadIO m => PhysicalDevice -> SurfaceKHR -> QueueFamilyIndex -> m Bool instance GHC.Show.Show Vulkan.Utils.QueueAssignment.QueueIndex instance GHC.Enum.Enum Vulkan.Utils.QueueAssignment.QueueIndex instance GHC.Classes.Ord Vulkan.Utils.QueueAssignment.QueueIndex instance GHC.Classes.Eq Vulkan.Utils.QueueAssignment.QueueIndex instance GHC.Show.Show Vulkan.Utils.QueueAssignment.QueueFamilyIndex instance GHC.Enum.Enum Vulkan.Utils.QueueAssignment.QueueFamilyIndex instance GHC.Classes.Ord Vulkan.Utils.QueueAssignment.QueueFamilyIndex instance GHC.Classes.Eq Vulkan.Utils.QueueAssignment.QueueFamilyIndex module Vulkan.Utils.ShaderQQ.Interpolate -- | interpExp performs very simple interpolation of Haskell values -- into Strings. -- -- -- --
--   >>> let foo = 123 in $(interpExp "hello, $foo")
--   "hello, 123"
--   
-- --
--   >>> let foo = "world" in $(interpExp "hello, \\$foo")
--   "hello, $foo"
--   
-- --
--   >>> let foo = "world" in $(interpExp "hello\r\n\rworld")
--   "hello\r\n\rworld"
--   
interpExp :: String -> Q Exp module Vulkan.Utils.ShaderQQ -- | glsl is a QuasiQuoter which produces GLSL source code with -- #line directives inserted so that error locations point to -- the correct location in the Haskell source file. It also permits basic -- string interpolation. -- -- -- -- It is intended to be used in concert with compileShaderQ like -- so -- --
--   myConstant = 3.141 -- Note that this will have to be in a different module
--   myFragmentShader = $(compileShaderQ "frag" [glsl|
--     #version 450
--     const float myConstant = ${myConstant};
--     main (){
--     }
--   |])
--   
-- -- An explicit example (interactive is from doctest): -- --
--   >>> let version = 450 :: Int in [glsl|#version $version|]
--   "#version 450\n#extension GL_GOOGLE_cpp_style_line_directive : enable\n#line 46 \"<interactive>\"\n"
--   
-- -- Note that line number will be thrown off if any of the interpolated -- variables contain newlines. glsl :: QuasiQuoter -- | QuasiQuoter for creating a compute shader. -- -- Equivalent to calling $(compileShaderQ "comp" [glsl|...|]) -- without interpolation support. comp :: QuasiQuoter -- | QuasiQuoter for creating a fragment shader. -- -- Equivalent to calling $(compileShaderQ "frag" [glsl|...|]) -- without interpolation support. frag :: QuasiQuoter -- | QuasiQuoter for creating a geometry shader. -- -- Equivalent to calling $(compileShaderQ "geom" [glsl|...|]) -- without interpolation support. geom :: QuasiQuoter -- | QuasiQuoter for creating a tessellation control shader. -- -- Equivalent to calling $(compileShaderQ "tesc" [glsl|...|]) -- without interpolation support. tesc :: QuasiQuoter -- | QuasiQuoter for creating a tessellation evaluation shader. -- -- Equivalent to calling $(compileShaderQ "tese" [glsl|...|]) -- without interpolation support. tese :: QuasiQuoter -- | QuasiQuoter for creating a vertex shader. -- -- Equivalent to calling $(compileShaderQ "vert" [glsl|...|]) -- without interpolation support. vert :: QuasiQuoter type GLSLError = String type GLSLWarning = String -- | Compile a glsl shader to spir-v using glslangValidator. -- -- Messages are converted to GHC warnings or errors depending on -- compilation success. compileShaderQ :: String -> String -> Q Exp -- | Compile a glsl shader to spir-v using glslangValidator compileShader :: MonadIO m => Maybe Loc -> String -> String -> m ([GLSLWarning], Either [GLSLError] ByteString) processValidatorMessages :: ByteString -> ([GLSLWarning], [GLSLError]) module Vulkan.Utils.ShaderQQ.Shaderc -- | hlsl is a QuasiQuoter which produces HLSL source code with a -- #line directive inserted so that error locations point to the -- correct location in the Haskell source file. It also permits basic -- string interpolation. -- -- -- -- It is intended to be used in concert with compileShaderQ like -- so -- --
--   myConstant = 3.141 -- Note that this will have to be in a different module
--   myFragmentShader = $(compileShaderQ "frag" [hlsl|
--     static const float myConstant = ${myConstant};
--     float main (){
--       return myConstant;
--     }
--   |])
--   
-- -- An explicit example (interactive is from doctest): -- --
--   >>> let foo = 450 :: Int in [hlsl|const float foo = $foo|]
--   "#line 31 \"<interactive>\"\nconst float foo = 450"
--   
-- -- Note that line number will be thrown off if any of the interpolated -- variables contain newlines. hlsl :: QuasiQuoter -- | QuasiQuoter for creating a compute shader. -- -- Equivalent to calling $(compileShaderQ "comp" [hlsl|...|]) -- without interpolation support. comp :: QuasiQuoter -- | QuasiQuoter for creating a fragment shader. -- -- Equivalent to calling $(compileShaderQ "frag" [hlsl|...|]) -- without interpolation support. frag :: QuasiQuoter -- | QuasiQuoter for creating a geometry shader. -- -- Equivalent to calling $(compileShaderQ "geom" [hlsl|...|]) -- without interpolation support. geom :: QuasiQuoter -- | QuasiQuoter for creating a tessellation control shader. -- -- Equivalent to calling $(compileShaderQ "tesc" [hlsl|...|]) -- without interpolation support. tesc :: QuasiQuoter -- | QuasiQuoter for creating a tessellation evaluation shader. -- -- Equivalent to calling $(compileShaderQ "tese" [hlsl|...|]) -- without interpolation support. tese :: QuasiQuoter -- | QuasiQuoter for creating a vertex shader. -- -- Equivalent to calling $(compileShaderQ "vert" [hlsl|...|]) -- without interpolation support. vert :: QuasiQuoter type ShadercError = String type ShadercWarning = String -- | Compile a HLSL shader to SPIR-V using glslc (from the shaderc project) -- -- Messages are converted to GHC warnings or errors depending on -- compilation success. compileShaderQ :: String -> String -> Q Exp -- | Compile a HLSL shader to spir-v using glslc compileShader :: MonadIO m => Maybe Loc -> String -> String -> m ([ShadercWarning], Either [ShadercError] ByteString) processShadercMessages :: ByteString -> ([ShadercWarning], [ShadercError])