-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Use easytensor with vulkan-api. -- -- Use easytensor DataFrame types with vulkan-api. This package provides -- an orphan instance of PrimBytes for Vulkan structures, so they can be -- used as elements of DataFrames. In addition, it provides a few helper -- functions for working with array-like structures. @package easytensor-vulkan @version 2.0.0.0 -- | This module provides an orphan instance of PrimBytes for -- VulkanMarshalPrim structures. This enables them to be stored -- in DataFrames from easytensor package. Thanks to -- internal structure of Vulkan structures, they can be manipulated -- inside DataFrames in a very efficient way (just by copying byte -- arrays). However, original DataFrames are based on unpinned -- arrays; functions here check this and copy data to new pinned arrays -- if needed. -- -- In addition to the orphan instance, this module provides a few handy -- helper functions. module Graphics.Vulkan.Marshal.Create.DataFrame -- | Write an array of values in one go. setVec :: forall fname x t. (FieldType fname x ~ t, PrimBytes t, KnownDim (FieldArrayLength fname x), CanWriteFieldArray fname x) => Vector t (FieldArrayLength fname x) -> CreateVkStruct x '[fname] () -- | Get an array of values, possibly without copying (if vector -- implementation allows). getVec :: forall fname x t a. (FieldType fname x ~ t, PrimBytes t, KnownDim (FieldArrayLength fname x), CanReadFieldArray fname x, x ~ VulkanStruct a) => x -> Vector t (FieldArrayLength fname x) -- | Given the number of elements, create a new pinned DataFrame and -- initialize it using the provided function. -- -- The argument function is called one time with a Ptr pointing to -- the beginning of a contiguous array. This array is converted into a -- dataframe, possibly without copying. -- -- It is safe to pass result of this function to withDFPtr. fillDataFrame :: forall a. PrimBytes a => Word -> (Ptr a -> IO ()) -> IO (Vector a (XN 0)) -- | Run some operation with a pointer to the first item in the frame. All -- items of the frame are kept in a contiguous memory area accessed by -- that pointer. -- -- The function attempts to get an underlying ByteArray# without -- data copy; otherwise, it creates a new pinned ByteArray# and -- passes a pointer to it. Therefore: -- -- withDFPtr :: VulkanDataFrame a ds => DataFrame a ds -> (Ptr a -> IO b) -> IO b -- | A variant of setVkRef that writes a pointer to a contiguous -- array of structures. -- -- Write a pointer to a vulkan structure - member of current structure -- and make sure the member exists as long as this structure exists. -- -- Prefer this function to using unsafePtr a, because the latter -- does not keep the dependency information in GC, which results in -- member structure being garbage-collected and the reference being -- invalid. setDFRef :: forall fname x a ds. (CanWriteField fname x, FieldType fname x ~ Ptr a, VulkanDataFrame a ds) => DataFrame a ds -> CreateVkStruct x '[fname] () class VulkanDataFrame a (ds :: [k]) -- | Construct a new VkDataFrame possibly without copying. It -- performs no copy if the DataFrame implementation is a pinned -- ByteArray#. frameToVkData :: VulkanDataFrame a ds => DataFrame a ds -> VkDataFrame a ds -- | Construct a new (pinned if implementation allows) DataFrame from VK -- data, possibly without copying. -- -- Note, this is a user responsibility to check if the real size of -- VkDataFrame and the dimensionality ds agree. vkDataToFrame :: VulkanDataFrame a ds => Dims ds -> VkDataFrame a ds -> DataFrame a ds -- | Special data type used to provide VulkanMarshal instance for -- DataFrames. It is guaranteed to be pinned. type VkDataFrame (t :: l) (ds :: [k]) = VulkanStruct (DataFrame t ds) instance (Numeric.PrimBytes.PrimBytes a, Numeric.Dimensions.Dim.Dimensions ds) => Graphics.Vulkan.Marshal.Create.DataFrame.VulkanDataFrame a ds instance (Numeric.PrimBytes.PrimBytes a, Data.Type.List.All Numeric.Dimensions.Dim.KnownXNatType ds) => Graphics.Vulkan.Marshal.Create.DataFrame.VulkanDataFrame a ds instance forall k l (t :: l) (ds :: [k]). Numeric.PrimBytes.PrimBytes (Numeric.DataFrame.Type.DataFrame t ds) => Foreign.Storable.Storable (Graphics.Vulkan.Marshal.Create.DataFrame.VkDataFrame t ds) instance forall k l (t :: l) (ds :: [k]). Numeric.PrimBytes.PrimBytes (Numeric.DataFrame.Type.DataFrame t ds) => Graphics.Vulkan.Marshal.VulkanMarshal (Graphics.Vulkan.Marshal.Create.DataFrame.VkDataFrame t ds) instance Foreign.Storable.Storable (Graphics.Vulkan.Marshal.Internal.VulkanStruct a) => Numeric.PrimBytes.PrimBytes (Graphics.Vulkan.Marshal.Internal.VulkanStruct a)