@luma.gl/webgpu 9.0.0-alpha.29 → 9.0.0-alpha.30
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/LICENSE +2 -1
- package/dist/adapter/helpers/accessor-to-format.js.map +1 -1
- package/dist/adapter/helpers/convert-texture-format.d.ts +1 -1
- package/dist/adapter/helpers/convert-texture-format.d.ts.map +1 -1
- package/dist/adapter/helpers/convert-texture-format.js.map +1 -1
- package/dist/adapter/helpers/get-bind-group.d.ts +1 -1
- package/dist/adapter/helpers/get-bind-group.d.ts.map +1 -1
- package/dist/adapter/helpers/get-bind-group.js +1 -1
- package/dist/adapter/helpers/get-bind-group.js.map +1 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts +1 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.js +10 -4
- package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +1 -1
- package/dist/adapter/helpers/webgpu-parameters.d.ts +1 -1
- package/dist/adapter/helpers/webgpu-parameters.d.ts.map +1 -1
- package/dist/adapter/helpers/webgpu-parameters.js.map +1 -1
- package/dist/adapter/resources/webgpu-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgpu-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-buffer.js +1 -1
- package/dist/adapter/resources/webgpu-buffer.js.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.d.ts +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.js +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.d.ts +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.js +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.js.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.d.ts +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.js +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgpu-external-texture.d.ts +1 -1
- package/dist/adapter/resources/webgpu-external-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-external-texture.js +1 -1
- package/dist/adapter/resources/webgpu-external-texture.js.map +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.d.ts +2 -2
- package/dist/adapter/resources/webgpu-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.js +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgpu-query.js.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.d.ts +2 -2
- package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.js +1 -1
- package/dist/adapter/resources/webgpu-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts +2 -2
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.js +3 -3
- package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgpu-sampler.d.ts +1 -1
- package/dist/adapter/resources/webgpu-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-sampler.js +1 -1
- package/dist/adapter/resources/webgpu-sampler.js.map +1 -1
- package/dist/adapter/resources/webgpu-shader.d.ts +2 -2
- package/dist/adapter/resources/webgpu-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-shader.js +1 -1
- package/dist/adapter/resources/webgpu-shader.js.map +1 -1
- package/dist/adapter/resources/webgpu-texture.d.ts +1 -1
- package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-texture.js +1 -1
- package/dist/adapter/resources/webgpu-texture.js.map +1 -1
- package/dist/adapter/webgpu-canvas-context.d.ts +3 -3
- package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgpu-canvas-context.js +1 -1
- package/dist/adapter/webgpu-canvas-context.js.map +1 -1
- package/dist/adapter/webgpu-device.d.ts +2 -2
- package/dist/adapter/webgpu-device.d.ts.map +1 -1
- package/dist/adapter/webgpu-device.js +1 -1
- package/dist/adapter/webgpu-device.js.map +1 -1
- package/dist/dist.dev.js +41 -26
- package/dist/index.cjs +77 -71
- package/dist.min.js +4 -4
- package/package.json +3 -3
- package/src/adapter/helpers/accessor-to-format.ts +1 -1
- package/src/adapter/helpers/convert-texture-format.ts +1 -1
- package/src/adapter/helpers/get-bind-group.ts +2 -2
- package/src/adapter/helpers/get-vertex-buffer-layout.ts +13 -5
- package/src/adapter/helpers/webgpu-parameters.ts +1 -1
- package/src/adapter/resources/webgpu-buffer.ts +1 -1
- package/src/adapter/resources/webgpu-command-encoder.ts +1 -1
- package/src/adapter/resources/webgpu-compute-pass.ts +1 -1
- package/src/adapter/resources/webgpu-compute-pipeline.ts +1 -1
- package/src/adapter/resources/webgpu-external-texture.ts +1 -1
- package/src/adapter/resources/webgpu-framebuffer.ts +2 -2
- package/src/adapter/resources/webgpu-query.ts +1 -1
- package/src/adapter/resources/webgpu-render-pass.ts +2 -2
- package/src/adapter/resources/webgpu-render-pipeline.ts +4 -4
- package/src/adapter/resources/webgpu-sampler.ts +1 -1
- package/src/adapter/resources/webgpu-shader.ts +2 -2
- package/src/adapter/resources/webgpu-texture.ts +1 -1
- package/src/adapter/webgpu-canvas-context.ts +2 -2
- package/src/adapter/webgpu-device.ts +2 -2
package/dist/index.cjs
CHANGED
|
@@ -65,15 +65,15 @@ __export(src_exports, {
|
|
|
65
65
|
module.exports = __toCommonJS(src_exports);
|
|
66
66
|
|
|
67
67
|
// src/adapter/webgpu-device.ts
|
|
68
|
-
var
|
|
68
|
+
var import_core14 = require("@luma.gl/core");
|
|
69
69
|
|
|
70
70
|
// src/adapter/resources/webgpu-buffer.ts
|
|
71
|
-
var
|
|
71
|
+
var import_core = require("@luma.gl/core");
|
|
72
72
|
function getByteLength(props) {
|
|
73
73
|
var _a;
|
|
74
74
|
return props.byteLength || ((_a = props.data) == null ? void 0 : _a.byteLength) || 0;
|
|
75
75
|
}
|
|
76
|
-
var WebGPUBuffer = class extends
|
|
76
|
+
var WebGPUBuffer = class extends import_core.Buffer {
|
|
77
77
|
constructor(device, props) {
|
|
78
78
|
super(device, props);
|
|
79
79
|
this.device = device;
|
|
@@ -108,7 +108,7 @@ var WebGPUBuffer = class extends import_api.Buffer {
|
|
|
108
108
|
}
|
|
109
109
|
readAsync() {
|
|
110
110
|
return __async(this, arguments, function* (byteOffset = 0, byteLength = this.byteLength) {
|
|
111
|
-
const tempBuffer = new WebGPUBuffer(this.device, { usage:
|
|
111
|
+
const tempBuffer = new WebGPUBuffer(this.device, { usage: import_core.Buffer.MAP_READ | import_core.Buffer.COPY_DST, byteLength });
|
|
112
112
|
const commandEncoder = this.device.handle.createCommandEncoder();
|
|
113
113
|
commandEncoder.copyBufferToBuffer(this.handle, byteOffset, tempBuffer.handle, 0, byteLength);
|
|
114
114
|
this.device.handle.queue.submit([commandEncoder.finish()]);
|
|
@@ -136,7 +136,7 @@ var WebGPUBuffer = class extends import_api.Buffer {
|
|
|
136
136
|
};
|
|
137
137
|
|
|
138
138
|
// src/adapter/resources/webgpu-texture.ts
|
|
139
|
-
var
|
|
139
|
+
var import_core3 = require("@luma.gl/core");
|
|
140
140
|
|
|
141
141
|
// src/adapter/helpers/convert-texture-format.ts
|
|
142
142
|
function getWebGPUTextureFormat(format) {
|
|
@@ -147,8 +147,8 @@ function getWebGPUTextureFormat(format) {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
// src/adapter/resources/webgpu-sampler.ts
|
|
150
|
-
var
|
|
151
|
-
var WebGPUSampler = class extends
|
|
150
|
+
var import_core2 = require("@luma.gl/core");
|
|
151
|
+
var WebGPUSampler = class extends import_core2.Sampler {
|
|
152
152
|
constructor(device, props) {
|
|
153
153
|
super(device, props);
|
|
154
154
|
this.device = device;
|
|
@@ -172,7 +172,7 @@ var BASE_DIMENSIONS = {
|
|
|
172
172
|
"cube-array": "2d",
|
|
173
173
|
"3d": "3d"
|
|
174
174
|
};
|
|
175
|
-
var WebGPUTexture = class extends
|
|
175
|
+
var WebGPUTexture = class extends import_core3.Texture {
|
|
176
176
|
// static async createFromImageURL(src, usage = 0) {
|
|
177
177
|
// const img = document.createElement('img');
|
|
178
178
|
// img.src = src;
|
|
@@ -361,8 +361,8 @@ var WebGPUTexture = class extends import_api3.Texture {
|
|
|
361
361
|
};
|
|
362
362
|
|
|
363
363
|
// src/adapter/resources/webgpu-external-texture.ts
|
|
364
|
-
var
|
|
365
|
-
var WebGPUExternalTexture = class extends
|
|
364
|
+
var import_core4 = require("@luma.gl/core");
|
|
365
|
+
var WebGPUExternalTexture = class extends import_core4.ExternalTexture {
|
|
366
366
|
constructor(device, props) {
|
|
367
367
|
super(device, props);
|
|
368
368
|
this.device = device;
|
|
@@ -382,8 +382,8 @@ var WebGPUExternalTexture = class extends import_api4.ExternalTexture {
|
|
|
382
382
|
};
|
|
383
383
|
|
|
384
384
|
// src/adapter/resources/webgpu-shader.ts
|
|
385
|
-
var
|
|
386
|
-
var WebGPUShader = class extends
|
|
385
|
+
var import_core5 = require("@luma.gl/core");
|
|
386
|
+
var WebGPUShader = class extends import_core5.Shader {
|
|
387
387
|
constructor(device, props) {
|
|
388
388
|
super(device, props);
|
|
389
389
|
this.device = device;
|
|
@@ -397,7 +397,7 @@ var WebGPUShader = class extends import_api5.Shader {
|
|
|
397
397
|
const error = yield errorScope;
|
|
398
398
|
if (error) {
|
|
399
399
|
const shaderLog = yield this.compilationInfo();
|
|
400
|
-
|
|
400
|
+
import_core5.log.error(`Shader compilation error: ${error.message}`, shaderLog)();
|
|
401
401
|
throw new Error(`Shader compilation error: ${error.message}`);
|
|
402
402
|
}
|
|
403
403
|
});
|
|
@@ -433,7 +433,7 @@ var WebGPUShader = class extends import_api5.Shader {
|
|
|
433
433
|
};
|
|
434
434
|
|
|
435
435
|
// src/adapter/resources/webgpu-render-pipeline.ts
|
|
436
|
-
var
|
|
436
|
+
var import_core8 = require("@luma.gl/core");
|
|
437
437
|
|
|
438
438
|
// src/adapter/helpers/webgpu-parameters.ts
|
|
439
439
|
function addDepthStencil(descriptor) {
|
|
@@ -621,7 +621,7 @@ function addColorState(descriptor) {
|
|
|
621
621
|
}
|
|
622
622
|
|
|
623
623
|
// src/adapter/helpers/get-bind-group.ts
|
|
624
|
-
var
|
|
624
|
+
var import_core6 = require("@luma.gl/core");
|
|
625
625
|
function getBindGroup(device, bindGroupLayout, layout, bindings) {
|
|
626
626
|
const entries = getBindGroupEntries(bindings, layout);
|
|
627
627
|
return device.createBindGroup({
|
|
@@ -632,7 +632,7 @@ function getBindGroup(device, bindGroupLayout, layout, bindings) {
|
|
|
632
632
|
function getShaderLayoutBinding(layout, bindingName) {
|
|
633
633
|
const bindingLayout = layout.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
|
}
|
|
@@ -647,30 +647,36 @@ function getBindGroupEntries(bindings, layout) {
|
|
|
647
647
|
return entries;
|
|
648
648
|
}
|
|
649
649
|
function getBindGroupEntry(binding, index) {
|
|
650
|
-
if (binding instanceof
|
|
650
|
+
if (binding instanceof import_core6.Buffer) {
|
|
651
651
|
return {
|
|
652
652
|
binding: index,
|
|
653
653
|
resource: {
|
|
654
|
-
buffer: (0,
|
|
654
|
+
buffer: (0, import_core6.cast)(binding).handle
|
|
655
655
|
}
|
|
656
656
|
};
|
|
657
657
|
}
|
|
658
|
-
if (binding instanceof
|
|
658
|
+
if (binding instanceof import_core6.Sampler) {
|
|
659
659
|
return {
|
|
660
660
|
binding: index,
|
|
661
|
-
resource: (0,
|
|
661
|
+
resource: (0, import_core6.cast)(binding).handle
|
|
662
662
|
};
|
|
663
|
-
} else if (binding instanceof
|
|
663
|
+
} else if (binding instanceof import_core6.Texture) {
|
|
664
664
|
return {
|
|
665
665
|
binding: index,
|
|
666
|
-
resource: (0,
|
|
666
|
+
resource: (0, import_core6.cast)(binding).handle.createView()
|
|
667
667
|
};
|
|
668
668
|
}
|
|
669
669
|
throw new Error("invalid binding");
|
|
670
670
|
}
|
|
671
671
|
|
|
672
672
|
// src/adapter/helpers/get-vertex-buffer-layout.ts
|
|
673
|
-
var
|
|
673
|
+
var import_core7 = require("@luma.gl/core");
|
|
674
|
+
function getWebGPUVertexFormat(format) {
|
|
675
|
+
if (format.endsWith("-webgl")) {
|
|
676
|
+
throw new Error(`WebGPU does not support vertex format ${format}`);
|
|
677
|
+
}
|
|
678
|
+
return format;
|
|
679
|
+
}
|
|
674
680
|
function getVertexBufferLayout(layout, bufferMap) {
|
|
675
681
|
const vertexBufferLayouts = [];
|
|
676
682
|
const usedAttributes = /* @__PURE__ */ new Set();
|
|
@@ -684,18 +690,18 @@ function getVertexBufferLayout(layout, bufferMap) {
|
|
|
684
690
|
const attributeLayout = findAttributeLayout(layout, interleaved.name, usedAttributes);
|
|
685
691
|
stepMode = attributeLayout.stepMode || "vertex";
|
|
686
692
|
vertexAttributes.push({
|
|
687
|
-
format: attributeLayout.format,
|
|
693
|
+
format: getWebGPUVertexFormat(attributeLayout.format),
|
|
688
694
|
offset: byteOffset + byteStride,
|
|
689
695
|
shaderLocation: attributeLayout.location
|
|
690
696
|
});
|
|
691
|
-
byteStride += (0,
|
|
697
|
+
byteStride += (0, import_core7.decodeVertexFormat)(attributeLayout.format).byteLength;
|
|
692
698
|
}
|
|
693
699
|
} else {
|
|
694
700
|
const attributeLayout = findAttributeLayout(layout, mapping.name, usedAttributes);
|
|
695
|
-
byteStride = (0,
|
|
701
|
+
byteStride = (0, import_core7.decodeVertexFormat)(attributeLayout.format).byteLength;
|
|
696
702
|
stepMode = attributeLayout.stepMode || "vertex";
|
|
697
703
|
vertexAttributes.push({
|
|
698
|
-
format: attributeLayout.format,
|
|
704
|
+
format: getWebGPUVertexFormat(attributeLayout.format),
|
|
699
705
|
offset: byteOffset,
|
|
700
706
|
shaderLocation: attributeLayout.location
|
|
701
707
|
});
|
|
@@ -709,10 +715,10 @@ function getVertexBufferLayout(layout, bufferMap) {
|
|
|
709
715
|
for (const attribute of layout.attributes) {
|
|
710
716
|
if (!usedAttributes.has(attribute.name)) {
|
|
711
717
|
vertexBufferLayouts.push({
|
|
712
|
-
arrayStride: (0,
|
|
718
|
+
arrayStride: (0, import_core7.decodeVertexFormat)(attribute.format).byteLength,
|
|
713
719
|
stepMode: attribute.stepMode || "vertex",
|
|
714
720
|
attributes: [{
|
|
715
|
-
format: attribute.format,
|
|
721
|
+
format: getWebGPUVertexFormat(attribute.format),
|
|
716
722
|
offset: 0,
|
|
717
723
|
shaderLocation: attribute.location
|
|
718
724
|
}]
|
|
@@ -755,7 +761,7 @@ function findAttributeLayout(layout, name, attributeNames) {
|
|
|
755
761
|
}
|
|
756
762
|
|
|
757
763
|
// src/adapter/resources/webgpu-render-pipeline.ts
|
|
758
|
-
var WebGPURenderPipeline = class extends
|
|
764
|
+
var WebGPURenderPipeline = class extends import_core8.RenderPipeline {
|
|
759
765
|
constructor(device, props) {
|
|
760
766
|
super(device, props);
|
|
761
767
|
this.fs = null;
|
|
@@ -764,8 +770,8 @@ var WebGPURenderPipeline = class extends import_api8.RenderPipeline {
|
|
|
764
770
|
this.device = device;
|
|
765
771
|
this.handle = this.props.handle || this.createHandle();
|
|
766
772
|
this.handle.label = this.props.id;
|
|
767
|
-
this.vs = (0,
|
|
768
|
-
this.fs = (0,
|
|
773
|
+
this.vs = (0, import_core8.cast)(props.vs);
|
|
774
|
+
this.fs = (0, import_core8.cast)(props.fs);
|
|
769
775
|
this._bufferSlots = getBufferSlots(this.props.layout, this.props.bufferMap);
|
|
770
776
|
this._buffers = new Array(Object.keys(this._bufferSlots).length).fill(null);
|
|
771
777
|
this._bindGroupLayout = this.handle.getBindGroupLayout(0);
|
|
@@ -773,15 +779,15 @@ var WebGPURenderPipeline = class extends import_api8.RenderPipeline {
|
|
|
773
779
|
createHandle() {
|
|
774
780
|
const descriptor = this._getRenderPipelineDescriptor();
|
|
775
781
|
const renderPipeline = this.device.handle.createRenderPipeline(descriptor);
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
782
|
+
import_core8.log.groupCollapsed(1, `new WebGPRenderPipeline(${this.id})`)();
|
|
783
|
+
import_core8.log.log(1, JSON.stringify(descriptor, null, 2))();
|
|
784
|
+
import_core8.log.groupEnd(1)();
|
|
779
785
|
return renderPipeline;
|
|
780
786
|
}
|
|
781
787
|
destroy() {
|
|
782
788
|
}
|
|
783
789
|
setIndexBuffer(indexBuffer) {
|
|
784
|
-
this._indexBuffer = (0,
|
|
790
|
+
this._indexBuffer = (0, import_core8.cast)(indexBuffer);
|
|
785
791
|
}
|
|
786
792
|
setAttributes(attributes) {
|
|
787
793
|
for (const [name, buffer] of Object.entries(attributes)) {
|
|
@@ -801,7 +807,7 @@ var WebGPURenderPipeline = class extends import_api8.RenderPipeline {
|
|
|
801
807
|
}
|
|
802
808
|
/** Set the bindings */
|
|
803
809
|
setBindings(bindings) {
|
|
804
|
-
if (!(0,
|
|
810
|
+
if (!(0, import_core8.isObjectEmpty)(this.props.bindings)) {
|
|
805
811
|
Object.assign(this.props.bindings, bindings);
|
|
806
812
|
this._bindGroup = getBindGroup(
|
|
807
813
|
this.device.handle,
|
|
@@ -812,7 +818,7 @@ var WebGPURenderPipeline = class extends import_api8.RenderPipeline {
|
|
|
812
818
|
}
|
|
813
819
|
}
|
|
814
820
|
setUniforms(uniforms) {
|
|
815
|
-
if (!(0,
|
|
821
|
+
if (!(0, import_core8.isObjectEmpty)(uniforms)) {
|
|
816
822
|
throw new Error("WebGPU does not support uniforms");
|
|
817
823
|
}
|
|
818
824
|
}
|
|
@@ -827,14 +833,14 @@ var WebGPURenderPipeline = class extends import_api8.RenderPipeline {
|
|
|
827
833
|
_getRenderPipelineDescriptor() {
|
|
828
834
|
var _a, _b;
|
|
829
835
|
const vertex = {
|
|
830
|
-
module: (0,
|
|
836
|
+
module: (0, import_core8.cast)(this.props.vs).handle,
|
|
831
837
|
entryPoint: this.props.vsEntryPoint || "main",
|
|
832
838
|
buffers: getVertexBufferLayout(this.props.layout, this.props.bufferMap)
|
|
833
839
|
};
|
|
834
840
|
let fragment;
|
|
835
841
|
if (this.props.fs) {
|
|
836
842
|
fragment = {
|
|
837
|
-
module: (0,
|
|
843
|
+
module: (0, import_core8.cast)(this.props.fs).handle,
|
|
838
844
|
entryPoint: this.props.fsEntryPoint || "main",
|
|
839
845
|
targets: [
|
|
840
846
|
{
|
|
@@ -845,8 +851,8 @@ var WebGPURenderPipeline = class extends import_api8.RenderPipeline {
|
|
|
845
851
|
};
|
|
846
852
|
}
|
|
847
853
|
switch (this.props.topology) {
|
|
848
|
-
case "triangle-fan":
|
|
849
|
-
case "line-loop":
|
|
854
|
+
case "triangle-fan-webgl":
|
|
855
|
+
case "line-loop-webgl":
|
|
850
856
|
throw new Error(`WebGPU does not support primitive topology ${this.props.topology}`);
|
|
851
857
|
default:
|
|
852
858
|
}
|
|
@@ -862,7 +868,7 @@ var WebGPURenderPipeline = class extends import_api8.RenderPipeline {
|
|
|
862
868
|
return descriptor;
|
|
863
869
|
}
|
|
864
870
|
draw(options) {
|
|
865
|
-
const webgpuRenderPass = (0,
|
|
871
|
+
const webgpuRenderPass = (0, import_core8.cast)(options.renderPass) || this.device.getDefaultRenderPass();
|
|
866
872
|
webgpuRenderPass.handle.setPipeline(this.handle);
|
|
867
873
|
const bindGroup = this._getBindGroup();
|
|
868
874
|
if (bindGroup) {
|
|
@@ -892,7 +898,7 @@ var WebGPURenderPipeline = class extends import_api8.RenderPipeline {
|
|
|
892
898
|
}
|
|
893
899
|
const buffers = this._getBuffers();
|
|
894
900
|
for (let i = 0; i < buffers.length; ++i) {
|
|
895
|
-
const buffer = (0,
|
|
901
|
+
const buffer = (0, import_core8.cast)(buffers[i]);
|
|
896
902
|
if (!buffer) {
|
|
897
903
|
const attribute = this.props.layout.attributes.find(
|
|
898
904
|
(attribute2) => attribute2.location === i
|
|
@@ -907,12 +913,12 @@ var WebGPURenderPipeline = class extends import_api8.RenderPipeline {
|
|
|
907
913
|
};
|
|
908
914
|
|
|
909
915
|
// src/adapter/resources/webgpu-compute-pipeline.ts
|
|
910
|
-
var
|
|
911
|
-
var WebGPUComputePipeline = class extends
|
|
916
|
+
var import_core9 = require("@luma.gl/core");
|
|
917
|
+
var WebGPUComputePipeline = class extends import_core9.ComputePipeline {
|
|
912
918
|
constructor(device, props) {
|
|
913
919
|
super(device, props);
|
|
914
920
|
this.device = device;
|
|
915
|
-
const module2 = (0,
|
|
921
|
+
const module2 = (0, import_core9.cast)(this.props.cs).handle;
|
|
916
922
|
this.handle = this.props.handle || this.device.handle.createComputePipeline({
|
|
917
923
|
label: this.props.id,
|
|
918
924
|
compute: {
|
|
@@ -930,8 +936,8 @@ var WebGPUComputePipeline = class extends import_api9.ComputePipeline {
|
|
|
930
936
|
};
|
|
931
937
|
|
|
932
938
|
// src/adapter/resources/webgpu-render-pass.ts
|
|
933
|
-
var
|
|
934
|
-
var WebGPURenderPass = class extends
|
|
939
|
+
var import_core10 = require("@luma.gl/core");
|
|
940
|
+
var WebGPURenderPass = class extends import_core10.RenderPass {
|
|
935
941
|
constructor(device, props = {}) {
|
|
936
942
|
super(device, props);
|
|
937
943
|
/** Active pipeline */
|
|
@@ -948,7 +954,7 @@ var WebGPURenderPass = class extends import_api10.RenderPass {
|
|
|
948
954
|
this.handle.end();
|
|
949
955
|
}
|
|
950
956
|
setPipeline(pipeline) {
|
|
951
|
-
this.pipeline = (0,
|
|
957
|
+
this.pipeline = (0, import_core10.cast)(pipeline);
|
|
952
958
|
this.handle.setPipeline(this.pipeline.handle);
|
|
953
959
|
}
|
|
954
960
|
/** Sets an array of bindings (uniform buffers, samplers, textures, ...) */
|
|
@@ -961,10 +967,10 @@ var WebGPURenderPass = class extends import_api10.RenderPass {
|
|
|
961
967
|
}
|
|
962
968
|
}
|
|
963
969
|
setIndexBuffer(buffer, indexFormat, offset = 0, size) {
|
|
964
|
-
this.handle.setIndexBuffer((0,
|
|
970
|
+
this.handle.setIndexBuffer((0, import_core10.cast)(buffer).handle, indexFormat, offset, size);
|
|
965
971
|
}
|
|
966
972
|
setVertexBuffer(slot, buffer, offset = 0) {
|
|
967
|
-
this.handle.setVertexBuffer(slot, (0,
|
|
973
|
+
this.handle.setVertexBuffer(slot, (0, import_core10.cast)(buffer).handle, offset);
|
|
968
974
|
}
|
|
969
975
|
draw(options) {
|
|
970
976
|
if (options.indexCount) {
|
|
@@ -1050,8 +1056,8 @@ var WebGPURenderPass = class extends import_api10.RenderPass {
|
|
|
1050
1056
|
};
|
|
1051
1057
|
|
|
1052
1058
|
// src/adapter/resources/webgpu-compute-pass.ts
|
|
1053
|
-
var
|
|
1054
|
-
var WebGPUComputePass = class extends
|
|
1059
|
+
var import_core11 = require("@luma.gl/core");
|
|
1060
|
+
var WebGPUComputePass = class extends import_core11.ComputePass {
|
|
1055
1061
|
constructor(device, props) {
|
|
1056
1062
|
var _a;
|
|
1057
1063
|
super(device, props);
|
|
@@ -1069,7 +1075,7 @@ var WebGPUComputePass = class extends import_api11.ComputePass {
|
|
|
1069
1075
|
this.handle.end();
|
|
1070
1076
|
}
|
|
1071
1077
|
setPipeline(pipeline) {
|
|
1072
|
-
const wgpuPipeline = (0,
|
|
1078
|
+
const wgpuPipeline = (0, import_core11.cast)(pipeline);
|
|
1073
1079
|
this.handle.setPipeline(wgpuPipeline.handle);
|
|
1074
1080
|
this._bindGroupLayout = wgpuPipeline._getBindGroupLayout();
|
|
1075
1081
|
}
|
|
@@ -1092,7 +1098,7 @@ var WebGPUComputePass = class extends import_api11.ComputePass {
|
|
|
1092
1098
|
* @param indirectOffset
|
|
1093
1099
|
*/
|
|
1094
1100
|
dispatchIndirect(indirectBuffer, indirectOffset = 0) {
|
|
1095
|
-
this.handle.dispatchWorkgroupsIndirect((0,
|
|
1101
|
+
this.handle.dispatchWorkgroupsIndirect((0, import_core11.cast)(indirectBuffer).handle, indirectOffset);
|
|
1096
1102
|
}
|
|
1097
1103
|
pushDebugGroup(groupLabel) {
|
|
1098
1104
|
this.handle.pushDebugGroup(groupLabel);
|
|
@@ -1109,11 +1115,11 @@ var WebGPUComputePass = class extends import_api11.ComputePass {
|
|
|
1109
1115
|
};
|
|
1110
1116
|
|
|
1111
1117
|
// src/adapter/webgpu-canvas-context.ts
|
|
1112
|
-
var
|
|
1118
|
+
var import_core13 = require("@luma.gl/core");
|
|
1113
1119
|
|
|
1114
1120
|
// src/adapter/resources/webgpu-framebuffer.ts
|
|
1115
|
-
var
|
|
1116
|
-
var WebGPUFramebuffer = class extends
|
|
1121
|
+
var import_core12 = require("@luma.gl/core");
|
|
1122
|
+
var WebGPUFramebuffer = class extends import_core12.Framebuffer {
|
|
1117
1123
|
constructor(device, props) {
|
|
1118
1124
|
super(device, props);
|
|
1119
1125
|
this.device = device;
|
|
@@ -1122,7 +1128,7 @@ var WebGPUFramebuffer = class extends import_api12.Framebuffer {
|
|
|
1122
1128
|
};
|
|
1123
1129
|
|
|
1124
1130
|
// src/adapter/webgpu-canvas-context.ts
|
|
1125
|
-
var WebGPUCanvasContext = class extends
|
|
1131
|
+
var WebGPUCanvasContext = class extends import_core13.CanvasContext {
|
|
1126
1132
|
constructor(device, adapter, props) {
|
|
1127
1133
|
super(props);
|
|
1128
1134
|
this.depthStencilFormat = "depth24plus";
|
|
@@ -1172,7 +1178,7 @@ var WebGPUCanvasContext = class extends import_api13.CanvasContext {
|
|
|
1172
1178
|
colorSpace: this.props.colorSpace,
|
|
1173
1179
|
alphaMode: this.props.alphaMode
|
|
1174
1180
|
});
|
|
1175
|
-
|
|
1181
|
+
import_core13.log.log(1, `Resized to ${this.width}x${this.height}px`)();
|
|
1176
1182
|
}
|
|
1177
1183
|
}
|
|
1178
1184
|
resize(options) {
|
|
@@ -1194,9 +1200,9 @@ var WebGPUCanvasContext = class extends import_api13.CanvasContext {
|
|
|
1194
1200
|
};
|
|
1195
1201
|
|
|
1196
1202
|
// src/adapter/webgpu-device.ts
|
|
1197
|
-
var _WebGPUDevice = class extends
|
|
1203
|
+
var _WebGPUDevice = class extends import_core14.Device {
|
|
1198
1204
|
constructor(device, adapter, props) {
|
|
1199
|
-
super(__spreadProps(__spreadValues({}, props), { id: props.id || (0,
|
|
1205
|
+
super(__spreadProps(__spreadValues({}, props), { id: props.id || (0, import_core14.uid)("webgpu-device") }));
|
|
1200
1206
|
this.canvasContext = null;
|
|
1201
1207
|
this.commandEncoder = null;
|
|
1202
1208
|
this.renderPass = null;
|
|
@@ -1239,7 +1245,7 @@ var _WebGPUDevice = class extends import_api14.Device {
|
|
|
1239
1245
|
"WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu"
|
|
1240
1246
|
);
|
|
1241
1247
|
}
|
|
1242
|
-
|
|
1248
|
+
import_core14.log.groupCollapsed(1, "WebGPUDevice created")();
|
|
1243
1249
|
const adapter = yield navigator.gpu.requestAdapter({
|
|
1244
1250
|
powerPreference: "high-performance"
|
|
1245
1251
|
// forceSoftware: false
|
|
@@ -1248,21 +1254,21 @@ var _WebGPUDevice = class extends import_api14.Device {
|
|
|
1248
1254
|
throw new Error("Failed to request WebGPU adapter");
|
|
1249
1255
|
}
|
|
1250
1256
|
const adapterInfo = yield adapter.requestAdapterInfo();
|
|
1251
|
-
|
|
1257
|
+
import_core14.log.probe(1, "Adapter available", adapterInfo)();
|
|
1252
1258
|
const gpuDevice = yield adapter.requestDevice({
|
|
1253
1259
|
requiredFeatures: adapter.features
|
|
1254
1260
|
// TODO ensure we obtain best limits
|
|
1255
1261
|
// requiredLimits: adapter.limits
|
|
1256
1262
|
});
|
|
1257
|
-
|
|
1263
|
+
import_core14.log.probe(1, "GPUDevice available")();
|
|
1258
1264
|
if (typeof props.canvas === "string") {
|
|
1259
|
-
yield
|
|
1260
|
-
|
|
1265
|
+
yield import_core14.CanvasContext.pageLoaded;
|
|
1266
|
+
import_core14.log.probe(1, "DOM is loaded")();
|
|
1261
1267
|
}
|
|
1262
1268
|
const device = new _WebGPUDevice(gpuDevice, adapter, props);
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1269
|
+
import_core14.log.probe(1, "Device created", device.info)();
|
|
1270
|
+
import_core14.log.table(1, device.info)();
|
|
1271
|
+
import_core14.log.groupEnd(1)();
|
|
1266
1272
|
return device;
|
|
1267
1273
|
});
|
|
1268
1274
|
}
|