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 struct PendingTransfer
33 const void *object = 0;
35 int buffer_index = -1;
36 std::size_t offset = 0;
38 void *staging_address = 0;
39 std::function<void()> synchronize;
40 std::function<void(VkCommandBuffer, VkBuffer, std::size_t)> transfer;
44 std::size_t default_buffer_size = 16*1048576;
45 std::vector<StagingBuffer> buffers;
46 std::vector<PendingTransfer> transfers;
47 std::vector<PendingTransfer> async_transfers;
48 std::map<const void *, unsigned> next_orders;
51 TransferQueue(Device &);
53 template<typename S, typename T>
54 void *prepare_transfer(const void *, bool, std::size_t, S &&, T &&);
56 template<typename S, typename T>
57 void prepare_transfer(const void *o, bool r, S &&s, T &&t)
58 { prepare_transfer(o, r, 0, std::forward<S>(s), std::forward<T>(t)); }
60 void finalize_transfer(void *);
63 void allocate_staging(PendingTransfer &, std::size_t);
64 PendingTransfer &prepare_transfer(const void *, bool, std::size_t);
65 PendingTransfer &insert_transfer(PendingTransfer &&);
68 void dispatch_transfers(VkCommandBuffer);
71 template<typename S, typename T>
72 void *TransferQueue::prepare_transfer(const void *object, bool ordered, std::size_t size, S &&synchronize, T &&transfer)
74 PendingTransfer &pt = prepare_transfer(object, ordered, size);
75 pt.synchronize = std::forward<S>(synchronize);
76 pt.transfer = std::forward<T>(transfer);
77 return pt.staging_address;