Temporary vertex data is now uploaded synchronously in the presentation thread with the graphics command buffer.

This commit is contained in:
2022-07-25 00:43:11 -07:00
parent 6551e6d8a6
commit d19f340d32
3 changed files with 19 additions and 2 deletions

View File

@@ -711,6 +711,13 @@ void KRDevice::streamUpload(KRDataBlock& data, VkBuffer destination)
data.unlock();
}
void KRDevice::graphicsUpload(KRDataBlock& data, VkBuffer destination)
{
data.lock();
graphicsUpload(data.getStart(), data.getSize(), destination);
data.unlock();
}
void KRDevice::checkFlushStreamBuffer(size_t size)
{
// Flush the buffers if we would run out of space

View File

@@ -80,6 +80,7 @@ public:
void streamUpload(void* data, size_t size, Vector2i dimensions, VkImage destination);
void streamEnd();
void graphicsUpload(KRDataBlock& data, VkBuffer destination);
void graphicsUpload(void* data, size_t size, VkBuffer destination);
VkPhysicalDevice m_device;

View File

@@ -577,7 +577,12 @@ void KRMeshManager::KRVBOData::load()
, debug_label
#endif // KRENGINE_DEBUG_GPU_LABELS
);
device.streamUpload(*m_data, allocation.vertex_buffer);
if (m_type == vbo_type::TEMPORARY) {
device.graphicsUpload(*m_data, allocation.vertex_buffer);
} else {
device.streamUpload(*m_data, allocation.vertex_buffer);
}
if (m_index_data->getSize() > 0) {
#if KRENGINE_DEBUG_GPU_LABELS
@@ -593,7 +598,11 @@ void KRMeshManager::KRVBOData::load()
, debug_label
#endif
);
device.streamUpload(*m_index_data, allocation.index_buffer);
if (m_type == vbo_type::TEMPORARY) {
device.graphicsUpload(*m_index_data, allocation.index_buffer);
} else {
device.streamUpload(*m_index_data, allocation.index_buffer);
}
}
}