1 #ifndef MSP_GL_VULKAN_TRANSFERQUEUE_H_
2 #define MSP_GL_VULKAN_TRANSFERQUEUE_H_
21 unsigned memory_id = 0;
24 void *mapped_address = 0;
26 StagingBuffer(Device &, std::size_t);
27 StagingBuffer(StagingBuffer &&);
31 using TransferCallback = void(VkCommandBuffer, VkBuffer, std::size_t);
33 struct PendingTransfer
35 unsigned buffer_index = 0;
36 std::size_t offset = 0;
38 std::function<TransferCallback> callback;
42 std::size_t default_buffer_size = 16*1048576;
43 std::vector<StagingBuffer> buffers;
44 std::vector<PendingTransfer> transfers;
47 TransferQueue(Device &);
50 void *prepare_transfer(std::size_t, T &&);
53 PendingTransfer &prepare_transfer(std::size_t);
56 void dispatch_transfers(VkCommandBuffer);
60 void *TransferQueue::prepare_transfer(std::size_t size, T &&callback)
62 PendingTransfer &pt = prepare_transfer(size);
63 pt.callback = std::forward<T>(callback);
64 return static_cast<char *>(buffers[pt.buffer_index].mapped_address)+pt.offset;