void Buffer::AsyncTransfer::allocate()
{
- dest_addr = buffer.map();
+ dest_addr = buffer->map();
}
void Buffer::AsyncTransfer::finalize()
{
- buffer.unmap();
+ buffer->unmap();
}
} // namespace GL
void Buffer::AsyncTransfer::allocate()
{
- if(buffer.can_map())
- dest_addr = static_cast<char *>(buffer.map())+offset;
+ if(buffer->can_map())
+ dest_addr = static_cast<char *>(buffer->map())+offset;
else
{
- Buffer &buf = buffer;
+ Buffer &buf = *buffer;
size_t off = offset;
size_t sz = size;
- dest_addr = buffer.device.get_transfer_queue().prepare_transfer(&buffer, false, size,
+ dest_addr = buf.device.get_transfer_queue().prepare_transfer(buffer, false, size,
[&buf, off, sz](){
buf.device.get_synchronizer().write_buffer(buf.handle, off, sz);
},
void Buffer::AsyncTransfer::finalize()
{
- if(buffer.can_map())
+ if(buffer->can_map())
{
- buffer.unmap();
- buffer.device.get_synchronizer().write_buffer(buffer.handle, offset, size, true);
+ buffer->unmap();
+ buffer->device.get_synchronizer().write_buffer(buffer->handle, offset, size, true);
}
else
- buffer.device.get_transfer_queue().finalize_transfer(dest_addr);
+ buffer->device.get_transfer_queue().finalize_transfer(dest_addr);
}
} // namespace GL
Buffer::AsyncTransfer::AsyncTransfer(Buffer &b, size_t o, size_t s):
- buffer(b),
+ buffer(&b),
offset(o),
size(s),
dest_addr(0)
other.dest_addr = 0;
}
+Buffer::AsyncTransfer &Buffer::AsyncTransfer::operator=(AsyncTransfer &&other)
+{
+ if(dest_addr)
+ finalize();
+
+ buffer = other.buffer;
+ offset = other.offset;
+ size = other.size;
+ dest_addr = other.dest_addr;
+
+ other.dest_addr = 0;
+
+ return *this;
+}
+
Buffer::AsyncTransfer::~AsyncTransfer()
{
if(dest_addr)
friend class Buffer;
private:
- Buffer &buffer;
+ Buffer *buffer = 0;
std::size_t offset = 0;
std::size_t size = 0;
void *dest_addr = 0;
AsyncTransfer(Buffer &, std::size_t, std::size_t);
public:
+ AsyncTransfer() = default;
AsyncTransfer(AsyncTransfer &&);
+ AsyncTransfer &operator=(AsyncTransfer &&);
~AsyncTransfer();
private: