• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

visgl / luma.gl / 28705243730

04 Jul 2026 11:48AM UTC coverage: 72.17% (-0.02%) from 72.186%
28705243730

Pull #2734

github

web-flow
Merge 670b406d7 into 30d8c7ace
Pull Request #2734: feat(tables): support composite GPU inputs

11250 of 17547 branches covered (64.11%)

Branch coverage included in aggregate %.

27 of 33 new or added lines in 3 files covered. (81.82%)

21708 of 28120 relevant lines covered (77.2%)

5635.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

71.79
/modules/tables/src/engine/gpu-input-schema.ts
1
// luma.gl
2
// SPDX-License-Identifier: MIT
3
// Copyright (c) vis.gl contributors
4

5
import {assert} from '@luma.gl/core';
6
import type {GPUVector} from '../table/gpu-vector';
7
import type {GPUConstant} from '../table/gpu-constant';
8
import type {GPUVectorFormat} from '../table/gpu-vector-format';
9

10
/** Semantic role consumed by one GPU input. */
11
export type GPUInputKind = 'positions' | 'colors' | 'scalars' | 'matrices' | 'text' | 'time';
12

13
/** Shader-attribute mapping supplied by one logical GPU input. */
14
type GPUInputAttributeMapping =
15
  | {
16
      /** Optional shader attribute supplied by this column. */
17
      attributeName?: string;
18
      /** Composite attribute mappings are mutually exclusive with `attributeName`. */
19
      attributeNames?: never;
20
    }
21
  | {
22
      /** Singular attribute mappings are mutually exclusive with `attributeNames`. */
23
      attributeName?: never;
24
      /** Two or more shader attributes supplied by views of the same physical column. */
25
      attributeNames: readonly [string, string, ...string[]];
26
    };
27

28
/** Runtime declaration for one prepared GPUVector consumed by a model or renderer. */
29
export type GPUInputDeclaration<
30
  ColumnName extends string = string,
31
  Format extends GPUVectorFormat = GPUVectorFormat
32
> = GPUInputAttributeMapping & {
33
  /** Prepared GPUTable column and GPUVector map key. */
34
  columnName: ColumnName;
35
  /** Optional shader storage binding supplied by this column. */
36
  storageBindingName?: string;
37
  /** Semantic role consumed by the model or renderer. */
38
  kind: GPUInputKind;
39
  /** Whether callers must provide this prepared GPU input. */
40
  required: boolean;
41
  /** Accepted canonical GPUVector memory formats. */
42
  formats: readonly Format[];
43
  /**
44
   * Whether this input is generated during conversion or model preparation.
45
   * Omit for inputs that source mapping may resolve directly.
46
   */
47
  internal?: boolean;
48
};
49

50
/** Runtime prepared GPU input contract declared by one model or renderer. */
51
export type GPUInputSchema = readonly GPUInputDeclaration[];
52

53
/** Prepared varying GPU vectors keyed by declared GPU input column name. */
54
export type GPUInputVectors = Record<string, GPUVector | undefined>;
55

56
/** Prepared logical GPU columns keyed by declared GPU input column name. */
57
export type GPUInputColumns = Record<string, GPUVector | GPUConstant | undefined>;
58

59
/**
60
 * Returns the shader attributes supplied by one logical GPU input.
61
 *
62
 * Runtime validation complements the composite tuple type for JavaScript callers and values that
63
 * reach the API through an unchecked cast.
64
 */
65
export function getGPUInputAttributeNames(input: GPUInputDeclaration): readonly string[] {
66
  if (input.attributeNames !== undefined) {
680!
67
    // Singular mappings use attributeName.
NEW
68
    assert(input.attributeNames.length >= 2);
×
NEW
69
    const uniqueNames = new Set(input.attributeNames);
×
70
    // Each name identifies a distinct shader-visible view.
NEW
71
    assert(uniqueNames.size === input.attributeNames.length);
×
NEW
72
    return input.attributeNames;
×
73
  }
74
  return input.attributeName === undefined ? [] : [input.attributeName];
680✔
75
}
76

77
/** Validates prepared GPU vectors against one runtime GPU input schema. */
78
export function validateGPUInputVectors(
79
  ownerName: string,
80
  schema: GPUInputSchema,
81
  vectors: GPUInputColumns
82
): void {
83
  for (const input of schema) {
90✔
84
    getGPUInputAttributeNames(input);
544✔
85
    const column = vectors[input.columnName];
544✔
86
    if (!column) {
544✔
87
      if (input.required) {
304!
88
        throw new Error(`${ownerName} requires GPU input "${input.columnName}"`);
×
89
      }
90
      continue;
304✔
91
    }
92

93
    if ('isConstant' in column && input.required) {
240!
94
      throw new Error(
×
95
        `${ownerName} requires varying GPU input "${input.columnName}"; required inputs cannot be constant`
96
      );
97
    }
98

99
    const format = column.format;
240✔
100
    if (!format || !(input.formats as readonly GPUVectorFormat[]).includes(format)) {
240✔
101
      const columnType = 'isConstant' in column ? 'GPUConstant' : 'GPUVector';
2!
102
      throw new Error(
2✔
103
        `${ownerName} ${input.columnName} ${columnType}.format "${format ?? 'undefined'}" must be one of ${input.formats.join(', ')}`
2!
104
      );
105
    }
106
  }
107
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc