Skip to content

Step 1: reuse GPU buffers when displayed geometry has not changed #594

Closed

Description

@dancmari

After #590, Step 1 can display live trajectories using synchronized snapshots. A separate optimization opportunity remains: unchanged display geometry is rebuilt and submitted to the GPU on every rendered frame.

At current main (6e29f528626bb5ccd9227dab6fa3aebce5430cf9):

This is based on source inspection. The redundant work is identifiable, but its contribution to total frame time or odometry time has not yet been measured; no specific speedup is claimed.

Proposed incremental approach:

  1. Start with trajectory points using the existing ScanRenderer::PointsGPU, uploadPoints() and drawPoints(). Reuse the uploaded buffer between data changes. The current uploadPoints() recreates its allocation, so this first step does not imply in-place updates between snapshots.
  2. Extend the existing renderer for persistent line buffers for trajectory axes and predictions, reusing its position layout and shader setup.
  3. Handle buckets separately: copy only display fields under the map mutex, then prepare colors and perform GPU work outside it. Use explicit map revisions to avoid copying/rebuilding unchanged maps.

The cache should remain valid until an operation changes its source. Invalidation must cover new trajectory snapshots, loading/resetting a recording, manual interval corrections (Accept Gizmo), consistency/smoothing, and bucket updates or resets. Changes to poses must refresh affected geometry even if the vertex count stays the same. Camera movement and display-only parameters such as point size should not rebuild geometry.

Validation should preserve live points, axes, predictions, colors and depth behavior during processing, pause/resume and after completion. It should also check reloads and post-processing corrections, demonstrate no geometry uploads for unchanged visible data, and measure CPU preparation/upload costs and frame times before and after on the same recording and settings. Snapshot-copy and memory costs should be included when assessing the result.

Is anyone already planning or working on this? If not, I can prepare a small follow-up PR starting with trajectory points, then address lines and buckets separately.

Activity

  1. dancmari commented on Oct 31, 2026

    @dancmari
    ContributorAuthor

    Implemented in #599.

    The PR covers the complete Step 1 display path, reuses the existing renderer/vertex types and rlgl buffers, and moves bucket preparation/drawing outside map locks. It contains only functional source changes.

    One controlled recording comparison reduced processing time from 418.63 s to 284.75 s (32.0%), with byte-identical pose dumps, the same iteration count and almost unchanged peak resident memory. The PR describes the test conditions and remaining manual checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions