Skip to content

feat(aggregation-layers): return GPUVectors from WebGLAggregator - #11045

Merged
ibgreen merged 5 commits into
masterfrom
codex/webgl-aggregation-vectors
Nov 7, 2026
Merged

ibgreen merged 5 commits into
masterfrom
codex/webgl-aggregation-vectors

Conversation

@ibgreen

@ibgreen ibgreen commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Follow up of #11044; stacked on its branch.

Background

WebGLAggregator returns 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 lengths
  • Treat non-finite bin ranges as empty outputs
  • Defer grid/hexagon cells until resized results are available
  • Honor vector offsets and strides in contour readback
  • Unit tests: resizing, ownership, shared channels, and empty outputs
  • Documentation: output layout and lifetime
  • Upgrade guide: replace direct descriptor access

Verified: 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 WebGLAggregator output types and alters GPU buffer allocation and draw synchronization logic across aggregation layers.

Overview
Updates WebGLAggregator.getBins() and getResult() to return borrowed GPUVector instances 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. WebGLAggregationTransform and WebGLBinSorter now allocate minimum non-zero capacities to prevent GPU errors on zero or non-finite bin counts, GridLayer and HexagonLayer defer sublayer rendering until scales match the aggregator bin count, and ContourLayer value 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-05T01:57:38.176864Z
We couldn’t complete this review. Comment @codex review to try again.
7a95873 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@greptile-apps

greptile-apps Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable new issue was established.

Summary

WebGLAggregator now returns borrowed GPUVector outputs without copying GPU buffers.

  • WebGLAggregator returns borrowed GPUVector views for bin IDs and channel values.
  • Empty or invalid bin ranges produce zero-length aggregation outputs.
  • Contour values follow each channel's offset and stride.
  • Grid and hexagon cells wait for scales sized to the current bin count.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Input points] --> B[WebGL bin sorter]
  B --> C[Aggregation transform]
  C --> D[Aggregator-owned buffers]
  D --> E[Borrowed GPUVector views]
  E --> F[Cell attributes]
  E --> G[Contour readback]
Loading

Reviews (7) · Last reviewed commit: "Merge remote-tracking branch 'origin/mas..." · Reviewed by Greptile

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@coveralls

coveralls commented Nov 5, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 85.066% (+0.05%) from 85.02% — codex/webgl-aggregation-vectors into master

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Base automatically changed from codex/aggregation-vector-prep to master November 6, 2026 20:32
@ibgreen
ibgreen force-pushed the codex/webgl-aggregation-vectors branch from 1321bed to 06792cc Compare November 6, 2026 20:35
@ibgreen
ibgreen merged commit 505987f into master Nov 7, 2026
9 checks passed
@ibgreen
ibgreen deleted the codex/webgl-aggregation-vectors branch November 7, 2026 18:18

@chrisgervang chrisgervang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +591 to +598
// 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;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 cellSize change (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 in preDraw(), as aggregator.md asks.
  • Probe: a headless Deck with _animate: true that records the agg-cells layer in onAfterRender.

Comment thread docs/upgrade-guide.md
Comment on lines +11 to +15
`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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: Could this entry lead with who it applies to, then one instruction?

Suggested change
`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.

Comment on lines +83 to +93
`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`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Suggested 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`.
`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`.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants