transfer.staging_address = static_cast<char *>(i->mapped_address)+transfer.offset;
i->used += size;
+ ++i->async_count;
}
TransferQueue::PendingTransfer &TransferQueue::prepare_transfer(const void *object, bool ordered, size_t size)
if(i==async_transfers.end() || i->staging_address!=staging)
throw key_error(staging);
+ if(i->buffer_index>=0)
+ --buffers[i->buffer_index].async_count;
insert_transfer(move(*i));
async_transfers.erase(i);
}
if(transfers.empty())
return;
+ ++current_frame;
for(auto i=transfers.begin(); i!=transfers.end(); )
{
auto j = i;
{
VkBuffer buffer = (i->buffer_index>=0 ? buffers[i->buffer_index].buffer : 0);
i->transfer(command_buffer, buffer, i->offset);
+ if(i->buffer_index>=0)
+ buffers[i->buffer_index].last_frame = current_frame;
}
}
transfers.clear();
next_orders.clear();
+
+ unsigned n_frames_in_flight = device.get_n_frames_in_flight();
+ for(StagingBuffer &b: buffers)
+ if(!b.async_count && b.last_frame+n_frames_in_flight<current_frame)
+ b.used = 0;
}
std::size_t size = 0;
std::size_t used = 0;
void *mapped_address = 0;
+ unsigned async_count = 0;
+ unsigned last_frame = 0;
StagingBuffer(Device &, std::size_t);
StagingBuffer(StagingBuffer &&);
std::vector<PendingTransfer> transfers;
std::vector<PendingTransfer> async_transfers;
std::map<const void *, unsigned> next_orders;
+ unsigned current_frame = 0;
public:
TransferQueue(Device &);