Skip to content

Commit ab27322

Browse files
chore(luma): Upgrade to luma.gl v9 alpha-50 (#8379)
--------- Co-authored-by: Felix Palmer <felixpalmer@gmail.com>
1 parent 97334a8 commit ab27322

File tree

30 files changed

+292
-258
lines changed

30 files changed

+292
-258
lines changed

modules/aggregation-layers/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@
3232
},
3333
"dependencies": {
3434
"@babel/runtime": "^7.0.0",
35-
"@luma.gl/constants": "9.0.0-alpha.42",
36-
"@luma.gl/core": "9.0.0-alpha.42",
37-
"@luma.gl/shadertools": "9.0.0-alpha.42",
35+
"@luma.gl/constants": "9.0.0-alpha.50",
36+
"@luma.gl/core": "9.0.0-alpha.50",
37+
"@luma.gl/shadertools": "9.0.0-alpha.50",
3838
"@math.gl/web-mercator": "^4.0.0",
3939
"d3-hexbin": "^0.2.1"
4040
},
4141
"peerDependencies": {
4242
"@deck.gl/core": "^9.0.0-alpha",
4343
"@deck.gl/layers": "^9.0.0-alpha",
44-
"@luma.gl/core": "9.0.0-alpha.42",
45-
"@luma.gl/engine": "9.0.0-alpha.42"
44+
"@luma.gl/core": "9.0.0-alpha.50",
45+
"@luma.gl/engine": "9.0.0-alpha.50"
4646
},
4747
"gitHead": "13ace64fc2cee08c133afc882fc307253489a4e4"
4848
}

modules/aggregation-layers/src/heatmap-layer/heatmap-layer.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
} from './heatmap-layer-utils';
3030
import {Buffer, DeviceFeature, Texture, TextureProps, TextureFormat} from '@luma.gl/core';
3131
import {GL} from '@luma.gl/constants';
32-
import {Transform} from '@luma.gl/engine';
32+
import {TextureTransform, TextureTransformProps} from '@luma.gl/engine';
3333
import {withGLParameters} from '@luma.gl/webgl';
3434
import {
3535
Accessor,
@@ -201,8 +201,8 @@ export default class HeatmapLayer<
201201
updateTimer?: any;
202202
triPositionBuffer?: Buffer;
203203
triTexCoordBuffer?: Buffer;
204-
weightsTransform?: Transform;
205-
maxWeightTransform?: Transform;
204+
weightsTransform?: TextureTransform;
205+
maxWeightTransform?: TextureTransform;
206206
textureSize: number;
207207
format: TextureFormat;
208208
type: GL;
@@ -424,16 +424,15 @@ export default class HeatmapLayer<
424424

425425
_createWeightsTransform(shaders = {}) {
426426
let {weightsTransform} = this.state;
427-
const {weightsTexture} = this.state;
428427
weightsTransform?.delete();
429428

430-
weightsTransform = new Transform(this.context.device, {
429+
weightsTransform = new TextureTransform(this.context.device, {
431430
id: `${this.id}-weights-transform`,
432-
elementCount: 1,
433-
_targetTexture: weightsTexture,
434-
_targetTextureVarying: 'weightsTexture',
431+
vertexCount: 1,
432+
targetTexture: this.state.weightsTexture!,
433+
targetTextureVarying: 'weightsTexture',
435434
...shaders
436-
});
435+
} as TextureTransformProps);
437436
this.setState({weightsTransform});
438437
}
439438

@@ -445,7 +444,7 @@ export default class HeatmapLayer<
445444
this._createWeightsTransform(weightsTransformShaders);
446445

447446
const maxWeightsTransformShaders = this.getShaders('max-weights-transform');
448-
const maxWeightTransform = new Transform(this.context.device, {
447+
const maxWeightTransform = new TextureTransform(this.context.device, {
449448
id: `${this.id}-max-weights-transform`,
450449
_sourceTextures: {
451450
inTexture: weightsTexture
@@ -484,6 +483,7 @@ export default class HeatmapLayer<
484483
const {maxWeightTransform} = this.state;
485484
maxWeightTransform!.run({
486485
parameters: {
486+
// @ts-expect-error TODO(v9): Resolve errors.
487487
blend: true,
488488
depthTest: false,
489489
blendFunc: [GL.ONE, GL.ONE],
@@ -618,13 +618,13 @@ export default class HeatmapLayer<
618618
weightsTransform.run({
619619
uniforms,
620620
parameters: {
621+
// @ts-expect-error TODO(v9): Resolve errors.
621622
blend: true,
622623
depthTest: false,
623624
blendFunc: [GL.ONE, GL.ONE],
624625
blendEquation: GL.FUNC_ADD
625626
},
626627
clearRenderTarget: true,
627-
// @ts-expect-error TODO - no longer supported in v9?
628628
attributes: this.getAttributes(),
629629
moduleSettings: this.getModuleSettings()
630630
});

modules/aggregation-layers/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// THE SOFTWARE.
2020

2121
import type {Device, DeviceFeature} from '@luma.gl/core';
22-
import {Model, Transform} from '@luma.gl/engine';
22+
import {Model, TextureTransform} from '@luma.gl/engine';
2323
import {fp64arithmetic} from '@luma.gl/shadertools';
2424
import {readPixelsToBuffer, withGLParameters, clear} from '@luma.gl/webgl';
2525
import {GL} from '@luma.gl/constants';
@@ -696,7 +696,7 @@ function getAllAggregationModel(device: Device, instanceCount: number): Model {
696696
}
697697

698698
function getMeanTransform(device: Device, opts) {
699-
return new Transform(device, {
699+
return new TextureTransform(device, {
700700
vs: TRANSFORM_MEAN_VS,
701701
_targetTextureVarying: 'meanValues',
702702
...opts

modules/arcgis/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
"peerDependencies": {
3333
"@arcgis/core": "^4.0.0",
3434
"@deck.gl/core": "^9.0.0-alpha",
35-
"@luma.gl/core": "9.0.0-alpha.42",
36-
"@luma.gl/engine": "9.0.0-alpha.42"
35+
"@luma.gl/core": "9.0.0-alpha.50",
36+
"@luma.gl/engine": "9.0.0-alpha.50"
3737
},
3838
"dependencies": {
3939
"@babel/runtime": "^7.0.0",

modules/carto/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
"@loaders.gl/loader-utils": "4.0.3",
4141
"@loaders.gl/mvt": "4.0.3",
4242
"@loaders.gl/tiles": "4.0.3",
43-
"@luma.gl/constants": "9.0.0-alpha.42",
44-
"@luma.gl/core": "9.0.0-alpha.42",
43+
"@luma.gl/constants": "9.0.0-alpha.50",
44+
"@luma.gl/core": "9.0.0-alpha.50",
4545
"@math.gl/web-mercator": "^4.0.0",
4646
"cartocolor": "^4.0.2",
4747
"d3-array": "^3.2.0",

modules/carto/src/layers/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function mergeBoundaryData(geometry: VectorTile, properties: PropertiesTi
2020
const mapping = {};
2121
for (const {geoid, ...rest} of properties.properties) {
2222
if (geoid in mapping) {
23-
log.warn(`Duplicate geoid key in boundary mapping, using first occurance`)();
23+
log.warn('Duplicate geoid key in boundary mapping, using first occurance')();
2424
} else {
2525
mapping[geoid] = rest;
2626
}

modules/core/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
"@babel/runtime": "^7.0.0",
3737
"@loaders.gl/core": "4.0.3",
3838
"@loaders.gl/images": "4.0.3",
39-
"@luma.gl/constants": "9.0.0-alpha.42",
40-
"@luma.gl/core": "9.0.0-alpha.42",
41-
"@luma.gl/engine": "9.0.0-alpha.42",
42-
"@luma.gl/shadertools": "9.0.0-alpha.42",
43-
"@luma.gl/webgl": "9.0.0-alpha.42",
39+
"@luma.gl/constants": "9.0.0-alpha.50",
40+
"@luma.gl/core": "9.0.0-alpha.50",
41+
"@luma.gl/engine": "9.0.0-alpha.50",
42+
"@luma.gl/shadertools": "9.0.0-alpha.50",
43+
"@luma.gl/webgl": "9.0.0-alpha.50",
4444
"@math.gl/core": "^4.0.0",
4545
"@math.gl/sun": "^4.0.0",
4646
"@math.gl/web-mercator": "^4.0.0",

modules/core/src/lib/attribute/attribute-transition-manager.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// deck.gl, MIT license
22

33
import type {Device} from '@luma.gl/core';
4-
import {Transform} from '@luma.gl/engine';
54
import GPUInterpolationTransition from '../../transitions/gpu-interpolation-transition';
65
import GPUSpringTransition from '../../transitions/gpu-spring-transition';
76
import log from '../../utils/log';
@@ -38,14 +37,15 @@ export default class AttributeTransitionManager {
3837
timeline?: Timeline;
3938
}
4039
) {
40+
if (!device) throw new Error('AttributeTransitionManager is constructed without device');
4141
this.id = id;
4242
this.device = device;
4343
this.timeline = timeline;
4444

4545
this.transitions = {};
4646
this.needsRedraw = false;
4747
this.numInstances = 1;
48-
this.isSupported = Transform.isSupported(device);
48+
this.isSupported = device.features.has('transform-feedback-webgl2');
4949
}
5050

5151
finalize(): void {
@@ -148,8 +148,11 @@ export default class AttributeTransitionManager {
148148
// TODO: when switching transition types, make sure to carry over the attribute's
149149
// previous buffers, currentLength, startIndices, etc, to be used as the starting point
150150
// for the next transition
151-
let isNew = !transition || transition.type !== settings.type;
152-
if (isNew) {
151+
let needsUpdate = !transition || transition.type !== settings.type;
152+
needsUpdate ||=
153+
attribute.buffer.byteLength > transition?.attributeInTransition.buffer.byteLength;
154+
155+
if (needsUpdate) {
153156
if (!this.isSupported) {
154157
log.warn(
155158
`WebGL2 not supported by this browser. Transition for ${attributeName} is disabled.`
@@ -170,11 +173,11 @@ export default class AttributeTransitionManager {
170173
});
171174
} else {
172175
log.error(`unsupported transition type '${settings.type}'`)();
173-
isNew = false;
176+
needsUpdate = false;
174177
}
175178
}
176179

177-
if (isNew || attribute.needsRedraw()) {
180+
if (needsUpdate || attribute.needsRedraw()) {
178181
this.needsRedraw = true;
179182
this.transitions[attributeName].start(settings, this.numInstances);
180183
}

modules/core/src/lib/attribute/data-column.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ export default class DataColumn<Options, State> {
184184
bounds: null,
185185
constant: false
186186
};
187-
this._buffer = null;
187+
188+
// TODO(v9): Can we pre-allocate the correct size, instead?
189+
this._buffer = this._createBuffer(0);
188190
}
189191
/* eslint-enable max-statements */
190192

@@ -193,10 +195,6 @@ export default class DataColumn<Options, State> {
193195
}
194196

195197
get buffer(): Buffer {
196-
if (!this._buffer) {
197-
// TODO(v9): No point in allocating an empty buffer, try to avoid this.
198-
this._createBuffer(4);
199-
}
200198
return this._buffer!;
201199
}
202200

@@ -418,8 +416,7 @@ export default class DataColumn<Options, State> {
418416
// Shader attributes may try to access this buffer with bigger offsets
419417
const requiredBufferSize = value.byteLength + byteOffset + stride * 2;
420418
if (buffer.byteLength < requiredBufferSize) {
421-
this._createBuffer(requiredBufferSize);
422-
buffer = this.buffer;
419+
buffer = this._createBuffer(requiredBufferSize);
423420
}
424421

425422
buffer.write(value, byteOffset);
@@ -469,8 +466,7 @@ export default class DataColumn<Options, State> {
469466
let {buffer} = this;
470467

471468
if (buffer.byteLength < value.byteLength + byteOffset) {
472-
this._createBuffer(value.byteLength + byteOffset);
473-
buffer = this.buffer;
469+
buffer = this._createBuffer(value.byteLength + byteOffset);
474470
if (copy && oldValue) {
475471
// Upload the full existing attribute value to the GPU, so that updateBuffer
476472
// can choose to only update a partial range.
@@ -590,11 +586,12 @@ export default class DataColumn<Options, State> {
590586
return true;
591587
}
592588

593-
protected _createBuffer(byteLength: number) {
589+
protected _createBuffer(byteLength: number): Buffer {
594590
if (this._buffer) {
591+
// console.log(`DataColumn#destroyBuffer: id = ${this.id}, byteLength = ${this._buffer.byteLength}`);
595592
this._buffer.destroy();
596593
}
597-
594+
// console.log(`DataColumn#createBuffer: id = ${this.id}, byteLength = ${byteLength}`);
598595
const {isIndexed, type} = this.settings;
599596
this._buffer = this.device.createBuffer({
600597
...this._buffer?.props,
@@ -603,5 +600,7 @@ export default class DataColumn<Options, State> {
603600
indexType: isIndexed ? (type === GL.UNSIGNED_SHORT ? 'uint16' : 'uint32') : undefined,
604601
byteLength
605602
});
603+
604+
return this._buffer;
606605
}
607606
}

modules/core/src/passes/screen-pass.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export default class ScreenPass extends Pass {
6262
protected _renderPass(device: Device, options: ScreenPassRenderOptions) {
6363
const {inputBuffer} = options;
6464
clear(this.device, {color: true});
65+
// @ts-expect-error TODO(v9): Resolve errors.
6566
this.model.setShaderModuleProps(options.moduleSettings);
6667
this.model.setBindings({
6768
texture: inputBuffer.colorAttachments[0]

0 commit comments

Comments
 (0)