@luma.gl/webgpu 9.0.0-alpha.30 → 9.0.0-alpha.32

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/dist/index.cjs CHANGED
@@ -622,24 +622,24 @@ function addColorState(descriptor) {
622
622
 
623
623
  // src/adapter/helpers/get-bind-group.ts
624
624
  var import_core6 = require("@luma.gl/core");
625
- function getBindGroup(device, bindGroupLayout, layout, bindings) {
626
- const entries = getBindGroupEntries(bindings, layout);
625
+ function getBindGroup(device, bindGroupLayout, shaderLayout, bindings) {
626
+ const entries = getBindGroupEntries(bindings, shaderLayout);
627
627
  return device.createBindGroup({
628
628
  layout: bindGroupLayout,
629
629
  entries
630
630
  });
631
631
  }
632
- function getShaderLayoutBinding(layout, bindingName) {
633
- const bindingLayout = layout.bindings.find((binding) => binding.name === bindingName);
632
+ function getShaderLayoutBinding(shaderLayout, bindingName) {
633
+ const bindingLayout = shaderLayout.bindings.find((binding) => binding.name === bindingName);
634
634
  if (!bindingLayout) {
635
635
  import_core6.log.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();
636
636
  }
637
637
  return bindingLayout;
638
638
  }
639
- function getBindGroupEntries(bindings, layout) {
639
+ function getBindGroupEntries(bindings, shaderLayout) {
640
640
  const entries = [];
641
641
  for (const [bindingName, value] of Object.entries(bindings)) {
642
- const bindingLayout = getShaderLayoutBinding(layout, bindingName);
642
+ const bindingLayout = getShaderLayoutBinding(shaderLayout, bindingName);
643
643
  if (bindingLayout) {
644
644
  entries.push(getBindGroupEntry(value, bindingLayout.location));
645
645
  }
@@ -677,31 +677,31 @@ function getWebGPUVertexFormat(format) {
677
677
  }
678
678
  return format;
679
679
  }
680
- function getVertexBufferLayout(layout, bufferMap) {
680
+ function getVertexBufferLayout(shaderLayout, bufferLayout) {
681
681
  const vertexBufferLayouts = [];
682
682
  const usedAttributes = /* @__PURE__ */ new Set();
683
- for (const mapping of bufferMap) {
683
+ for (const mapping of bufferLayout) {
684
684
  const vertexAttributes = [];
685
685
  let stepMode = "vertex";
686
686
  let byteStride = 0;
687
687
  const byteOffset = mapping.byteOffset || 0;
688
- if ("attributes" in mapping) {
688
+ if (mapping.attributes) {
689
689
  for (const interleaved of mapping.attributes) {
690
- const attributeLayout = findAttributeLayout(layout, interleaved.name, usedAttributes);
690
+ const attributeLayout = findAttributeLayout(shaderLayout, interleaved.name, usedAttributes);
691
691
  stepMode = attributeLayout.stepMode || "vertex";
692
692
  vertexAttributes.push({
693
- format: getWebGPUVertexFormat(attributeLayout.format),
693
+ format: getWebGPUVertexFormat(interleaved.format || mapping.format),
694
694
  offset: byteOffset + byteStride,
695
695
  shaderLocation: attributeLayout.location
696
696
  });
697
- byteStride += (0, import_core7.decodeVertexFormat)(attributeLayout.format).byteLength;
697
+ byteStride += (0, import_core7.decodeVertexFormat)(mapping.format).byteLength;
698
698
  }
699
699
  } else {
700
- const attributeLayout = findAttributeLayout(layout, mapping.name, usedAttributes);
701
- byteStride = (0, import_core7.decodeVertexFormat)(attributeLayout.format).byteLength;
700
+ const attributeLayout = findAttributeLayout(shaderLayout, mapping.name, usedAttributes);
701
+ byteStride = (0, import_core7.decodeVertexFormat)(mapping.format).byteLength;
702
702
  stepMode = attributeLayout.stepMode || "vertex";
703
703
  vertexAttributes.push({
704
- format: getWebGPUVertexFormat(attributeLayout.format),
704
+ format: getWebGPUVertexFormat(mapping.format),
705
705
  offset: byteOffset,
706
706
  shaderLocation: attributeLayout.location
707
707
  });
@@ -712,26 +712,28 @@ function getVertexBufferLayout(layout, bufferMap) {
712
712
  attributes: vertexAttributes
713
713
  });
714
714
  }
715
- for (const attribute of layout.attributes) {
715
+ for (const attribute of shaderLayout.attributes) {
716
716
  if (!usedAttributes.has(attribute.name)) {
717
717
  vertexBufferLayouts.push({
718
- arrayStride: (0, import_core7.decodeVertexFormat)(attribute.format).byteLength,
718
+ arrayStride: (0, import_core7.decodeVertexFormat)("float32x3").byteLength,
719
719
  stepMode: attribute.stepMode || "vertex",
720
- attributes: [{
721
- format: getWebGPUVertexFormat(attribute.format),
722
- offset: 0,
723
- shaderLocation: attribute.location
724
- }]
720
+ attributes: [
721
+ {
722
+ format: getWebGPUVertexFormat("float32x3"),
723
+ offset: 0,
724
+ shaderLocation: attribute.location
725
+ }
726
+ ]
725
727
  });
726
728
  }
727
729
  }
728
730
  return vertexBufferLayouts;
729
731
  }
730
- function getBufferSlots(layout, bufferMap) {
732
+ function getBufferSlots(shaderLayout, bufferLayout) {
731
733
  const usedAttributes = /* @__PURE__ */ new Set();
732
734
  let bufferSlot = 0;
733
735
  const bufferSlots = {};
734
- for (const mapping of bufferMap) {
736
+ for (const mapping of bufferLayout) {
735
737
  if ("attributes" in mapping) {
736
738
  for (const interleaved of mapping.attributes) {
737
739
  usedAttributes.add(interleaved.name);
@@ -741,15 +743,15 @@ function getBufferSlots(layout, bufferMap) {
741
743
  }
742
744
  bufferSlots[mapping.name] = bufferSlot++;
743
745
  }
744
- for (const attribute of layout.attributes) {
746
+ for (const attribute of shaderLayout.attributes) {
745
747
  if (!usedAttributes.has(attribute.name)) {
746
748
  bufferSlots[attribute.name] = bufferSlot++;
747
749
  }
748
750
  }
749
751
  return bufferSlots;
750
752
  }
751
- function findAttributeLayout(layout, name, attributeNames) {
752
- const attribute = layout.attributes.find((attribute2) => attribute2.name === name);
753
+ function findAttributeLayout(shaderLayout, name, attributeNames) {
754
+ const attribute = shaderLayout.attributes.find((attribute2) => attribute2.name === name);
753
755
  if (!attribute) {
754
756
  throw new Error(`Unknown attribute ${name}`);
755
757
  }
@@ -772,7 +774,7 @@ var WebGPURenderPipeline = class extends import_core8.RenderPipeline {
772
774
  this.handle.label = this.props.id;
773
775
  this.vs = (0, import_core8.cast)(props.vs);
774
776
  this.fs = (0, import_core8.cast)(props.fs);
775
- this._bufferSlots = getBufferSlots(this.props.layout, this.props.bufferMap);
777
+ this._bufferSlots = getBufferSlots(this.props.shaderLayout, this.props.bufferLayout);
776
778
  this._buffers = new Array(Object.keys(this._bufferSlots).length).fill(null);
777
779
  this._bindGroupLayout = this.handle.getBindGroupLayout(0);
778
780
  }
@@ -801,18 +803,16 @@ var WebGPURenderPipeline = class extends import_core8.RenderPipeline {
801
803
  }
802
804
  }
803
805
  }
804
- /** Constant attributes are not available in WebGPU */
805
806
  setConstantAttributes(attributes) {
806
- console.error("not implemented");
807
+ throw new Error("not implemented");
807
808
  }
808
- /** Set the bindings */
809
809
  setBindings(bindings) {
810
810
  if (!(0, import_core8.isObjectEmpty)(this.props.bindings)) {
811
811
  Object.assign(this.props.bindings, bindings);
812
812
  this._bindGroup = getBindGroup(
813
813
  this.device.handle,
814
814
  this._bindGroupLayout,
815
- this.props.layout,
815
+ this.props.shaderLayout,
816
816
  this.props.bindings
817
817
  );
818
818
  }
@@ -835,7 +835,7 @@ var WebGPURenderPipeline = class extends import_core8.RenderPipeline {
835
835
  const vertex = {
836
836
  module: (0, import_core8.cast)(this.props.vs).handle,
837
837
  entryPoint: this.props.vsEntryPoint || "main",
838
- buffers: getVertexBufferLayout(this.props.layout, this.props.bufferMap)
838
+ buffers: getVertexBufferLayout(this.props.shaderLayout, this.props.bufferLayout)
839
839
  };
840
840
  let fragment;
841
841
  if (this.props.fs) {
@@ -900,7 +900,7 @@ var WebGPURenderPipeline = class extends import_core8.RenderPipeline {
900
900
  for (let i = 0; i < buffers.length; ++i) {
901
901
  const buffer = (0, import_core8.cast)(buffers[i]);
902
902
  if (!buffer) {
903
- const attribute = this.props.layout.attributes.find(
903
+ const attribute = this.props.shaderLayout.attributes.find(
904
904
  (attribute2) => attribute2.location === i
905
905
  );
906
906
  throw new Error(