first little steps

This commit is contained in:
nek0 2023-04-19 15:20:44 +02:00
parent 91e33f4b6c
commit 13bd4ac3f1
2 changed files with 28 additions and 22 deletions

View file

@ -25,6 +25,7 @@ import Devices
import Types import Types
import Memory import Memory
import Util import Util
import Control.Exception (bracket, bracket_)
frameOverlap :: Int frameOverlap :: Int
frameOverlap = 2 frameOverlap = 2
@ -275,7 +276,8 @@ recordCommandBuffer
deviceProps deviceProps
scenePointer <- VMA.mapMemory allocator (bufferAllocation sceneParameterBuffer) liftIO $ VMA.withMappedMemory allocator (bufferAllocation sceneParameterBuffer) bracket $
\scenePointer ->
-- dataPointer <- liftIO $ new scenePointer -- dataPointer <- liftIO $ new scenePointer
@ -298,7 +300,7 @@ recordCommandBuffer
-- test <- peek (castPtr scenePointer :: Ptr GPUSceneData) -- test <- peek (castPtr scenePointer :: Ptr GPUSceneData)
-- print test -- print test
VMA.unmapMemory allocator (bufferAllocation sceneParameterBuffer) -- VMA.unmapMemory allocator (bufferAllocation sceneParameterBuffer)
renderObjects <- (liftIO . STM.atomically . STM.readTMVar) =<< asks renderables renderObjects <- (liftIO . STM.atomically . STM.readTMVar) =<< asks renderables
meshMap <- (liftIO . STM.atomically . STM.readTMVar) =<< asks meshLibrary meshMap <- (liftIO . STM.atomically . STM.readTMVar) =<< asks meshLibrary
@ -330,11 +332,15 @@ recordCommandBuffer
mesh = meshMap M.! meshID mesh = meshMap M.! meshID
material = materialMap M.! materialID material = materialMap M.! materialID
memoryPointer <- VMA.mapMemory allocator (bufferAllocation $ frameCameraBuffer frame) liftIO $ VMA.withMappedMemory
allocator
(bufferAllocation $ frameCameraBuffer frame)
bracket
$ \memoryPointer ->
liftIO $ poke (castPtr memoryPointer) cameraData liftIO $ poke (castPtr memoryPointer) cameraData
VMA.unmapMemory allocator (bufferAllocation $ frameCameraBuffer frame) -- VMA.unmapMemory allocator (bufferAllocation $ frameCameraBuffer frame)
Vk.cmdBindPipeline commandBuffer Vk.PIPELINE_BIND_POINT_GRAPHICS (materialPipeline material) Vk.cmdBindPipeline commandBuffer Vk.PIPELINE_BIND_POINT_GRAPHICS (materialPipeline material)

View file

@ -203,7 +203,7 @@ initDescriptors device = do
0 0
sceneBind = descriptorsetLayoutBinding sceneBind = descriptorsetLayoutBinding
Vk.DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC Vk.DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC
(Vk.SHADER_STAGE_VERTEX_BIT .|. Vk.SHADER_STAGE_FRAGMENT_BIT) Vk.SHADER_STAGE_FRAGMENT_BIT
1 1
objectBind = descriptorsetLayoutBinding objectBind = descriptorsetLayoutBinding
Vk.DESCRIPTOR_TYPE_STORAGE_BUFFER Vk.DESCRIPTOR_TYPE_STORAGE_BUFFER