prepare synchronisation objects for drawing

This commit is contained in:
nek0 2022-07-14 02:23:29 +02:00
parent a9715e1767
commit bfb3b1a814

View file

@ -4,23 +4,16 @@
module CommandBuffer where module CommandBuffer where
import Control.Monad import Control.Monad
import Control.Monad.Loops
import Control.Monad.IO.Class
import Control.Monad.Trans.Resource import Control.Monad.Trans.Resource
import Data.Bits
import qualified Data.Vector as V import qualified Data.Vector as V
import Data.Word
import Foreign.C.Types (CInt) import Foreign.C.Types (CInt)
import Linear import Linear
import qualified SDL hiding (V2)
import qualified Control.Concurrent.STM as STM
import qualified Vulkan as Vk import qualified Vulkan as Vk
import qualified Vulkan.Zero as Vk import qualified Vulkan.Zero as Vk
-- internal imports -- internal imports
import Devices import Devices
import qualified Vulkan.Dynamic as Vk
createCommandPool createCommandPool
:: (MonadResource m) :: (MonadResource m)
@ -120,3 +113,25 @@ recordCommandBuffer commandBuffer renderPass frameBuffer (V2 width height) graph
Vk.cmdDraw commandBuffer 3 1 0 0 Vk.cmdDraw commandBuffer 3 1 0 0
Vk.cmdEndRenderPass commandBuffer Vk.cmdEndRenderPass commandBuffer
createSyncObjects
:: (MonadResource m, MonadFail m)
=> Vk.Device
-> m (Vk.Semaphore, Vk.Semaphore, Vk.Fence)
createSyncObjects logicalDevice = do
let semaphoreCreateInfo = Vk.zero
fenceCreateInfo = Vk.zero
[imageAvailableSemaphore, renderFinishedSemaphore] <- replicateM 2
(snd <$> allocate
(Vk.createSemaphore logicalDevice semaphoreCreateInfo Nothing)
(\semaphore -> do
putStrLn "destroying semaphore"
Vk.destroySemaphore logicalDevice semaphore Nothing
)
)
inFlightFence <- Vk.createFence logicalDevice fenceCreateInfo Nothing
return (imageAvailableSemaphore, renderFinishedSemaphore,inFlightFence)