Skip to content

feat(geo-layers): pace tile creation without losing fallback coverage - #10784

Closed
charlieforward9 wants to merge 12 commits into
masterfrom
codex/tile3d-frame-pacing
Closed

charlieforward9 wants to merge 12 commits into
masterfrom
codex/tile3d-frame-pacing

Conversation

@charlieforward9

@charlieforward9 charlieforward9 commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Follow up of visgl/loaders.gl#4090 (skip-LOD refinement, already on master via @loaders.gl/tiles 5.0.0-alpha.11).

Tile3DLayer creates GPU resources for every arriving scenegraph tile within the frame, so bursts of tiles stall interaction. When a coarse replacement parent is drawn above its children, depth testing also hides detail that has already loaded.

Change List

  • Tile3DLayer: opt-in _maxTileProcessingTime per-frame budget for scenegraph creation
    • Drops unfinished work for tiles no longer selected
  • Opt-in _refinementStencil for opaque WebGL scenegraphs: drawn descendants mask only their own replacement ancestors
    • Additive parents keep drawing before their children
    • Keeps the original order and depth testing when layer or model parameters enable blending, materials use BLEND or KHR_materials_transmission, or the color target has no stencil (always on WebGPU)
    • Switches order one frame after the color target gains or loses stencil
  • DeckPicker: picking framebuffers use depth24plus-stencil8, so picking matches what is drawn
  • ScenegraphLayer: draw options for refinement coverage
  • Unit and GPU readback tests
  • Documentation
cleared-recording-github.mp4

Left: the previous candidate. Right: this PR with the loaders.gl changes (capture details). This is not a cold-load or smoothness benchmark.

Questions

  • DeckPicker now allocates depth24plus-stencil8 for every Deck, not only when a layer sets _refinementStencil: twice the picking depth memory of depth16unorm, with higher precision. Is that acceptable, or should stencil be allocated only on request?

TODO

  • Close the remaining fly-in and zoom-out coverage gaps
  • Measure cold-load and interaction performance under controlled conditions

@charlieforward9
charlieforward9 force-pushed the codex/tile3d-frame-pacing branch from c28bc7c to 27f1336 Compare October 5, 2026 18:22
@coveralls

coveralls commented Oct 5, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 84.3% (+0.1%) from 84.157% — codex/tile3d-frame-pacing into master

@charlieforward9
charlieforward9 marked this pull request as ready for review October 5, 2026 19:47
@greptile-apps

greptile-apps Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect Tile3D rendering and picking across Deck applications.

Fix the missing follow-up redraw before merging so stencil coverage reliably resumes after post-processing is removed.

Findings

  1. P1 Stencil coverage stays disabled ▶

Summary

This PR spreads scenegraph creation across frames and adds optional stencil coverage for replacement tiles.

  • Tile3D tiles spread scenegraph creation across multiple frames.
  • Opaque replacement tiles keep finished detail visible above their parents.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Post-processing removed] --> B[Layers return to stencil canvas]
  B --> C[First draw keeps coverage disabled]
  C --> D{Another redraw requested?}
  D -->|No| E[Coarse parent keeps hiding detail]
  D -->|Yes| F[Later draws restore coverage]
Loading

Reviews (5) · Last reviewed commit: "fix(geo-layers): treat transmissive Tile..." · Reviewed by Greptile

@charlieforward9
charlieforward9 force-pushed the codex/tile3d-frame-pacing branch from 27f1336 to efdd8a8 Compare October 5, 2026 21:13

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

Comment thread modules/core/src/lib/deck-picker.ts Resolved
Base automatically changed from codex/tile3d-gpu-debug-fix to master October 26, 2026 02:14
charlieforward9 and others added 4 commits October 25, 2026 23:48
…e-pacing

# Conflicts:
#	docs/whats-new.md
#	test/modules/core/lib/deck.spec.ts
With `_refinementStencil` enabled, every selected tile was drawn in postorder,
so additive parents moved after their children even though additive
refinement receives no stencil coverage. Where an additive parent and child
were coplanar, the reordered parent then won the depth tie and covered the
finer child.

Only replacement parents with selected children now draw after the
descendants that mask them. Additive parents keep their coarse-to-fine order,
and selections without any replacement keep the original draw order.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Coverage treated a tile as opaque when its glTF material JSON lacked BLEND
and its layer opacity was 1. Models supplied by a custom `getScene`, glTF
transmission materials, and layer `parameters` that enable blending could
still write coverage, so their translucent pixels hid the parent behind them.

Scenegraph sublayers now record whether their created models enable blending
before WebGL draws replace model parameters, and also check layer blend
parameters. Such selections keep ordinary depth testing in their original
order. When models created after the draw plan turn out to be blended, the
layer drops the stale plan on its first draw and asks the Tile3DLayer to
rebuild it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Picking framebuffers always attach stencil, so `_refinementStencil` masked
parents while picking even when the color pass fell back to depth testing
because the canvas or a post-processing target had no stencil. Clicks could
then hit a replacement child that the screen still showed behind its parent.

Coverage now records whether the latest color pass could apply it, and the
picking pass applies coverage only in that case. The coverage test now also
picks with a stencil-less color target.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

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

charlieforward9 and others added 2 commits October 26, 2026 00:27
…ot mask

With `_refinementStencil` enabled, the coverage plan drew replacement parents
after their children before any draw knew whether masking could run. On
WebGPU or WebGL targets without stencil, draws then skipped masking but kept
the reversed order, so coplanar parents with `depthCompare: 'less-equal'`
covered children that win when the option is disabled.

Sublayers now keep their original order unless color targets can mask. The
plan starts from the device and canvas stencil, and color passes report their
target: a reordered list replans in the original order as soon as a target
cannot mask, and a deferred plan reorders once targets can. A masking pass
directly after an unmasked one does not count, so frames that mix targets do
not alternate. Shadow map passes are ignored, and picking masks only when the
list was reordered for color.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`isOpaque` inspected glTF materials only for the `BLEND` alpha mode, while
luma.gl also blends `KHR_materials_transmission` materials. Created models
record that blending, but the coverage plan runs before models exist and
before deferred creation completes, and custom `getScene` models may not
carry material parameters. Transmissive children could therefore be planned
as opaque and mask the parent behind them.

Materials with a positive transmission factor or a transmission texture now
count as blended, matching luma.gl and the `_refinementStencil` docs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment on lines +329 to +333
this.colorMasking = canMask && !this.sawUnmaskedTarget;
this.sawUnmaskedTarget = !canMask;
// Replan when the draw order no longer matches: a reordered list that cannot be masked
// lets coplanar parents cover their children, and an unordered list cannot mask.
if (this.planned && this.colorMasking !== this.entries.size > 0) this.replan(layer);

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 Stencil coverage stays disabled

Removing a post-processing effect can leave raised parents hiding finished children. The old target leaves sawUnmaskedTarget true, so the first draw back to a stencil canvas keeps colorMasking false and clears sawUnmaskedTarget. Because the draw order already matches that false value, this check requests no further update. An idle Deck then stops drawing before coverage can resume.

Request another redraw when this check needs a second masked pass. The target-switch test forces three frames, which hides this case.

@charlieforward9

Copy link
Copy Markdown
Member Author

Closing in favor of two smaller PRs: #11150 fixes ScenegraphLayer's first-draw signal so loaders.gl keeps fallback parents until their replacement has drawn, and #11151 adds opt-in _maxNewTilesPerFrame pacing in Tile3DLayer without a sublayer subclass or scheduler. The stencil refinement coverage and the DeckPicker depth format change are deferred until we measure whether parents still hide drawn children with those in.

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.

2 participants