Visitar URL original
feat(extensions): add dashUnits by chrisgervang · Pull Request #10583 · visgl/deck.gl · GitHub
Skip to content

feat(extensions): add dashUnits - #10583

Merged
chrisgervang merged 169 commits into
masterfrom
claude/deck-gl-path-dashing-2jnq8i-5
Sep 2, 2026
Merged

chrisgervang merged 169 commits into
masterfrom
claude/deck-gl-path-dashing-2jnq8i-5

Conversation

@chrisgervang

@chrisgervang chrisgervang commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

Stack position: Part 5 of 6; base #10582.

Goal

Let applications choose the semantic measurement for a dash pattern instead of always tying it to stroke width.

Changes

  • Add dashUnits: 'widths' | 'pixels' | 'meters' | 'common'; widths preserves existing behavior and remains the default.
  • Define pixels as nominal zoom-stable projected pixels: exact for flat/orthographic paths and approximate under pitch, perspective, or elevation.
  • Convert each unit through the shared vertex coordinate model so flat, billboarded, path-continuous, and offset strokes agree.
  • Export DashUnits and cover live uniform mapping plus forwarding through PolygonLayer and GeoJsonLayer.
  • Keep ScatterplotLayer outlines and TextLayer backgrounds width-relative.
  • Add dash-unit controls and semantic comparisons to the dash-styles test app.
  • Extend the benchmark harness introduced in test(extensions): add PathStyleExtension dash render-test matrix #10579 with pixel, justification, offset-only, and all-controls variants.
  • Preserve feat(extensions): add dashMode and whole-path justification #10582's consolidated RFC byte-for-byte. Historical commits contain RFC edits, but this PR has no effective RFC delta.

Performance snapshot

Measured at production benchmark head bb4bdd7818 on Apple M1 Max, headless Chromium/ANGLE Metal, WebGL2, 3840×2160, with 20 timestamp-query samples. Subsequent parent-only merges supply the CPU benchmark viewport fixture, correct rounded-cap AA composition, scope the remapped rounded-corner envelope to PATH_STYLE_OFFSET, and preserve both phase and visible cap/joint bounds for camera-clipped billboards. These GPU variants use flat Orthographic paths with square caps and antialiasing: false, so the AA and billboard-clipping branches do not execute. The inherited bounds fix adds one dash-only vec2 varying, plus one vec2 multiply in dash+offset variants, so the table is the closest measured reference rather than a post-fix A/B.

Enabled options 100K sparse 1 px strokes Added vs plain 256 overlapping 64 px strokes Added vs plain
Plain PathLayer 2.388 ms — 0.458 ms —
Segment, widths 2.812 ms +0.424 ms 0.665 ms +0.207 ms
Path, widths 2.792 ms +0.403 ms 0.680 ms +0.222 ms
Path, pixels 2.790 ms +0.401 ms 0.683 ms +0.225 ms
Path, pixels, justified 2.789 ms +0.401 ms 0.682 ms +0.223 ms
Offset only 2.446 ms +0.058 ms 0.482 ms +0.023 ms
Path, pixels, justified, offset 2.827 ms +0.439 ms 0.688 ms +0.230 ms

In the heavy workload, all controls add 0.230 ms to the PathLayer pass: 1.38% of a 60 Hz frame or 2.76% of a 120 Hz frame. Path mode adds 0.015 ms beyond segment mode; pixels add 0.003 ms and justification changes the measured median by -0.001 ms, both immaterial here; adding offset capability to that combination adds 0.006 ms.

For 100,000 segments, seven calibrated CPU runs measured approximately 3.8 ms for production normalized rendered-path metrics, 1.5 ms for the public nested-position compatibility helper, and 3.1 ms for its flat-position input. These are hardware- and workload-specific comparison results, not expected application FPS.

The unit render benchmark also confirms semantics: width-relative periods scale 17.6/34.7/67.9 px across zooms 12/13/14, while pixel units remain 43.6/43.6/43.6 px with flat/billboard parity.

Validation

  • Focused PathStyle and analytic-AA tests passed 29/29.
  • Dash-unit uniform mapping and PolygonLayer/GeoJsonLayer forwarding tests pass.
  • Focused WebGL dash render suite: 43 passed, one intentional backend-selection skip.
  • The inherited no-MSAA clipped-composition fixture passes and its golden remains byte-identical to feat(extensions): prefilter dash coverage #10581.
  • CPU and GPU benchmark pages build; the CPU production row now executes with its viewport fixture.
  • Required GitHub checks and automated reviews are tracked on the current head.

Note

Medium Risk
Touches core path dash GLSL and coordinate conversion (billboard, offset, projection), so visual regressions are possible despite broad golden tests; default widths limits breakage for existing apps.

Overview
Adds dashUnits ('widths' | 'pixels' | 'meters' | 'common') so getDashArray is no longer tied only to half stroke width. 'widths' stays the default and preserves today’s scaling with line width.

Path-layer dash vertex math now converts each mode into screen pixels (including flat vs billboard via strokeHalfWidthPixels / dashWidthPixels) and passes a dashUnits uniform to the shader. Absolute units (pixels, meters, common) are not rescaled when path offset widens geometry; widths still follows the original stroke.

Exports DashUnits. Scatterplot/text-background dashes remain width-relative. The dash-styles demo, GPU/CPU benches, unit tests, and golden render cases cover zoom-stable pixels, width independence, and offset + pixel dashes.

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

@coveralls

coveralls commented Aug 21, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 82.39% (+0.01%) from 82.377% — claude/deck-gl-path-dashing-2jnq8i-5 into master

@chrisgervang
chrisgervang marked this pull request as ready for review August 21, 2026 23:15
@greptile-apps

greptile-apps Bot commented Aug 21, 2026 •

Copy link
Copy Markdown

Greptile Summary

The PR adds configurable measurement units for path dash patterns while retaining width-relative behavior as the default.

  • Exports the new DashUnits public type and maps each unit to shader uniforms.
  • Converts dash patterns through the shared vertex-coordinate model across path rendering modes.
  • Adds unit, composite-layer forwarding, benchmark, test-app, and visual-regression coverage.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
modules/extensions/src/path-style/path-style-extension.ts Adds the documented dashUnits prop, default, public type, and runtime uniform mapping.
modules/extensions/src/path-style/shaders.glsl.ts Converts dash values from the selected semantic units into the fragment shader’s path-position units.
test/modules/extensions/path.spec.ts Covers unit mapping and propagation through PolygonLayer and GeoJsonLayer.
test/render/test-cases/path-dash.spec.ts Adds visual cases for zoom, stroke-width, billboard, rounded-cap, and offset behavior; the previously flagged callback naming issue is resolved.

Reviews (43): Last reviewed commit: "Merge latest master" | Re-trigger 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.

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 9365041. Configure here.

@chrisgervang
chrisgervang force-pushed the claude/deck-gl-path-dashing-2jnq8i-5 branch from 9365041 to c0f6b90 Compare August 22, 2026 00:59
@chrisgervang
chrisgervang force-pushed the claude/deck-gl-path-dashing-2jnq8i-5 branch from c0f6b90 to bc1ed23 Compare August 22, 2026 01:05
@chrisgervang
chrisgervang force-pushed the claude/deck-gl-path-dashing-2jnq8i-5 branch from bc1ed23 to 5387360 Compare August 22, 2026 01:09
@chrisgervang
chrisgervang force-pushed the claude/deck-gl-path-dashing-2jnq8i-5 branch from 5387360 to 2c629d0 Compare August 22, 2026 01:54
@chrisgervang
chrisgervang force-pushed the claude/deck-gl-path-dashing-2jnq8i-5 branch from 2c629d0 to 1da7f31 Compare August 22, 2026 22:00
@chrisgervang
chrisgervang force-pushed the claude/deck-gl-path-dashing-2jnq8i-5 branch from 1da7f31 to e05d917 Compare August 22, 2026 22:15
claude and others added 4 commits August 22, 2026 15:28
…ension

Adds a render-test matrix and an interactive app for PathStyleExtension dashing,
covering segment density, dash arrays, corners, zoom levels, device pixel ratio,
3D elevation and billboard/flat parity.

The golden images record current behavior, defects included, so that subsequent
work shows up as a direct image diff. Measured from these goldens with
getDashArray [4, 5]:

- Six strips drawing the identical straight line diverge purely by vertex count.
  1, 2 and 4 segments dash correctly at a 43.4px period, 12 segments drifts to
  55.4px, and 40 and 120 segments render fully solid. Dash phase restarts at
  every vertex, so once a segment is shorter than one dash period nothing is
  discarded.
- dashJustified collapses the same way; justification is also per segment.
- highPrecisionDash renders all six strips identically and correctly, confirming
  the continuous-arclength mechanism works and is merely opt-in.
- billboard: true combined with highPrecisionDash is broken: the same geometry
  renders solid when dense and at a 52.0px period, 1.5x too long, when sparse,
  against 34.8px for the flat copy.
- Dash length grows along paths that climb in Z, because the CPU accumulates 3D
  distance while the shader coordinate measures 2D.

No source changes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014GipN1niYRgRuLVat2wujw
@chrisgervang
chrisgervang force-pushed the claude/deck-gl-path-dashing-2jnq8i-5 branch 3 times, most recently from 3074225 to f826f36 Compare August 23, 2026 19:44
@chrisgervang
chrisgervang force-pushed the claude/deck-gl-path-dashing-2jnq8i-5 branch from f826f36 to a4056ba Compare August 24, 2026 00:05
chrisgervang and others added 25 commits August 31, 2026 09:01
# Conflicts:
#	modules/extensions/src/path-style/path-style-extension.ts
#	modules/extensions/src/path-style/shaders.glsl.ts
# Conflicts:
#	modules/extensions/src/path-style/shaders.glsl.ts
#	test/modules/extensions/path.spec.ts
# Conflicts:
#	modules/extensions/src/path-style/shaders.glsl.ts
#	test/modules/extensions/path.spec.ts
# Conflicts:
#	test/render/golden-images/path-dash-clipped-composition.png
# Conflicts:
#	test/render/test-cases/path-dash.spec.ts
# Conflicts:
#	test/render/test-cases/path-dash.spec.ts
# Conflicts:
#	test/render/test-cases/path-dash.spec.ts
Base automatically changed from claude/deck-gl-path-dashing-2jnq8i-4 to master September 2, 2026 04:04
@chrisgervang
chrisgervang merged commit 286b5e2 into master Sep 2, 2026
8 checks passed
@chrisgervang
chrisgervang deleted the claude/deck-gl-path-dashing-2jnq8i-5 branch September 2, 2026 05:48
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