Skip to content

feat(layers): add LineLayer analytic antialiasing - #10558

Merged
chrisgervang merged 11 commits into
claude/deckgl-path-aliasing-4tx9a3from
chrisgervang/line-layer-antialiasing
Aug 21, 2026
Merged

chrisgervang merged 11 commits into
claude/deckgl-path-aliasing-4tx9a3from
chrisgervang/line-layer-antialiasing

Conversation

@chrisgervang

@chrisgervang chrisgervang commented Aug 14, 2026 •

Copy link
Copy Markdown
Collaborator

Goal

Add opt-in analytic edge antialiasing to LineLayer independently of PathLayer.

Change List

  • Add LineLayer.antialiasing, defaulting to false.
  • Feather the two long edges of each line strip in GLSL and WGSL from fwidth(uv.y).
  • Keep segment ends hard so neighboring segments do not seam.
  • Preserve the setting through LineLayer's second wrapLongitude draw.
  • Include the LineLayer API documentation and focused uniform/no-MSAA coverage tests in this PR.

Validation

  • Focused LineLayer headless test
  • Focused isolated WebGL test with MSAA disabled
  • Included in stack-wide yarn lint and yarn build

Performance benchmark

Extends yarn bench-antialiasing with 100K sparse 1px LineLayer segments. On an Apple M1 Max running macOS 26.3 in headless Chrome 151.0.7922.138, the median of 100 alternating GPU timestamp samples was 0.441→0.442 ms (+0%) on WebGL2 and 0.420→0.424 ms (+1%) on WebGPU.

Visual comparison

The render-test device has framebuffer MSAA disabled. Left: antialiasing: false. Right: antialiasing: true.

LineLayer analytic antialiasing comparison


Note

Medium Risk
Touches LineLayer vertex/fragment shaders (including discard and picking coverage) on both WebGL and WebGPU. Default remains off, so existing visuals stay unchanged unless the new prop is enabled.

Overview
Adds an opt-in antialiasing prop on LineLayer (default false) so long edges can be feathered in the shader instead of relying on framebuffer MSAA.

When enabled, GLSL and WGSL expand the rasterized width by half a device pixel and apply fwidth-based coverage along uv.y. Segment ends stay hard so neighboring segments do not seam. The model is rebuilt when the prop changes; wrapLongitude’s second draw keeps the same shader variant. Overlapping lines can still show coverage artifacts.

Docs, unit tests, no-MSAA render tests, and a LineLayer bench workload cover the new path.

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

@coveralls

coveralls commented Aug 14, 2026 •

Copy link
Copy Markdown

Coverage Status

Coverage is 82.199% — chrisgervang/line-layer-antialiasing into claude/deckgl-path-aliasing-4tx9a3. No base build found for claude/deckgl-path-aliasing-4tx9a3.

@chrisgervang
chrisgervang force-pushed the chrisgervang/line-layer-antialiasing branch from 6ddf070 to a9db815 Compare August 14, 2026 00:52
@chrisgervang
chrisgervang force-pushed the chrisgervang/line-layer-antialiasing branch from a9db815 to b7cca97 Compare August 14, 2026 17:39

@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 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 b7cca97. Configure here.

@chrisgervang
chrisgervang force-pushed the chrisgervang/line-layer-antialiasing branch from b7cca97 to 79c401b Compare August 14, 2026 18:39
@chrisgervang
chrisgervang force-pushed the chrisgervang/line-layer-antialiasing branch from 79c401b to 07cc35f Compare August 14, 2026 19:44

@ibgreen ibgreen 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.

There is a concrete default-off WebGPU regression here: edgeCoord and edgePixels (including fwidth, max, and division) are computed before checking line.antialiasing. This work therefore remains in every fragment, including the picking path, when the prop is left at its default false. The vertex shader likewise computes length(filteredOffset.xy) before the guard on both backends.

I think this should be addressed before merge. Moving the derivative into the uniform branch would remove the most obvious unconditional work, but to guarantee the non-opt-in fast path across drivers I recommend compiling separate AA-on/off shader variants: a GLSL define plus generated WGSL, with model recreation or lazy selection when the prop toggles. The disabled variant should contain neither the derivative calculation nor the vertex coverage-envelope logic.

@chrisgervang
chrisgervang force-pushed the chrisgervang/line-layer-antialiasing branch from 07cc35f to cd98950 Compare August 15, 2026 00:43
@chrisgervang

chrisgervang commented Aug 15, 2026 •

Copy link
Copy Markdown
Collaborator Author

Addressed in cd98950. LineLayer now uses compile-time GLSL/WGSL variants and recreates the model when the antialiasing prop changes. The default WGSL source no longer contains the unconditional fwidth, edge division, vertex length, coverage envelope, AA branch, or AA uniform. Source-level and lifecycle tests guard the fast path and variant transition.

@chrisgervang
chrisgervang force-pushed the chrisgervang/line-layer-antialiasing branch from cd98950 to 3b3933f Compare August 15, 2026 00:47
@chrisgervang
chrisgervang force-pushed the chrisgervang/line-layer-antialiasing branch from 3b3933f to ee9d725 Compare August 15, 2026 23:39
@chrisgervang
chrisgervang force-pushed the chrisgervang/line-layer-antialiasing branch 2 times, most recently from b46440b to 9ba2158 Compare August 17, 2026 21:45
@greptile-apps

greptile-apps Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

Greptile Summary

Adds opt-in analytic antialiasing to LineLayer across WebGL and WebGPU while retaining the existing default rendering path.

  • Adds shader-based edge coverage and expands the rasterized line envelope when antialiasing is enabled.
  • Recreates the model when the antialiasing shader variant changes and preserves it through longitude wrapping.
  • Documents the property and adds shader, render, no-MSAA, WebGPU premultiplication, and benchmark coverage.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
modules/layers/src/line-layer/line-layer.ts Adds the public antialiasing property, shader define selection, and model recreation when the variant changes.
modules/layers/src/line-layer/line-layer-fragment.glsl.ts Adds optional analytic coverage and out-of-ramp fragment discard for WebGL.
modules/layers/src/line-layer/line-layer-vertex.glsl.ts Expands the antialiased line envelope by half a device pixel for WebGL.
modules/layers/src/line-layer/line-layer.wgsl.ts Implements equivalent vertex expansion and fragment coverage behavior for WebGPU.
test/render/test-cases/line-layer.spec.ts Adds isolated no-MSAA and WebGPU rendering checks for analytic line coverage.
test/modules/layers/line-antialiasing.spec.ts Verifies shader variants, default fast-path preprocessing, and model recreation.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[LineLayer antialiasing prop] --> B{Enabled?}
  B -->|No| C[Existing shader path]
  B -->|Yes| D[Compile ANTIALIASING variant]
  D --> E[Expand rasterized width]
  E --> F[Calculate edge coverage with fwidth]
  F --> G[Discard fragments outside ramp]
  G --> H[Apply alpha coverage]
Loading

Reviews (17): Last reviewed commit: "refactor(line-layer): preserve named WGS..." | Re-trigger Greptile

Comment thread test/render/line-antialiasing.spec.ts Resolved
@chrisgervang
chrisgervang force-pushed the chrisgervang/line-layer-antialiasing branch from 9ba2158 to fd97a08 Compare August 18, 2026 18:09
@chrisgervang chrisgervang added this to the v9.4 milestone Aug 19, 2026
@chrisgervang
chrisgervang force-pushed the chrisgervang/line-layer-antialiasing branch from fd97a08 to bea30c3 Compare August 19, 2026 00:15
@chrisgervang
chrisgervang force-pushed the chrisgervang/line-layer-antialiasing branch from e72a419 to 947b8f7 Compare August 20, 2026 03:38

const webgpuAntialiasingTestCase: TestCase = {
...antialiasingTestCase,
skip: false

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.

Why the override? Why not just remove webgpu from skip?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good point — simplified in 2314c0a. The case now uses only skip: ["msaa"], so the ordinary shared WebGPU suite runs it and selects the WebGPU golden override, while shared MSAA WebGL skips it and the isolated no-MSAA WebGL suite still runs it. This removes the cloned test case and the extra WebGPU suite. I applied the same registration pattern to PathLayer, ArcLayer, and PointCloudLayer as well. Focused AA results remain 8/8 on WebGPU and 9/9 on WebGL.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah.. that last turn over complicated the ask. Thanks for pointing it out

@chrisgervang
chrisgervang force-pushed the chrisgervang/line-layer-antialiasing branch from 947b8f7 to 2314c0a Compare August 20, 2026 05:36
@chrisgervang
chrisgervang force-pushed the chrisgervang/line-layer-antialiasing branch from 2314c0a to ba82176 Compare August 20, 2026 05:47
@chrisgervang
chrisgervang force-pushed the chrisgervang/line-layer-antialiasing branch 2 times, most recently from 5eae6ef to a573f3f Compare August 20, 2026 18:39
@chrisgervang
chrisgervang force-pushed the chrisgervang/line-layer-antialiasing branch 2 times, most recently from cc34673 to b8bce35 Compare August 20, 2026 23:01
@chrisgervang
chrisgervang force-pushed the chrisgervang/line-layer-antialiasing branch from b8bce35 to a11d17d Compare August 20, 2026 23:25
@chrisgervang
chrisgervang force-pushed the chrisgervang/line-layer-antialiasing branch from a11d17d to cc7c245 Compare August 20, 2026 23:33
@chrisgervang
chrisgervang merged commit 9846e04 into master Aug 21, 2026
12 checks passed
@chrisgervang
chrisgervang deleted the chrisgervang/line-layer-antialiasing branch August 21, 2026 02:46
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.

4 participants