From 5601e6fcabb3629e3aec06202390f71c1434d026 Mon Sep 17 00:00:00 2001 From: nek0 Date: Mon, 2 Jan 2023 02:11:12 +0100 Subject: [PATCH] clean the states out --- src/Draw.hs | 14 ++------------ src/Mesh.hs | 8 ++++---- src/Types.hs | 6 ------ 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/Draw.hs b/src/Draw.hs index 3b9fa58..7ad0587 100644 --- a/src/Draw.hs +++ b/src/Draw.hs @@ -2,7 +2,6 @@ {-# LANGUAGE DuplicateRecordFields #-} module Draw where -import qualified Control.Concurrent.STM as STM import Control.Monad import Control.Monad.Trans.Resource import qualified Data.Vector as V @@ -15,15 +14,13 @@ import qualified Vulkan.Zero as Vk import CommandBuffer import Types -import Control.Monad.IO.Class (MonadIO(liftIO)) drawFrame :: (MonadResource m, MonadFail m) => EngineData - -> STM.TMVar Pipelines -> Int -> m () -drawFrame engineData switch frameNumber = do +drawFrame engineData frameNumber = do unless (all (V.length (engineCommandBuffers engineData) ==) [ V.length (engineCommandBuffers engineData) @@ -54,8 +51,6 @@ drawFrame engineData switch frameNumber = do Vk.resetCommandBuffer (engineCommandBuffers engineData V.! fromIntegral index) (Vk.CommandBufferResetFlagBits 0) - switchState <- liftIO $ STM.atomically $ STM.readTMVar switch - -- liftIO $ putStrLn "recording command buffer" recordCommandBuffer (engineCommandBuffers engineData V.! fromIntegral index) @@ -64,12 +59,7 @@ drawFrame engineData switch frameNumber = do (engineWindowDimensions engineData) (meshPipeline engineData V.! fromIntegral index) (meshPipelineLayout engineData) - (case switchState of - Green -> - Just $ engineMesh engineData - _ -> - Nothing - ) + (Just $ engineMesh engineData) frameNumber let submitInfo = Vk.zero diff --git a/src/Mesh.hs b/src/Mesh.hs index d12977b..037eb7c 100644 --- a/src/Mesh.hs +++ b/src/Mesh.hs @@ -47,12 +47,12 @@ uploadMesh vertices allocator = do } :: VMA.AllocationCreateInfo (_, mesh) <- allocate (do - (buffer, allocation, _) <- VMA.createBuffer allocator bufferCreateInfo allocationCreateInfo - return (Mesh vertices (AllocatedBuffer buffer allocation)) + (buffer, bAllocation, _) <- VMA.createBuffer allocator bufferCreateInfo allocationCreateInfo + return (Mesh vertices (AllocatedBuffer buffer bAllocation)) ) - (\(Mesh _ (AllocatedBuffer buffer allocation)) -> do + (\(Mesh _ (AllocatedBuffer buffer bAllocation)) -> do putStrLn "destroying mesh" - VMA.destroyBuffer allocator buffer allocation + VMA.destroyBuffer allocator buffer bAllocation ) (dataReleaseKey, dataPtr) <- allocate diff --git a/src/Types.hs b/src/Types.hs index 87e2b0a..36f02a9 100644 --- a/src/Types.hs +++ b/src/Types.hs @@ -10,12 +10,6 @@ import qualified Vulkan as Vk import qualified Vulkan.Zero as Vk import qualified VulkanMemoryAllocator as VMA -data Pipelines - = Rainbow - | Red - | Green - deriving (Eq, Ord, Enum, Bounded) - data ShaderContainer = ShaderContainer { containedVertexShader :: Maybe Vk.ShaderModule , containedFragmentShader :: Maybe Vk.ShaderModule