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

Improve performance with vertex buffer updates #777

Conversation

kblaschke
Copy link
Member

In wave/shape drawing code, we now preallocate the vertex buffer once for the maximum number of sides and only update the existing buffer instead of reallocating it over and over again. Trades a few KB of additional RAM for a good amount of drawing performance.

In the motion vector grid code, we only reallocate the buffer if we draw more vertices than in the previous draw call.

Also changed the drawing hint to GL_STREAM_DRAW, which is slightly better suited for this kind of usage (update once, draw once, repeat).

These changes should hopefully improve performance, especially when large numbers of custom shapes are drawn.

In wave/shape drawing code, we now preallocate the vertex buffer once for the maximum number of sides and only update the existing buffer instead of reallocating it over and over again. Trades a few KB of additional RAM for a good amount of drawing performance.

In the motion vector grid code, we only reallocate the buffer if we draw more vertices than in the previous draw call.

Also changed the drawing hint to GL_STREAM_DRAW, which is slightly better suited for this kind of usage (update once, draw once, repeat).

These changes should hopefully improve performance, especially when large numbers of custom shapes are drawn.
@kblaschke kblaschke added this to the 4.1 milestone Feb 12, 2024
@kblaschke kblaschke self-assigned this Feb 12, 2024
@kblaschke kblaschke merged commit 2eb1e41 into projectM-visualizer:master Feb 12, 2024
9 checks passed
@kblaschke kblaschke deleted the improve-vertex-buffer-performance branch February 12, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

2 participants