Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid reallocating vectors with every push_back #260

Merged
merged 1 commit into from
Oct 6, 2020

Conversation

DRracer
Copy link
Collaborator

@DRracer DRracer commented Oct 6, 2020

Description

Avoid reallocating vectors with every push_back +avoid using std::vector when not necessary (replace with std::array if possible).

Constants VectorPrealoc and VectorPrealoc3 serve as initial preallocated size of the vectors, may be fine tuned for balanced usage of RAM.

There is much more space for optimization, but this one really brought the biggest benefit.

Behaviour/ Breaking changes

Removes lagging of recalculation of extrusion visualization (3d extrusion, Quad_HR)

Have you tested the changes?

Yes, I did 2 prints with extrusion visualization and compared to previous state. Each print took roughly 1 hour. The lagging disappeared, the rendering is visibly faster.

Linked issues:

#114

+avoid using std::vector when not necessary (replace with std::array)

Constants VectorPrealoc and VectorPrealoc3 serve as initial preallocated
size of the vectors, may be fine tuned for balanced usage of RAM
@vintagepc
Copy link
Owner

vintagepc commented Oct 6, 2020

Yeah, that is pretty heavy code that was okay for lines but not too performant for triangles.
Nice work; this should be a happy medium, though longer term I'd like to look at moving to GL VBOs instead so we don't need to keep pipelining the data from main memory to the GPU, but that introduces its own complexity with regards to updating VBO contents. But that might not be necessary if we move to a geometry-shader based system as contemplated in #246, where we'd only need to track the path and width (so we're back to only providing lines) and the GPU takes care of inflating the path into tubes/quads as necessary.

Some of our other drawing calls are pretty painful too, particularly the LCD with a lot of GLBegin/GLEnd calls.

Don't mind the broken check; looks like it failed on a third party action step and not the actual tests.

@vintagepc vintagepc merged commit 920d4e8 into vintagepc:master Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants