Reduce GPU load of selection scan - #356
Conversation
- Cache the GPGPU selection scan result keyed by matrices and revision counters, skipping redundant full-cloud transform feedback passes and 4B/point readbacks. Add scan_cache console command as a kill switch. - Remove duplicated scanSelection calls on Alt/Ctrl click. - Poll the GPU fence with exponential backoff starting at 1ms instead of a flat 10ms interval. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #356 +/- ##
==========================================
+ Coverage 38.96% 39.91% +0.94%
==========================================
Files 8 8
Lines 1414 1443 +29
==========================================
+ Hits 551 576 +25
- Misses 827 831 +4
Partials 36 36 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR reduces the latency and GPU/CPU overhead of selection-related operations by avoiding redundant selection scans, reusing prior scan results when inputs are unchanged, and improving GPU fence polling behavior.
Changes:
- Adds a selection scan cache keyed by cursor position (when needed), relevant matrices, and new revision counters for point cloud / selection-mask state.
- Removes a duplicated selection scan in the Alt/Ctrl click paths by reusing the click’s initial scan result.
- Changes GPU fence polling to use exponential backoff instead of a fixed sleep interval.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| main_js.go | Adds scan-result caching, removes duplicate scan on Alt/Ctrl click, and updates fence polling behavior. |
| console.go | Adds a scan_cache console command to toggle the scan cache at runtime. |
| command.go | Introduces revision counters and cache-enable state to support reliable scan-cache invalidation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The doubling was applied after the cap check, so the wait could grow to 16ms. Add tests for the scan_cache command and revision counters. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (1)
command.go:680
Undo()bumpspointCloudRev(viasetPointCloudUpdated()) even when there is nothing to undo. This unnecessarily invalidates the selection-scan cache and forces point cloud re-uploads/rerenders despite no state change. Bump the revision only wheneditor.Undo()actually succeeds.
func (c *commandContext) Undo() bool {
c.setPointCloudUpdated()
return c.editor.Undo()
}
Problem
scanSelectionruns a transform-feedback pass over all points and reads the result back from the GPU on every click, Delete, label key, and console command. On large clouds this wait occurs on every operation. In addition, the Alt/Ctrl click paths ran the same scan twice.Changes
setPointCloudUpdated()to prevent missed invalidations). Only the click path uses the cursor-dependent bit, so it alone requires an exact (x, y) match (needNearCursor).A missed invalidation would silently apply an edit with a stale selection, so the cache can be disabled at runtime with the new
scan_cache 0console command.