From d2dac89ce385b4807adce7e903cef0947744d3ce Mon Sep 17 00:00:00 2001 From: nek0 Date: Thu, 24 Aug 2023 03:54:57 +0200 Subject: [PATCH] small-ish fixes --- src/CommandBuffer.hs | 85 ++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/src/CommandBuffer.hs b/src/CommandBuffer.hs index 188d568..60c315a 100644 --- a/src/CommandBuffer.hs +++ b/src/CommandBuffer.hs @@ -103,8 +103,11 @@ createFrames indirectBuffer <- createAllocatedBuffer allocator - (sizeOf maxObjects) - Vk.BUFFER_USAGE_STORAGE_BUFFER_BIT + (sizeOf (undefined :: Vk.DrawIndirectCommand)) + (Vk.BUFFER_USAGE_TRANSFER_DST_BIT .|. + Vk.BUFFER_USAGE_STORAGE_BUFFER_BIT .|. + Vk.BUFFER_USAGE_INDIRECT_BUFFER_BIT + ) VMA.MEMORY_USAGE_CPU_TO_GPU let allocationInfo = Vk.zero @@ -285,7 +288,7 @@ recordCommandBuffer (V.fromList [ allocatedBuffer $ meshBuffer mesh ]) (V.fromList [ 0 ]) - let indirectOffset = fromIntegral $ + let indirectOffset = fromIntegral $ first * fromIntegral ( sizeOf (undefined :: Vk.DrawIndirectCommand)) drawStride = fromIntegral $ sizeOf (undefined :: Vk.DrawIndirectCommand) @@ -298,51 +301,49 @@ recordCommandBuffer ) draws - V.mapM_ - (\(IndirectBatch mesh material first count) -> do + -- V.mapM_ + -- (\(IndirectBatch mesh material first count) -> do - when - (materialTextureSet material /= Vk.NULL_HANDLE) - (Vk.cmdBindDescriptorSets - commandBuffer - Vk.PIPELINE_BIND_POINT_GRAPHICS - (materialPipelineLayout material) - 2 - (V.singleton $ materialTextureSet material) - V.empty - ) + -- when + -- (materialTextureSet material /= Vk.NULL_HANDLE) + -- (Vk.cmdBindDescriptorSets + -- commandBuffer + -- Vk.PIPELINE_BIND_POINT_GRAPHICS + -- (materialPipelineLayout material) + -- 2 + -- (V.singleton $ materialTextureSet material) + -- V.empty + -- ) - Vk.cmdBindPipeline commandBuffer Vk.PIPELINE_BIND_POINT_GRAPHICS (materialPipeline material) + -- Vk.cmdBindPipeline commandBuffer Vk.PIPELINE_BIND_POINT_GRAPHICS (materialPipeline material) - Vk.cmdBindDescriptorSets - commandBuffer - Vk.PIPELINE_BIND_POINT_GRAPHICS - (materialPipelineLayout material) - 0 - (V.singleton $ frameGlobalDescriptor frame) - V.empty + -- Vk.cmdBindDescriptorSets + -- commandBuffer + -- Vk.PIPELINE_BIND_POINT_GRAPHICS + -- (materialPipelineLayout material) + -- 0 + -- (V.singleton $ frameGlobalDescriptor frame) + -- V.empty - Vk.cmdBindDescriptorSets - commandBuffer - Vk.PIPELINE_BIND_POINT_GRAPHICS - (materialPipelineLayout material) - 1 - (V.singleton $ frameObjectDescriptor frame) - V.empty + -- Vk.cmdBindDescriptorSets + -- commandBuffer + -- Vk.PIPELINE_BIND_POINT_GRAPHICS + -- (materialPipelineLayout material) + -- 1 + -- (V.singleton $ frameObjectDescriptor frame) + -- V.empty - Vk.cmdBindVertexBuffers - commandBuffer - 0 - (V.fromList [ allocatedBuffer $ meshBuffer mesh ]) - (V.fromList [ 0 ]) + -- Vk.cmdBindVertexBuffers + -- commandBuffer + -- 0 + -- (V.fromList [ allocatedBuffer $ meshBuffer mesh ]) + -- (V.fromList [ 0 ]) - mapM_ - (\index -> - Vk.cmdDraw commandBuffer (fromIntegral $ V.length $ meshVertices mesh) 1 0 index - ) - ([first .. first + count]) - ) - draws + -- mapM_ + -- (Vk.cmdDraw commandBuffer (fromIntegral $ V.length $ meshVertices mesh) 1 0) + -- [first .. (count - 1)] + -- ) + -- draws prepareRecording :: V2 CInt