Speed improvement of initial G-code preview:

1) Preallocating the vertex / index buffers to limit reallocation.
2) Inlining the pushing into the vertex / index buffers.
3) Running the vertex buffer generator on a limited number of threads
   as the generator does not scale well due to memory pressure.
   Not using all the threads leaves some of the threads to G-code
   generator.
This commit is contained in:
Vojtech Bubnik 2022-08-23 11:28:25 +02:00
parent 14e0cd0e96
commit 9aee934d53
4 changed files with 28 additions and 25 deletions

View file

@ -1429,6 +1429,13 @@ static void thick_lines_to_geometry(
double width_initial = 0.0;
double bottom_z_initial = 0.0;
// Reserve for a smooth path. Likley the path will not be that smooth, but better than nothing.
// Allocated 1.5x more data than minimum.
// Number of indices, not triangles.
geometry.reserve_more_indices((lines.size() * 8 * 3) * 3 / 2);
// Number of vertices, not floats.
geometry.reserve_more_vertices(((lines.size() + 1) * 4) * 3 / 2);
// loop once more in case of closed loops
const size_t lines_end = closed ? (lines.size() + 1) : lines.size();
for (size_t ii = 0; ii < lines_end; ++ii) {