@luma.gl/engine 9.0.0-alpha.53 → 9.0.0-alpha.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma.gl/engine",
3
- "version": "9.0.0-alpha.53",
3
+ "version": "9.0.0-alpha.54",
4
4
  "description": "WebGL2 Components for High Performance Rendering and Computation",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,12 +40,12 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@babel/runtime": "^7.0.0",
43
- "@luma.gl/constants": "9.0.0-alpha.53",
44
- "@luma.gl/core": "9.0.0-alpha.53",
45
- "@luma.gl/shadertools": "9.0.0-alpha.53",
43
+ "@luma.gl/constants": "9.0.0-alpha.54",
44
+ "@luma.gl/core": "9.0.0-alpha.54",
45
+ "@luma.gl/shadertools": "9.0.0-alpha.54",
46
46
  "@math.gl/core": "^4.0.0",
47
47
  "@probe.gl/log": "^4.0.2",
48
48
  "@probe.gl/stats": "^4.0.2"
49
49
  },
50
- "gitHead": "f8939f1cf52a15f11ec053d4906e40f0b2a86836"
50
+ "gitHead": "6028eb651303eadbc8f25e86d135d28f118fa3cf"
51
51
  }
@@ -1,10 +1,21 @@
1
1
  // luma.gl, MIT license
2
2
  // Copyright (c) vis.gl contributors
3
3
 
4
- import type {TypedArray, RenderPipelineProps, RenderPipelineParameters} from '@luma.gl/core';
4
+ import type {
5
+ TypedArray,
6
+ RenderPipelineProps,
7
+ RenderPipelineParameters
8
+ } from '@luma.gl/core';
5
9
  import type {BufferLayout, VertexArray, TransformFeedback} from '@luma.gl/core';
6
10
  import type {AttributeInfo, Binding, UniformValue, PrimitiveTopology} from '@luma.gl/core';
7
- import {Device, Buffer, RenderPipeline, RenderPass, UniformStore} from '@luma.gl/core';
11
+ import {
12
+ Device,
13
+ Buffer,
14
+ RenderPipeline,
15
+ RenderPass,
16
+ UniformStore,
17
+ getTypedArrayFromDataType
18
+ } from '@luma.gl/core';
8
19
  import {log, uid, deepEqual, splitUniformsAndBindings} from '@luma.gl/core';
9
20
  import {getAttributeInfosFromLayouts} from '@luma.gl/core';
10
21
  import type {ShaderModule, PlatformInfo} from '@luma.gl/shadertools';
@@ -160,13 +171,20 @@ export class Model {
160
171
  Object.assign(this.userData, props.userData);
161
172
 
162
173
  // Setup shader module inputs
163
- const moduleMap = Object.fromEntries(this.props.modules?.map(module => [module.name, module]) || []);
174
+ const moduleMap = Object.fromEntries(
175
+ this.props.modules?.map(module => [module.name, module]) || []
176
+ );
164
177
  this.setShaderInputs(props.shaderInputs || new ShaderInputs(moduleMap));
165
178
 
166
179
  // Setup shader assembler
167
180
  const platformInfo = getPlatformInfo(device);
168
- const modules = (this.props.modules?.length > 0 ? this.props.modules : this.shaderInputs?.getModules()) || [];
169
- const {vs, fs, getUniforms} = this.props.shaderAssembler.assembleShaders({platformInfo, ...this.props, modules});
181
+ const modules =
182
+ (this.props.modules?.length > 0 ? this.props.modules : this.shaderInputs?.getModules()) || [];
183
+ const {vs, fs, getUniforms} = this.props.shaderAssembler.assembleShaders({
184
+ platformInfo,
185
+ ...this.props,
186
+ modules
187
+ });
170
188
 
171
189
  this.vs = vs;
172
190
  this.fs = fs;
@@ -380,10 +398,7 @@ export class Model {
380
398
  this._uniformStore = new UniformStore(this.shaderInputs.modules);
381
399
  // Create uniform buffer bindings for all modules
382
400
  for (const moduleName of Object.keys(this.shaderInputs.modules)) {
383
- const uniformBuffer = this._uniformStore.getManagedUniformBuffer(
384
- this.device,
385
- moduleName
386
- );
401
+ const uniformBuffer = this._uniformStore.getManagedUniformBuffer(this.device, moduleName);
387
402
  this.bindings[`${moduleName}Uniforms`] = uniformBuffer;
388
403
  }
389
404
  }
@@ -401,7 +416,7 @@ export class Model {
401
416
  Object.assign(this.bindings, bindings);
402
417
  Object.assign(this.uniforms, uniforms);
403
418
  }
404
-
419
+
405
420
  /**
406
421
  * Sets bindings (textures, samplers, uniform buffers)
407
422
  */
@@ -446,16 +461,14 @@ export class Model {
446
461
  )();
447
462
  }
448
463
  for (const [bufferName, buffer] of Object.entries(buffers)) {
449
- const bufferLayout = this.bufferLayout.find(layout => layout.name === bufferName);
464
+ const bufferLayout = this.bufferLayout.find(layout => getAttributeNames(layout).includes(bufferName));
450
465
  if (!bufferLayout) {
451
466
  log.warn(`Model(${this.id}): Missing layout for buffer "${bufferName}".`)();
452
467
  continue; // eslint-disable-line no-continue
453
468
  }
454
469
 
455
470
  // For an interleaved attribute we may need to set multiple attributes
456
- const attributeNames = bufferLayout.attributes
457
- ? bufferLayout.attributes?.map(layout => layout.attribute)
458
- : [bufferLayout.name];
471
+ const attributeNames = getAttributeNames(bufferLayout);
459
472
  let set = false;
460
473
  for (const attributeName of attributeNames) {
461
474
  const attributeInfo = this._attributeInfos[attributeName];
@@ -560,10 +573,49 @@ export class Model {
560
573
  }
561
574
  log.table(LOG_DRAW_PRIORITY, uniformTable)();
562
575
 
576
+ const attributeTable = this._getAttributeDebugTable();
577
+ log.table(LOG_DRAW_PRIORITY, this._attributeInfos)();
578
+ log.table(LOG_DRAW_PRIORITY, attributeTable)();
579
+
563
580
  log.groupEnd(LOG_DRAW_PRIORITY)();
564
581
  this._logOpen = false;
565
582
  }
566
583
  }
584
+
585
+ _getAttributeDebugTable(): Record<string, Record<string, unknown>> {
586
+ const table: Record<string, Record<string, unknown>> = {};
587
+ for (const [name, attributeInfo] of Object.entries(this._attributeInfos)) {
588
+ table[attributeInfo.location] = {
589
+ name,
590
+ type: attributeInfo.shaderType,
591
+ values: this._getBufferOrConstantValues(
592
+ this.vertexArray.attributes[attributeInfo.location],
593
+ attributeInfo.bufferDataType
594
+ )
595
+ };
596
+ }
597
+ if (this.vertexArray.indexBuffer) {
598
+ const {indexBuffer} = this.vertexArray;
599
+ const values =
600
+ indexBuffer.indexType === 'uint32'
601
+ ? new Uint32Array(indexBuffer.debugData)
602
+ : new Uint16Array(indexBuffer.debugData);
603
+ table.indices = {
604
+ name: 'indices',
605
+ type: indexBuffer.indexType,
606
+ values: values.toString()
607
+ };
608
+ }
609
+ return table;
610
+ }
611
+
612
+ // TODO - fix typing of luma data types
613
+ _getBufferOrConstantValues(attribute: Buffer | TypedArray, dataType: any): string {
614
+ const TypedArrayConstructor = getTypedArrayFromDataType(dataType);
615
+ const typedArray =
616
+ attribute instanceof Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
617
+ return typedArray.toString();
618
+ }
567
619
  }
568
620
 
569
621
  // HELPERS
@@ -592,3 +644,10 @@ export function getPlatformInfo(device: Device): PlatformInfo {
592
644
  features: device.features
593
645
  };
594
646
  }
647
+
648
+ /** Get attribute names from a BufferLayout */
649
+ function getAttributeNames(bufferLayout: BufferLayout): string[] {
650
+ return bufferLayout.attributes
651
+ ? bufferLayout.attributes?.map(layout => layout.attribute)
652
+ : [bufferLayout.name];
653
+ }