Vertex data is now uploaded asynchronously, using staging buffers.

This commit is contained in:
2022-07-12 00:48:53 -07:00
parent 96e57d9344
commit e280ac486a
2 changed files with 6 additions and 18 deletions

View File

@@ -694,6 +694,8 @@ void KRContext::doStreaming()
device.streamStart(); device.streamStart();
} }
// TODO - Ensure that each iteration does not exhaust the currently fixed 256MB staging buffer
long streaming_start_frame = m_current_frame; long streaming_start_frame = m_current_frame;
long memoryRemaining = KRENGINE_GPU_MEM_TARGET; long memoryRemaining = KRENGINE_GPU_MEM_TARGET;

View File

@@ -570,22 +570,14 @@ void KRMeshManager::KRVBOData::load()
device.createBuffer( device.createBuffer(
m_data->getSize(), m_data->getSize(),
VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
&allocation.vertex_buffer, &allocation.vertex_buffer,
&allocation.vertex_allocation &allocation.vertex_allocation
#if KRENGINE_DEBUG_GPU_LABELS #if KRENGINE_DEBUG_GPU_LABELS
, debug_label , debug_label
#endif // KRENGINE_DEBUG_GPU_LABELS #endif // KRENGINE_DEBUG_GPU_LABELS
); );
device.streamUpload(*m_data, allocation.vertex_buffer);
// TODO - Use staging buffers
void* mappedData = nullptr;
m_data->lock();
vmaMapMemory(allocator, allocation.vertex_allocation, &mappedData);
memcpy(mappedData, m_data->getStart(), m_data->getSize());
vmaUnmapMemory(allocator, allocation.vertex_allocation);
m_data->unlock();
if (m_index_data->getSize() > 0) { if (m_index_data->getSize() > 0) {
#if KRENGINE_DEBUG_GPU_LABELS #if KRENGINE_DEBUG_GPU_LABELS
@@ -594,20 +586,14 @@ void KRMeshManager::KRVBOData::load()
device.createBuffer( device.createBuffer(
m_index_data->getSize(), m_index_data->getSize(),
VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
&allocation.index_buffer, &allocation.index_buffer,
&allocation.index_allocation &allocation.index_allocation
#if KRENGINE_DEBUG_GPU_LABELS #if KRENGINE_DEBUG_GPU_LABELS
, debug_label , debug_label
#endif #endif
); );
device.streamUpload(*m_index_data, allocation.index_buffer);
mappedData = nullptr;
m_index_data->lock();
vmaMapMemory(allocator, allocation.index_allocation, &mappedData);
memcpy(mappedData, m_index_data->getStart(), m_index_data->getSize());
vmaUnmapMemory(allocator, allocation.index_allocation);
m_index_data->unlock();
} }
} }