Repository navigation
feat(aggregation-layers): return GPUVectors from WebGLAggregator - #11045
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
[Medium impact] The PR appears safe to merge; no actionable new issue was established. Summary
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1321bed. Configure here.
1321bed to
06792cc
Compare
chrisgervang
left a comment
There was a problem hiding this comment.
Reviewed 75dd12d after merge; follow-ups below.
One P1: GridLayer and HexagonLayer still draw no cells for one frame after each bin-range change on master. The two docs items are optional.
Labels: P1 settle before this is merged, P2 can follow, Non-blocking optional.
| // Resized outputs are populated at draw time. Wait for their onUpdate callbacks | ||
| // before combining new bin IDs with scaled results from the previous aggregation. | ||
| if ( | ||
| !this.state.colors?.matchesLength(aggregator.binCount) || | ||
| !this.state.elevations?.matchesLength(aggregator.binCount) | ||
| ) { | ||
| return null; | ||
| } |
There was a problem hiding this comment.
P1: This guard leaves GridLayer and HexagonLayer with no cells for one frame after each bin-range change, so a cellSize or radius slider, or data with moving bounds, will blink. It is still on master (grid-layer.ts:763, hexagon-layer.ts:698).
- On master e6dc89c with WebGL aggregation, the frame after each
cellSizechange (200 to 800 to 100) had no cells layer. Cells came back one frame later. - On master just before this PR (bf303a1), the same frames drew 224 and 12960 cells.
Could renderLayers use the current getResult() vectors when the lengths differ, as before, and wait only when a scale reads values on the CPU?
Details
- The cells sublayer is also finalized and rebuilt on each change.
- HexagonLayer shows the same pattern (144 and 5400 cells). Its copy of the guard is at hexagon-layer.ts:596-603 in this diff.
- It also delays custom aggregators that allocate in
update()and fill inpreDraw(), asaggregator.mdasks. - Probe: a headless Deck with
_animate: truethat records theagg-cellslayer inonAfterRender.
| `WebGLAggregator.getBins()` and `getResult(channel)` now return borrowed `GPUVector` | ||
| views instead of binary attribute descriptors. They can still be passed directly | ||
| as layer binary attributes. For direct buffer access, use `getGPUVectorData(vector)` | ||
| from `@luma.gl/graph/gpu-data` and read its `buffer`, `byteOffset`, and `byteStride` | ||
| instead of the former descriptor's `buffer`, `offset`, and `stride` fields. |
There was a problem hiding this comment.
Non-blocking: Could this entry lead with who it applies to, then one instruction?
| `WebGLAggregator.getBins()` and `getResult(channel)` now return borrowed `GPUVector` | |
| views instead of binary attribute descriptors. They can still be passed directly | |
| as layer binary attributes. For direct buffer access, use `getGPUVectorData(vector)` | |
| from `@luma.gl/graph/gpu-data` and read its `buffer`, `byteOffset`, and `byteStride` | |
| instead of the former descriptor's `buffer`, `offset`, and `stride` fields. | |
| This applies if you read `buffer`, `offset` or `stride` from `WebGLAggregator.getBins()` or | |
| `getResult(channel)`. Read them from `getGPUVectorData(vector)` in `@luma.gl/graph/gpu-data` | |
| as `buffer`, `byteOffset` and `byteStride`. Outputs passed straight to layer attributes need no change. |
| `getBins()` returns a `GPUVector` with `float32` or `float32x2` bin IDs, matching | ||
| `dimensions`. `getResult(channel)` returns a scalar `float32` `GPUVector`. Each | ||
| vector has `binCount` elements. Channel vectors share interleaved storage, with | ||
| byte offset `channel * 4` and byte stride `channelCount * 4`. | ||
|
|
||
| Outputs are borrowed views of buffers owned by the aggregator. Pass them directly | ||
| to layer binary attributes. Retrieving these outputs does not copy data to the CPU. | ||
| Repeated calls return the same vector while its buffer and length are unchanged; | ||
| fetch outputs again after resizing, and do not use them after destroying the aggregator. | ||
| The methods return `null` before output buffers are allocated, and `getResult` | ||
| also returns `null` for a channel outside `channelCount`. |
There was a problem hiding this comment.
Non-blocking: The byte offset and stride are internal layout, and readers who need them get them from getGPUVectorData. Could this section keep only what the reader does with the outputs?
| `getBins()` returns a `GPUVector` with `float32` or `float32x2` bin IDs, matching | |
| `dimensions`. `getResult(channel)` returns a scalar `float32` `GPUVector`. Each | |
| vector has `binCount` elements. Channel vectors share interleaved storage, with | |
| byte offset `channel * 4` and byte stride `channelCount * 4`. | |
| Outputs are borrowed views of buffers owned by the aggregator. Pass them directly | |
| to layer binary attributes. Retrieving these outputs does not copy data to the CPU. | |
| Repeated calls return the same vector while its buffer and length are unchanged; | |
| fetch outputs again after resizing, and do not use them after destroying the aggregator. | |
| The methods return `null` before output buffers are allocated, and `getResult` | |
| also returns `null` for a channel outside `channelCount`. | |
| `getBins()` returns a `GPUVector` of `float32` (1D) or `float32x2` (2D) bin IDs, and | |
| `getResult(channel)` returns a `float32` `GPUVector`. Each has `binCount` rows. Pass them | |
| directly to layer [binary attributes](../core/layer.md#dataattributes); nothing is copied to the CPU. | |
| The aggregator owns these vectors. Call `getBins()` and `getResult()` again after the bin | |
| count changes, and stop using them after `destroy()`. Both return `null` before the first | |
| `update()`, and `getResult` returns `null` for a channel outside `channelCount`. |

Follow up of #11044; stacked on its branch.
Background
WebGLAggregatorreturns binary descriptors. Returning borrowed GPUVectors lets its bin IDs and interleaved channel values use the aggregator vector interface without copying buffers.Change List
WebGLAggregator: return borrowed vectors with stable identities and lengthsVerified: 164 browser tests passed (2 existing skips), 49 node tests, lint, scoped aggregation typecheck. Full build, golden render, and website checks not run.
Note
Medium Risk
Introduces a breaking API change to
WebGLAggregatoroutput types and alters GPU buffer allocation and draw synchronization logic across aggregation layers.Overview
Updates
WebGLAggregator.getBins()andgetResult()to return borrowedGPUVectorinstances instead of binary attribute descriptors, aligning with the vector output interface for GPU aggregators without copying buffers. Vector views retain stable identities across calls and are invalidated and recreated when buffer capacities or bin lengths change.Improves edge-case handling for empty or resizing aggregation states.
WebGLAggregationTransformandWebGLBinSorternow allocate minimum non-zero capacities to prevent GPU errors on zero or non-finite bin counts,GridLayerandHexagonLayerdefer sublayer rendering until scales match the aggregator bin count, andContourLayervalue readback accounts for channel byte offsets and strides.Reviewed by Cursor Bugbot for commit 75dd12d. Bugbot is set up for automated code reviews on this repo. Configure here.