fix rendering!
This commit is contained in:
parent
8f6f5e428d
commit
1b6a6392ba
2 changed files with 24 additions and 2 deletions
|
@ -182,7 +182,8 @@ createFrames
|
||||||
|
|
||||||
recordCommandBuffer
|
recordCommandBuffer
|
||||||
:: (MonadResource m, MonadReader ReadState m, MonadIO m)
|
:: (MonadResource m, MonadReader ReadState m, MonadIO m)
|
||||||
=> Vk.CommandBuffer
|
=> VMA.Allocator
|
||||||
|
-> Vk.CommandBuffer
|
||||||
-> Vk.RenderPass
|
-> Vk.RenderPass
|
||||||
-> Vk.Framebuffer
|
-> Vk.Framebuffer
|
||||||
-> V2 CInt
|
-> V2 CInt
|
||||||
|
@ -190,6 +191,7 @@ recordCommandBuffer
|
||||||
-> FrameData
|
-> FrameData
|
||||||
-> m ()
|
-> m ()
|
||||||
recordCommandBuffer
|
recordCommandBuffer
|
||||||
|
allocator
|
||||||
commandBuffer
|
commandBuffer
|
||||||
renderPass
|
renderPass
|
||||||
frameBuffer
|
frameBuffer
|
||||||
|
@ -236,7 +238,7 @@ recordCommandBuffer
|
||||||
let draws = compactDraws meshMap materialMap renderObjects
|
let draws = compactDraws meshMap materialMap renderObjects
|
||||||
|
|
||||||
let drawCommands = V.map
|
let drawCommands = V.map
|
||||||
(\(i, RenderObject mesh matrix material) ->
|
(\(i, RenderObject mesh _ _) ->
|
||||||
Vk.DrawIndirectCommand
|
Vk.DrawIndirectCommand
|
||||||
{ vertexCount = fromIntegral (V.length $ meshVertices $ meshMap M.! mesh)
|
{ vertexCount = fromIntegral (V.length $ meshVertices $ meshMap M.! mesh)
|
||||||
, firstVertex = 0
|
, firstVertex = 0
|
||||||
|
@ -249,6 +251,24 @@ recordCommandBuffer
|
||||||
renderObjects
|
renderObjects
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(memRelease, memPtr) <- VMA.withMappedMemory
|
||||||
|
allocator
|
||||||
|
(bufferAllocation $ frameIndirectBuffer frame)
|
||||||
|
allocate
|
||||||
|
|
||||||
|
V.mapM_
|
||||||
|
(\(idx, command) -> liftIO $
|
||||||
|
poke
|
||||||
|
(castPtr memPtr `plusPtr` (idx * sizeOf command))
|
||||||
|
command
|
||||||
|
)
|
||||||
|
(V.zip
|
||||||
|
(V.fromList [0 ..])
|
||||||
|
drawCommands
|
||||||
|
)
|
||||||
|
|
||||||
|
release memRelease
|
||||||
|
|
||||||
V.mapM_
|
V.mapM_
|
||||||
(\(IndirectBatch mesh material first count) -> do
|
(\(IndirectBatch mesh material first count) -> do
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{-# LANGUAGE DuplicateRecordFields #-}
|
{-# LANGUAGE DuplicateRecordFields #-}
|
||||||
{-# LANGUAGE FlexibleContexts #-}
|
{-# LANGUAGE FlexibleContexts #-}
|
||||||
|
{-# LANGUAGE OverloadedRecordDot #-}
|
||||||
module Draw where
|
module Draw where
|
||||||
|
|
||||||
import qualified Control.Concurrent.STM as STM
|
import qualified Control.Concurrent.STM as STM
|
||||||
|
@ -80,6 +81,7 @@ drawFrame engineData frameNumber = do
|
||||||
cameraData
|
cameraData
|
||||||
|
|
||||||
recordCommandBuffer
|
recordCommandBuffer
|
||||||
|
(engineData.engineAllocator)
|
||||||
(frameMainCommandBuffer frame)
|
(frameMainCommandBuffer frame)
|
||||||
(engineRenderPass engineData)
|
(engineRenderPass engineData)
|
||||||
(engineFramebuffers engineData V.! fromIntegral index)
|
(engineFramebuffers engineData V.! fromIntegral index)
|
||||||
|
|
Loading…
Reference in a new issue