more restructuring
This commit is contained in:
parent
b3a1545fd2
commit
cec99c0b6c
2 changed files with 30 additions and 31 deletions
|
@ -172,9 +172,7 @@ recordCommandBuffer
|
|||
-> Vk.Framebuffer
|
||||
-> V2 CInt
|
||||
-> Vk.Pipeline
|
||||
-> GPUSceneData
|
||||
-> FrameData
|
||||
-> Int
|
||||
-> m ()
|
||||
recordCommandBuffer
|
||||
commandBuffer
|
||||
|
@ -182,13 +180,9 @@ recordCommandBuffer
|
|||
frameBuffer
|
||||
(V2 width height)
|
||||
graphicsPipeline
|
||||
sceneParameters
|
||||
frame
|
||||
frameNumber
|
||||
= do
|
||||
|
||||
liftIO $ pokeData frame frameNumber sceneParameters (width, height)
|
||||
|
||||
let commandBufferBeginInfo = Vk.zero
|
||||
{ Vk.flags = Vk.COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
|
||||
, Vk.inheritanceInfo = Nothing
|
||||
|
@ -313,9 +307,9 @@ pokeData
|
|||
:: FrameData
|
||||
-> Int
|
||||
-> GPUSceneData
|
||||
-> (CInt, CInt)
|
||||
-> GPUCameraData
|
||||
-> IO ()
|
||||
pokeData frame frameNumber sceneParameters (width, height) = do
|
||||
pokeData frame frameNumber sceneParameters cameraParameters = do
|
||||
let scenePointer = VMA.mappedData (bufferInfo $ frameSceneBuffer frame)
|
||||
memoryPointer = VMA.mappedData (bufferInfo $ frameCameraBuffer frame)
|
||||
framed = fromIntegral frameNumber / 120
|
||||
|
@ -325,26 +319,8 @@ pokeData frame frameNumber sceneParameters (width, height) = do
|
|||
{ ambientColor = ambient
|
||||
}
|
||||
|
||||
camPosition = V3
|
||||
(-10 * sin (fromIntegral frameNumber / 90))
|
||||
(-2)
|
||||
(-10 * cos (fromIntegral frameNumber / 90))
|
||||
camCenter = V3 0 0 0
|
||||
camUp = V3 0 1 0
|
||||
camView = lookAt camPosition camCenter camUp
|
||||
camProjection = perspective
|
||||
(pi/4)
|
||||
(fromIntegral width / fromIntegral height)
|
||||
0.1
|
||||
200
|
||||
cameraData = GPUCameraData
|
||||
{ view = transpose camView
|
||||
, projection = transpose camProjection
|
||||
, viewProjection = transpose $ camProjection !*! camView
|
||||
}
|
||||
|
||||
poke
|
||||
(castPtr scenePointer)
|
||||
ambientParams
|
||||
|
||||
poke (castPtr memoryPointer) cameraData
|
||||
poke (castPtr memoryPointer) cameraParameters
|
||||
|
|
31
src/Draw.hs
31
src/Draw.hs
|
@ -10,6 +10,7 @@ import Control.Monad.Reader
|
|||
import Control.Monad.Trans.Resource
|
||||
import qualified Data.Map.Strict as M
|
||||
import qualified Data.Vector as V
|
||||
import Linear
|
||||
import qualified Vulkan.Core10 as Vk
|
||||
import qualified Vulkan.Extensions.VK_KHR_swapchain as Khr
|
||||
import qualified Vulkan.CStruct.Extends as Vk
|
||||
|
@ -48,22 +49,44 @@ drawFrame engineData frameNumber = do
|
|||
unless (imageResult == Vk.SUCCESS) $
|
||||
error "drawFrame: Failed acquiring next image from swapchain"
|
||||
|
||||
-- liftIO $ putStrLn "resetting command buffer"
|
||||
Vk.resetCommandBuffer
|
||||
(frameMainCommandBuffer frame) (Vk.CommandBufferResetFlagBits 0)
|
||||
|
||||
matLibrary <- (liftIO . STM.atomically. STM.readTMVar) =<< asks materialLibrary
|
||||
|
||||
-- liftIO $ putStrLn "recording command buffer"
|
||||
let (V2 width height) = engineWindowDimensions engineData
|
||||
camPosition = V3
|
||||
(-10 * sin (fromIntegral frameNumber / 90))
|
||||
(-2)
|
||||
(-10 * cos (fromIntegral frameNumber / 90))
|
||||
camCenter = V3 0 0 0
|
||||
camUp = V3 0 1 0
|
||||
camView = lookAt camPosition camCenter camUp
|
||||
camProjection = perspective
|
||||
(pi/4)
|
||||
(fromIntegral width / fromIntegral height)
|
||||
0.1
|
||||
200
|
||||
cameraData = GPUCameraData
|
||||
{ view = transpose camView
|
||||
, projection = transpose camProjection
|
||||
, viewProjection = transpose $ camProjection !*! camView
|
||||
}
|
||||
|
||||
liftIO $
|
||||
pokeData
|
||||
frame
|
||||
frameNumber
|
||||
(engineSceneParameters engineData)
|
||||
cameraData
|
||||
|
||||
recordCommandBuffer
|
||||
(frameMainCommandBuffer frame)
|
||||
(engineRenderPass engineData)
|
||||
(engineFramebuffers engineData V.! fromIntegral index)
|
||||
(engineWindowDimensions engineData)
|
||||
(materialPipeline $ matLibrary M.! "defaultMesh")
|
||||
(engineSceneParameters engineData)
|
||||
frame
|
||||
frameNumber
|
||||
|
||||
let submitInfo = Vk.zero
|
||||
{ Vk.waitSemaphores =
|
||||
|
|
Loading…
Reference in a new issue