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
|
||||
:: (MonadResource m, MonadReader ReadState m, MonadIO m)
|
||||
=> Vk.CommandBuffer
|
||||
=> VMA.Allocator
|
||||
-> Vk.CommandBuffer
|
||||
-> Vk.RenderPass
|
||||
-> Vk.Framebuffer
|
||||
-> V2 CInt
|
||||
|
@ -190,6 +191,7 @@ recordCommandBuffer
|
|||
-> FrameData
|
||||
-> m ()
|
||||
recordCommandBuffer
|
||||
allocator
|
||||
commandBuffer
|
||||
renderPass
|
||||
frameBuffer
|
||||
|
@ -236,7 +238,7 @@ recordCommandBuffer
|
|||
let draws = compactDraws meshMap materialMap renderObjects
|
||||
|
||||
let drawCommands = V.map
|
||||
(\(i, RenderObject mesh matrix material) ->
|
||||
(\(i, RenderObject mesh _ _) ->
|
||||
Vk.DrawIndirectCommand
|
||||
{ vertexCount = fromIntegral (V.length $ meshVertices $ meshMap M.! mesh)
|
||||
, firstVertex = 0
|
||||
|
@ -249,6 +251,24 @@ recordCommandBuffer
|
|||
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_
|
||||
(\(IndirectBatch mesh material first count) -> do
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE DuplicateRecordFields #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE OverloadedRecordDot #-}
|
||||
module Draw where
|
||||
|
||||
import qualified Control.Concurrent.STM as STM
|
||||
|
@ -80,6 +81,7 @@ drawFrame engineData frameNumber = do
|
|||
cameraData
|
||||
|
||||
recordCommandBuffer
|
||||
(engineData.engineAllocator)
|
||||
(frameMainCommandBuffer frame)
|
||||
(engineRenderPass engineData)
|
||||
(engineFramebuffers engineData V.! fromIntegral index)
|
||||
|
|
Loading…
Reference in a new issue