Skip to content

feat(aggregation-layers): add WebGPU ScreenGrid aggregation - #11052

Merged
ibgreen merged 2 commits into
masterfrom
codex/webgpu-screen-grid
Nov 7, 2026
Merged

ibgreen merged 2 commits into
masterfrom
codex/webgpu-screen-grid

Conversation

@ibgreen

@ibgreen ibgreen commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Follow up of #11045; stacked on its branch.

Background

ScreenGrid currently falls back to CPU aggregation on WebGPU. Three compute passes project points, reduce bins, and write GPUVectors consumed directly by cell rendering.

Change List

  • Add compute SUM, MEAN, MIN, MAX, and COUNT reductions
  • Accept accessor inputs and borrowed GPU columns
  • Require explicit domains; retain CPU fallback for picking/extensions
  • Preserve output ownership, offsets, strides, and prefix updates
  • Unit tests: GPU validation, rendering, reductions, empty inputs, recovery
  • Documentation: supported inputs and fallback conditions

Verified: 172 browser tests passed, 2 existing skips; lint and scoped aggregation typecheck passed. Full build, golden render, and website checks not run.


Note

Medium Risk
Introduces new WGSL compute shaders and GPU buffer handling for WebGPU aggregation in ScreenGridLayer. Risk is mitigated by strict gating that falls back to CPU aggregation when compute constraints are not satisfied.

Overview
Adds WebGPU compute shader aggregation to ScreenGridLayer through a new WebGPUScreenGridAggregator. This enables screen-space binning reductions (SUM, MEAN, MIN, MAX, and COUNT) to execute entirely on the GPU when running on WebGPU devices.

The compute path activates when gpuAggregation is enabled, an explicit colorDomain is provided, and both pickable and layer extensions are disabled, automatically falling back to CPU aggregation otherwise. It supports standard accessor inputs as well as borrowed GPUVector position and weight columns, retaining bin IDs and output values in GPU buffers for direct consumption by cell rendering without CPU readback.

In addition, AggregationLayer is updated to allow GPU column inputs on the built-in WebGPU path without requiring a custom aggregator instance, accompanied by new WebGPU reduction tests and documentation.

Reviewed by Cursor Bugbot for commit 84ba584. Bugbot is set up for automated code reviews on this repo. Configure here.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-06T19:31:47.933120Z
We couldn’t complete this review. Comment @codex review to try again.
69c129d 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 6, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 3/5

[Medium impact] The change reaches ScreenGrid aggregation and its cell-rendering workflow.

Fix binary input compatibility before merging; integer weights and two-component positions can stop the grid from drawing.

Findings

  1. P1 Integer weights stop drawing ▶
  2. P1 Two-component positions stop drawing ▶

Summary

Adds WebGPU compute aggregation for ScreenGridLayer.

  • ScreenGridLayer now groups eligible points on WebGPU.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Accessor or GPU inputs] --> B{Compute conditions met?}
  B -->|WebGPU, explicit domain, no picking or extensions| C[Project and reduce bins]
  C --> D[GPUVector results]
  D --> E[Draw grid cells]
  B -->|Otherwise| F[Existing aggregation path]
  F --> E
Loading

Reviews (5) · Last reviewed commit: "Hide empty count bins and refresh Screen..." · Reviewed by Greptile

@coveralls

coveralls commented Nov 6, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 84.652% (-0.4%) from 85.066% — codex/webgpu-screen-grid into master

const position = this.props.positions || positionColumns.positions;
const components = position?.format === 'float32x2' ? 2 : 3;
const p = prepare(position, components);
const low = prepare(this.props.positions ? undefined : positionColumns.positions64Low, 3);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Two-component positions stop drawing

Binary getPosition inputs with size: 2 expose both position columns as float32x2. This call requires three components for positions64Low, so prepare() throws before aggregation runs and the grid cannot draw.

Use the low column's actual component count; the shader already supports two-component columns. PR #11053 retains the same mismatch.

Base automatically changed from codex/webgl-aggregation-vectors to master November 7, 2026 18:18
@ibgreen
ibgreen force-pushed the codex/webgpu-screen-grid branch from 5829a37 to 84ba584 Compare November 7, 2026 18:18
Comment on lines +198 to +199
if (info.type !== 'float32' || info.components !== components)
throw new Error('ScreenGrid aggregation requires float32 columns');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Integer weights stop drawing

Binary getWeight inputs backed by Uint32Array stop drawing when WebGPU compute is selected. The attribute path preserves their uint32 format, but prepare() accepts only float32 and throws. These inputs previously worked through CPU aggregation.

Convert supported binary weights to floats or retain CPU fallback for unsupported formats. PR #11053 keeps the same restriction.

@ibgreen
ibgreen merged commit 300377d into master Nov 7, 2026
9 checks passed
@ibgreen
ibgreen deleted the codex/webgpu-screen-grid branch November 7, 2026 18:30

@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 84ba584 after merge; follow-ups below.

No P1s. #11063 has since rewritten the compute intro; the column rules and page layout below are unchanged on master.

Labels: P1 settle before this is merged, P2 can follow, Non-blocking optional.

Comment on lines +177 to +181
This path also accepts `positions` and `weights` GPUVectors without a custom
aggregator. Positions must be single-chunk `float32x2` or `float32x3`, and weights
must be a single-chunk `float32` vector. Buffers need `STORAGE` or `COPY_SRC` usage;
non-storage inputs are copied on the GPU. Custom views require GPU positions in
the view's coordinate system. Accessor inputs use the normal position conversion.

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.

P2: The GPU column rules now appear on the ScreenGrid, Grid and Hexagon pages and in aggregator.md, and they have started to drift. aggregator.md:223 names only the ScreenGrid and Grid compute paths as accepting columns without a custom aggregator, but Hexagon's page says it accepts them too. Grid and Hexagon also word the custom-view limit differently. Could the rules live once in GPU column inputs, with each page linking there? For example:

This path also accepts GPU column inputs without a custom aggregator.

Details

Proposed text for aggregator.md:

The built-in ScreenGrid, Grid and Hexagon compute paths accept positions as one float32x2 or float32x3 chunk and weights as one float32 chunk. Buffers need STORAGE or COPY_SRC usage; other buffers are copied on the GPU first. In custom views, positions must already use the view's coordinate system. Extensions need accessor data.




## Compute aggregation

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: This page puts Compute aggregation in a ## section before Installation. Grid uses a #### heading among its props, and Hexagon a ##### under gpuAggregation. ScreenGrid's gpuAggregation entry also doesn't link here. Could the three pages use one placement, with each gpuAggregation entry linking to it?

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