{-# language Strict #-} {-# language CPP #-} {-# language GeneralizedNewtypeDeriving #-} {-# language PatternSynonyms #-} {-# language DataKinds #-} {-# language TypeOperators #-} {-# language DuplicateRecordFields #-} module Graphics.Vulkan.Core10.Shader ( VkShaderModuleCreateFlags(..) , VkShaderModule , vkCreateShaderModule , vkDestroyShaderModule , VkShaderModuleCreateInfo(..) ) where import Data.Bits ( Bits , FiniteBits ) import Data.Word ( Word32 ) import Foreign.C.Types ( CSize(..) ) import Foreign.Ptr ( plusPtr , Ptr ) import Foreign.Storable ( Storable(..) , Storable ) import GHC.Read ( expectP , choose ) import Graphics.Vulkan.NamedType ( (:::) ) import Text.ParserCombinators.ReadPrec ( (+++) , prec , step ) import Text.Read ( Read(..) , parens ) import Text.Read.Lex ( Lexeme(Ident) ) import Graphics.Vulkan.Core10.Core ( VkStructureType(..) , VkResult(..) , VkFlags ) import Graphics.Vulkan.Core10.DeviceInitialization ( VkAllocationCallbacks(..) , VkDevice ) -- ** VkShaderModuleCreateFlags -- | VkShaderModuleCreateFlags - Reserved for future use -- -- = Description -- #_description# -- -- @VkShaderModuleCreateFlags@ is a bitmask type for setting a mask, but is -- currently reserved for future use. -- -- = See Also -- #_see_also# -- -- 'VkShaderModuleCreateInfo' newtype VkShaderModuleCreateFlags = VkShaderModuleCreateFlags VkFlags deriving (Eq, Ord, Storable, Bits, FiniteBits) instance Show VkShaderModuleCreateFlags where showsPrec p (VkShaderModuleCreateFlags x) = showParen (p >= 11) (showString "VkShaderModuleCreateFlags " . showsPrec 11 x) instance Read VkShaderModuleCreateFlags where readPrec = parens ( choose [ ] +++ prec 10 (do expectP (Ident "VkShaderModuleCreateFlags") v <- step readPrec pure (VkShaderModuleCreateFlags v) ) ) -- | Dummy data to tag the 'Ptr' with data VkShaderModule_T -- | VkShaderModule - Opaque handle to a shader module object -- -- = Description -- #_description# -- -- = See Also -- #_see_also# -- -- 'Graphics.Vulkan.Core10.Pipeline.VkPipelineShaderStageCreateInfo', -- 'vkCreateShaderModule', 'vkDestroyShaderModule' type VkShaderModule = Ptr VkShaderModule_T -- | vkCreateShaderModule - Creates a new shader module object -- -- = Parameters -- #_parameters# -- -- - @device@ is the logical device that creates the shader module. -- -- - @pCreateInfo@ parameter is a pointer to an instance of the -- @VkShaderModuleCreateInfo@ structure. -- -- - @pAllocator@ controls host memory allocation as described in the -- <{html_spec_relative}#memory-allocation Memory Allocation> chapter. -- -- - @pShaderModule@ points to a @VkShaderModule@ handle in which the -- resulting shader module object is returned. -- -- = Description -- #_description# -- -- Once a shader module has been created, any entry points it contains -- /can/ be used in pipeline shader stages as described in -- <{html_spec_relative}#pipelines-compute Compute Pipelines> and -- <{html_spec_relative}#pipelines-graphics Graphics Pipelines>. -- -- == Valid Usage (Implicit) -- -- - @device@ /must/ be a valid @VkDevice@ handle -- -- - @pCreateInfo@ /must/ be a valid pointer to a valid -- @VkShaderModuleCreateInfo@ structure -- -- - If @pAllocator@ is not @NULL@, @pAllocator@ /must/ be a valid -- pointer to a valid @VkAllocationCallbacks@ structure -- -- - @pShaderModule@ /must/ be a valid pointer to a @VkShaderModule@ -- handle -- -- == Return Codes -- -- [<#fundamentals-successcodes Success>] -- - @VK_SUCCESS@ -- -- [<#fundamentals-errorcodes Failure>] -- - @VK_ERROR_OUT_OF_HOST_MEMORY@ -- -- - @VK_ERROR_OUT_OF_DEVICE_MEMORY@ -- -- - @VK_ERROR_INVALID_SHADER_NV@ -- -- = See Also -- #_see_also# -- -- 'Graphics.Vulkan.Core10.DeviceInitialization.VkAllocationCallbacks', -- 'Graphics.Vulkan.Core10.DeviceInitialization.VkDevice', -- 'VkShaderModule', 'VkShaderModuleCreateInfo' foreign import ccall "vkCreateShaderModule" vkCreateShaderModule :: ("device" ::: VkDevice) -> ("pCreateInfo" ::: Ptr VkShaderModuleCreateInfo) -> ("pAllocator" ::: Ptr VkAllocationCallbacks) -> ("pShaderModule" ::: Ptr VkShaderModule) -> IO VkResult -- | vkDestroyShaderModule - Destroy a shader module module -- -- = Parameters -- #_parameters# -- -- - @device@ is the logical device that destroys the shader module. -- -- - @shaderModule@ is the handle of the shader module to destroy. -- -- - @pAllocator@ controls host memory allocation as described in the -- <{html_spec_relative}#memory-allocation Memory Allocation> chapter. -- -- = Description -- #_description# -- -- A shader module /can/ be destroyed while pipelines created using its -- shaders are still in use. -- -- == Valid Usage -- -- - If @VkAllocationCallbacks@ were provided when @shaderModule@ was -- created, a compatible set of callbacks /must/ be provided here -- -- - If no @VkAllocationCallbacks@ were provided when @shaderModule@ was -- created, @pAllocator@ /must/ be @NULL@ -- -- == Valid Usage (Implicit) -- -- - @device@ /must/ be a valid @VkDevice@ handle -- -- - If @shaderModule@ is not -- 'Graphics.Vulkan.Core10.Constants.VK_NULL_HANDLE', @shaderModule@ -- /must/ be a valid @VkShaderModule@ handle -- -- - If @pAllocator@ is not @NULL@, @pAllocator@ /must/ be a valid -- pointer to a valid @VkAllocationCallbacks@ structure -- -- - If @shaderModule@ is a valid handle, it /must/ have been created, -- allocated, or retrieved from @device@ -- -- == Host Synchronization -- -- - Host access to @shaderModule@ /must/ be externally synchronized -- -- = See Also -- #_see_also# -- -- 'Graphics.Vulkan.Core10.DeviceInitialization.VkAllocationCallbacks', -- 'Graphics.Vulkan.Core10.DeviceInitialization.VkDevice', 'VkShaderModule' foreign import ccall "vkDestroyShaderModule" vkDestroyShaderModule :: ("device" ::: VkDevice) -> ("shaderModule" ::: VkShaderModule) -> ("pAllocator" ::: Ptr VkAllocationCallbacks) -> IO () -- | VkShaderModuleCreateInfo - Structure specifying parameters of a newly -- created shader module -- -- = Description -- #_description# -- -- == Valid Usage -- -- - @codeSize@ /must/ be greater than 0 -- -- - @codeSize@ /must/ be a multiple of 4 -- -- - @pCode@ /must/ point to valid SPIR-V code, formatted and packed as -- described by the -- <{html_spec_relative}#spirv-spec Khronos SPIR-V Specification> -- -- - @pCode@ /must/ adhere to the validation rules described by the -- <{html_spec_relative}#spirvenv-module-validation Validation Rules within a Module> -- section of the -- <{html_spec_relative}#spirvenv-capabilities SPIR-V Environment> -- appendix -- -- - @pCode@ /must/ declare the @Shader@ capability for SPIR-V code -- -- - @pCode@ /must/ not declare any capability that is not supported by -- the API, as described by the -- <{html_spec_relative}#spirvenv-module-validation Capabilities> -- section of the -- <{html_spec_relative}#spirvenv-capabilities SPIR-V Environment> -- appendix -- -- - If @pCode@ declares any of the capabilities listed as /optional/ in -- the -- <{html_spec_relative}#spirvenv-capabilities-table SPIR-V Environment> -- appendix, the corresponding feature(s) /must/ be enabled. -- -- == Valid Usage (Implicit) -- -- - @sType@ /must/ be @VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO@ -- -- - @pNext@ /must/ be @NULL@ or a pointer to a valid instance of -- 'Graphics.Vulkan.Extensions.VK_EXT_validation_cache.VkShaderModuleValidationCacheCreateInfoEXT' -- -- - @flags@ /must/ be @0@ -- -- - @pCode@ /must/ be a valid pointer to an array of -- <> -- @uint32_t@ values -- -- = See Also -- #_see_also# -- -- 'VkShaderModuleCreateFlags', -- 'Graphics.Vulkan.Core10.Core.VkStructureType', 'vkCreateShaderModule' data VkShaderModuleCreateInfo = VkShaderModuleCreateInfo { -- No documentation found for Nested "VkShaderModuleCreateInfo" "vkSType" vkSType :: VkStructureType , -- No documentation found for Nested "VkShaderModuleCreateInfo" "vkPNext" vkPNext :: Ptr () , -- No documentation found for Nested "VkShaderModuleCreateInfo" "vkFlags" vkFlags :: VkShaderModuleCreateFlags , -- No documentation found for Nested "VkShaderModuleCreateInfo" "vkCodeSize" vkCodeSize :: CSize , -- No documentation found for Nested "VkShaderModuleCreateInfo" "vkPCode" vkPCode :: Ptr Word32 } deriving (Eq, Show) instance Storable VkShaderModuleCreateInfo where sizeOf ~_ = 40 alignment ~_ = 8 peek ptr = VkShaderModuleCreateInfo <$> peek (ptr `plusPtr` 0) <*> peek (ptr `plusPtr` 8) <*> peek (ptr `plusPtr` 16) <*> peek (ptr `plusPtr` 24) <*> peek (ptr `plusPtr` 32) poke ptr poked = poke (ptr `plusPtr` 0) (vkSType (poked :: VkShaderModuleCreateInfo)) *> poke (ptr `plusPtr` 8) (vkPNext (poked :: VkShaderModuleCreateInfo)) *> poke (ptr `plusPtr` 16) (vkFlags (poked :: VkShaderModuleCreateInfo)) *> poke (ptr `plusPtr` 24) (vkCodeSize (poked :: VkShaderModuleCreateInfo)) *> poke (ptr `plusPtr` 32) (vkPCode (poked :: VkShaderModuleCreateInfo))