make it work

This commit is contained in:
nek0 2023-01-17 05:35:57 +01:00
parent e8e37f1ced
commit f2af2a8ccf
2 changed files with 20 additions and 16 deletions

View file

@ -107,10 +107,11 @@ createFrames physicalDevice logicalDevice allocator descriptorPool setLayout = d
, Vk.range = fromIntegral $ sizeOf (GPUCameraData identity identity identity) , Vk.range = fromIntegral $ sizeOf (GPUCameraData identity identity identity)
} :: Vk.DescriptorBufferInfo } :: Vk.DescriptorBufferInfo
setWrite = Vk.zero setWrite = Vk.zero
{ Vk.dstBinding = 0 { Vk.dstBinding = 0
, Vk.dstSet = V.head globalDescriptor , Vk.dstSet = V.head globalDescriptor
, Vk.descriptorType = Vk.DESCRIPTOR_TYPE_UNIFORM_BUFFER , Vk.descriptorCount = 1
, Vk.bufferInfo = V.singleton bufferInfo , Vk.descriptorType = Vk.DESCRIPTOR_TYPE_UNIFORM_BUFFER
, Vk.bufferInfo = V.singleton bufferInfo
} }
Vk.updateDescriptorSets logicalDevice (V.singleton (Vk.SomeStruct setWrite)) V.empty Vk.updateDescriptorSets logicalDevice (V.singleton (Vk.SomeStruct setWrite)) V.empty
@ -210,16 +211,19 @@ recordCommandBuffer
V.mapM_ V.mapM_
(\(RenderObject meshID materialID modelMatrix) -> do (\(RenderObject meshID materialID modelMatrix) -> do
let camPosition = V3 0 0 (-10) let camPosition = V3
(-10 * sin (fromIntegral frameNumber / 90))
(-2)
(-10 * cos (fromIntegral frameNumber / 90))
camCenter = V3 0 0 0 camCenter = V3 0 0 0
camUp = V3 0 1 0 camUp = V3 0 1 0
camView = lookAt camPosition camCenter camUp camView = lookAt camPosition camCenter camUp
camProjection = perspective (pi/4) (1280 / 1024) 0.1 200 camProjection = perspective (pi/4) (fromIntegral width / fromIntegral height) 0.1 200
cameraData = GPUCameraData cameraData = GPUCameraData
{ view = camView { view = transpose camView
, projection = camProjection , projection = transpose camProjection
, viewProjection = camProjection !*! camView , viewProjection = transpose $ camProjection !*! camView
} }
-- pvm = projection !*! view !*! modelMatrix -- pvm = projection !*! view !*! modelMatrix
@ -256,11 +260,11 @@ recordCommandBuffer
(fromIntegral $ sizeOf constants) (fromIntegral $ sizeOf constants)
dataPointer dataPointer
-- Vk.cmdBindVertexBuffers Vk.cmdBindVertexBuffers
-- commandBuffer commandBuffer
-- 0 0
-- (V.fromList [ allocatedBuffer $ meshBuffer mesh ]) (V.fromList [ allocatedBuffer $ meshBuffer mesh ])
-- (V.fromList [ 0 ]) (V.fromList [ 0 ])
Vk.cmdDraw commandBuffer (fromIntegral $ V.length $ meshVertices mesh) 1 0 0 Vk.cmdDraw commandBuffer (fromIntegral $ V.length $ meshVertices mesh) 1 0 0
) )

View file

@ -189,8 +189,8 @@ initDescriptors device = do
, Vk.maxSets = 10 , Vk.maxSets = 10
, Vk.poolSizes = V.singleton , Vk.poolSizes = V.singleton
( Vk.zero ( Vk.zero
{ Vk.type' = Vk.DESCRIPTOR_TYPE_UNIFORM_BUFFER { Vk.type' = Vk.DESCRIPTOR_TYPE_UNIFORM_BUFFER
, Vk.descriptorCount = 1 , Vk.descriptorCount = 10
} }
) )
} }