Skip to content

Commit f5d49d8

Browse files
feat(arrow) WebGL transform handles Vectors and writeback (#2618)
1 parent aea66b9 commit f5d49d8

18 files changed

Lines changed: 931 additions & 86 deletions

File tree

AGENTS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
## Before committing
2424
- Format code: `yarn lint fix`
2525
- Always `yarn lint fix` after making changes to ensure that Biome formatting is maintained.
26+
27+
## Merge preparation
28+
- When asked to "get ready for merge", create a copyable Markdown description of the changes versus `master`.
29+
- Start that Markdown description with `Goals` and `Changes` sections, then include verification, risks, follow-up notes, or other merge-relevant sections when useful.
2630

2731
## Code style
2832
- TypeScript strict mode

docs/api-guide/gpu/arrow-table-columns.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,8 @@ const model = new ArrowModel(device, {
537537

538538
`TableTransform` is the WebGL transform-feedback counterpart. It converts an
539539
Arrow table to a `GPUTable` when needed, merges the table attribute layouts into
540-
the underlying `BufferTransform`, and can run one preserved GPU batch at a time:
540+
the underlying `BufferTransform`, accepts already-created `GPUVector` inputs,
541+
and can run one preserved GPU batch at a time:
541542

542543
```ts
543544
const transform = new TableTransform(device, {
@@ -553,14 +554,37 @@ transform.runBatches({
553554
});
554555
```
555556

557+
For a compute-like update path, pass `inputVectors` plus
558+
`copyOutputToInputVectors`. `outputs` is inferred from the copy map when it is
559+
omitted:
560+
561+
```ts
562+
const transform = new TableTransform(device, {
563+
vs,
564+
shaderLayout,
565+
inputVectors: {
566+
particlePositions,
567+
particleVelocities
568+
},
569+
copyOutputToInputVectors: {
570+
nextParticlePositions: 'particlePositions',
571+
nextParticleVelocities: 'particleVelocities'
572+
}
573+
});
574+
```
575+
576+
Transform feedback writes a dense output stream, so automatic copy-back targets
577+
tightly packed, directly bindable GPUVectors. It can not scatter-copy into
578+
padded or interleaved rows.
579+
556580
Use `TableTransform` only for attribute-backed WebGL transform feedback. It is
557581
not a storage-buffer compute abstraction.
558582

559583
Relevant public types:
560584

561585
| Type | Meaning |
562586
| --- | --- |
563-
| `TableTransformProps` | Construction props, including `table`, `arrowTable`, `arrowPaths`, `arrowBufferProps`, and `tableCount`. |
587+
| `TableTransformProps` | Construction props, including `table`, `arrowTable`, `inputVectors`, `copyOutputToInputVectors`, `arrowPaths`, `arrowBufferProps`, and `tableCount`. |
564588
| `TableTransformBatchOptions` | `runBatches()` options, including fixed or per-batch `outputBuffers`. |
565589

566590
### `TableComputation`
@@ -572,7 +596,7 @@ storage bindings. Supply `GPUVector` objects by binding name:
572596
const computation = new TableComputation(device, {
573597
source: computeShader,
574598
shaderLayout: computeShaderLayout,
575-
vectorBindings: {
599+
inputVectors: {
576600
particlePositions,
577601
particleVelocities
578602
}
@@ -587,7 +611,7 @@ Relevant public types:
587611

588612
| Type | Meaning |
589613
| --- | --- |
590-
| `TableComputationProps` | Construction props, including ordinary `bindings` plus `vectorBindings`. |
614+
| `TableComputationProps` | Construction props, including ordinary `bindings` plus `inputVectors`. |
591615
| `TableComputationBatch` | Batch metadata passed to a dynamic workgroup-count callback. |
592616

593617
## Mesh Arrow Geometry

docs/api-guide/gpu/gpu-storage-buffers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ For table vectors, use `TableComputation` when storage bindings should come from
104104
const computation = new TableComputation(device, {
105105
source: computeShader,
106106
shaderLayout,
107-
vectorBindings: {
107+
inputVectors: {
108108
particlePositions,
109109
particleVelocities
110110
}

docs/api-reference/engine/picking-manager.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {Model, PickingManager, ShaderInputs, picking} from '@luma.gl/engine';
1212
const shaderInputs = new ShaderInputs({picking});
1313
const pickingManager = new PickingManager(device, {
1414
shaderInputs,
15-
mode: 'auto'
15+
mode: 'auto',
16+
getTooltip: ({objectIndex}) => (objectIndex === null ? null : `row ${objectIndex}`)
1617
});
1718

1819
const pickingPass = pickingManager.beginRenderPass();
@@ -33,6 +34,12 @@ export type PickInfo = {
3334
};
3435
```
3536

37+
### `PickingTooltip`
38+
39+
```ts
40+
export type PickingTooltip = string | null;
41+
```
42+
3643
### `PickingMode`
3744

3845
```ts
@@ -50,10 +57,14 @@ export type PickingMode = 'auto' | 'index' | 'color';
5057
export type PickingManagerProps = {
5158
shaderInputs?: ShaderInputs<{picking: typeof pickingUniforms.props}>;
5259
onObjectPicked?: (info: PickInfo) => void;
60+
getTooltip?: (info: PickInfo) => PickingTooltip;
5361
mode?: PickingMode;
5462
};
5563
```
5664

65+
- `getTooltip` returns plain tooltip text for the latest picked row/object. Returning `null` hides the tooltip.
66+
- The tooltip is positioned beside the latest mouse position within the active canvas container.
67+
5768
### `supportsIndexPicking(device: Device): boolean`
5869

5970
Returns `true` when the device can use the index-picking backend.
@@ -100,7 +111,7 @@ When the backend is:
100111

101112
### `updatePickInfo(mousePosition: [number, number]): Promise<PickInfo | null>`
102113

103-
Reads back one picked pixel, updates shader inputs, and calls `onObjectPicked` when the pick result changes.
114+
Reads back one picked pixel, updates shader inputs, calls `onObjectPicked` when the pick result changes, and refreshes the tooltip when `getTooltip` is provided.
104115

105116
### `getPickPosition(mousePosition: [number, number]): [number, number]`
106117

@@ -109,6 +120,7 @@ Converts CSS pixel mouse coordinates into device-pixel picking coordinates.
109120
## Remarks
110121

111122
- `PickingManager` only manages the framebuffer and readback flow. Your model shaders still need to use a compatible picking module.
123+
- `getTooltip` is intentionally a formatting callback. Table-aware row lookup belongs with the caller so engine picking does not depend on Arrow or another columnar-data container.
112124
- Use `picking` when you want the engine to select the appropriate shader path for GLSL/WebGL vs WGSL/WebGPU.
113125
- Use `colorPicking` when you explicitly want the color-encoded path.
114126
- Use `indexPicking` when you explicitly want the integer render-target path.

0 commit comments

Comments
 (0)