summaryrefslogtreecommitdiff
path: root/src/vk/source_buffer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/vk/source_buffer.cpp')
-rw-r--r--src/vk/source_buffer.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/vk/source_buffer.cpp b/src/vk/source_buffer.cpp
index 7e6c570..f8f1aee 100644
--- a/src/vk/source_buffer.cpp
+++ b/src/vk/source_buffer.cpp
@@ -21,8 +21,7 @@
namespace VK
{
-SourceBuffer::SourceBuffer(Device *device, void *data, size_t data_size):
- data{data}
+SourceBuffer::SourceBuffer(Device *device, void *data, size_t data_size)
{
this->device = device;
this->device_size = data_size;
@@ -40,7 +39,7 @@ SourceBuffer::SourceBuffer(Device *device, void *data, size_t data_size):
error += command_error.what();
throw std::runtime_error{error};
}
- this->copy_data();
+ this->copy_data(data);
}
SourceBuffer::SourceBuffer(SourceBuffer &&that)
@@ -50,11 +49,9 @@ SourceBuffer::SourceBuffer(SourceBuffer &&that)
this->device_size = that.device_size;
this->buffer_usage = that.buffer_usage;
this->memory_properties = that.memory_properties;
- this->data = that.data;
that.buffer = VK_NULL_HANDLE;
that.device_memory = VK_NULL_HANDLE;
- that.data = nullptr;
}
SourceBuffer&
@@ -65,11 +62,9 @@ SourceBuffer::operator=(SourceBuffer &&that)
this->device_size = that.device_size;
this->buffer_usage = that.buffer_usage;
this->memory_properties = that.memory_properties;
- this->data = that.data;
that.buffer = VK_NULL_HANDLE;
that.device_memory = VK_NULL_HANDLE;
- that.data = nullptr;
return *this;
}
@@ -80,12 +75,12 @@ SourceBuffer::~SourceBuffer()
}
void
-SourceBuffer::copy_data()
+SourceBuffer::copy_data(void *src_data)
{
void *dst_data;
vkMapMemory(this->device->device, this->device_memory, 0, this->device_size,
0, &dst_data);
- memcpy(dst_data, this->data, static_cast<size_t>(this->device_size));
+ memcpy(dst_data, src_data, static_cast<size_t>(this->device_size));
vkUnmapMemory(this->device->device, this->device_memory);
}