You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(render): keep a GPU layer's tiles across pans - #3212
Step 3 of #2541: the GPU map keeps a layer's tiles when it pans. A panned scene takes the meshes of the tiles still in it and meshes only the tiles it brings in.
Tiles independent of the cull. A tile's mesh now hangs only on the tile and the features reaching it, not on where the scene's cull edge falls (crates/render/src/mesh_tiles.rs):
a tile lists every feature whose stroke reaches it, anywhere in the tile;
collect_layer takes lines and polygons within a tile of the cull's tiles (feature_area), not only those touching the cull; markers are still culled as before.
So a kept tile is the one meshing it again makes, vertex for vertex.
Kept with the layer's mesh.layer_meshes keeps each layer's tiles (MadeTile, sharing their meshes with the kept commands) beside its whole mesh. A scene that can't take the whole mesh (the cull moved) asks for the latest tiles of the layer as it is, with the same projection, geometry copy, scale, pixel ratio, wireframe and rows drawn (tiles).
The same limits. Each tile records the least vertex limit it meshes within. A kept tile past the limit refuses the layer in its place in grid order, as meshing it again would. Kept tiles count toward the layer's shared budget.
Threads. The thread count is worked out from the tiles still to mesh, so a pan bringing in a few tiles doesn't start many threads.
Not kept:
a layer with a stroke reaching a tile side or more past its feature (over about 1,000 px wide): it could reach in from a feature left out;
tilted views (one mesh a layer, as before), streamed sources (no look), exports.
If a layer has too many tiles and is made one mesh, that mesh still takes only the features visible keeps.
Benchmark
vector_layers_bench, swisstopo swiss-map-vector25 sheet 216 (Winterthur; 66 layers, 335,173 features), BENCH_BACKEND=gpu, BENCH_ONLY="<scale>,<sequence>", 16 threads. Base: main at 7ffe842 (with #3122). Each cell is the median frame in ms, the median of three runs.
sequence
main
kept tiles
1× pan 3 m
98
46 (−53%)
2× pan 3 m
134
58 (−57%)
1× pan 10 m
379
358 (−6%)
2× pan 10 m
443
402 (−9%)
1× zoom
380
380 (±0)
At 10 m a point, a step brings in a quarter of the view, and part of each frame is the CPU picture of a layer the GPU doesn't draw, so less is saved. A zoom changes the scale and keeps no tiles.
Memory
Scene vertices. A scene's meshes hold more vertices: tiles at the cull's edge now take every feature reaching them, out of view too. The bench's median scenes went from 0.77M to 1.08M at 1× pan 3 m, 0.89M to 1.03M at 2× pan 3 m, and 4.73M to 5.14M at 1× pan 10 m (+9 to +40%).
Kept tiles. Kept tiles share their meshes with the kept commands and the scenes drawing them, so no mesh is copied. Each tile adds one small record (its grid cell, its vertex need and a shared command).
The cache's budget. A layer keeps two views (VIEWS), as before. When both share tiles, the shared meshes are counted in each, so the 128 MB budget (32 MB in the browser) fills sooner than the memory it holds.
Layer data. None is copied.
Testing
cargo xtask ci (fmt, clippy, workspace tests, wasm build), plus cargo xtask rows.
New tests:
mesh_tiles::a_panned_scene_takes_its_kept_tiles_and_is_the_one_made_afresh: tiles made for one area, then for a panned area with and without them, give the same bytes. The tiles in both areas are the same meshes. A stroke past the new area's edge reaches its last column. A kept tile past the limit refuses the layer, as meshing it again does.
layer_meshes::a_panned_scene_takes_the_tiles_still_in_it: a GPU scene panned takes some of its tiles from the scene before and is the scene drawn afresh there, vertices, indices, origins and squares.
The existing layer_meshes tests (a pan doesn't take the whole mesh, two views kept) pass unchanged.
Reach
Render only: the desktop app and the browser draw GPU maps through it. The command line, Python and exports draw on the CPU or keep nothing. No command, setting or saved data changes.
UI evidence
No visible UI change. The parity tests compare GPU and CPU pixels.
Map rendering now reuses previously rendered tiles when panning at the same zoom level, helping preserve a consistent scene while updating newly visible areas.
Large tiled views are processed with limits applied to individual tiles, improving rendering behavior across the view.
No actionable comments were generated in the recent review.
Walkthrough
GPU layer collection now retains tile meshes and reuses compatible tiles across same-scale pans. Tile-aware collection selects features for scene tiles, meshes tiles not found in the retained set, and includes tile storage in the kept mesh budget.
Changes: Pan-aware tile mesh reuse
Layer / File(s)
Summary
Tile coverage and feature bucketing crates/render/src/mesh_tiles.rs
Tiling and MadeTile represent the tile area and retained mesh data. Feature extents are bucketed against the area’s tile ranges.
Tile meshing, reuse, and limits crates/render/src/mesh_tiles.rs
Tile meshing reuses matching retained tiles and builds missing tiles. Vertex limits include retained meshes, and tile results remain in grid order. Tests compare reused output with fresh meshing and check vertex limits.
Layer collection and retained cache crates/render/src/mesh.rs, crates/render/src/layer_meshes.rs, crates/render/src/lib.rs
Layer collection uses tile-aware feature selection and passes retained tiles to tile meshing. The cache matches tiles without comparing cull extents and stores the resulting tiles with the kept mesh. Tests check same-scale pan reuse against fresh rendering.
sequenceDiagram
participant GPU_layer_collection
participant layer_meshes_tiles
participant collect_layer
participant tile_meshes
GPU_layer_collection->>layer_meshes_tiles: look up compatible retained tiles
layer_meshes_tiles-->>GPU_layer_collection: return retained tiles
GPU_layer_collection->>collect_layer: collect layer with tiling context
collect_layer->>tile_meshes: provide tile buckets and retained tiles
tile_meshes-->>collect_layer: return tile commands and vertex total
collect_layer-->>GPU_layer_collection: return collected layer mesh and tiles
GPU_layer_collection->>layer_meshes_tiles: retain mesh and resulting tiles
Loading
Possibly related issues
opengeos/RustGIS#2541 — This PR reuses tile meshes during pans, addressing part of the issue’s GPU tessellation work; the issue summary says multithreaded layer tessellation remains unchanged.
Possibly related PRs
opengeos/RustGIS#2628 — This PR extends the same retained GPU mesh cache with tile reuse, and the retained tiles share its per-view budget.
opengeos/RustGIS#3122 — This PR builds on the per-layer tile meshes and limits introduced there.
Suggested reviewers:mavrick-f, deniial00
Merge Risk: Minimal · up to 25771
This change lets GPU map layers reuse tile meshes that remain in view after a pan, so only newly entering tiles are meshed. Review found no concrete defect: reuse is disabled for wide strokes, and the vertex limits still apply to kept tiles. The change is render-only and easy to revert, so merge-readiness risk is minimal.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "perf(render): keep a GPU layer's tiles across pans" names the main change: GPU layer tile meshes are kept and reused when a scene pans, with only newly entering tiles meshed. The changeset …
Description check
The description follows the repository template. It has a Summary that explains the tile reuse change and why it matters, a Testing section listing cargo xtask ci, cargo xtask rows, and two new tests,…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "perf(render): keep a GPU layer's tiles across pans" names the main change: GPU layer tile meshes are kept and reused when a scene pans, with only newly entering tiles meshed. The changeset (mesh_tiles.rs, layer_meshes.rs, mesh.rs, lib.rs) matches this. The title is concise, specific, and follows a conventional-commit style.
Full details: Description check
Explanation
The description follows the repository template. It has a Summary that explains the tile reuse change and why it matters, a Testing section listing cargo xtask ci, cargo xtask rows, and two new tests, and a UI evidence section that correctly states no visible UI change. It also includes a Related issue section (Refs #2541, step 3). It adds Benchmark, Memory, and Reach sections beyond the template, which is acceptable. The template's Related issue placeholder is filled in.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit watched the map tiles glide, Then kept the meshes that stayed inside. New tiles arrived along the way, While old ones hopped from cache to play. The scene matched fresh, tile by tile, And rabbit nibbled, pleased awhile.
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: ASSERTIVE
Plan: Advanced
Run ID: 24d387a1-f771-4661-8eec-5edd49581068
Commits
Reviewing files that changed from the base of the PR and between 7ffe842 and 25771d5.
Files selected for processing: 4
crates/render/src/layer_meshes.rs
crates/render/src/lib.rs
crates/render/src/mesh.rs
crates/render/src/mesh_tiles.rs
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the preview label (once per commit).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Step 3 of #2541: the GPU map keeps a layer's tiles when it pans. A panned scene takes the meshes of the tiles still in it and meshes only the tiles it brings in.
Tiles independent of the cull. A tile's mesh now hangs only on the tile and the features reaching it, not on where the scene's cull edge falls (
crates/render/src/mesh_tiles.rs):collect_layertakes lines and polygons within a tile of the cull's tiles (feature_area), not only those touching the cull; markers are still culled as before.So a kept tile is the one meshing it again makes, vertex for vertex.
Kept with the layer's mesh.
layer_mesheskeeps each layer's tiles (MadeTile, sharing their meshes with the kept commands) beside its whole mesh. A scene that can't take the whole mesh (the cull moved) asks for the latest tiles of the layer as it is, with the same projection, geometry copy, scale, pixel ratio, wireframe and rows drawn (tiles).The same limits. Each tile records the least vertex limit it meshes within. A kept tile past the limit refuses the layer in its place in grid order, as meshing it again would. Kept tiles count toward the layer's shared budget.
Threads. The thread count is worked out from the tiles still to mesh, so a pan bringing in a few tiles doesn't start many threads.
Not kept:
From the perf(render): a GPU layer's meshes cut into tiles and made on several threads #3122 review: the whole-layer estimate is summed only where it is used (untiled).
If a layer has too many tiles and is made one mesh, that mesh still takes only the features
visiblekeeps.Benchmark
vector_layers_bench, swisstopo swiss-map-vector25 sheet 216 (Winterthur; 66 layers, 335,173 features),BENCH_BACKEND=gpu,BENCH_ONLY="<scale>,<sequence>", 16 threads. Base: main at 7ffe842 (with #3122). Each cell is the median frame in ms, the median of three runs.At 10 m a point, a step brings in a quarter of the view, and part of each frame is the CPU picture of a layer the GPU doesn't draw, so less is saved. A zoom changes the scale and keeps no tiles.
Memory
VIEWS), as before. When both share tiles, the shared meshes are counted in each, so the 128 MB budget (32 MB in the browser) fills sooner than the memory it holds.Testing
cargo xtask ci(fmt, clippy, workspace tests, wasm build), pluscargo xtask rows.mesh_tiles::a_panned_scene_takes_its_kept_tiles_and_is_the_one_made_afresh: tiles made for one area, then for a panned area with and without them, give the same bytes. The tiles in both areas are the same meshes. A stroke past the new area's edge reaches its last column. A kept tile past the limit refuses the layer, as meshing it again does.layer_meshes::a_panned_scene_takes_the_tiles_still_in_it: a GPU scene panned takes some of its tiles from the scene before and is the scene drawn afresh there, vertices, indices, origins and squares.layer_meshestests (a pan doesn't take the whole mesh, two views kept) pass unchanged.Reach
Render only: the desktop app and the browser draw GPU maps through it. The command line, Python and exports draw on the CPU or keep nothing. No command, setting or saved data changes.
UI evidence
No visible UI change. The parity tests compare GPU and CPU pixels.
Related issue
Refs #2541 (step 3)
Summary by CodeRabbit