Skip to content

feat(layers): accept typed BitmapLayer meshes - #11030

Open
ibgreen wants to merge 13 commits into
masterfrom
codex/bitmap-vectors
Open

ibgreen wants to merge 13 commits into
masterfrom
codex/bitmap-vectors

Conversation

@ibgreen

@ibgreen ibgreen commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Background

BitmapLayer currently generates its mesh from bounds. Accept Arrow columns and GPU vectors for explicit vertex and index inputs, retaining caller ownership.

Change List

  • Add BitmapLayer positions, texCoords, and indices props
  • Bind explicit meshes with upstream GPUVectorModel
  • Preserve bounds fallback, UV picking, and extension metadata
  • Keep Apache Arrow optional for GPU-only meshes
  • Unit tests: cover lifecycle, offsets, and borrowed buffer survival
  • Render tests: WebGL/WebGPU match existing bitmap goldens
  • Documentation: describe formats, ownership, and single-chunk limitation

Verified build, lint, website, five Node tests, nine browser tests, eight render tests.


Note

Medium Risk
Adds new geometry pipeline paths and resource lifecycle management in BitmapLayer, but preserves existing bounds-based quad generation as fallback.

Overview
Adds support for explicit triangle meshes in BitmapLayer via new positions, texCoords, and indices props, enabling custom geometry instead of automatic quad generation from bounds.

Mesh inputs accept single-chunk Apache Arrow columns or pre-allocated GPUVector instances. A new BitmapLayerMesh class coordinates asynchronous Arrow conversion, binds geometry and index vectors directly to GPUVectorModel, computes bounds, and manages resource cleanup while preserving caller ownership of external GPU buffers. BitmapLayer also supports dynamically toggling between explicit mesh inputs and the traditional quad mesh.

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-04T20:04:38.039703Z
We couldn’t complete this review. Comment @codex review to try again.
9c5b8fd 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 4, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change affects mesh drawing and extension attributes in BitmapLayer workflows.

Add the required release note before merging; no new behavior problem was found.

Findings

  1. P2 Mesh release note is missing ▶

Summary

BitmapLayer accepts explicit Arrow or GPU meshes while keeping caller-owned buffers alive. The latest change fixes Arrow imports in the proposals examples.

  • BitmapLayer can draw caller-supplied triangle meshes.

Reviews (11) · Last reviewed commit: "fix(examples): resolve the Arrow subpath..." · Reviewed by Greptile

@coveralls

coveralls commented Nov 4, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 84.498% (+0.1%) from 84.391% — codex/bitmap-vectors into master

@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 a43fe3f; recommend approval. No P1s. Arrow stays optional because the layers entry reaches apache-arrow only through dynamic imports. The bitmap node tests pass at this head.

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


[modules/layers/src/bitmap-layer](https://github.com/visgl/deck.gl/tree/master/modules/layers/src/bitmap-layer)

### Typed meshes

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 new props sit as prose under ## Source. The Properties section has no positions, texCoords or indices entries with types and defaults. The bounds entry doesn't say that positions replace it for rendering, or that it only sets view fitting for GPU-only meshes.

Could these become #### prop entries under Properties, with a line in bounds about the override?

}

/** Owns only converted Arrow allocations; supplied GPU vectors remain caller-owned. */
export class BitmapLayerMesh {

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: Master now has _LayerColumns in core (#11029, #11046). It has the same version guard, bounds tracking and fp64 residuals as BitmapLayerMesh. This branch predates it and merges cleanly.

Could BitmapLayerMesh build on _LayerColumns after a rebase, or do indices need their own path?

import type {ColumnSource} from '@deck.gl/core/arrow';

/** A single contiguous Arrow column or caller-owned GPU vector. */
export type BitmapMeshSource = ColumnSource | GPUVector;

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: BitmapMeshSource isn't exported from the @deck.gl/layers index. Neither is BitmapImageMapping from #11031. Could both join the BitmapLayerProps type exports?

Comment on lines +285 to +298
Supply positions and texture coordinates together, with matching vertex counts.
Without indices, every three consecutive vertices form a triangle. Inputs must
have a single contiguous chunk; indexed multi-chunk topology is not supported.
GPU buffers retain their offsets and strides and remain caller-owned. Keep them
alive until the layer no longer uses them. Arrow conversion buffers are released
by the layer. In-place mutations do not trigger updates; replace the input object.

Supplied UVs take precedence over `_imageCoordinateSystem`. Bitmap picking still
returns image UV and pixel coordinates. CPU positions provide view-fitting bounds;
for GPU-only inputs, set `bounds` to the mesh footprint. GPU-only positions cannot
be used when a custom projection requires CPU preprojection. No implicit GPU
readback is performed. Async mesh iterators and topology transitions are not supported.

Removing all three mesh props restores the bounds-generated mesh.

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: This block mixes the few rules users act on with internals (strides, readback, chunk topology). The Arrow update and ownership rules repeat Using with Arrow. Could it read as below, with a short example near the top like the one #11031 adds?

Suggested change
Supply positions and texture coordinates together, with matching vertex counts.
Without indices, every three consecutive vertices form a triangle. Inputs must
have a single contiguous chunk; indexed multi-chunk topology is not supported.
GPU buffers retain their offsets and strides and remain caller-owned. Keep them
alive until the layer no longer uses them. Arrow conversion buffers are released
by the layer. In-place mutations do not trigger updates; replace the input object.
Supplied UVs take precedence over `_imageCoordinateSystem`. Bitmap picking still
returns image UV and pixel coordinates. CPU positions provide view-fitting bounds;
for GPU-only inputs, set `bounds` to the mesh footprint. GPU-only positions cannot
be used when a custom projection requires CPU preprojection. No implicit GPU
readback is performed. Async mesh iterators and topology transitions are not supported.
Removing all three mesh props restores the bounds-generated mesh.
Supply `positions` and `texCoords` together, with the same vertex count. Without `indices`, every
three vertices form a triangle. Removing all three props restores the quad from [`bounds`](#bounds).
Arrow inputs update as described in [Using with Arrow](../../developer-guide/using-with-arrow.md#loading-and-updates):
pass a new vector when the mesh changes. GPUVector inputs stay owned by the app; keep them alive
while the layer uses them.
`texCoords` take precedence over [`_imageCoordinateSystem`](#_imagecoordinatesystem), and
[pixel picking](#pixel-picking) still reports image UV and pixel coordinates. With GPU-only
`positions`, set `bounds` to the mesh footprint so views can fit it.
#### Limitations
- Each input must be a single Arrow chunk or GPU buffer.
- GPU-only `positions` don't work when deck.gl converts positions on the CPU (see [Coordinate Systems](../../developer-guide/coordinate-systems.md#positions)).
- Mesh inputs can't be async iterables, and mesh changes don't transition.

Comment on lines +16 to +21
/** XY/XYZ positions. GPU-only meshes use bounds for view-fitting metadata. */
positions?: BitmapMeshSource | null;
/** Two texture coordinates per vertex, with (0, 0) at the image's top left. */
texCoords?: BitmapMeshSource | null;
/** Optional tightly packed uint16/uint32 triangle indices. */
indices?: BitmapMeshSource | null;

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: These TSDoc lines are what IDE users see for the new props. Could they say what each replaces and accepts?

Suggested change
/** XY/XYZ positions. GPU-only meshes use bounds for view-fitting metadata. */
positions?: BitmapMeshSource | null;
/** Two texture coordinates per vertex, with (0, 0) at the image's top left. */
texCoords?: BitmapMeshSource | null;
/** Optional tightly packed uint16/uint32 triangle indices. */
indices?: BitmapMeshSource | null;
/**
* Mesh vertex positions, replacing the quad from `bounds`: Arrow XY/XYZ lists or a
* `float32x2`/`float32x3` GPUVector. With GPU-only positions, set `bounds` to the footprint.
*/
positions?: BitmapMeshSource | null;
/** Texture coordinates per vertex, with (0, 0) at the image's top left. Supply with `positions`. */
texCoords?: BitmapMeshSource | null;
/** Optional `uint16` or `uint32` triangle indices. Without them, every three vertices form a triangle. */
indices?: BitmapMeshSource | null;

Comment on lines +166 to +168
Mesh vertex positions, replacing the quad from `bounds`. Accepts numeric Arrow XY/XYZ
fixed-size lists or a `float32x2`/`float32x3` GPUVector. With GPU-only positions,
set `bounds` to the footprint for view fitting.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Mesh release note is missing

The new BitmapLayer mesh support is documented here but missing from docs/whats-new.md. Repository instructions require newly added support to be documented there. Before merging, add a short release note covering positions, texCoords, and indices.

Rule Used: In the deck.gl repository, use Remarks sections only for user-facing, actionable limitations; document newly added support in docs/whats-new.md instead. (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

ibgreen commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator Author

Coordinating projection support: #11112 adds Deck({projectionEngine}) and exposes the selected factory through layer.context.projectionEngine. This is independent of the typed mesh API here. The generated-UV integration belongs in #11031 on top of this PR; #11112 does not duplicate or change the typed bitmap mesh implementation.

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

Thank you. The ownership rules and the async version guard are careful, and the tests cover much of the lifecycle. The bitmap node and headless tests and the linter pass for me on this head. I found two problems.

  1. Float64 texCoords replace the position residuals. In bitmap-layer-mesh.ts, the conversion loop runs for positions and for texCoords. Line 100 sets positions64Low from result.residualVector for both. A Float64 UV column has a residual vector. In a node probe with Float64 positions near [-122.42, 37.77] and Float64 UVs, positions64Low has name = texCoords and format = float32x2. This occurs with fp64: false and with fp64: true. So the shader adds UV rounding residuals to the positions. With fp64: true, the real position residuals are lost. vectorFromArray makes Float64 by default for numbers, so this input is common. Please limit the assignment to positions. Please also add a node test with Float64 UVs that checks positions64Low.
  2. A change of extensions in mesh mode drops the extension attributes. On extensionsChanged, updateMeshState makes a new GPUVectorModel and binds only the mesh vectors. It does not invalidate the attributes, so nothing binds them to the new model. In a headless probe, I changed [ClipExtension, DataFilterExtension] to [DataFilterExtension]. Before the update, the model has a filterValues binding. After the update, the new model has none. The bounds path calls invalidateAll() in this case. The earlier Greptile thread "Mesh filters lose their values" covers the first render. This problem is in the update path. Please call invalidateAll() here too, and add an extensions change case to the lifecycle test.

Small item: mesh mode converts the Arrow inputs again on a modelMatrix or coordinateOrigin change, also when state.preproject is off. In that case the uploaded data does not change. The bounds path checks state.preproject first. The same check here would skip that work.

GitHub now reports a merge conflict with master.

});
resources.push(result);
attributes[name] = result.vector;
if (result.residualVector) attributes.positions64Low = result.residualVector;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This line also runs for texCoords. A Float64 UV column has a residual vector, so it replaces the position residuals. Could the condition be name === 'positions' && result.residualVector?

inferDrawCount: 'no',
vertexCount: 0
});
this.state.typedMesh!.bind(this.state.model);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The new model gets the mesh vectors, but the extension attributes are not invalidated. So nothing binds them to this model. Could this call this.getAttributeManager()!.invalidateAll(), as the bounds path does?

if (
enteringMesh ||
changeFlags.projectionChanged ||
!deepEqual(props.modelMatrix, oldProps.modelMatrix, 1) ||

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When state.preproject is off, a modelMatrix or coordinateOrigin change does not change the uploaded data. Could these two checks depend on state.preproject, as in the bounds path?

@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 84913e4; comments only at this point.

No P1s.

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


Generated by Claude Code

#### `bounds` (number[4] | Position[4]) {#bounds}

When `positions` is supplied, it defines the rendered mesh. For GPU-only positions, `bounds`
provides the footprint for view fitting.

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: "it" can read as bounds. Could it name positions?

Suggested change
provides the footprint for view fitting.
When `positions` is supplied, it replaces the quad from `bounds`. With GPU-only positions,
`bounds` still sets the footprint for view fitting.

Generated by Claude Code

Optional `uint16` or `uint32` triangle indices. Without indices, every three vertices form
a triangle. Removing all mesh props restores the quad from `bounds`.

Remarks:

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: These Remarks apply to all three mesh props but sit under indices. Could the lead-in say so?

Suggested change
Remarks:
Remarks for `positions`, `texCoords` and `indices`:

Generated by Claude Code

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants