slowly working forwards
This commit is contained in:
parent
ce5bed8843
commit
1107ea91da
6 changed files with 83 additions and 49 deletions
|
@ -14,6 +14,8 @@ import qualified Vulkan.Zero as Vk
|
||||||
-- internal imports
|
-- internal imports
|
||||||
|
|
||||||
import Devices
|
import Devices
|
||||||
|
import Types
|
||||||
|
import Mesh
|
||||||
|
|
||||||
createCommandPool
|
createCommandPool
|
||||||
:: (MonadResource m)
|
:: (MonadResource m)
|
||||||
|
@ -64,8 +66,16 @@ recordCommandBuffer
|
||||||
-> Vk.Framebuffer
|
-> Vk.Framebuffer
|
||||||
-> V2 CInt
|
-> V2 CInt
|
||||||
-> Vk.Pipeline
|
-> Vk.Pipeline
|
||||||
|
-> Maybe Mesh
|
||||||
-> m ()
|
-> m ()
|
||||||
recordCommandBuffer commandBuffer renderPass frameBuffer (V2 width height) graphicsPipeline = do
|
recordCommandBuffer
|
||||||
|
commandBuffer
|
||||||
|
renderPass
|
||||||
|
frameBuffer
|
||||||
|
(V2 width height)
|
||||||
|
graphicsPipeline
|
||||||
|
mesh
|
||||||
|
= do
|
||||||
|
|
||||||
let commandBufferBeginInfo = Vk.zero
|
let commandBufferBeginInfo = Vk.zero
|
||||||
{ Vk.flags = Vk.COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
|
{ Vk.flags = Vk.COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
|
||||||
|
@ -116,7 +126,18 @@ recordCommandBuffer commandBuffer renderPass frameBuffer (V2 width height) graph
|
||||||
Vk.cmdSetViewport commandBuffer 0 (V.singleton viewport)
|
Vk.cmdSetViewport commandBuffer 0 (V.singleton viewport)
|
||||||
Vk.cmdSetScissor commandBuffer 0 (V.singleton scissor)
|
Vk.cmdSetScissor commandBuffer 0 (V.singleton scissor)
|
||||||
|
|
||||||
Vk.cmdDraw commandBuffer 3 1 0 0
|
maybe
|
||||||
|
(Vk.cmdDraw commandBuffer 3 1 0 0)
|
||||||
|
(\jmesh -> do
|
||||||
|
Vk.cmdBindVertexBuffers
|
||||||
|
commandBuffer
|
||||||
|
0
|
||||||
|
(V.fromList [ allocatedBuffer $ meshBuffer jmesh ])
|
||||||
|
(V.fromList [ 0 ])
|
||||||
|
|
||||||
|
Vk.cmdDraw commandBuffer (fromIntegral $ V.length $ meshVertices jmesh) 1 0 0
|
||||||
|
)
|
||||||
|
mesh
|
||||||
|
|
||||||
Vk.cmdEndRenderPass commandBuffer
|
Vk.cmdEndRenderPass commandBuffer
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import Types
|
||||||
import Control.Monad.IO.Class (MonadIO(liftIO))
|
import Control.Monad.IO.Class (MonadIO(liftIO))
|
||||||
|
|
||||||
drawFrame
|
drawFrame
|
||||||
:: (MonadResource m)
|
:: (MonadResource m, MonadFail m)
|
||||||
=> EngineData
|
=> EngineData
|
||||||
-> STM.TMVar Pipelines
|
-> STM.TMVar Pipelines
|
||||||
-> m ()
|
-> m ()
|
||||||
|
@ -69,6 +69,12 @@ drawFrame engineData switch = do
|
||||||
Green ->
|
Green ->
|
||||||
meshPipeline engineData V.! fromIntegral index
|
meshPipeline engineData V.! fromIntegral index
|
||||||
)
|
)
|
||||||
|
(case switchState of
|
||||||
|
Green ->
|
||||||
|
Just $ engineMesh engineData
|
||||||
|
_ ->
|
||||||
|
Nothing
|
||||||
|
)
|
||||||
|
|
||||||
let submitInfo = Vk.zero
|
let submitInfo = Vk.zero
|
||||||
{ Vk.waitSemaphores =
|
{ Vk.waitSemaphores =
|
||||||
|
|
|
@ -12,6 +12,7 @@ import Data.Bits
|
||||||
import qualified Data.ByteString.Char8 as BS
|
import qualified Data.ByteString.Char8 as BS
|
||||||
import qualified Data.Vector as V
|
import qualified Data.Vector as V
|
||||||
import Foreign.C.Types (CInt)
|
import Foreign.C.Types (CInt)
|
||||||
|
import qualified Vulkan as VK
|
||||||
import qualified Vulkan.Core10 as Vk
|
import qualified Vulkan.Core10 as Vk
|
||||||
import qualified Vulkan.Zero as Vk
|
import qualified Vulkan.Zero as Vk
|
||||||
import qualified Vulkan.CStruct.Extends as Vk
|
import qualified Vulkan.CStruct.Extends as Vk
|
||||||
|
@ -19,8 +20,7 @@ import qualified Vulkan.Utils.ShaderQQ.GLSL.Shaderc as Vk
|
||||||
|
|
||||||
-- internal imports
|
-- internal imports
|
||||||
import Types
|
import Types
|
||||||
import qualified Vulkan as VK
|
import Mesh
|
||||||
import qualified Vulkan.CStruct.Extends as VK
|
|
||||||
|
|
||||||
loadShader
|
loadShader
|
||||||
:: (MonadResource m)
|
:: (MonadResource m)
|
||||||
|
@ -128,7 +128,7 @@ createVertexInputAssemblyStateCreateInfo topology =
|
||||||
|
|
||||||
createRasterizationStateCreateInfo
|
createRasterizationStateCreateInfo
|
||||||
:: Vk.PolygonMode
|
:: Vk.PolygonMode
|
||||||
-> VK.SomeStruct Vk.PipelineRasterizationStateCreateInfo
|
-> Vk.SomeStruct Vk.PipelineRasterizationStateCreateInfo
|
||||||
createRasterizationStateCreateInfo mode =
|
createRasterizationStateCreateInfo mode =
|
||||||
Vk.SomeStruct $ Vk.zero
|
Vk.SomeStruct $ Vk.zero
|
||||||
{ Vk.depthClampEnable = False
|
{ Vk.depthClampEnable = False
|
||||||
|
@ -198,9 +198,10 @@ createGraphicsPipelines
|
||||||
pipelineDynamicStateCreateInfo = Vk.zero
|
pipelineDynamicStateCreateInfo = Vk.zero
|
||||||
{ Vk.dynamicStates = dynamicStates
|
{ Vk.dynamicStates = dynamicStates
|
||||||
}
|
}
|
||||||
|
vertexDescription = getVertexDescription (V.head loadMeshes)
|
||||||
pipelineVertexInputCreateInfo = Vk.zero
|
pipelineVertexInputCreateInfo = Vk.zero
|
||||||
{ Vk.vertexBindingDescriptions = V.empty -- Fill me?
|
{ Vk.vertexBindingDescriptions = vidBindings vertexDescription
|
||||||
, Vk.vertexAttributeDescriptions = V.empty -- Fill me?
|
, Vk.vertexAttributeDescriptions = vidAttributes vertexDescription
|
||||||
}
|
}
|
||||||
viewport = Vk.Viewport
|
viewport = Vk.Viewport
|
||||||
{ Vk.x = 0
|
{ Vk.x = 0
|
||||||
|
|
|
@ -130,7 +130,9 @@ initVulkan window = do
|
||||||
return $ EngineData
|
return $ EngineData
|
||||||
window
|
window
|
||||||
dimensions
|
dimensions
|
||||||
|
vulkanPhysicalDevice
|
||||||
vulkanLogicalDevice
|
vulkanLogicalDevice
|
||||||
|
vulkanInstance
|
||||||
swapchain
|
swapchain
|
||||||
graphicsQueue
|
graphicsQueue
|
||||||
commandBuffer
|
commandBuffer
|
||||||
|
@ -143,3 +145,4 @@ initVulkan window = do
|
||||||
imageAvailableSemaphore
|
imageAvailableSemaphore
|
||||||
renderFinishedSemaphore
|
renderFinishedSemaphore
|
||||||
mesh
|
mesh
|
||||||
|
allocator
|
||||||
|
|
|
@ -28,7 +28,7 @@ main = runResourceT $ do
|
||||||
|
|
||||||
-- create abort condition for upcoming lop
|
-- create abort condition for upcoming lop
|
||||||
quit <- liftIO $ STM.newTMVarIO True
|
quit <- liftIO $ STM.newTMVarIO True
|
||||||
showPipeline <- liftIO $ STM.newTMVarIO Rainbow
|
showPipeline <- liftIO $ STM.newTMVarIO Green
|
||||||
|
|
||||||
-- main loop
|
-- main loop
|
||||||
whileM_
|
whileM_
|
||||||
|
|
|
@ -27,7 +27,9 @@ data ShaderContainer = ShaderContainer
|
||||||
data EngineData = EngineData
|
data EngineData = EngineData
|
||||||
{ engineWindow :: SDL.Window
|
{ engineWindow :: SDL.Window
|
||||||
, engineWindowDimensions :: V2 CInt
|
, engineWindowDimensions :: V2 CInt
|
||||||
|
, enginePhysicalDevice :: Vk.PhysicalDevice
|
||||||
, engineLogicalDevice :: Vk.Device
|
, engineLogicalDevice :: Vk.Device
|
||||||
|
, engineInstance :: Vk.Instance
|
||||||
, engineSwapchain :: Vk.SwapchainKHR
|
, engineSwapchain :: Vk.SwapchainKHR
|
||||||
, engineQueue :: Vk.Queue
|
, engineQueue :: Vk.Queue
|
||||||
, engineCommandBuffers :: V.Vector Vk.CommandBuffer
|
, engineCommandBuffers :: V.Vector Vk.CommandBuffer
|
||||||
|
@ -40,6 +42,7 @@ data EngineData = EngineData
|
||||||
, engineImageAvailableSemaphore :: Vk.Semaphore
|
, engineImageAvailableSemaphore :: Vk.Semaphore
|
||||||
, engineRenderFinishedSemaphore :: Vk.Semaphore
|
, engineRenderFinishedSemaphore :: Vk.Semaphore
|
||||||
, engineMesh :: Mesh
|
, engineMesh :: Mesh
|
||||||
|
, engineAllocator :: VMA.Allocator
|
||||||
}
|
}
|
||||||
|
|
||||||
data AllocatedBuffer = AllocatedBuffer
|
data AllocatedBuffer = AllocatedBuffer
|
||||||
|
|
Loading…
Reference in a new issue