@luma.gl/webgpu 9.0.0-alpha.30 → 9.0.0-alpha.31
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/adapter/helpers/get-bind-group.d.ts +3 -3
- package/dist/adapter/helpers/get-bind-group.d.ts.map +1 -1
- package/dist/adapter/helpers/get-bind-group.js +6 -6
- package/dist/adapter/helpers/get-bind-group.js.map +1 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts +4 -4
- package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.js +17 -17
- package/dist/adapter/helpers/get-vertex-buffer-layout.js.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-render-pipeline.js +5 -5
- package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -1
- package/dist/dist.dev.js +152 -140
- package/dist/index.cjs +34 -32
- package/dist.min.js +4 -4
- package/package.json +3 -3
- package/src/adapter/helpers/get-bind-group.ts +18 -8
- package/src/adapter/helpers/get-vertex-buffer-layout.ts +39 -27
- package/src/adapter/resources/webgpu-command-encoder.ts +1 -1
- package/src/adapter/resources/webgpu-render-pipeline.ts +6 -6
package/dist/dist.dev.js
CHANGED
|
@@ -820,11 +820,6 @@ var __exports__ = (() => {
|
|
|
820
820
|
}
|
|
821
821
|
|
|
822
822
|
// ../core/src/adapter/resources/resource.ts
|
|
823
|
-
var DEFAULT_RESOURCE_PROPS = {
|
|
824
|
-
id: "undefined",
|
|
825
|
-
handle: void 0,
|
|
826
|
-
userData: void 0
|
|
827
|
-
};
|
|
828
823
|
var Resource = class {
|
|
829
824
|
/** props.id, for debugging. */
|
|
830
825
|
userData = {};
|
|
@@ -936,7 +931,11 @@ var __exports__ = (() => {
|
|
|
936
931
|
}
|
|
937
932
|
};
|
|
938
933
|
/** Default properties for resource */
|
|
939
|
-
__publicField(Resource, "defaultProps",
|
|
934
|
+
__publicField(Resource, "defaultProps", {
|
|
935
|
+
id: "undefined",
|
|
936
|
+
handle: void 0,
|
|
937
|
+
userData: void 0
|
|
938
|
+
});
|
|
940
939
|
function selectivelyMerge(props, defaultProps) {
|
|
941
940
|
const mergedProps = {
|
|
942
941
|
...defaultProps
|
|
@@ -950,16 +949,6 @@ var __exports__ = (() => {
|
|
|
950
949
|
}
|
|
951
950
|
|
|
952
951
|
// ../core/src/adapter/resources/buffer.ts
|
|
953
|
-
var DEFAULT_BUFFER_PROPS = {
|
|
954
|
-
...DEFAULT_RESOURCE_PROPS,
|
|
955
|
-
usage: 0,
|
|
956
|
-
// Buffer.COPY_DST | Buffer.COPY_SRC
|
|
957
|
-
byteLength: 0,
|
|
958
|
-
byteOffset: 0,
|
|
959
|
-
data: null,
|
|
960
|
-
indexType: "uint16",
|
|
961
|
-
mappedAtCreation: false
|
|
962
|
-
};
|
|
963
952
|
var _Buffer = class extends Resource {
|
|
964
953
|
get [Symbol.toStringTag]() {
|
|
965
954
|
return "Buffer";
|
|
@@ -976,7 +965,7 @@ var __exports__ = (() => {
|
|
|
976
965
|
deducedProps.indexType = "uint16";
|
|
977
966
|
}
|
|
978
967
|
}
|
|
979
|
-
super(device, deducedProps,
|
|
968
|
+
super(device, deducedProps, _Buffer.defaultProps);
|
|
980
969
|
}
|
|
981
970
|
write(data, byteOffset) {
|
|
982
971
|
throw new Error("not implemented");
|
|
@@ -1034,6 +1023,16 @@ var __exports__ = (() => {
|
|
|
1034
1023
|
// abstract unmap(): void;
|
|
1035
1024
|
};
|
|
1036
1025
|
var Buffer2 = _Buffer;
|
|
1026
|
+
__publicField(Buffer2, "defaultProps", {
|
|
1027
|
+
...Resource.defaultProps,
|
|
1028
|
+
usage: 0,
|
|
1029
|
+
// Buffer.COPY_DST | Buffer.COPY_SRC
|
|
1030
|
+
byteLength: 0,
|
|
1031
|
+
byteOffset: 0,
|
|
1032
|
+
data: null,
|
|
1033
|
+
indexType: "uint16",
|
|
1034
|
+
mappedAtCreation: false
|
|
1035
|
+
});
|
|
1037
1036
|
// Usage Flags
|
|
1038
1037
|
__publicField(Buffer2, "MAP_READ", 1);
|
|
1039
1038
|
__publicField(Buffer2, "MAP_WRITE", 2);
|
|
@@ -1083,8 +1082,14 @@ var __exports__ = (() => {
|
|
|
1083
1082
|
};
|
|
1084
1083
|
this.id = this.props.id || uid(this[Symbol.toStringTag].toLowerCase());
|
|
1085
1084
|
}
|
|
1085
|
+
/** id of this device, primarily for debugging */
|
|
1086
|
+
/** stats */
|
|
1086
1087
|
statsManager = lumaStats;
|
|
1088
|
+
/** A copy of the device props */
|
|
1089
|
+
/** Available for the application to store data on the device */
|
|
1087
1090
|
userData = {};
|
|
1091
|
+
/** Used by other luma.gl modules to store data on the device */
|
|
1092
|
+
_lumaData = {};
|
|
1088
1093
|
// Capabilities
|
|
1089
1094
|
/** Information about the device (vendor, versions etc) */
|
|
1090
1095
|
/** Optional capability discovery */
|
|
@@ -1431,25 +1436,7 @@ var __exports__ = (() => {
|
|
|
1431
1436
|
}
|
|
1432
1437
|
|
|
1433
1438
|
// ../core/src/adapter/resources/texture.ts
|
|
1434
|
-
var
|
|
1435
|
-
...DEFAULT_RESOURCE_PROPS,
|
|
1436
|
-
data: null,
|
|
1437
|
-
dimension: "2d",
|
|
1438
|
-
format: "rgba8unorm",
|
|
1439
|
-
width: void 0,
|
|
1440
|
-
height: void 0,
|
|
1441
|
-
depth: 1,
|
|
1442
|
-
mipmaps: true,
|
|
1443
|
-
sampler: {},
|
|
1444
|
-
// type: undefined,
|
|
1445
|
-
compressed: false,
|
|
1446
|
-
// mipLevels: 1,
|
|
1447
|
-
usage: 0,
|
|
1448
|
-
mipLevels: void 0,
|
|
1449
|
-
samples: void 0,
|
|
1450
|
-
type: void 0
|
|
1451
|
-
};
|
|
1452
|
-
var Texture = class extends Resource {
|
|
1439
|
+
var _Texture = class extends Resource {
|
|
1453
1440
|
get [Symbol.toStringTag]() {
|
|
1454
1441
|
return "Texture";
|
|
1455
1442
|
}
|
|
@@ -1459,7 +1446,7 @@ var __exports__ = (() => {
|
|
|
1459
1446
|
/** height in pixels of this texture */
|
|
1460
1447
|
/** depth of this texture */
|
|
1461
1448
|
/** Default sampler for this texture */
|
|
1462
|
-
constructor(device, props, defaultProps =
|
|
1449
|
+
constructor(device, props, defaultProps = _Texture.defaultProps) {
|
|
1463
1450
|
super(device, props, defaultProps);
|
|
1464
1451
|
this.dimension = this.props.dimension;
|
|
1465
1452
|
this.format = this.props.format;
|
|
@@ -1468,6 +1455,26 @@ var __exports__ = (() => {
|
|
|
1468
1455
|
this.depth = this.props.depth;
|
|
1469
1456
|
}
|
|
1470
1457
|
};
|
|
1458
|
+
var Texture = _Texture;
|
|
1459
|
+
__publicField(Texture, "defaultProps", {
|
|
1460
|
+
...Resource.defaultProps,
|
|
1461
|
+
data: null,
|
|
1462
|
+
dimension: "2d",
|
|
1463
|
+
format: "rgba8unorm",
|
|
1464
|
+
width: void 0,
|
|
1465
|
+
height: void 0,
|
|
1466
|
+
depth: 1,
|
|
1467
|
+
mipmaps: true,
|
|
1468
|
+
sampler: {},
|
|
1469
|
+
// type: undefined,
|
|
1470
|
+
compressed: false,
|
|
1471
|
+
// mipLevels: 1,
|
|
1472
|
+
usage: 0,
|
|
1473
|
+
// usage: GPUTextureUsage.COPY_DST
|
|
1474
|
+
mipLevels: void 0,
|
|
1475
|
+
samples: void 0,
|
|
1476
|
+
type: void 0
|
|
1477
|
+
});
|
|
1471
1478
|
__publicField(Texture, "COPY_SRC", 1);
|
|
1472
1479
|
__publicField(Texture, "COPY_DST", 2);
|
|
1473
1480
|
__publicField(Texture, "TEXTURE_BINDING", 4);
|
|
@@ -1475,43 +1482,54 @@ var __exports__ = (() => {
|
|
|
1475
1482
|
__publicField(Texture, "RENDER_ATTACHMENT", 16);
|
|
1476
1483
|
|
|
1477
1484
|
// ../core/src/adapter/resources/external-texture.ts
|
|
1478
|
-
var
|
|
1479
|
-
...DEFAULT_RESOURCE_PROPS,
|
|
1480
|
-
source: null,
|
|
1481
|
-
colorSpace: "srgb"
|
|
1482
|
-
};
|
|
1483
|
-
var ExternalTexture = class extends Resource {
|
|
1485
|
+
var _ExternalTexture = class extends Resource {
|
|
1484
1486
|
get [Symbol.toStringTag]() {
|
|
1485
1487
|
return "ExternalTexture";
|
|
1486
1488
|
}
|
|
1487
1489
|
constructor(device, props) {
|
|
1488
|
-
super(device, props,
|
|
1490
|
+
super(device, props, _ExternalTexture.defaultProps);
|
|
1489
1491
|
}
|
|
1490
1492
|
};
|
|
1493
|
+
var ExternalTexture = _ExternalTexture;
|
|
1494
|
+
__publicField(ExternalTexture, "defaultProps", {
|
|
1495
|
+
...Resource.defaultProps,
|
|
1496
|
+
source: null,
|
|
1497
|
+
colorSpace: "srgb"
|
|
1498
|
+
});
|
|
1491
1499
|
|
|
1492
1500
|
// ../core/src/adapter/resources/shader.ts
|
|
1493
|
-
var
|
|
1494
|
-
...DEFAULT_RESOURCE_PROPS,
|
|
1495
|
-
stage: "vertex",
|
|
1496
|
-
source: "",
|
|
1497
|
-
sourceMap: null,
|
|
1498
|
-
language: "glsl",
|
|
1499
|
-
shaderType: 0
|
|
1500
|
-
};
|
|
1501
|
-
var Shader = class extends Resource {
|
|
1501
|
+
var _Shader = class extends Resource {
|
|
1502
1502
|
get [Symbol.toStringTag]() {
|
|
1503
1503
|
return "Shader";
|
|
1504
1504
|
}
|
|
1505
1505
|
constructor(device, props) {
|
|
1506
|
-
super(device, props,
|
|
1506
|
+
super(device, props, _Shader.defaultProps);
|
|
1507
1507
|
this.stage = this.props.stage;
|
|
1508
1508
|
this.source = this.props.source;
|
|
1509
1509
|
}
|
|
1510
1510
|
};
|
|
1511
|
+
var Shader = _Shader;
|
|
1512
|
+
__publicField(Shader, "defaultProps", {
|
|
1513
|
+
...Resource.defaultProps,
|
|
1514
|
+
stage: "vertex",
|
|
1515
|
+
source: "",
|
|
1516
|
+
sourceMap: null,
|
|
1517
|
+
language: "glsl",
|
|
1518
|
+
shaderType: 0
|
|
1519
|
+
});
|
|
1511
1520
|
|
|
1512
1521
|
// ../core/src/adapter/resources/sampler.ts
|
|
1513
|
-
var
|
|
1514
|
-
|
|
1522
|
+
var _Sampler = class extends Resource {
|
|
1523
|
+
get [Symbol.toStringTag]() {
|
|
1524
|
+
return "Sampler";
|
|
1525
|
+
}
|
|
1526
|
+
constructor(device, props) {
|
|
1527
|
+
super(device, props, _Sampler.defaultProps);
|
|
1528
|
+
}
|
|
1529
|
+
};
|
|
1530
|
+
var Sampler = _Sampler;
|
|
1531
|
+
__publicField(Sampler, "defaultProps", {
|
|
1532
|
+
...Resource.defaultProps,
|
|
1515
1533
|
type: "color-sampler",
|
|
1516
1534
|
addressModeU: "clamp-to-edge",
|
|
1517
1535
|
addressModeV: "clamp-to-edge",
|
|
@@ -1524,27 +1542,10 @@ var __exports__ = (() => {
|
|
|
1524
1542
|
// Per WebGPU spec
|
|
1525
1543
|
compare: "less-equal",
|
|
1526
1544
|
maxAnisotropy: 1
|
|
1527
|
-
};
|
|
1528
|
-
var Sampler = class extends Resource {
|
|
1529
|
-
get [Symbol.toStringTag]() {
|
|
1530
|
-
return "Sampler";
|
|
1531
|
-
}
|
|
1532
|
-
constructor(device, props) {
|
|
1533
|
-
super(device, props, DEFAULT_SAMPLER_PROPS);
|
|
1534
|
-
}
|
|
1535
|
-
};
|
|
1545
|
+
});
|
|
1536
1546
|
|
|
1537
1547
|
// ../core/src/adapter/resources/framebuffer.ts
|
|
1538
|
-
var
|
|
1539
|
-
...DEFAULT_RESOURCE_PROPS,
|
|
1540
|
-
width: 1,
|
|
1541
|
-
height: 1,
|
|
1542
|
-
colorAttachments: [],
|
|
1543
|
-
// ['rgba8unorm-unsized'],
|
|
1544
|
-
depthStencilAttachment: null
|
|
1545
|
-
// 'depth24plus-stencil8'
|
|
1546
|
-
};
|
|
1547
|
-
var Framebuffer = class extends Resource {
|
|
1548
|
+
var _Framebuffer = class extends Resource {
|
|
1548
1549
|
get [Symbol.toStringTag]() {
|
|
1549
1550
|
return "Framebuffer";
|
|
1550
1551
|
}
|
|
@@ -1555,7 +1556,7 @@ var __exports__ = (() => {
|
|
|
1555
1556
|
/** Depth-stencil attachment, if provided */
|
|
1556
1557
|
depthStencilAttachment = null;
|
|
1557
1558
|
constructor(device, props = {}) {
|
|
1558
|
-
super(device, props,
|
|
1559
|
+
super(device, props, _Framebuffer.defaultProps);
|
|
1559
1560
|
this.width = this.props.width;
|
|
1560
1561
|
this.height = this.props.height;
|
|
1561
1562
|
}
|
|
@@ -1721,10 +1722,36 @@ var __exports__ = (() => {
|
|
|
1721
1722
|
}
|
|
1722
1723
|
*/
|
|
1723
1724
|
};
|
|
1725
|
+
var Framebuffer = _Framebuffer;
|
|
1726
|
+
__publicField(Framebuffer, "defaultProps", {
|
|
1727
|
+
...Resource.defaultProps,
|
|
1728
|
+
width: 1,
|
|
1729
|
+
height: 1,
|
|
1730
|
+
colorAttachments: [],
|
|
1731
|
+
// ['rgba8unorm-unsized'],
|
|
1732
|
+
depthStencilAttachment: null
|
|
1733
|
+
// 'depth24plus-stencil8'
|
|
1734
|
+
});
|
|
1724
1735
|
|
|
1725
1736
|
// ../core/src/adapter/resources/render-pipeline.ts
|
|
1726
|
-
var
|
|
1727
|
-
|
|
1737
|
+
var _RenderPipeline = class extends Resource {
|
|
1738
|
+
get [Symbol.toStringTag]() {
|
|
1739
|
+
return "RenderPipeline";
|
|
1740
|
+
}
|
|
1741
|
+
hash = "";
|
|
1742
|
+
constructor(device, props) {
|
|
1743
|
+
super(device, props, _RenderPipeline.defaultProps);
|
|
1744
|
+
}
|
|
1745
|
+
/** Set attributes (stored on pipeline and set before each call) */
|
|
1746
|
+
/** Set attributes (stored on pipeline and set before each call) */
|
|
1747
|
+
/** Set constant attributes (WebGL only) */
|
|
1748
|
+
/** Set bindings (stored on pipeline and set before each call) */
|
|
1749
|
+
/** Uniforms (only supported on WebGL devices. Reset before each call to enable pipeline sharing) */
|
|
1750
|
+
/** Draw call */
|
|
1751
|
+
};
|
|
1752
|
+
var RenderPipeline = _RenderPipeline;
|
|
1753
|
+
__publicField(RenderPipeline, "defaultProps", {
|
|
1754
|
+
...Resource.defaultProps,
|
|
1728
1755
|
vs: null,
|
|
1729
1756
|
vsEntryPoint: "",
|
|
1730
1757
|
// main
|
|
@@ -1733,54 +1760,36 @@ var __exports__ = (() => {
|
|
|
1733
1760
|
fsEntryPoint: "",
|
|
1734
1761
|
// main
|
|
1735
1762
|
fsConstants: {},
|
|
1736
|
-
|
|
1737
|
-
|
|
1763
|
+
shaderLayout: null,
|
|
1764
|
+
bufferLayout: [],
|
|
1738
1765
|
topology: "triangle-list",
|
|
1739
|
-
// targets:
|
|
1740
1766
|
parameters: {},
|
|
1741
|
-
bufferMap: [],
|
|
1742
1767
|
vertexCount: 0,
|
|
1743
1768
|
instanceCount: 0,
|
|
1744
1769
|
indices: null,
|
|
1745
1770
|
attributes: {},
|
|
1746
1771
|
bindings: {},
|
|
1747
1772
|
uniforms: {}
|
|
1748
|
-
};
|
|
1749
|
-
var RenderPipeline = class extends Resource {
|
|
1750
|
-
get [Symbol.toStringTag]() {
|
|
1751
|
-
return "RenderPipeline";
|
|
1752
|
-
}
|
|
1753
|
-
hash = "";
|
|
1754
|
-
constructor(device, props) {
|
|
1755
|
-
super(device, props, DEFAULT_RENDER_PIPELINE_PROPS);
|
|
1756
|
-
}
|
|
1757
|
-
};
|
|
1758
|
-
/** Set attributes (stored on pipeline and set before each call) */
|
|
1759
|
-
/** Set attributes (stored on pipeline and set before each call) */
|
|
1760
|
-
/** Set constant attributes (WebGL only) */
|
|
1761
|
-
/** Set bindings (stored on pipeline and set before each call) */
|
|
1762
|
-
/** Uniforms (only supported on WebGL devices. Reset before each call to enable pipeline sharing) */
|
|
1763
|
-
/** Draw call */
|
|
1764
|
-
/** Private "export" for Model class */
|
|
1765
|
-
__publicField(RenderPipeline, "_DEFAULT_PROPS", DEFAULT_RENDER_PIPELINE_PROPS);
|
|
1773
|
+
});
|
|
1766
1774
|
|
|
1767
1775
|
// ../core/src/adapter/resources/compute-pipeline.ts
|
|
1768
|
-
var
|
|
1769
|
-
...DEFAULT_RESOURCE_PROPS,
|
|
1770
|
-
// cs: undefined,
|
|
1771
|
-
// csEntryPoint: undefined,
|
|
1772
|
-
csConstants: {},
|
|
1773
|
-
layout: []
|
|
1774
|
-
};
|
|
1775
|
-
var ComputePipeline = class extends Resource {
|
|
1776
|
+
var _ComputePipeline = class extends Resource {
|
|
1776
1777
|
get [Symbol.toStringTag]() {
|
|
1777
1778
|
return "ComputePipeline";
|
|
1778
1779
|
}
|
|
1779
1780
|
hash = "";
|
|
1780
1781
|
constructor(device, props) {
|
|
1781
|
-
super(device, props,
|
|
1782
|
+
super(device, props, _ComputePipeline.defaultProps);
|
|
1782
1783
|
}
|
|
1783
1784
|
};
|
|
1785
|
+
var ComputePipeline = _ComputePipeline;
|
|
1786
|
+
__publicField(ComputePipeline, "defaultProps", {
|
|
1787
|
+
...Resource.defaultProps,
|
|
1788
|
+
cs: void 0,
|
|
1789
|
+
csEntryPoint: void 0,
|
|
1790
|
+
csConstants: {},
|
|
1791
|
+
shaderLayout: []
|
|
1792
|
+
});
|
|
1784
1793
|
|
|
1785
1794
|
// ../core/src/adapter/resources/render-pass.ts
|
|
1786
1795
|
var _RenderPass = class extends Resource {
|
|
@@ -1845,7 +1854,7 @@ var __exports__ = (() => {
|
|
|
1845
1854
|
return "ComputePass";
|
|
1846
1855
|
}
|
|
1847
1856
|
constructor(device, props) {
|
|
1848
|
-
super(device, props,
|
|
1857
|
+
super(device, props, Resource.defaultProps);
|
|
1849
1858
|
}
|
|
1850
1859
|
/** Sets an array of bindings (uniform buffers, samplers, textures, ...) */
|
|
1851
1860
|
// abstract setBindings(bindings: Binding[]): void;
|
|
@@ -1864,8 +1873,11 @@ var __exports__ = (() => {
|
|
|
1864
1873
|
// beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
|
|
1865
1874
|
// endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
|
|
1866
1875
|
};
|
|
1876
|
+
__publicField(ComputePass, "defaultProps", {
|
|
1877
|
+
...Resource.defaultProps
|
|
1878
|
+
});
|
|
1867
1879
|
|
|
1868
|
-
// ../core/src/adapter/utils/decode-data-type.ts
|
|
1880
|
+
// ../core/src/adapter/type-utils/decode-data-type.ts
|
|
1869
1881
|
function decodeVertexType(type) {
|
|
1870
1882
|
const dataType = TYPE_MAP[type];
|
|
1871
1883
|
const bytes = getDataTypeBytes(dataType);
|
|
@@ -1909,7 +1921,7 @@ var __exports__ = (() => {
|
|
|
1909
1921
|
sint32: 4
|
|
1910
1922
|
};
|
|
1911
1923
|
|
|
1912
|
-
// ../core/src/adapter/utils/decode-vertex-format.ts
|
|
1924
|
+
// ../core/src/adapter/type-utils/decode-vertex-format.ts
|
|
1913
1925
|
function decodeVertexFormat(format) {
|
|
1914
1926
|
let webglOnly;
|
|
1915
1927
|
if (format.endsWith("-webgl")) {
|
|
@@ -2471,24 +2483,24 @@ var __exports__ = (() => {
|
|
|
2471
2483
|
}
|
|
2472
2484
|
|
|
2473
2485
|
// src/adapter/helpers/get-bind-group.ts
|
|
2474
|
-
function getBindGroup(device, bindGroupLayout,
|
|
2475
|
-
const entries = getBindGroupEntries(bindings,
|
|
2486
|
+
function getBindGroup(device, bindGroupLayout, shaderLayout, bindings) {
|
|
2487
|
+
const entries = getBindGroupEntries(bindings, shaderLayout);
|
|
2476
2488
|
return device.createBindGroup({
|
|
2477
2489
|
layout: bindGroupLayout,
|
|
2478
2490
|
entries
|
|
2479
2491
|
});
|
|
2480
2492
|
}
|
|
2481
|
-
function getShaderLayoutBinding(
|
|
2482
|
-
const bindingLayout =
|
|
2493
|
+
function getShaderLayoutBinding(shaderLayout, bindingName) {
|
|
2494
|
+
const bindingLayout = shaderLayout.bindings.find((binding) => binding.name === bindingName);
|
|
2483
2495
|
if (!bindingLayout) {
|
|
2484
2496
|
log.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();
|
|
2485
2497
|
}
|
|
2486
2498
|
return bindingLayout;
|
|
2487
2499
|
}
|
|
2488
|
-
function getBindGroupEntries(bindings,
|
|
2500
|
+
function getBindGroupEntries(bindings, shaderLayout) {
|
|
2489
2501
|
const entries = [];
|
|
2490
2502
|
for (const [bindingName, value] of Object.entries(bindings)) {
|
|
2491
|
-
const bindingLayout = getShaderLayoutBinding(
|
|
2503
|
+
const bindingLayout = getShaderLayoutBinding(shaderLayout, bindingName);
|
|
2492
2504
|
if (bindingLayout) {
|
|
2493
2505
|
entries.push(getBindGroupEntry(value, bindingLayout.location));
|
|
2494
2506
|
}
|
|
@@ -2525,31 +2537,31 @@ var __exports__ = (() => {
|
|
|
2525
2537
|
}
|
|
2526
2538
|
return format;
|
|
2527
2539
|
}
|
|
2528
|
-
function getVertexBufferLayout(
|
|
2540
|
+
function getVertexBufferLayout(shaderLayout, bufferLayout) {
|
|
2529
2541
|
const vertexBufferLayouts = [];
|
|
2530
2542
|
const usedAttributes = /* @__PURE__ */ new Set();
|
|
2531
|
-
for (const mapping of
|
|
2543
|
+
for (const mapping of bufferLayout) {
|
|
2532
2544
|
const vertexAttributes = [];
|
|
2533
2545
|
let stepMode = "vertex";
|
|
2534
2546
|
let byteStride = 0;
|
|
2535
2547
|
const byteOffset = mapping.byteOffset || 0;
|
|
2536
|
-
if (
|
|
2548
|
+
if (mapping.attributes) {
|
|
2537
2549
|
for (const interleaved of mapping.attributes) {
|
|
2538
|
-
const attributeLayout = findAttributeLayout(
|
|
2550
|
+
const attributeLayout = findAttributeLayout(shaderLayout, interleaved.name, usedAttributes);
|
|
2539
2551
|
stepMode = attributeLayout.stepMode || "vertex";
|
|
2540
2552
|
vertexAttributes.push({
|
|
2541
|
-
format: getWebGPUVertexFormat(
|
|
2553
|
+
format: getWebGPUVertexFormat(interleaved.format || mapping.format),
|
|
2542
2554
|
offset: byteOffset + byteStride,
|
|
2543
2555
|
shaderLocation: attributeLayout.location
|
|
2544
2556
|
});
|
|
2545
|
-
byteStride += decodeVertexFormat(
|
|
2557
|
+
byteStride += decodeVertexFormat(mapping.format).byteLength;
|
|
2546
2558
|
}
|
|
2547
2559
|
} else {
|
|
2548
|
-
const attributeLayout = findAttributeLayout(
|
|
2549
|
-
byteStride = decodeVertexFormat(
|
|
2560
|
+
const attributeLayout = findAttributeLayout(shaderLayout, mapping.name, usedAttributes);
|
|
2561
|
+
byteStride = decodeVertexFormat(mapping.format).byteLength;
|
|
2550
2562
|
stepMode = attributeLayout.stepMode || "vertex";
|
|
2551
2563
|
vertexAttributes.push({
|
|
2552
|
-
format: getWebGPUVertexFormat(
|
|
2564
|
+
format: getWebGPUVertexFormat(mapping.format),
|
|
2553
2565
|
offset: byteOffset,
|
|
2554
2566
|
shaderLocation: attributeLayout.location
|
|
2555
2567
|
});
|
|
@@ -2560,13 +2572,13 @@ var __exports__ = (() => {
|
|
|
2560
2572
|
attributes: vertexAttributes
|
|
2561
2573
|
});
|
|
2562
2574
|
}
|
|
2563
|
-
for (const attribute of
|
|
2575
|
+
for (const attribute of shaderLayout.attributes) {
|
|
2564
2576
|
if (!usedAttributes.has(attribute.name)) {
|
|
2565
2577
|
vertexBufferLayouts.push({
|
|
2566
|
-
arrayStride: decodeVertexFormat(
|
|
2578
|
+
arrayStride: decodeVertexFormat("float32x3").byteLength,
|
|
2567
2579
|
stepMode: attribute.stepMode || "vertex",
|
|
2568
2580
|
attributes: [{
|
|
2569
|
-
format: getWebGPUVertexFormat(
|
|
2581
|
+
format: getWebGPUVertexFormat("float32x3"),
|
|
2570
2582
|
offset: 0,
|
|
2571
2583
|
shaderLocation: attribute.location
|
|
2572
2584
|
}]
|
|
@@ -2575,11 +2587,11 @@ var __exports__ = (() => {
|
|
|
2575
2587
|
}
|
|
2576
2588
|
return vertexBufferLayouts;
|
|
2577
2589
|
}
|
|
2578
|
-
function getBufferSlots(
|
|
2590
|
+
function getBufferSlots(shaderLayout, bufferLayout) {
|
|
2579
2591
|
const usedAttributes = /* @__PURE__ */ new Set();
|
|
2580
2592
|
let bufferSlot = 0;
|
|
2581
2593
|
const bufferSlots = {};
|
|
2582
|
-
for (const mapping of
|
|
2594
|
+
for (const mapping of bufferLayout) {
|
|
2583
2595
|
if ("attributes" in mapping) {
|
|
2584
2596
|
for (const interleaved of mapping.attributes) {
|
|
2585
2597
|
usedAttributes.add(interleaved.name);
|
|
@@ -2589,15 +2601,15 @@ var __exports__ = (() => {
|
|
|
2589
2601
|
}
|
|
2590
2602
|
bufferSlots[mapping.name] = bufferSlot++;
|
|
2591
2603
|
}
|
|
2592
|
-
for (const attribute of
|
|
2604
|
+
for (const attribute of shaderLayout.attributes) {
|
|
2593
2605
|
if (!usedAttributes.has(attribute.name)) {
|
|
2594
2606
|
bufferSlots[attribute.name] = bufferSlot++;
|
|
2595
2607
|
}
|
|
2596
2608
|
}
|
|
2597
2609
|
return bufferSlots;
|
|
2598
2610
|
}
|
|
2599
|
-
function findAttributeLayout(
|
|
2600
|
-
const attribute =
|
|
2611
|
+
function findAttributeLayout(shaderLayout, name, attributeNames) {
|
|
2612
|
+
const attribute = shaderLayout.attributes.find((attribute2) => attribute2.name === name);
|
|
2601
2613
|
if (!attribute) {
|
|
2602
2614
|
throw new Error(`Unknown attribute ${name}`);
|
|
2603
2615
|
}
|
|
@@ -2623,7 +2635,7 @@ var __exports__ = (() => {
|
|
|
2623
2635
|
this.handle.label = this.props.id;
|
|
2624
2636
|
this.vs = cast(props.vs);
|
|
2625
2637
|
this.fs = cast(props.fs);
|
|
2626
|
-
this._bufferSlots = getBufferSlots(this.props.
|
|
2638
|
+
this._bufferSlots = getBufferSlots(this.props.shaderLayout, this.props.bufferLayout);
|
|
2627
2639
|
this._buffers = new Array(Object.keys(this._bufferSlots).length).fill(null);
|
|
2628
2640
|
this._bindGroupLayout = this.handle.getBindGroupLayout(0);
|
|
2629
2641
|
}
|
|
@@ -2652,13 +2664,13 @@ var __exports__ = (() => {
|
|
|
2652
2664
|
}
|
|
2653
2665
|
/** Constant attributes are not available in WebGPU */
|
|
2654
2666
|
setConstantAttributes(attributes) {
|
|
2655
|
-
|
|
2667
|
+
throw new Error("not implemented");
|
|
2656
2668
|
}
|
|
2657
2669
|
/** Set the bindings */
|
|
2658
2670
|
setBindings(bindings) {
|
|
2659
2671
|
if (!isObjectEmpty(this.props.bindings)) {
|
|
2660
2672
|
Object.assign(this.props.bindings, bindings);
|
|
2661
|
-
this._bindGroup = getBindGroup(this.device.handle, this._bindGroupLayout, this.props.
|
|
2673
|
+
this._bindGroup = getBindGroup(this.device.handle, this._bindGroupLayout, this.props.shaderLayout, this.props.bindings);
|
|
2662
2674
|
}
|
|
2663
2675
|
}
|
|
2664
2676
|
setUniforms(uniforms) {
|
|
@@ -2678,7 +2690,7 @@ var __exports__ = (() => {
|
|
|
2678
2690
|
const vertex = {
|
|
2679
2691
|
module: cast(this.props.vs).handle,
|
|
2680
2692
|
entryPoint: this.props.vsEntryPoint || "main",
|
|
2681
|
-
buffers: getVertexBufferLayout(this.props.
|
|
2693
|
+
buffers: getVertexBufferLayout(this.props.shaderLayout, this.props.bufferLayout)
|
|
2682
2694
|
};
|
|
2683
2695
|
let fragment;
|
|
2684
2696
|
if (this.props.fs) {
|
|
@@ -2730,7 +2742,7 @@ var __exports__ = (() => {
|
|
|
2730
2742
|
for (let i = 0; i < buffers.length; ++i) {
|
|
2731
2743
|
const buffer = cast(buffers[i]);
|
|
2732
2744
|
if (!buffer) {
|
|
2733
|
-
const attribute = this.props.
|
|
2745
|
+
const attribute = this.props.shaderLayout.attributes.find((attribute2) => attribute2.location === i);
|
|
2734
2746
|
throw new Error(`No buffer provided for attribute '${attribute?.name || ""}' in Model '${this.props.id}'`);
|
|
2735
2747
|
}
|
|
2736
2748
|
webgpuRenderPass.handle.setVertexBuffer(i, buffer.handle);
|