Skip to content

Improve memory usage by using a single buffer for WebGL layers#16942

Merged
jahow merged 6 commits into
openlayers:mainfrom
jahow:webgl-use-single-buffer
Jun 30, 2025
Merged

Improve memory usage by using a single buffer for WebGL layers#16942
jahow merged 6 commits into
openlayers:mainfrom
jahow:webgl-use-single-buffer

Conversation

@jahow

@jahow jahow commented Jun 27, 2025

Copy link
Copy Markdown
Contributor

This PR makes it so that a single WebGL layer will generate a single buffer (for each geometry type) combining the attributes used in all the style rules, instead of one buffer per style rule).

This single buffer will be a bit bigger compared to the separate ones before, but the overall memory usage should be drastically reduced. The time spent generating those buffers as well as the render instructions is also reduced, thus improving performance overall.

Inspired by @nssang00 propositions in #16898

No noticeable effect on the benchmark app unfortunately... But this will give way to instanced rendering which should improve things further.

Note: this PR also fixes the fact that the cacheSize option of the WebGLVectorTileLayer class wasn't properly taken into account.

jahow added 2 commits June 26, 2025 12:26
This utility also now converts all flat style rules to shaders, to be
processed by a single VectorStyleRenderer
@github-actions

Copy link
Copy Markdown

📦 Preview the website for this branch here: https://deploy-preview-16942--ol-site.netlify.app/.

jahow added 4 commits June 27, 2025 13:54
The VectorStyleRenderer class now handles multiple render passes
while still using a single buffer; attributes of all the styles
are assembled into a single buffer.

This also means that there is no need to filter the geometry batches anymore
before rendering.
@jahow jahow force-pushed the webgl-use-single-buffer branch from 663e7c6 to 6897fdb Compare June 27, 2025 11:54
@jahow

jahow commented Jun 30, 2025

Copy link
Copy Markdown
Contributor Author

Thank you @ahocevar

@jahow jahow merged commit 19c8031 into openlayers:main Jun 30, 2025
8 checks passed
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