Fix #143989: Vulkan: Text drawing performance

Text drawing can be improved. At this moment a vertex buffer is
allocated for 2048 chars. When drawing a string the vertex buffer is
filled from the beginning with the string to draw. The next string will
replace the chars of the previous string. This locks up GPUs as the data
can only be overwritten when the buffer isn't used anymore.

Vulkan backend had an issue that uploading the new data would always
send over 2048 chars even when some chars were only used. By fixing this
the scene in the report went from 0.6 fps to 2.6 fps. OpenGL is 6 fps as
vulkan has to manage a rendergraph with 100.000 of nodes.

Text drawing performance can be improved by continue using the space of
the vertex buffers. In this case more drawing calls can be done, before
the vertex buffer needs to be updated.

Pull Request: https://projects.blender.org/blender/blender/pulls/144604
This commit is contained in:
Jeroen Bakker
2025-08-15 10:36:27 +02:00
parent 17f1c055da
commit ea633b930f

View File

@@ -150,7 +150,8 @@ void VKVertexBuffer::upload_data_direct(const VKBuffer &host_buffer)
void VKVertexBuffer::upload_data_via_staging_buffer(VKContext &context)
{
VKStagingBuffer staging_buffer(buffer_, VKStagingBuffer::Direction::HostToDevice);
VKStagingBuffer staging_buffer(
buffer_, VKStagingBuffer::Direction::HostToDevice, 0, this->size_used_get());
VKBuffer &buffer = staging_buffer.host_buffer_get();
if (buffer.is_allocated()) {
upload_data_direct(buffer);