perf(render): tessellate a GPU scene's layers on several threads

Aperta
#2,541 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
58/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust

Direzione di ricerca

Start by reading the GPU branch in crates/render/src/lib.rs, then inspect mesh::collect_layer in crates/render/src/mesh.rs and the threaded mesh building in tile_mesh.rs. Check AGENTS.md for the threading guidance and use the vector_layers_bench command in the issue to establish the GPU baseline. Done means the one-thread and multi-thread scenes match, the vertex-room fallback matches, and the GPU benchmark sequences improve.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

With the GPU backend on (the status bar's CPU/GPU switch, or RUSTGIS_GPU), each full redraw tessellates every layer's geometry into meshes on one thread. Zoomed out, that makes a GPU redraw slower than drawing the frame on the CPU.

Measured

vector_layers_bench (#2525, with BENCH_BACKEND=gpu, #2539) on swisstopo's swiss-map-vector25, one map sheet (66 layers, 335,000 features, 3.0 million vertices). This is the CPU side of a GPU frame (the scene render_backend(.., Backend::Gpu) builds), not the device's upload and draw. Median frame, one build, CPU backend drawing in bands on 16 threads:

Sequence CPU 1× GPU 1× CPU 2× GPU 2×
whole sheet 336 ms 322 ms 828 ms 613 ms
zoom 166 ms 250 ms 293 ms 278 ms
pan 10 m 120 ms 211 ms 293 ms 283 ms
pan 3 m 54 ms 38 ms 158 ms 49 ms

The GPU wins zoomed in and at 2×: its cost doesn't grow with the pixels. Zoomed out at 1× it is up to 75% slower. A zoomed-out scene holds 3.2–4.9 million vertices (about 130–195 MB at 40 bytes a vertex).

While the map moves, the app moves the last scene's meshes without building anything (the camera fast path). These numbers are the redraw when it stops, or when the view leaves the meshes' reach.

Where

render_frame's GPU branch (crates/render/src/lib.rs, mesh::collect_layer for each layer) and crates/render/src/mesh.rs. Each layer's tessellation is independent of the others. Vector tiles already build their meshes on several threads (tile_mesh.rs).

Proposal

Tessellate the layers, or a big layer's features in chunks, on rustgis_data::threads::max() threads (AGENTS.md "Use the threads"):

  • the same scene as one thread, command for command, in layer order;
  • the layer's vertex room (MAX_LAYER_VERTICES) decided as one thread decides it;
  • one thread below a size threshold and in the browser;
  • scratch within memory::thread_scratch;
  • a thread the system refuses costs speed only.

The CPU parts of the scene (layers drawn as pictures) stay where they are in the order.

Keeping a layer's meshes between redraws is #1057's step 2.4, and goes with it.

Tests

  • A scene built on 1 and several threads is the same.
  • A layer over its vertex room falls back as on one thread.
  • The benchmark's GPU sequences before and after.

Related

  • The benchmark's GPU option is merged (#2539): BENCH_BACKEND=gpu cargo run --release -p rustgis-render --example vector_layers_bench -- map.gpkg.
  • #2540's second step decides before tessellating whether a layer is worth a mesh (features in view and their size on screen) instead of after MAX_LAYER_VERTICES is reached. That takes the biggest zoomed-out layers out of tessellation altogether, so it comes before this and changes what is left to split; measure again after it.
  • Keeping a layer's meshes between redraws is #1057's step 2.4 (measurements posted there).
Lingua principale
Rust
Stelle
1.9k
Fork
268
Merge medio
11h 1m
PR unite (30g)
942

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di opengeos/RustGIS

Tutte le issue di opengeos/RustGIS

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.