Skip to content

refactor(extensions): order PathStyle shader coordinates - #10644

Merged
chrisgervang merged 5 commits into
masterfrom
codex/path-style-shader-cleanup
Sep 29, 2026
Merged

chrisgervang merged 5 commits into
masterfrom
codex/path-style-shader-cleanup

Conversation

@chrisgervang

@chrisgervang chrisgervang commented Sep 3, 2026 •

Copy link
Copy Markdown
Collaborator

Goal

Make the PathStyleExtension shader easier to maintain without changing how paths render.

Offset paths need a widened mesh so the shifted stroke still fits. Before this change, dash values were calculated from that widened mesh and then repaired afterward: several coordinates were rescaled, the path-length phase was rescaled, and the justified period was calculated a second time. Adding a new dash-space value meant remembering to repair it in the later offset block.

This was identified as follow-up work in the earlier shader-order review.

Stack (merge bottom-up): #10644 → #10646 → #10647 → #10648 → #10649

Changes

  • Introduce one explicitly ordered PathStyle pipeline for PathLayer:
    1. widen the mesh for the offset stroke, as before;
    2. map PathLayer coordinates back to the pre-offset stroke;
    3. recover the pre-offset half-width;
    4. convert dash units and calculate dash phase once.
  • Keep dash- and offset-specific declarations/setup in their capability shaders, while removing their competing vs:#main-end and fs:#main-end injections.
  • Centralize deferred fragment finalization so dash rejection still happens after PathLayer evaluates derivatives, followed by the non-AA offset boundary.
  • Add preprocessing assertions for offset-only, dash-only, combined path-dash/offset, antialiased, and non-antialiased variants.

There are no public API, uniform, attribute, core PathLayer, WGSL, or golden-image changes.

Render equivalence

A strict same-machine A/B rendered all 43 cases in path-dash.spec.ts from the branch point, v9.4.0-beta.3 (7f1e9e6301), and this change. Every captured image was byte-for-byte identical. The matrix includes segment/path modes, all dash units, justification, positive/negative/large offsets, flat and billboard paths, 3D/elevated paths, rounded caps, analytic AA, subpixel patterns, and camera clipping.

No checked-in golden image changed.

Performance and resource impact

This refactor does not add vertex attributes, interstage varyings, uniforms, buffers, bindings, draw calls, or per-instance storage. It only changes how the existing PathStyle shader stages are assembled. Segment dash plus offset gains one vertex division to recover the original stroke width; path mode removes the old second period/phase repair. The hardware measurement below covers both sides of that tradeoff.

Apple M1 Max, Chrome/ANGLE Metal, WebGL2 timestamp queries, 3840x2160. The table is the median of four alternating parent/head rounds with 30 samples per variant and workload in each round. It compares the direct feature snapshots 7f1e9e6301 and 805b7efcb5; later merge-only synchronization does not change the feature trees.

100K-path workload baseline (7f1e9e6301) cleanup delta
segment dash 2.8258 ms 2.8254 ms -0.05%
path dash, widths 2.9211 ms 2.9203 ms -0.04%
offset only 2.5665 ms 2.5667 ms +0.03%
all controls 2.9275 ms 2.8990 ms -0.97%

The fragment-heavy workload was also noise-scale. These results show no measurable regression. The repeatable all-controls trend is consistent with removing duplicate path-period work, but this sample is intentionally not presented as a general speedup claim.

Validation

  • yarn build
  • yarn lint
  • yarn vitest run --project headless test/modules/extensions/path.spec.ts test/modules/layers/path-antialiasing.spec.ts test/modules/extensions/clip.spec.ts — 32/32 passed
  • RENDER_TEST_DEVICE=webgl yarn vitest run --project render test/render/test-cases/path-dash.spec.ts test/render/test-cases/path-layer.spec.ts test/render/test-cases/polygon-layer.spec.ts — 61 passed, four intentional backend-selection skips
  • pre-commit affected tests — 19/19 passed
  • git diff --exit-code 7f1e9e6301 -- test/render/golden-images

Stacked follow-ups

Further opportunities

These higher-risk ideas remain separate so the landed visual baselines continue to protect them:

  • encapsulate normalized PathTessellator traversal behind a typed reader and pure metric accumulator;
  • align the vertex and fragment justified-period helpers for extremely small periods.

Note

Low Risk
Internal GLSL assembly reorder for PathLayer dash/offset only; behavior is guarded by expanded shader-order tests and reported byte-identical render comparisons.

Overview
Refactors PathStyleExtension PathLayer shaders so offset remapping and dash math run in one fixed order instead of separate vs:#main-end / fs:#main-end blocks that had to “repair” dash coordinates after offset widening.

pathStylePipelineShaders is merged when dash or offset is on. The vertex stage remaps widened mesh coordinates back to the pre-offset stroke, recovers strokeHalfWidth, then computes dash arrays and phase once (dropping the old second justified-period pass). Dash and offset modules keep declarations and dash fragment logic; deferred fragment work (dash discard/coverage after PathLayer derivatives, then non-AA offset clip) lives in the shared pipeline.

Tests now assert injection order and that dash-only / offset-only / combined / AA variants compile without competing vertex-end hooks. No public API or intended visual change (stack follow-up to shader-order review).

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

@coveralls

coveralls commented Sep 3, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 82.466% (-0.006%) from 82.472% — codex/path-style-shader-cleanup into master

@chrisgervang
chrisgervang marked this pull request as ready for review September 3, 2026 04:55
@chrisgervang chrisgervang added this to the v9.4 milestone Sep 3, 2026
@greptile-apps

greptile-apps Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Reorders shader coordinate calculations in path rendering.

The PR appears safe to merge based on the reviewed changes.

Summary

This PR consolidates PathStyle’s PathLayer shader stages so offset coordinates are remapped before dash units and phase are calculated.

  • Keeps capability-specific declarations and setup in the dash and offset shaders.
  • Defers dash rejection and offset clipping until fragment finalization.
  • Adds preprocessing assertions for the shader variants.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[PathLayer coordinates] --> B[Widen mesh for offset]
  B --> C[Remap to pre-offset stroke]
  C --> D[Recover stroke half-width]
  D --> E[Convert dash units and phase]
  E --> F[Fragment coverage and deferred rejection]
Loading

Reviews (5) · Last reviewed commit: "Merge branch 'master' into codex/path-st..."

@chrisgervang
chrisgervang merged commit 0b6a25d into master Sep 29, 2026
8 checks passed
@chrisgervang
chrisgervang deleted the codex/path-style-shader-cleanup branch September 29, 2026 15:15
@chrisgervang chrisgervang modified the milestones: v9.4, v9.4 patch releases Oct 4, 2026
@chrisgervang chrisgervang mentioned this pull request Oct 7, 2026
53 of 66 tasks
chrisgervang added a commit that referenced this pull request Oct 22, 2026
@chrisgervang

Copy link
Copy Markdown
Collaborator Author

Released in deck.gl 9.4.1.

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