@luma.gl/webgl 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/adapter/converters/shader-formats.d.ts +9 -0
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -0
- package/dist/adapter/converters/shader-formats.js +53 -0
- package/dist/adapter/converters/shader-formats.js.map +1 -0
- package/dist/adapter/converters/texture-formats.d.ts +1 -2
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +2 -23
- package/dist/adapter/converters/texture-formats.js.map +1 -1
- package/dist/adapter/converters/vertex-formats.d.ts +8 -2
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +47 -9
- package/dist/adapter/converters/vertex-formats.js.map +1 -1
- package/dist/adapter/helpers/{uniforms.d.ts → decode-webgl-types.d.ts} +9 -8
- package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -0
- package/dist/adapter/helpers/{uniforms.js → decode-webgl-types.js} +14 -13
- package/dist/adapter/helpers/decode-webgl-types.js.map +1 -0
- package/dist/adapter/helpers/get-shader-layout.d.ts +1 -51
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +14 -86
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/adapter/helpers/set-uniform.d.ts +3 -2
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +25 -25
- package/dist/adapter/helpers/set-uniform.js.map +1 -1
- package/dist/adapter/helpers/{attribute-utils.d.ts → webgl-topology-utils.d.ts} +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -0
- package/dist/adapter/helpers/{attribute-utils.js → webgl-topology-utils.js} +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js.map +1 -0
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts +2 -1
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +16 -10
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +58 -59
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/classic/buffer-with-accessor.d.ts +0 -1
- package/dist/classic/buffer-with-accessor.d.ts.map +1 -1
- package/dist/classic/buffer-with-accessor.js +0 -1
- package/dist/classic/buffer-with-accessor.js.map +1 -1
- package/dist/dist.dev.js +513 -418
- package/dist/index.cjs +670 -722
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist.min.js +22 -22
- package/package.json +5 -5
- package/src/adapter/converters/shader-formats.ts +41 -0
- package/src/adapter/converters/texture-formats.ts +3 -16
- package/src/adapter/converters/vertex-formats.ts +67 -10
- package/src/adapter/helpers/{uniforms.ts → decode-webgl-types.ts} +22 -17
- package/src/adapter/helpers/get-shader-layout.ts +51 -159
- package/src/adapter/helpers/set-uniform.ts +33 -33
- package/src/adapter/objects/webgl-vertex-array-object.ts +2 -1
- package/src/adapter/resources/webgl-command-encoder.ts +1 -1
- package/src/adapter/resources/webgl-render-pipeline.ts +125 -82
- package/src/classic/buffer-with-accessor.ts +0 -1
- package/src/index.ts +1 -1
- package/src/types.ts +2 -0
- package/dist/adapter/helpers/attribute-utils.d.ts.map +0 -1
- package/dist/adapter/helpers/attribute-utils.js.map +0 -1
- package/dist/adapter/helpers/uniforms.d.ts.map +0 -1
- package/dist/adapter/helpers/uniforms.js.map +0 -1
- /package/src/adapter/helpers/{attribute-utils.ts → webgl-topology-utils.ts} +0 -0
package/dist/dist.dev.js
CHANGED
|
@@ -11,8 +11,8 @@ var __exports__ = (() => {
|
|
|
11
11
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
12
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
13
|
var __export = (target, all) => {
|
|
14
|
-
for (var
|
|
15
|
-
__defProp(target,
|
|
14
|
+
for (var name2 in all)
|
|
15
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
16
16
|
};
|
|
17
17
|
var __copyProps = (to, from, except, desc) => {
|
|
18
18
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -59,7 +59,6 @@ var __exports__ = (() => {
|
|
|
59
59
|
getWebGL2Context: () => getWebGL2Context,
|
|
60
60
|
isWebGL: () => isWebGL,
|
|
61
61
|
isWebGL2: () => isWebGL2,
|
|
62
|
-
mergeShaderLayout: () => mergeShaderLayout,
|
|
63
62
|
polyfillContext: () => polyfillContext,
|
|
64
63
|
popContextState: () => popContextState,
|
|
65
64
|
pushContextState: () => pushContextState,
|
|
@@ -304,7 +303,7 @@ var __exports__ = (() => {
|
|
|
304
303
|
for (const key of propNames) {
|
|
305
304
|
const value = object[key];
|
|
306
305
|
if (typeof value === "function") {
|
|
307
|
-
if (!predefined.find((
|
|
306
|
+
if (!predefined.find((name2) => key === name2)) {
|
|
308
307
|
object[key] = value.bind(obj);
|
|
309
308
|
}
|
|
310
309
|
}
|
|
@@ -693,7 +692,7 @@ var __exports__ = (() => {
|
|
|
693
692
|
|
|
694
693
|
// ../../node_modules/@probe.gl/stats/dist/lib/stat.js
|
|
695
694
|
var Stat = class {
|
|
696
|
-
constructor(
|
|
695
|
+
constructor(name2, type) {
|
|
697
696
|
this.name = void 0;
|
|
698
697
|
this.type = void 0;
|
|
699
698
|
this.sampleSize = 1;
|
|
@@ -708,7 +707,7 @@ var __exports__ = (() => {
|
|
|
708
707
|
this._samples = 0;
|
|
709
708
|
this._startTime = 0;
|
|
710
709
|
this._timerPending = false;
|
|
711
|
-
this.name =
|
|
710
|
+
this.name = name2;
|
|
712
711
|
this.type = type;
|
|
713
712
|
this.reset();
|
|
714
713
|
}
|
|
@@ -813,10 +812,10 @@ var __exports__ = (() => {
|
|
|
813
812
|
this._initializeStats(options.stats);
|
|
814
813
|
Object.seal(this);
|
|
815
814
|
}
|
|
816
|
-
get(
|
|
815
|
+
get(name2) {
|
|
817
816
|
let type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "count";
|
|
818
817
|
return this._getOrCreate({
|
|
819
|
-
name,
|
|
818
|
+
name: name2,
|
|
820
819
|
type
|
|
821
820
|
});
|
|
822
821
|
}
|
|
@@ -852,17 +851,17 @@ var __exports__ = (() => {
|
|
|
852
851
|
}
|
|
853
852
|
_getOrCreate(stat) {
|
|
854
853
|
const {
|
|
855
|
-
name,
|
|
854
|
+
name: name2,
|
|
856
855
|
type
|
|
857
856
|
} = stat;
|
|
858
|
-
let result = this.stats[
|
|
857
|
+
let result = this.stats[name2];
|
|
859
858
|
if (!result) {
|
|
860
859
|
if (stat instanceof Stat) {
|
|
861
860
|
result = stat;
|
|
862
861
|
} else {
|
|
863
|
-
result = new Stat(
|
|
862
|
+
result = new Stat(name2, type);
|
|
864
863
|
}
|
|
865
|
-
this.stats[
|
|
864
|
+
this.stats[name2] = result;
|
|
866
865
|
}
|
|
867
866
|
return result;
|
|
868
867
|
}
|
|
@@ -871,16 +870,16 @@ var __exports__ = (() => {
|
|
|
871
870
|
// ../core/src/lib/utils/stats-manager.ts
|
|
872
871
|
var StatsManager = class {
|
|
873
872
|
stats = /* @__PURE__ */ new Map();
|
|
874
|
-
getStats(
|
|
875
|
-
return this.get(
|
|
873
|
+
getStats(name2) {
|
|
874
|
+
return this.get(name2);
|
|
876
875
|
}
|
|
877
|
-
get(
|
|
878
|
-
if (!this.stats.has(
|
|
879
|
-
this.stats.set(
|
|
880
|
-
id:
|
|
876
|
+
get(name2) {
|
|
877
|
+
if (!this.stats.has(name2)) {
|
|
878
|
+
this.stats.set(name2, new Stats({
|
|
879
|
+
id: name2
|
|
881
880
|
}));
|
|
882
881
|
}
|
|
883
|
-
return this.stats.get(
|
|
882
|
+
return this.stats.get(name2);
|
|
884
883
|
}
|
|
885
884
|
};
|
|
886
885
|
var lumaStats = new StatsManager();
|
|
@@ -929,11 +928,6 @@ var __exports__ = (() => {
|
|
|
929
928
|
}
|
|
930
929
|
|
|
931
930
|
// ../core/src/adapter/resources/resource.ts
|
|
932
|
-
var DEFAULT_RESOURCE_PROPS = {
|
|
933
|
-
id: "undefined",
|
|
934
|
-
handle: void 0,
|
|
935
|
-
userData: void 0
|
|
936
|
-
};
|
|
937
931
|
var Resource = class {
|
|
938
932
|
/** props.id, for debugging. */
|
|
939
933
|
userData = {};
|
|
@@ -1018,34 +1012,38 @@ var __exports__ = (() => {
|
|
|
1018
1012
|
/** Called by .destroy() to track object destruction. Subclass must call if overriding destroy() */
|
|
1019
1013
|
removeStats() {
|
|
1020
1014
|
const stats = this._device.statsManager.getStats("Resource Counts");
|
|
1021
|
-
const
|
|
1022
|
-
stats.get(`${
|
|
1015
|
+
const name2 = this[Symbol.toStringTag];
|
|
1016
|
+
stats.get(`${name2}s Active`).decrementCount();
|
|
1023
1017
|
}
|
|
1024
1018
|
/** Called by subclass to track memory allocations */
|
|
1025
|
-
trackAllocatedMemory(bytes,
|
|
1019
|
+
trackAllocatedMemory(bytes, name2 = this[Symbol.toStringTag]) {
|
|
1026
1020
|
const stats = this._device.statsManager.getStats("Resource Counts");
|
|
1027
1021
|
stats.get("GPU Memory").addCount(bytes);
|
|
1028
|
-
stats.get(`${
|
|
1022
|
+
stats.get(`${name2} Memory`).addCount(bytes);
|
|
1029
1023
|
this.allocatedBytes = bytes;
|
|
1030
1024
|
}
|
|
1031
1025
|
/** Called by subclass to track memory deallocations */
|
|
1032
|
-
trackDeallocatedMemory(
|
|
1026
|
+
trackDeallocatedMemory(name2 = this[Symbol.toStringTag]) {
|
|
1033
1027
|
const stats = this._device.statsManager.getStats("Resource Counts");
|
|
1034
1028
|
stats.get("GPU Memory").subtractCount(this.allocatedBytes);
|
|
1035
|
-
stats.get(`${
|
|
1029
|
+
stats.get(`${name2} Memory`).subtractCount(this.allocatedBytes);
|
|
1036
1030
|
this.allocatedBytes = 0;
|
|
1037
1031
|
}
|
|
1038
1032
|
/** Called by resource constructor to track object creation */
|
|
1039
1033
|
addStats() {
|
|
1040
1034
|
const stats = this._device.statsManager.getStats("Resource Counts");
|
|
1041
|
-
const
|
|
1035
|
+
const name2 = this[Symbol.toStringTag];
|
|
1042
1036
|
stats.get("Resources Created").incrementCount();
|
|
1043
|
-
stats.get(`${
|
|
1044
|
-
stats.get(`${
|
|
1037
|
+
stats.get(`${name2}s Created`).incrementCount();
|
|
1038
|
+
stats.get(`${name2}s Active`).incrementCount();
|
|
1045
1039
|
}
|
|
1046
1040
|
};
|
|
1047
1041
|
/** Default properties for resource */
|
|
1048
|
-
__publicField(Resource, "defaultProps",
|
|
1042
|
+
__publicField(Resource, "defaultProps", {
|
|
1043
|
+
id: "undefined",
|
|
1044
|
+
handle: void 0,
|
|
1045
|
+
userData: void 0
|
|
1046
|
+
});
|
|
1049
1047
|
function selectivelyMerge(props, defaultProps) {
|
|
1050
1048
|
const mergedProps = {
|
|
1051
1049
|
...defaultProps
|
|
@@ -1059,20 +1057,12 @@ var __exports__ = (() => {
|
|
|
1059
1057
|
}
|
|
1060
1058
|
|
|
1061
1059
|
// ../core/src/adapter/resources/buffer.ts
|
|
1062
|
-
var DEFAULT_BUFFER_PROPS = {
|
|
1063
|
-
...DEFAULT_RESOURCE_PROPS,
|
|
1064
|
-
usage: 0,
|
|
1065
|
-
// Buffer.COPY_DST | Buffer.COPY_SRC
|
|
1066
|
-
byteLength: 0,
|
|
1067
|
-
byteOffset: 0,
|
|
1068
|
-
data: null,
|
|
1069
|
-
indexType: "uint16",
|
|
1070
|
-
mappedAtCreation: false
|
|
1071
|
-
};
|
|
1072
1060
|
var _Buffer = class extends Resource {
|
|
1073
1061
|
get [Symbol.toStringTag]() {
|
|
1074
1062
|
return "Buffer";
|
|
1075
1063
|
}
|
|
1064
|
+
/** The usage with which this buffer was created */
|
|
1065
|
+
/** For index buffers, whether indices are 16 or 32 bit */
|
|
1076
1066
|
/** Length of buffer in bytes */
|
|
1077
1067
|
constructor(device, props) {
|
|
1078
1068
|
const deducedProps = {
|
|
@@ -1085,7 +1075,9 @@ var __exports__ = (() => {
|
|
|
1085
1075
|
deducedProps.indexType = "uint16";
|
|
1086
1076
|
}
|
|
1087
1077
|
}
|
|
1088
|
-
super(device, deducedProps,
|
|
1078
|
+
super(device, deducedProps, _Buffer.defaultProps);
|
|
1079
|
+
this.usage = props.usage || 0;
|
|
1080
|
+
this.indexType = deducedProps.indexType;
|
|
1089
1081
|
}
|
|
1090
1082
|
write(data, byteOffset) {
|
|
1091
1083
|
throw new Error("not implemented");
|
|
@@ -1143,6 +1135,16 @@ var __exports__ = (() => {
|
|
|
1143
1135
|
// abstract unmap(): void;
|
|
1144
1136
|
};
|
|
1145
1137
|
var Buffer2 = _Buffer;
|
|
1138
|
+
__publicField(Buffer2, "defaultProps", {
|
|
1139
|
+
...Resource.defaultProps,
|
|
1140
|
+
usage: 0,
|
|
1141
|
+
// Buffer.COPY_DST | Buffer.COPY_SRC
|
|
1142
|
+
byteLength: 0,
|
|
1143
|
+
byteOffset: 0,
|
|
1144
|
+
data: null,
|
|
1145
|
+
indexType: "uint16",
|
|
1146
|
+
mappedAtCreation: false
|
|
1147
|
+
});
|
|
1146
1148
|
// Usage Flags
|
|
1147
1149
|
__publicField(Buffer2, "MAP_READ", 1);
|
|
1148
1150
|
__publicField(Buffer2, "MAP_WRITE", 2);
|
|
@@ -1192,8 +1194,14 @@ var __exports__ = (() => {
|
|
|
1192
1194
|
};
|
|
1193
1195
|
this.id = this.props.id || uid(this[Symbol.toStringTag].toLowerCase());
|
|
1194
1196
|
}
|
|
1197
|
+
/** id of this device, primarily for debugging */
|
|
1198
|
+
/** stats */
|
|
1195
1199
|
statsManager = lumaStats;
|
|
1200
|
+
/** A copy of the device props */
|
|
1201
|
+
/** Available for the application to store data on the device */
|
|
1196
1202
|
userData = {};
|
|
1203
|
+
/** Used by other luma.gl modules to store data on the device */
|
|
1204
|
+
_lumaData = {};
|
|
1197
1205
|
// Capabilities
|
|
1198
1206
|
/** Information about the device (vendor, versions etc) */
|
|
1199
1207
|
/** Optional capability discovery */
|
|
@@ -1540,25 +1548,7 @@ var __exports__ = (() => {
|
|
|
1540
1548
|
}
|
|
1541
1549
|
|
|
1542
1550
|
// ../core/src/adapter/resources/texture.ts
|
|
1543
|
-
var
|
|
1544
|
-
...DEFAULT_RESOURCE_PROPS,
|
|
1545
|
-
data: null,
|
|
1546
|
-
dimension: "2d",
|
|
1547
|
-
format: "rgba8unorm",
|
|
1548
|
-
width: void 0,
|
|
1549
|
-
height: void 0,
|
|
1550
|
-
depth: 1,
|
|
1551
|
-
mipmaps: true,
|
|
1552
|
-
sampler: {},
|
|
1553
|
-
// type: undefined,
|
|
1554
|
-
compressed: false,
|
|
1555
|
-
// mipLevels: 1,
|
|
1556
|
-
usage: 0,
|
|
1557
|
-
mipLevels: void 0,
|
|
1558
|
-
samples: void 0,
|
|
1559
|
-
type: void 0
|
|
1560
|
-
};
|
|
1561
|
-
var Texture = class extends Resource {
|
|
1551
|
+
var _Texture = class extends Resource {
|
|
1562
1552
|
get [Symbol.toStringTag]() {
|
|
1563
1553
|
return "Texture";
|
|
1564
1554
|
}
|
|
@@ -1568,7 +1558,7 @@ var __exports__ = (() => {
|
|
|
1568
1558
|
/** height in pixels of this texture */
|
|
1569
1559
|
/** depth of this texture */
|
|
1570
1560
|
/** Default sampler for this texture */
|
|
1571
|
-
constructor(device, props, defaultProps =
|
|
1561
|
+
constructor(device, props, defaultProps = _Texture.defaultProps) {
|
|
1572
1562
|
super(device, props, defaultProps);
|
|
1573
1563
|
this.dimension = this.props.dimension;
|
|
1574
1564
|
this.format = this.props.format;
|
|
@@ -1577,6 +1567,26 @@ var __exports__ = (() => {
|
|
|
1577
1567
|
this.depth = this.props.depth;
|
|
1578
1568
|
}
|
|
1579
1569
|
};
|
|
1570
|
+
var Texture = _Texture;
|
|
1571
|
+
__publicField(Texture, "defaultProps", {
|
|
1572
|
+
...Resource.defaultProps,
|
|
1573
|
+
data: null,
|
|
1574
|
+
dimension: "2d",
|
|
1575
|
+
format: "rgba8unorm",
|
|
1576
|
+
width: void 0,
|
|
1577
|
+
height: void 0,
|
|
1578
|
+
depth: 1,
|
|
1579
|
+
mipmaps: true,
|
|
1580
|
+
sampler: {},
|
|
1581
|
+
// type: undefined,
|
|
1582
|
+
compressed: false,
|
|
1583
|
+
// mipLevels: 1,
|
|
1584
|
+
usage: 0,
|
|
1585
|
+
// usage: GPUTextureUsage.COPY_DST
|
|
1586
|
+
mipLevels: void 0,
|
|
1587
|
+
samples: void 0,
|
|
1588
|
+
type: void 0
|
|
1589
|
+
});
|
|
1580
1590
|
__publicField(Texture, "COPY_SRC", 1);
|
|
1581
1591
|
__publicField(Texture, "COPY_DST", 2);
|
|
1582
1592
|
__publicField(Texture, "TEXTURE_BINDING", 4);
|
|
@@ -1584,28 +1594,38 @@ var __exports__ = (() => {
|
|
|
1584
1594
|
__publicField(Texture, "RENDER_ATTACHMENT", 16);
|
|
1585
1595
|
|
|
1586
1596
|
// ../core/src/adapter/resources/shader.ts
|
|
1587
|
-
var
|
|
1588
|
-
...DEFAULT_RESOURCE_PROPS,
|
|
1589
|
-
stage: "vertex",
|
|
1590
|
-
source: "",
|
|
1591
|
-
sourceMap: null,
|
|
1592
|
-
language: "glsl",
|
|
1593
|
-
shaderType: 0
|
|
1594
|
-
};
|
|
1595
|
-
var Shader = class extends Resource {
|
|
1597
|
+
var _Shader = class extends Resource {
|
|
1596
1598
|
get [Symbol.toStringTag]() {
|
|
1597
1599
|
return "Shader";
|
|
1598
1600
|
}
|
|
1599
1601
|
constructor(device, props) {
|
|
1600
|
-
super(device, props,
|
|
1602
|
+
super(device, props, _Shader.defaultProps);
|
|
1601
1603
|
this.stage = this.props.stage;
|
|
1602
1604
|
this.source = this.props.source;
|
|
1603
1605
|
}
|
|
1604
1606
|
};
|
|
1607
|
+
var Shader = _Shader;
|
|
1608
|
+
__publicField(Shader, "defaultProps", {
|
|
1609
|
+
...Resource.defaultProps,
|
|
1610
|
+
stage: "vertex",
|
|
1611
|
+
source: "",
|
|
1612
|
+
sourceMap: null,
|
|
1613
|
+
language: "glsl",
|
|
1614
|
+
shaderType: 0
|
|
1615
|
+
});
|
|
1605
1616
|
|
|
1606
1617
|
// ../core/src/adapter/resources/sampler.ts
|
|
1607
|
-
var
|
|
1608
|
-
|
|
1618
|
+
var _Sampler = class extends Resource {
|
|
1619
|
+
get [Symbol.toStringTag]() {
|
|
1620
|
+
return "Sampler";
|
|
1621
|
+
}
|
|
1622
|
+
constructor(device, props) {
|
|
1623
|
+
super(device, props, _Sampler.defaultProps);
|
|
1624
|
+
}
|
|
1625
|
+
};
|
|
1626
|
+
var Sampler = _Sampler;
|
|
1627
|
+
__publicField(Sampler, "defaultProps", {
|
|
1628
|
+
...Resource.defaultProps,
|
|
1609
1629
|
type: "color-sampler",
|
|
1610
1630
|
addressModeU: "clamp-to-edge",
|
|
1611
1631
|
addressModeV: "clamp-to-edge",
|
|
@@ -1618,27 +1638,10 @@ var __exports__ = (() => {
|
|
|
1618
1638
|
// Per WebGPU spec
|
|
1619
1639
|
compare: "less-equal",
|
|
1620
1640
|
maxAnisotropy: 1
|
|
1621
|
-
};
|
|
1622
|
-
var Sampler = class extends Resource {
|
|
1623
|
-
get [Symbol.toStringTag]() {
|
|
1624
|
-
return "Sampler";
|
|
1625
|
-
}
|
|
1626
|
-
constructor(device, props) {
|
|
1627
|
-
super(device, props, DEFAULT_SAMPLER_PROPS);
|
|
1628
|
-
}
|
|
1629
|
-
};
|
|
1641
|
+
});
|
|
1630
1642
|
|
|
1631
1643
|
// ../core/src/adapter/resources/framebuffer.ts
|
|
1632
|
-
var
|
|
1633
|
-
...DEFAULT_RESOURCE_PROPS,
|
|
1634
|
-
width: 1,
|
|
1635
|
-
height: 1,
|
|
1636
|
-
colorAttachments: [],
|
|
1637
|
-
// ['rgba8unorm-unsized'],
|
|
1638
|
-
depthStencilAttachment: null
|
|
1639
|
-
// 'depth24plus-stencil8'
|
|
1640
|
-
};
|
|
1641
|
-
var Framebuffer = class extends Resource {
|
|
1644
|
+
var _Framebuffer = class extends Resource {
|
|
1642
1645
|
get [Symbol.toStringTag]() {
|
|
1643
1646
|
return "Framebuffer";
|
|
1644
1647
|
}
|
|
@@ -1649,7 +1652,7 @@ var __exports__ = (() => {
|
|
|
1649
1652
|
/** Depth-stencil attachment, if provided */
|
|
1650
1653
|
depthStencilAttachment = null;
|
|
1651
1654
|
constructor(device, props = {}) {
|
|
1652
|
-
super(device, props,
|
|
1655
|
+
super(device, props, _Framebuffer.defaultProps);
|
|
1653
1656
|
this.width = this.props.width;
|
|
1654
1657
|
this.height = this.props.height;
|
|
1655
1658
|
}
|
|
@@ -1815,10 +1818,40 @@ var __exports__ = (() => {
|
|
|
1815
1818
|
}
|
|
1816
1819
|
*/
|
|
1817
1820
|
};
|
|
1821
|
+
var Framebuffer = _Framebuffer;
|
|
1822
|
+
__publicField(Framebuffer, "defaultProps", {
|
|
1823
|
+
...Resource.defaultProps,
|
|
1824
|
+
width: 1,
|
|
1825
|
+
height: 1,
|
|
1826
|
+
colorAttachments: [],
|
|
1827
|
+
// ['rgba8unorm-unsized'],
|
|
1828
|
+
depthStencilAttachment: null
|
|
1829
|
+
// 'depth24plus-stencil8'
|
|
1830
|
+
});
|
|
1818
1831
|
|
|
1819
1832
|
// ../core/src/adapter/resources/render-pipeline.ts
|
|
1820
|
-
var
|
|
1821
|
-
|
|
1833
|
+
var _RenderPipeline = class extends Resource {
|
|
1834
|
+
get [Symbol.toStringTag]() {
|
|
1835
|
+
return "RenderPipeline";
|
|
1836
|
+
}
|
|
1837
|
+
hash = "";
|
|
1838
|
+
constructor(device, props) {
|
|
1839
|
+
super(device, props, _RenderPipeline.defaultProps);
|
|
1840
|
+
}
|
|
1841
|
+
/** Set attributes (stored on pipeline and set before each call) */
|
|
1842
|
+
/** Set attributes (stored on pipeline and set before each call) */
|
|
1843
|
+
/** Set constant attributes (WebGL only) */
|
|
1844
|
+
/** Set bindings (stored on pipeline and set before each call) */
|
|
1845
|
+
/** Uniforms
|
|
1846
|
+
* @deprecated Only supported on WebGL devices.
|
|
1847
|
+
* @note textures, samplers and uniform buffers should be set via `setBindings()`, these are not considered uniforms.
|
|
1848
|
+
* @note In WebGL uniforms have a performance penalty, they are reset before each call to enable pipeline sharing.
|
|
1849
|
+
*/
|
|
1850
|
+
/** Draw call */
|
|
1851
|
+
};
|
|
1852
|
+
var RenderPipeline = _RenderPipeline;
|
|
1853
|
+
__publicField(RenderPipeline, "defaultProps", {
|
|
1854
|
+
...Resource.defaultProps,
|
|
1822
1855
|
vs: null,
|
|
1823
1856
|
vsEntryPoint: "",
|
|
1824
1857
|
// main
|
|
@@ -1827,36 +1860,17 @@ var __exports__ = (() => {
|
|
|
1827
1860
|
fsEntryPoint: "",
|
|
1828
1861
|
// main
|
|
1829
1862
|
fsConstants: {},
|
|
1830
|
-
|
|
1831
|
-
|
|
1863
|
+
shaderLayout: null,
|
|
1864
|
+
bufferLayout: [],
|
|
1832
1865
|
topology: "triangle-list",
|
|
1833
|
-
// targets:
|
|
1834
1866
|
parameters: {},
|
|
1835
|
-
bufferMap: [],
|
|
1836
1867
|
vertexCount: 0,
|
|
1837
1868
|
instanceCount: 0,
|
|
1838
1869
|
indices: null,
|
|
1839
1870
|
attributes: {},
|
|
1840
1871
|
bindings: {},
|
|
1841
1872
|
uniforms: {}
|
|
1842
|
-
};
|
|
1843
|
-
var RenderPipeline = class extends Resource {
|
|
1844
|
-
get [Symbol.toStringTag]() {
|
|
1845
|
-
return "RenderPipeline";
|
|
1846
|
-
}
|
|
1847
|
-
hash = "";
|
|
1848
|
-
constructor(device, props) {
|
|
1849
|
-
super(device, props, DEFAULT_RENDER_PIPELINE_PROPS);
|
|
1850
|
-
}
|
|
1851
|
-
};
|
|
1852
|
-
/** Set attributes (stored on pipeline and set before each call) */
|
|
1853
|
-
/** Set attributes (stored on pipeline and set before each call) */
|
|
1854
|
-
/** Set constant attributes (WebGL only) */
|
|
1855
|
-
/** Set bindings (stored on pipeline and set before each call) */
|
|
1856
|
-
/** Uniforms (only supported on WebGL devices. Reset before each call to enable pipeline sharing) */
|
|
1857
|
-
/** Draw call */
|
|
1858
|
-
/** Private "export" for Model class */
|
|
1859
|
-
__publicField(RenderPipeline, "_DEFAULT_PROPS", DEFAULT_RENDER_PIPELINE_PROPS);
|
|
1873
|
+
});
|
|
1860
1874
|
|
|
1861
1875
|
// ../core/src/adapter/resources/render-pass.ts
|
|
1862
1876
|
var _RenderPass = class extends Resource {
|
|
@@ -1916,15 +1930,12 @@ var __exports__ = (() => {
|
|
|
1916
1930
|
});
|
|
1917
1931
|
|
|
1918
1932
|
// ../core/src/adapter/resources/command-encoder.ts
|
|
1919
|
-
var
|
|
1920
|
-
...DEFAULT_RESOURCE_PROPS
|
|
1921
|
-
};
|
|
1922
|
-
var CommandEncoder = class extends Resource {
|
|
1933
|
+
var _CommandEncoder = class extends Resource {
|
|
1923
1934
|
get [Symbol.toStringTag]() {
|
|
1924
1935
|
return "CommandEncoder";
|
|
1925
1936
|
}
|
|
1926
|
-
constructor(props) {
|
|
1927
|
-
super(props,
|
|
1937
|
+
constructor(device, props) {
|
|
1938
|
+
super(device, props, _CommandEncoder.defaultProps);
|
|
1928
1939
|
}
|
|
1929
1940
|
// TODO - return the CommandBuffer?
|
|
1930
1941
|
// beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;
|
|
@@ -1945,19 +1956,25 @@ var __exports__ = (() => {
|
|
|
1945
1956
|
// destinationOffset?: number;
|
|
1946
1957
|
// }): void;
|
|
1947
1958
|
};
|
|
1959
|
+
var CommandEncoder = _CommandEncoder;
|
|
1960
|
+
__publicField(CommandEncoder, "defaultProps", {
|
|
1961
|
+
...Resource.defaultProps,
|
|
1962
|
+
measureExecutionTime: void 0
|
|
1963
|
+
});
|
|
1948
1964
|
|
|
1949
1965
|
// ../core/src/adapter/resources/command-buffer.ts
|
|
1950
|
-
var
|
|
1951
|
-
...DEFAULT_RESOURCE_PROPS
|
|
1952
|
-
};
|
|
1953
|
-
var CommandBuffer = class extends Resource {
|
|
1966
|
+
var _CommandBuffer = class extends Resource {
|
|
1954
1967
|
get [Symbol.toStringTag]() {
|
|
1955
1968
|
return "CommandBuffer";
|
|
1956
1969
|
}
|
|
1957
1970
|
constructor(props) {
|
|
1958
|
-
super(props,
|
|
1971
|
+
super(props, _CommandBuffer.defaultProps);
|
|
1959
1972
|
}
|
|
1960
1973
|
};
|
|
1974
|
+
var CommandBuffer = _CommandBuffer;
|
|
1975
|
+
__publicField(CommandBuffer, "defaultProps", {
|
|
1976
|
+
...Resource.defaultProps
|
|
1977
|
+
});
|
|
1961
1978
|
|
|
1962
1979
|
// ../core/src/lib/utils/assert.ts
|
|
1963
1980
|
function assert2(condition, message2) {
|
|
@@ -1966,7 +1983,7 @@ var __exports__ = (() => {
|
|
|
1966
1983
|
}
|
|
1967
1984
|
}
|
|
1968
1985
|
|
|
1969
|
-
// ../core/src/adapter/utils/decode-data-type.ts
|
|
1986
|
+
// ../core/src/adapter/type-utils/decode-data-type.ts
|
|
1970
1987
|
function decodeVertexType(type) {
|
|
1971
1988
|
const dataType = TYPE_MAP[type];
|
|
1972
1989
|
const bytes = getDataTypeBytes(dataType);
|
|
@@ -2010,7 +2027,7 @@ var __exports__ = (() => {
|
|
|
2010
2027
|
sint32: 4
|
|
2011
2028
|
};
|
|
2012
2029
|
|
|
2013
|
-
// ../core/src/adapter/utils/decode-vertex-format.ts
|
|
2030
|
+
// ../core/src/adapter/type-utils/decode-vertex-format.ts
|
|
2014
2031
|
function decodeVertexFormat(format) {
|
|
2015
2032
|
let webglOnly;
|
|
2016
2033
|
if (format.endsWith("-webgl")) {
|
|
@@ -2035,7 +2052,7 @@ var __exports__ = (() => {
|
|
|
2035
2052
|
return result;
|
|
2036
2053
|
}
|
|
2037
2054
|
|
|
2038
|
-
// ../core/src/adapter/utils/decode-texture-format.ts
|
|
2055
|
+
// ../core/src/adapter/type-utils/decode-texture-format.ts
|
|
2039
2056
|
var REGEX = /^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;
|
|
2040
2057
|
function decodeTextureFormat(format) {
|
|
2041
2058
|
const matches = REGEX.exec(format);
|
|
@@ -2141,6 +2158,68 @@ var __exports__ = (() => {
|
|
|
2141
2158
|
};
|
|
2142
2159
|
}
|
|
2143
2160
|
|
|
2161
|
+
// ../core/src/adapter/type-utils/decode-attribute-type.ts
|
|
2162
|
+
function decodeShaderAttributeType(attributeType) {
|
|
2163
|
+
const [dataType, components] = TYPE_INFO[attributeType];
|
|
2164
|
+
const integer = dataType === "i32" || dataType === "u32";
|
|
2165
|
+
const signed = dataType !== "u32";
|
|
2166
|
+
const byteLength = TYPE_SIZES2[dataType] * components;
|
|
2167
|
+
const defaultVertexFormat = getCompatibleVertexFormat(dataType, components);
|
|
2168
|
+
return {
|
|
2169
|
+
dataType,
|
|
2170
|
+
components,
|
|
2171
|
+
defaultVertexFormat,
|
|
2172
|
+
byteLength,
|
|
2173
|
+
integer,
|
|
2174
|
+
signed
|
|
2175
|
+
};
|
|
2176
|
+
}
|
|
2177
|
+
function getCompatibleVertexFormat(dataType, components) {
|
|
2178
|
+
let vertexType;
|
|
2179
|
+
switch (dataType) {
|
|
2180
|
+
case "f32":
|
|
2181
|
+
vertexType = "float32";
|
|
2182
|
+
break;
|
|
2183
|
+
case "i32":
|
|
2184
|
+
vertexType = "sint32";
|
|
2185
|
+
break;
|
|
2186
|
+
case "u32":
|
|
2187
|
+
vertexType = "uint32";
|
|
2188
|
+
break;
|
|
2189
|
+
case "f16":
|
|
2190
|
+
return components <= 2 ? "float16x2" : "float16x4";
|
|
2191
|
+
}
|
|
2192
|
+
if (components === 1) {
|
|
2193
|
+
return vertexType;
|
|
2194
|
+
}
|
|
2195
|
+
return `${vertexType}x${components}`;
|
|
2196
|
+
}
|
|
2197
|
+
var TYPE_INFO = {
|
|
2198
|
+
f32: ["f32", 1],
|
|
2199
|
+
"vec2<f32>": ["f32", 2],
|
|
2200
|
+
"vec3<f32>": ["f32", 3],
|
|
2201
|
+
"vec4<f32>": ["f32", 4],
|
|
2202
|
+
f16: ["f16", 1],
|
|
2203
|
+
"vec2<f16>": ["f16", 2],
|
|
2204
|
+
"vec3<f16>": ["f16", 3],
|
|
2205
|
+
"vec4<f16>": ["f16", 4],
|
|
2206
|
+
i32: ["i32", 1],
|
|
2207
|
+
"vec2<i32>": ["i32", 2],
|
|
2208
|
+
"vec3<i32>": ["i32", 3],
|
|
2209
|
+
"vec4<i32>": ["i32", 4],
|
|
2210
|
+
u32: ["u32", 1],
|
|
2211
|
+
"vec2<u32>": ["u32", 2],
|
|
2212
|
+
"vec3<u32>": ["u32", 3],
|
|
2213
|
+
"vec4<u32>": ["u32", 4]
|
|
2214
|
+
};
|
|
2215
|
+
var TYPE_SIZES2 = {
|
|
2216
|
+
f32: 4,
|
|
2217
|
+
f16: 2,
|
|
2218
|
+
i32: 4,
|
|
2219
|
+
u32: 4
|
|
2220
|
+
// 'bool-webgl': 4,
|
|
2221
|
+
};
|
|
2222
|
+
|
|
2144
2223
|
// ../core/src/lib/compiler-log/format-compiler-log.ts
|
|
2145
2224
|
function formatCompilerLog(shaderLog, source, options) {
|
|
2146
2225
|
const lines = source.split(/\r?\n/);
|
|
@@ -2181,6 +2260,102 @@ var __exports__ = (() => {
|
|
|
2181
2260
|
return result + string;
|
|
2182
2261
|
}
|
|
2183
2262
|
|
|
2263
|
+
// ../core/src/adapter/attribute-utils/get-attribute-from-layouts.ts
|
|
2264
|
+
function getAttributeInfosFromLayouts(shaderLayout, bufferLayout) {
|
|
2265
|
+
const attributeInfos = {};
|
|
2266
|
+
for (const attribute of shaderLayout.attributes) {
|
|
2267
|
+
attributeInfos[attribute.name] = getAttributeInfoFromLayouts(shaderLayout, bufferLayout, attribute.name);
|
|
2268
|
+
}
|
|
2269
|
+
return attributeInfos;
|
|
2270
|
+
}
|
|
2271
|
+
function getAttributeInfoFromLayouts(shaderLayout, bufferLayout, name2) {
|
|
2272
|
+
const shaderDeclaration = getAttributeFromShaderLayout(shaderLayout, name2);
|
|
2273
|
+
const bufferMapping = getAttributeFromBufferLayout(bufferLayout, name2);
|
|
2274
|
+
if (!shaderDeclaration) {
|
|
2275
|
+
return null;
|
|
2276
|
+
}
|
|
2277
|
+
const attributeTypeInfo = decodeShaderAttributeType(shaderDeclaration.type);
|
|
2278
|
+
const vertexFormat = bufferMapping?.vertexFormat || attributeTypeInfo.defaultVertexFormat;
|
|
2279
|
+
const vertexFormatInfo = decodeVertexFormat(vertexFormat);
|
|
2280
|
+
return {
|
|
2281
|
+
name: name2,
|
|
2282
|
+
bufferName: bufferMapping?.name || name2,
|
|
2283
|
+
location: shaderDeclaration.location,
|
|
2284
|
+
shaderType: shaderDeclaration.type,
|
|
2285
|
+
shaderDataType: attributeTypeInfo.dataType,
|
|
2286
|
+
shaderComponents: attributeTypeInfo.components,
|
|
2287
|
+
vertexFormat,
|
|
2288
|
+
bufferDataType: vertexFormatInfo.type,
|
|
2289
|
+
bufferComponents: vertexFormatInfo.components,
|
|
2290
|
+
// normalized is a property of the buffer's vertex format
|
|
2291
|
+
normalized: vertexFormatInfo.normalized,
|
|
2292
|
+
// integer is a property of the shader declaration
|
|
2293
|
+
integer: attributeTypeInfo.integer,
|
|
2294
|
+
stepMode: bufferMapping?.stepMode || shaderDeclaration.stepMode,
|
|
2295
|
+
byteOffset: bufferMapping?.byteOffset || 0,
|
|
2296
|
+
byteStride: bufferMapping?.byteStride || 0
|
|
2297
|
+
};
|
|
2298
|
+
}
|
|
2299
|
+
function getAttributeFromShaderLayout(shaderLayout, name2) {
|
|
2300
|
+
const attribute = shaderLayout.attributes.find((attr) => attr.name === name2);
|
|
2301
|
+
if (!attribute) {
|
|
2302
|
+
log.warn(`shader layout attribute "${name2}" not present in shader`);
|
|
2303
|
+
}
|
|
2304
|
+
return attribute || null;
|
|
2305
|
+
}
|
|
2306
|
+
function getAttributeFromBufferLayout(bufferLayout, name2) {
|
|
2307
|
+
for (const bufferMapping of bufferLayout) {
|
|
2308
|
+
if (bufferMapping.name === name2) {
|
|
2309
|
+
return {
|
|
2310
|
+
name: bufferMapping.name,
|
|
2311
|
+
bufferName: name2,
|
|
2312
|
+
vertexFormat: bufferMapping.format,
|
|
2313
|
+
byteOffset: bufferMapping.byteOffset || 0,
|
|
2314
|
+
byteStride: bufferMapping.byteStride || 0
|
|
2315
|
+
};
|
|
2316
|
+
}
|
|
2317
|
+
let nextByteOffset = bufferMapping.byteOffset || 0;
|
|
2318
|
+
let byteStride = 0;
|
|
2319
|
+
for (const interleavedMapping of bufferMapping.attributes || []) {
|
|
2320
|
+
const info = decodeVertexFormat(interleavedMapping.format);
|
|
2321
|
+
byteStride += info.byteLength;
|
|
2322
|
+
}
|
|
2323
|
+
for (const interleavedMapping of bufferMapping.attributes || []) {
|
|
2324
|
+
const byteOffset = nextByteOffset;
|
|
2325
|
+
nextByteOffset += interleavedMapping?.byteStrideOffset || decodeVertexFormat(interleavedMapping.format).byteLength;
|
|
2326
|
+
if (interleavedMapping.name === name2) {
|
|
2327
|
+
return {
|
|
2328
|
+
name: bufferMapping.name,
|
|
2329
|
+
bufferName: name2,
|
|
2330
|
+
vertexFormat: interleavedMapping.format,
|
|
2331
|
+
byteOffset,
|
|
2332
|
+
byteStride: bufferMapping.byteStride || byteStride
|
|
2333
|
+
};
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2337
|
+
log.warn(`layout for attribute "${name2}" not present in buffer layout`);
|
|
2338
|
+
return null;
|
|
2339
|
+
}
|
|
2340
|
+
function mergeShaderLayout(baseLayout, overrideLayout) {
|
|
2341
|
+
const mergedLayout = {
|
|
2342
|
+
...baseLayout,
|
|
2343
|
+
attributes: baseLayout.attributes.map((attribute) => ({
|
|
2344
|
+
...attribute
|
|
2345
|
+
}))
|
|
2346
|
+
};
|
|
2347
|
+
for (const attribute of overrideLayout?.attributes || []) {
|
|
2348
|
+
const baseAttribute = mergedLayout.attributes.find((attr) => attr.name === attribute.name);
|
|
2349
|
+
if (!baseAttribute) {
|
|
2350
|
+
log.warn(`shader layout attribute ${attribute.name} not present in shader`);
|
|
2351
|
+
} else {
|
|
2352
|
+
baseAttribute.type = attribute.type || baseAttribute.type;
|
|
2353
|
+
baseAttribute.stepMode = attribute.stepMode || baseAttribute.stepMode;
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
return mergedLayout;
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2184
2359
|
// ../core/src/lib/utils/cast.ts
|
|
2185
2360
|
function cast(value) {
|
|
2186
2361
|
return value;
|
|
@@ -2554,12 +2729,12 @@ var __exports__ = (() => {
|
|
|
2554
2729
|
return list;
|
|
2555
2730
|
};
|
|
2556
2731
|
const original_getExtension = gl2.getExtension;
|
|
2557
|
-
gl2.getExtension = function getExtension(
|
|
2558
|
-
const ext = original_getExtension.call(this,
|
|
2732
|
+
gl2.getExtension = function getExtension(name2) {
|
|
2733
|
+
const ext = original_getExtension.call(this, name2);
|
|
2559
2734
|
if (ext) {
|
|
2560
2735
|
return ext;
|
|
2561
2736
|
}
|
|
2562
|
-
if (
|
|
2737
|
+
if (name2 !== "OES_vertex_array_object") {
|
|
2563
2738
|
return null;
|
|
2564
2739
|
}
|
|
2565
2740
|
if (!gl2.__OESVertexArrayObject) {
|
|
@@ -4416,6 +4591,37 @@ var __exports__ = (() => {
|
|
|
4416
4591
|
return isMSIE || isTrident;
|
|
4417
4592
|
}
|
|
4418
4593
|
|
|
4594
|
+
// src/adapter/converters/vertex-formats.ts
|
|
4595
|
+
function getGLFromVertexType(dataType) {
|
|
4596
|
+
switch (dataType) {
|
|
4597
|
+
case "uint8":
|
|
4598
|
+
return GL.UNSIGNED_BYTE;
|
|
4599
|
+
case "sint8":
|
|
4600
|
+
return GL.BYTE;
|
|
4601
|
+
case "unorm8":
|
|
4602
|
+
return GL.UNSIGNED_BYTE;
|
|
4603
|
+
case "snorm8":
|
|
4604
|
+
return GL.BYTE;
|
|
4605
|
+
case "uint16":
|
|
4606
|
+
return GL.UNSIGNED_SHORT;
|
|
4607
|
+
case "sint16":
|
|
4608
|
+
return GL.SHORT;
|
|
4609
|
+
case "unorm16":
|
|
4610
|
+
return GL.UNSIGNED_SHORT;
|
|
4611
|
+
case "snorm16":
|
|
4612
|
+
return GL.SHORT;
|
|
4613
|
+
case "uint32":
|
|
4614
|
+
return GL.UNSIGNED_INT;
|
|
4615
|
+
case "sint32":
|
|
4616
|
+
return GL.INT;
|
|
4617
|
+
case "float16":
|
|
4618
|
+
return GL.HALF_FLOAT;
|
|
4619
|
+
case "float32":
|
|
4620
|
+
return GL.FLOAT;
|
|
4621
|
+
}
|
|
4622
|
+
throw new Error(String(dataType));
|
|
4623
|
+
}
|
|
4624
|
+
|
|
4419
4625
|
// src/adapter/converters/texture-formats.ts
|
|
4420
4626
|
var texture_compression_bc = "texture-compression-bc";
|
|
4421
4627
|
var texture_compression_astc = "texture-compression-astc";
|
|
@@ -5197,7 +5403,7 @@ var __exports__ = (() => {
|
|
|
5197
5403
|
[GL.LUMINANCE]: 1,
|
|
5198
5404
|
[GL.LUMINANCE_ALPHA]: 2
|
|
5199
5405
|
};
|
|
5200
|
-
var
|
|
5406
|
+
var TYPE_SIZES3 = {
|
|
5201
5407
|
[GL.FLOAT]: 4,
|
|
5202
5408
|
[GL.UNSIGNED_INT]: 4,
|
|
5203
5409
|
[GL.INT]: 4,
|
|
@@ -5281,7 +5487,8 @@ var __exports__ = (() => {
|
|
|
5281
5487
|
return {
|
|
5282
5488
|
format: webglFormat,
|
|
5283
5489
|
dataFormat: getWebGLPixelDataFormat(decoded.format, decoded.integer, decoded.normalized, webglFormat),
|
|
5284
|
-
type
|
|
5490
|
+
// depth formats don't have a type
|
|
5491
|
+
type: decoded.dataType ? getGLFromVertexType(decoded.dataType) : GL.UNSIGNED_BYTE,
|
|
5285
5492
|
// @ts-expect-error
|
|
5286
5493
|
compressed: decoded.compressed
|
|
5287
5494
|
};
|
|
@@ -5320,7 +5527,7 @@ var __exports__ = (() => {
|
|
|
5320
5527
|
const format = convertGLToTextureFormat(formatOrGL);
|
|
5321
5528
|
const params = getWebGLTextureParameters(format, isWebGL23);
|
|
5322
5529
|
const channels = DATA_FORMAT_CHANNELS[params.dataFormat] || 4;
|
|
5323
|
-
const channelSize =
|
|
5530
|
+
const channelSize = TYPE_SIZES3[params.type] || 1;
|
|
5324
5531
|
return channels * channelSize;
|
|
5325
5532
|
}
|
|
5326
5533
|
function getWebGLPixelDataFormat(dataFormat, integer, normalized, format) {
|
|
@@ -5340,28 +5547,6 @@ var __exports__ = (() => {
|
|
|
5340
5547
|
return GL.RGBA;
|
|
5341
5548
|
}
|
|
5342
5549
|
}
|
|
5343
|
-
function getWebGLDataType(dataType) {
|
|
5344
|
-
switch (dataType) {
|
|
5345
|
-
case "uint8":
|
|
5346
|
-
return GL.UNSIGNED_BYTE;
|
|
5347
|
-
case "sint8":
|
|
5348
|
-
return GL.BYTE;
|
|
5349
|
-
case "uint16":
|
|
5350
|
-
return GL.UNSIGNED_SHORT;
|
|
5351
|
-
case "sint16":
|
|
5352
|
-
return GL.SHORT;
|
|
5353
|
-
case "uint32":
|
|
5354
|
-
return GL.UNSIGNED_INT;
|
|
5355
|
-
case "sint32":
|
|
5356
|
-
return GL.INT;
|
|
5357
|
-
case "float16":
|
|
5358
|
-
return GL.HALF_FLOAT;
|
|
5359
|
-
case "float32":
|
|
5360
|
-
return GL.FLOAT;
|
|
5361
|
-
default:
|
|
5362
|
-
return GL.UNSIGNED_BYTE;
|
|
5363
|
-
}
|
|
5364
|
-
}
|
|
5365
5550
|
|
|
5366
5551
|
// src/adapter/device-helpers/device-features.ts
|
|
5367
5552
|
function getDeviceFeatures(gl2) {
|
|
@@ -6797,17 +6982,17 @@ void main(void) {}`;
|
|
|
6797
6982
|
}
|
|
6798
6983
|
|
|
6799
6984
|
// src/adapter/objects/constants-to-keys.ts
|
|
6800
|
-
function getKeyValue(gl2,
|
|
6801
|
-
if (typeof
|
|
6802
|
-
return
|
|
6985
|
+
function getKeyValue(gl2, name2) {
|
|
6986
|
+
if (typeof name2 !== "string") {
|
|
6987
|
+
return name2;
|
|
6803
6988
|
}
|
|
6804
|
-
const number = Number(
|
|
6989
|
+
const number = Number(name2);
|
|
6805
6990
|
if (!isNaN(number)) {
|
|
6806
6991
|
return number;
|
|
6807
6992
|
}
|
|
6808
|
-
|
|
6809
|
-
const value = gl2[
|
|
6810
|
-
assert2(value !== void 0, `Accessing undefined constant GL.${
|
|
6993
|
+
name2 = name2.replace(/^.*\./, "");
|
|
6994
|
+
const value = gl2[name2];
|
|
6995
|
+
assert2(value !== void 0, `Accessing undefined constant GL.${name2}`);
|
|
6811
6996
|
return value;
|
|
6812
6997
|
}
|
|
6813
6998
|
|
|
@@ -8234,7 +8419,7 @@ ${formattedLog}`)();
|
|
|
8234
8419
|
// });
|
|
8235
8420
|
};
|
|
8236
8421
|
|
|
8237
|
-
// src/adapter/helpers/
|
|
8422
|
+
// src/adapter/helpers/decode-webgl-types.ts
|
|
8238
8423
|
function isSamplerUniform(type) {
|
|
8239
8424
|
return SAMPLER_TYPES.includes(type);
|
|
8240
8425
|
}
|
|
@@ -8252,10 +8437,11 @@ ${formattedLog}`)();
|
|
|
8252
8437
|
[GL.UNSIGNED_INT_VEC2]: [GL.UNSIGNED_INT, 2, "uvec2", "vec2<u32>", "uint32x2"],
|
|
8253
8438
|
[GL.UNSIGNED_INT_VEC3]: [GL.UNSIGNED_INT, 3, "uvec3", "vec3<u32>", "uint32x3"],
|
|
8254
8439
|
[GL.UNSIGNED_INT_VEC4]: [GL.UNSIGNED_INT, 4, "uvec4", "vec4<u32>", "uint32x4"],
|
|
8255
|
-
[GL.BOOL]: [GL.FLOAT, 1, "bool", "f32", "
|
|
8256
|
-
[GL.BOOL_VEC2]: [GL.FLOAT, 2, "bvec2", "vec2<f32>"],
|
|
8257
|
-
[GL.BOOL_VEC3]: [GL.FLOAT, 3, "bvec3", "vec3<f32>"],
|
|
8258
|
-
[GL.BOOL_VEC4]: [GL.FLOAT, 4, "bvec4", "vec4<f32>"],
|
|
8440
|
+
[GL.BOOL]: [GL.FLOAT, 1, "bool", "f32", "float32"],
|
|
8441
|
+
[GL.BOOL_VEC2]: [GL.FLOAT, 2, "bvec2", "vec2<f32>", "float32x2"],
|
|
8442
|
+
[GL.BOOL_VEC3]: [GL.FLOAT, 3, "bvec3", "vec3<f32>", "float32x3"],
|
|
8443
|
+
[GL.BOOL_VEC4]: [GL.FLOAT, 4, "bvec4", "vec4<f32>", "float32x4"],
|
|
8444
|
+
// TODO - are sizes/components below correct?
|
|
8259
8445
|
[GL.FLOAT_MAT2]: [GL.FLOAT, 8, "mat2", "mat2x2<f32>"],
|
|
8260
8446
|
// 4
|
|
8261
8447
|
[GL.FLOAT_MAT2x3]: [GL.FLOAT, 8, "mat2x3", "mat2x3<f32>"],
|
|
@@ -8275,8 +8461,8 @@ ${formattedLog}`)();
|
|
|
8275
8461
|
[GL.FLOAT_MAT4]: [GL.FLOAT, 16, "mat4", "mat4x4<f32>"]
|
|
8276
8462
|
// 16
|
|
8277
8463
|
};
|
|
8278
|
-
function
|
|
8279
|
-
const typeAndSize = COMPOSITE_GL_TYPES[
|
|
8464
|
+
function decodeGLUniformType(glUniformType) {
|
|
8465
|
+
const typeAndSize = COMPOSITE_GL_TYPES[glUniformType];
|
|
8280
8466
|
if (!typeAndSize) {
|
|
8281
8467
|
throw new Error("uniform");
|
|
8282
8468
|
}
|
|
@@ -8287,68 +8473,27 @@ ${formattedLog}`)();
|
|
|
8287
8473
|
glType
|
|
8288
8474
|
};
|
|
8289
8475
|
}
|
|
8290
|
-
function
|
|
8291
|
-
const typeAndSize = COMPOSITE_GL_TYPES[
|
|
8476
|
+
function decodeGLAttributeType(glAttributeType) {
|
|
8477
|
+
const typeAndSize = COMPOSITE_GL_TYPES[glAttributeType];
|
|
8292
8478
|
if (!typeAndSize) {
|
|
8293
8479
|
throw new Error("attribute");
|
|
8294
8480
|
}
|
|
8295
|
-
const [
|
|
8481
|
+
const [, components, , shaderType, vertexFormat] = typeAndSize;
|
|
8482
|
+
const attributeType = shaderType;
|
|
8296
8483
|
return {
|
|
8297
|
-
|
|
8298
|
-
|
|
8299
|
-
|
|
8484
|
+
attributeType,
|
|
8485
|
+
vertexFormat,
|
|
8486
|
+
components
|
|
8300
8487
|
};
|
|
8301
8488
|
}
|
|
8302
8489
|
|
|
8303
|
-
// src/adapter/converters/vertex-formats.ts
|
|
8304
|
-
function getVertexFormat(type, components) {
|
|
8305
|
-
const base = getDataFormat(type);
|
|
8306
|
-
switch (components) {
|
|
8307
|
-
case 1:
|
|
8308
|
-
return base;
|
|
8309
|
-
case 2:
|
|
8310
|
-
return `${base}x2`;
|
|
8311
|
-
case 3:
|
|
8312
|
-
return `${base}x3`;
|
|
8313
|
-
case 4:
|
|
8314
|
-
return `${base}x4`;
|
|
8315
|
-
default:
|
|
8316
|
-
throw new Error(String(components));
|
|
8317
|
-
}
|
|
8318
|
-
}
|
|
8319
|
-
function getDataFormat(type) {
|
|
8320
|
-
switch (type) {
|
|
8321
|
-
case GL.INT:
|
|
8322
|
-
return "sint32";
|
|
8323
|
-
case GL.UNSIGNED_INT:
|
|
8324
|
-
return "uint32";
|
|
8325
|
-
case GL.FLOAT:
|
|
8326
|
-
return "float32";
|
|
8327
|
-
default:
|
|
8328
|
-
throw new Error(String(type));
|
|
8329
|
-
}
|
|
8330
|
-
}
|
|
8331
|
-
|
|
8332
8490
|
// src/adapter/helpers/get-shader-layout.ts
|
|
8333
8491
|
function getShaderLayout(gl2, program) {
|
|
8334
8492
|
const shaderLayout = {
|
|
8335
8493
|
attributes: [],
|
|
8336
8494
|
bindings: []
|
|
8337
8495
|
};
|
|
8338
|
-
|
|
8339
|
-
for (const attribute of attributes) {
|
|
8340
|
-
const size = Math.min(attribute.accessor.size, 4);
|
|
8341
|
-
const format = (
|
|
8342
|
-
// attribute.accessor.format ||
|
|
8343
|
-
getVertexFormat(attribute.accessor.type || GL.FLOAT, size)
|
|
8344
|
-
);
|
|
8345
|
-
shaderLayout.attributes.push({
|
|
8346
|
-
name: attribute.name,
|
|
8347
|
-
location: attribute.location,
|
|
8348
|
-
format,
|
|
8349
|
-
stepMode: attribute.accessor.divisor === 1 ? "instance" : "vertex"
|
|
8350
|
-
});
|
|
8351
|
-
}
|
|
8496
|
+
shaderLayout.attributes = readAttributeDeclarations(gl2, program);
|
|
8352
8497
|
const uniformBlocks = readUniformBlocks(gl2, program);
|
|
8353
8498
|
for (const uniformBlock of uniformBlocks) {
|
|
8354
8499
|
const uniforms2 = uniformBlock.uniforms.map((uniform) => ({
|
|
@@ -8395,58 +8540,7 @@ ${formattedLog}`)();
|
|
|
8395
8540
|
}
|
|
8396
8541
|
return shaderLayout;
|
|
8397
8542
|
}
|
|
8398
|
-
function
|
|
8399
|
-
const mergedLayout = {
|
|
8400
|
-
...baseLayout,
|
|
8401
|
-
attributes: baseLayout.attributes.map((attribute) => ({
|
|
8402
|
-
...attribute
|
|
8403
|
-
}))
|
|
8404
|
-
};
|
|
8405
|
-
for (const attribute of overrideLayout?.attributes || []) {
|
|
8406
|
-
const baseAttribute = mergedLayout.attributes.find((attr) => attr.name === attribute.name);
|
|
8407
|
-
if (!baseAttribute) {
|
|
8408
|
-
log.warn(`shader layout attribute ${attribute.name} not present in shader`);
|
|
8409
|
-
} else {
|
|
8410
|
-
baseAttribute.format = attribute.format || baseAttribute.format;
|
|
8411
|
-
baseAttribute.stepMode = attribute.stepMode || baseAttribute.stepMode;
|
|
8412
|
-
}
|
|
8413
|
-
}
|
|
8414
|
-
return mergedLayout;
|
|
8415
|
-
}
|
|
8416
|
-
function mergeBufferMap(baseLayout, bufferMap) {
|
|
8417
|
-
const mergedLayout = {
|
|
8418
|
-
...baseLayout,
|
|
8419
|
-
attributes: baseLayout.attributes.map((attribute) => ({
|
|
8420
|
-
...attribute
|
|
8421
|
-
}))
|
|
8422
|
-
};
|
|
8423
|
-
for (const bufferMapping of bufferMap) {
|
|
8424
|
-
switch (bufferMapping.type) {
|
|
8425
|
-
case "interleave":
|
|
8426
|
-
for (const attributeOverride of bufferMapping.attributes) {
|
|
8427
|
-
overrideShaderLayoutAttribute(mergedLayout, attributeOverride);
|
|
8428
|
-
}
|
|
8429
|
-
break;
|
|
8430
|
-
default:
|
|
8431
|
-
overrideShaderLayoutAttribute(mergedLayout, bufferMapping);
|
|
8432
|
-
}
|
|
8433
|
-
}
|
|
8434
|
-
return mergedLayout;
|
|
8435
|
-
}
|
|
8436
|
-
function overrideShaderLayoutAttribute(layout, attributeOverride) {
|
|
8437
|
-
const attribute = getAttributeFromLayout(layout, attributeOverride.name);
|
|
8438
|
-
if (attribute && attributeOverride.format) {
|
|
8439
|
-
attribute.format = attributeOverride.format;
|
|
8440
|
-
}
|
|
8441
|
-
}
|
|
8442
|
-
function getAttributeFromLayout(shaderLayout, name) {
|
|
8443
|
-
const attribute = shaderLayout.attributes.find((attr) => attr.name === name);
|
|
8444
|
-
if (!attribute) {
|
|
8445
|
-
log.warn(`shader layout attribute "${name}" not present in shader`);
|
|
8446
|
-
}
|
|
8447
|
-
return attribute || null;
|
|
8448
|
-
}
|
|
8449
|
-
function readAttributeBindings(gl2, program) {
|
|
8543
|
+
function readAttributeDeclarations(gl2, program) {
|
|
8450
8544
|
const attributes = [];
|
|
8451
8545
|
const count = gl2.getProgramParameter(program, gl2.ACTIVE_ATTRIBUTES);
|
|
8452
8546
|
for (let index = 0; index < count; index++) {
|
|
@@ -8455,29 +8549,23 @@ ${formattedLog}`)();
|
|
|
8455
8549
|
throw new Error("activeInfo");
|
|
8456
8550
|
}
|
|
8457
8551
|
const {
|
|
8458
|
-
name,
|
|
8459
|
-
type: compositeType
|
|
8460
|
-
size
|
|
8552
|
+
name: name2,
|
|
8553
|
+
type: compositeType
|
|
8554
|
+
/* , size*/
|
|
8461
8555
|
} = activeInfo;
|
|
8462
|
-
const location = gl2.getAttribLocation(program,
|
|
8556
|
+
const location = gl2.getAttribLocation(program, name2);
|
|
8463
8557
|
if (location >= 0) {
|
|
8464
8558
|
const {
|
|
8465
|
-
|
|
8466
|
-
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
size: size * components
|
|
8471
|
-
};
|
|
8472
|
-
if (/instance/i.test(name)) {
|
|
8473
|
-
accessor.divisor = 1;
|
|
8474
|
-
}
|
|
8475
|
-
const attributeInfo = {
|
|
8559
|
+
attributeType
|
|
8560
|
+
} = decodeGLAttributeType(compositeType);
|
|
8561
|
+
const stepMode = /instance/i.test(name2) ? "instance" : "vertex";
|
|
8562
|
+
attributes.push({
|
|
8563
|
+
name: name2,
|
|
8476
8564
|
location,
|
|
8477
|
-
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8565
|
+
stepMode,
|
|
8566
|
+
type: attributeType
|
|
8567
|
+
// size - for arrays, size is the number of elements in the array
|
|
8568
|
+
});
|
|
8481
8569
|
}
|
|
8482
8570
|
}
|
|
8483
8571
|
attributes.sort((a, b) => a.location - b.location);
|
|
@@ -8496,21 +8584,21 @@ ${formattedLog}`)();
|
|
|
8496
8584
|
throw new Error("activeInfo");
|
|
8497
8585
|
}
|
|
8498
8586
|
const {
|
|
8499
|
-
name,
|
|
8587
|
+
name: name2,
|
|
8500
8588
|
type: compositeType,
|
|
8501
8589
|
size
|
|
8502
8590
|
} = activeInfo;
|
|
8503
8591
|
const {
|
|
8504
8592
|
glType,
|
|
8505
8593
|
components
|
|
8506
|
-
} =
|
|
8594
|
+
} = decodeGLUniformType(compositeType);
|
|
8507
8595
|
const accessor = new Accessor({
|
|
8508
8596
|
type: glType,
|
|
8509
8597
|
size: size * components
|
|
8510
8598
|
});
|
|
8511
8599
|
const varying = {
|
|
8512
8600
|
location,
|
|
8513
|
-
name,
|
|
8601
|
+
name: name2,
|
|
8514
8602
|
accessor
|
|
8515
8603
|
};
|
|
8516
8604
|
varyings.push(varying);
|
|
@@ -8532,14 +8620,14 @@ ${formattedLog}`)();
|
|
|
8532
8620
|
type
|
|
8533
8621
|
} = activeInfo;
|
|
8534
8622
|
const {
|
|
8535
|
-
name,
|
|
8623
|
+
name: name2,
|
|
8536
8624
|
isArray: isArray2
|
|
8537
8625
|
} = parseUniformName(rawName);
|
|
8538
|
-
let webglLocation = gl2.getUniformLocation(program,
|
|
8626
|
+
let webglLocation = gl2.getUniformLocation(program, name2);
|
|
8539
8627
|
const uniformInfo = {
|
|
8540
8628
|
// WebGL locations are uniquely typed but just numbers
|
|
8541
8629
|
location: webglLocation,
|
|
8542
|
-
name,
|
|
8630
|
+
name: name2,
|
|
8543
8631
|
size,
|
|
8544
8632
|
type,
|
|
8545
8633
|
isArray: isArray2
|
|
@@ -8547,7 +8635,7 @@ ${formattedLog}`)();
|
|
|
8547
8635
|
uniforms.push(uniformInfo);
|
|
8548
8636
|
if (uniformInfo.size > 1) {
|
|
8549
8637
|
for (let j = 0; j < uniformInfo.size; j++) {
|
|
8550
|
-
const elementName = `${
|
|
8638
|
+
const elementName = `${name2}[${j}]`;
|
|
8551
8639
|
webglLocation = gl2.getUniformLocation(program, elementName);
|
|
8552
8640
|
const arrayElementUniformInfo = {
|
|
8553
8641
|
...uniformInfo,
|
|
@@ -8590,7 +8678,7 @@ ${formattedLog}`)();
|
|
|
8590
8678
|
}
|
|
8591
8679
|
blockInfo.uniforms.push({
|
|
8592
8680
|
name: activeInfo.name,
|
|
8593
|
-
format:
|
|
8681
|
+
format: decodeGLUniformType(uniformType[i]).format,
|
|
8594
8682
|
type: uniformType[i],
|
|
8595
8683
|
arrayLength: uniformArrayLength[i],
|
|
8596
8684
|
byteOffset: uniformOffset[i],
|
|
@@ -8632,18 +8720,18 @@ ${formattedLog}`)();
|
|
|
8632
8720
|
sampleType
|
|
8633
8721
|
};
|
|
8634
8722
|
}
|
|
8635
|
-
function parseUniformName(
|
|
8636
|
-
if (
|
|
8723
|
+
function parseUniformName(name2) {
|
|
8724
|
+
if (name2[name2.length - 1] !== "]") {
|
|
8637
8725
|
return {
|
|
8638
|
-
name,
|
|
8726
|
+
name: name2,
|
|
8639
8727
|
length: 1,
|
|
8640
8728
|
isArray: false
|
|
8641
8729
|
};
|
|
8642
8730
|
}
|
|
8643
8731
|
const UNIFORM_NAME_REGEXP = /([^[]*)(\[[0-9]+\])?/;
|
|
8644
|
-
const matches = UNIFORM_NAME_REGEXP.exec(
|
|
8732
|
+
const matches = UNIFORM_NAME_REGEXP.exec(name2);
|
|
8645
8733
|
if (!matches || matches.length < 2) {
|
|
8646
|
-
throw new Error(`Failed to parse GLSL uniform name ${
|
|
8734
|
+
throw new Error(`Failed to parse GLSL uniform name ${name2}`);
|
|
8647
8735
|
}
|
|
8648
8736
|
return {
|
|
8649
8737
|
name: matches[1],
|
|
@@ -8655,34 +8743,34 @@ ${formattedLog}`)();
|
|
|
8655
8743
|
// src/adapter/helpers/set-uniform.ts
|
|
8656
8744
|
function setUniform(gl2, location, type, value) {
|
|
8657
8745
|
const gl22 = gl2;
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
|
|
8666
|
-
case GL.SAMPLER_CUBE_SHADOW:
|
|
8667
|
-
case GL.INT_SAMPLER_2D:
|
|
8668
|
-
case GL.INT_SAMPLER_3D:
|
|
8669
|
-
case GL.INT_SAMPLER_CUBE:
|
|
8670
|
-
case GL.INT_SAMPLER_2D_ARRAY:
|
|
8671
|
-
case GL.UNSIGNED_INT_SAMPLER_2D:
|
|
8672
|
-
case GL.UNSIGNED_INT_SAMPLER_3D:
|
|
8673
|
-
case GL.UNSIGNED_INT_SAMPLER_CUBE:
|
|
8674
|
-
case GL.UNSIGNED_INT_SAMPLER_2D_ARRAY:
|
|
8675
|
-
return gl2.uniform1i(location, value);
|
|
8676
|
-
}
|
|
8677
|
-
}
|
|
8678
|
-
if (value === true) {
|
|
8679
|
-
value = 1;
|
|
8680
|
-
}
|
|
8681
|
-
if (value === false) {
|
|
8682
|
-
value = 0;
|
|
8683
|
-
}
|
|
8684
|
-
const arrayValue = typeof value === "number" ? [value] : value;
|
|
8746
|
+
let uniformValue = value;
|
|
8747
|
+
if (uniformValue === true) {
|
|
8748
|
+
uniformValue = 1;
|
|
8749
|
+
}
|
|
8750
|
+
if (uniformValue === false) {
|
|
8751
|
+
uniformValue = 0;
|
|
8752
|
+
}
|
|
8753
|
+
const arrayValue = typeof uniformValue === "number" ? [uniformValue] : uniformValue;
|
|
8685
8754
|
switch (type) {
|
|
8755
|
+
case GL.SAMPLER_2D:
|
|
8756
|
+
case GL.SAMPLER_CUBE:
|
|
8757
|
+
case GL.SAMPLER_3D:
|
|
8758
|
+
case GL.SAMPLER_2D_SHADOW:
|
|
8759
|
+
case GL.SAMPLER_2D_ARRAY:
|
|
8760
|
+
case GL.SAMPLER_2D_ARRAY_SHADOW:
|
|
8761
|
+
case GL.SAMPLER_CUBE_SHADOW:
|
|
8762
|
+
case GL.INT_SAMPLER_2D:
|
|
8763
|
+
case GL.INT_SAMPLER_3D:
|
|
8764
|
+
case GL.INT_SAMPLER_CUBE:
|
|
8765
|
+
case GL.INT_SAMPLER_2D_ARRAY:
|
|
8766
|
+
case GL.UNSIGNED_INT_SAMPLER_2D:
|
|
8767
|
+
case GL.UNSIGNED_INT_SAMPLER_3D:
|
|
8768
|
+
case GL.UNSIGNED_INT_SAMPLER_CUBE:
|
|
8769
|
+
case GL.UNSIGNED_INT_SAMPLER_2D_ARRAY:
|
|
8770
|
+
if (typeof value !== "number") {
|
|
8771
|
+
throw new Error("samplers must be set to integers");
|
|
8772
|
+
}
|
|
8773
|
+
return gl2.uniform1i(location, value);
|
|
8686
8774
|
case GL.FLOAT:
|
|
8687
8775
|
return gl2.uniform1fv(location, arrayValue);
|
|
8688
8776
|
case GL.FLOAT_VEC2:
|
|
@@ -8934,8 +9022,8 @@ ${formattedLog}`)();
|
|
|
8934
9022
|
/** Handle to underlying WebGL program */
|
|
8935
9023
|
/** vertex shader */
|
|
8936
9024
|
/** fragment shader */
|
|
8937
|
-
/** The merged layout */
|
|
8938
9025
|
/** The layout extracted from shader by WebGL introspection APIs */
|
|
9026
|
+
/** The merged layout */
|
|
8939
9027
|
/** Buffer map describing buffer interleaving etc */
|
|
8940
9028
|
/** Uniforms set on this model */
|
|
8941
9029
|
uniforms = {};
|
|
@@ -8972,9 +9060,8 @@ ${formattedLog}`)();
|
|
|
8972
9060
|
}
|
|
8973
9061
|
this._compileAndLink();
|
|
8974
9062
|
this.introspectedLayout = getShaderLayout(this.device.gl, this.handle);
|
|
8975
|
-
this.
|
|
8976
|
-
this.
|
|
8977
|
-
this.layout = mergeBufferMap(this.layout, this.bufferMap);
|
|
9063
|
+
this.shaderLayout = mergeShaderLayout(this.introspectedLayout, props.shaderLayout);
|
|
9064
|
+
this.bufferLayout = props.bufferLayout || [];
|
|
8978
9065
|
this.vertexArrayObject = new WEBGLVertexArrayObject(this.device);
|
|
8979
9066
|
}
|
|
8980
9067
|
destroy() {
|
|
@@ -8989,70 +9076,75 @@ ${formattedLog}`)();
|
|
|
8989
9076
|
this._indexBuffer = webglBuffer;
|
|
8990
9077
|
}
|
|
8991
9078
|
/** @todo needed for portable model */
|
|
8992
|
-
setAttributes(
|
|
8993
|
-
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
9079
|
+
setAttributes(buffers) {
|
|
9080
|
+
const attributeInfos = getAttributeInfosFromLayouts(this.shaderLayout, this.bufferLayout);
|
|
9081
|
+
for (const [bufferName, buffer] of Object.entries(buffers)) {
|
|
9082
|
+
let set = false;
|
|
9083
|
+
for (const attributeInfo of Object.values(attributeInfos)) {
|
|
9084
|
+
if (attributeInfo.bufferName !== bufferName) {
|
|
9085
|
+
continue;
|
|
9086
|
+
}
|
|
9087
|
+
const webglBuffer = cast(buffer);
|
|
9088
|
+
const glType = getGLFromVertexType(attributeInfo.bufferDataType);
|
|
9089
|
+
log.log(1, {
|
|
9090
|
+
setAttribute: attributeInfo.name,
|
|
9091
|
+
toBuffer: bufferName,
|
|
9092
|
+
size: attributeInfo.bufferComponents,
|
|
9093
|
+
type: glType,
|
|
9094
|
+
stride: attributeInfo.byteStride,
|
|
9095
|
+
offset: attributeInfo.byteOffset,
|
|
9096
|
+
normalized: attributeInfo.normalized,
|
|
9097
|
+
// it is the shader attribute declaration, not the vertex memory format,
|
|
9098
|
+
// that determines if the data in the buffer will be treated as integers.
|
|
9099
|
+
// /
|
|
9100
|
+
// Also note that WebGL supports assigning non-normalized integer data to floating point attributes,
|
|
9101
|
+
// but as far as we can tell, WebGPU does not.
|
|
9102
|
+
integer: attributeInfo.integer,
|
|
9103
|
+
divisor: attributeInfo.stepMode === "instance" ? 1 : 0
|
|
9104
|
+
})();
|
|
9105
|
+
this.vertexArrayObject.setBuffer(attributeInfo.location, webglBuffer, {
|
|
9106
|
+
size: attributeInfo.bufferComponents,
|
|
9107
|
+
type: glType,
|
|
9108
|
+
stride: attributeInfo.byteStride,
|
|
9109
|
+
offset: attributeInfo.byteOffset,
|
|
9110
|
+
normalized: attributeInfo.normalized,
|
|
9111
|
+
// it is the shader attribute declaration, not the vertex memory format,
|
|
9112
|
+
// that determines if the data in the buffer will be treated as integers.
|
|
9113
|
+
// /
|
|
9114
|
+
// Also note that WebGL supports assigning non-normalized integer data to floating point attributes,
|
|
9115
|
+
// but as far as we can tell, WebGPU does not.
|
|
9116
|
+
integer: attributeInfo.integer,
|
|
9117
|
+
divisor: attributeInfo.stepMode === "instance" ? 1 : 0
|
|
9118
|
+
});
|
|
9119
|
+
set = true;
|
|
9120
|
+
}
|
|
9121
|
+
if (!set) {
|
|
9122
|
+
log.warn(`setAttributes(): Ignoring (buffer "${buffer.id}" for unknown attribute "${name}" in pipeline "${this.id}"`)();
|
|
8999
9123
|
}
|
|
9000
|
-
const decoded = decodeVertexFormat(attribute.format);
|
|
9001
|
-
const {
|
|
9002
|
-
type: typeString,
|
|
9003
|
-
components: size,
|
|
9004
|
-
byteLength: stride,
|
|
9005
|
-
normalized
|
|
9006
|
-
/* , integer*/
|
|
9007
|
-
} = decoded;
|
|
9008
|
-
const divisor = attribute.stepMode === "instance" ? 1 : 0;
|
|
9009
|
-
const type = getWebGLDataType(typeString);
|
|
9010
|
-
this.vertexArrayObject.setBuffer(attribute.location, webglBuffer, {
|
|
9011
|
-
size,
|
|
9012
|
-
type,
|
|
9013
|
-
stride,
|
|
9014
|
-
offset: 0,
|
|
9015
|
-
normalized,
|
|
9016
|
-
// it is the shader attribute declaration, not the vertex memory format,
|
|
9017
|
-
// that determines if the data in the buffer will be treated as integers.
|
|
9018
|
-
// /
|
|
9019
|
-
// Also note that WebGL supports assigning non-normalized integer data to floating point attributes,
|
|
9020
|
-
// but as far as we can tell, WebGPU does not.
|
|
9021
|
-
integer: false,
|
|
9022
|
-
divisor
|
|
9023
|
-
});
|
|
9024
9124
|
}
|
|
9025
9125
|
}
|
|
9026
9126
|
/**
|
|
9027
9127
|
* Constant attributes are only supported in WebGL, not in WebGPU
|
|
9028
9128
|
* Any attribute that is disabled in the current vertex array object
|
|
9029
9129
|
* is read from the context's global constant value for that attribute location.
|
|
9030
|
-
* @param attributes
|
|
9130
|
+
* @param attributes
|
|
9031
9131
|
*/
|
|
9032
9132
|
setConstantAttributes(attributes) {
|
|
9033
|
-
for (const [name, value] of Object.entries(attributes)) {
|
|
9034
|
-
const attribute = getAttributeLayout(this.layout, name);
|
|
9035
|
-
if (!attribute) {
|
|
9036
|
-
log.warn(`Ignoring constant value supplied for unknown attribute "${name}" in pipeline "${this.id}"`)();
|
|
9037
|
-
continue;
|
|
9038
|
-
}
|
|
9039
|
-
this.vertexArrayObject.setConstant(attribute.location, value);
|
|
9040
|
-
}
|
|
9041
9133
|
Object.assign(this.constantAttributes, attributes);
|
|
9042
9134
|
}
|
|
9043
|
-
/**
|
|
9135
|
+
/**
|
|
9044
9136
|
* Bindings include: textures, samplers and uniform buffers
|
|
9045
|
-
* @todo needed for portable model
|
|
9137
|
+
* @todo needed for portable model
|
|
9046
9138
|
*/
|
|
9047
9139
|
setBindings(bindings) {
|
|
9048
|
-
for (const [
|
|
9049
|
-
const binding = this.
|
|
9140
|
+
for (const [name2, value] of Object.entries(bindings)) {
|
|
9141
|
+
const binding = this.shaderLayout.bindings.find((binding2) => binding2.name === name2);
|
|
9050
9142
|
if (!binding) {
|
|
9051
|
-
log.warn(`Unknown binding ${
|
|
9143
|
+
log.warn(`Unknown binding ${name2} in render pipeline ${this.id}`)();
|
|
9052
9144
|
continue;
|
|
9053
9145
|
}
|
|
9054
9146
|
if (!value) {
|
|
9055
|
-
log.warn(`Unsetting binding ${
|
|
9147
|
+
log.warn(`Unsetting binding ${name2} in render pipeline ${this.id}`)();
|
|
9056
9148
|
}
|
|
9057
9149
|
switch (binding.type) {
|
|
9058
9150
|
case "uniform":
|
|
@@ -9066,12 +9158,12 @@ ${formattedLog}`)();
|
|
|
9066
9158
|
}
|
|
9067
9159
|
break;
|
|
9068
9160
|
case "sampler":
|
|
9069
|
-
log.warn(`Ignoring sampler ${
|
|
9161
|
+
log.warn(`Ignoring sampler ${name2}`)();
|
|
9070
9162
|
break;
|
|
9071
9163
|
default:
|
|
9072
9164
|
throw new Error(binding.type);
|
|
9073
9165
|
}
|
|
9074
|
-
this.bindings[
|
|
9166
|
+
this.bindings[name2] = value;
|
|
9075
9167
|
}
|
|
9076
9168
|
}
|
|
9077
9169
|
setUniforms(uniforms) {
|
|
@@ -9092,7 +9184,7 @@ ${formattedLog}`)();
|
|
|
9092
9184
|
// firstInstance,
|
|
9093
9185
|
// baseVertex
|
|
9094
9186
|
} = options;
|
|
9095
|
-
const drawMode =
|
|
9187
|
+
const drawMode = getGLDrawMode(this.props.topology);
|
|
9096
9188
|
const isIndexed = Boolean(this._indexBuffer);
|
|
9097
9189
|
const indexType = this._indexBuffer?.glIndexType;
|
|
9098
9190
|
const isInstanced = Number(options.instanceCount) > 0;
|
|
@@ -9178,7 +9270,24 @@ ${formattedLog}`)();
|
|
|
9178
9270
|
}
|
|
9179
9271
|
return texturesRenderable;
|
|
9180
9272
|
}
|
|
9181
|
-
/**
|
|
9273
|
+
/**
|
|
9274
|
+
* Constant attributes need to be reset before every draw call
|
|
9275
|
+
* Any attribute that is disabled in the current vertex array object
|
|
9276
|
+
* is read from the context's global constant value for that attribute location.
|
|
9277
|
+
* @note Constant attributes are only supported in WebGL, not in WebGPU
|
|
9278
|
+
*/
|
|
9279
|
+
_applyConstantAttributes() {
|
|
9280
|
+
const attributeInfos = getAttributeInfosFromLayouts(this.shaderLayout, this.bufferLayout);
|
|
9281
|
+
for (const [name2, value] of Object.entries(this.constantAttributes)) {
|
|
9282
|
+
const attributeInfo = attributeInfos[name2];
|
|
9283
|
+
if (!attributeInfo) {
|
|
9284
|
+
log.warn(`Ignoring constant value supplied for unknown attribute "${name2}" in pipeline "${this.id}"`)();
|
|
9285
|
+
continue;
|
|
9286
|
+
}
|
|
9287
|
+
this.vertexArrayObject.setConstant(attributeInfo.location, value);
|
|
9288
|
+
}
|
|
9289
|
+
}
|
|
9290
|
+
/** Apply any bindings (before each draw call) */
|
|
9182
9291
|
_applyBindings() {
|
|
9183
9292
|
this.device.gl.useProgram(this.handle);
|
|
9184
9293
|
const {
|
|
@@ -9189,7 +9298,7 @@ ${formattedLog}`)();
|
|
|
9189
9298
|
}
|
|
9190
9299
|
let textureUnit = 0;
|
|
9191
9300
|
let uniformBufferIndex = 0;
|
|
9192
|
-
for (const binding of this.
|
|
9301
|
+
for (const binding of this.shaderLayout.bindings) {
|
|
9193
9302
|
const value = this.bindings[binding.name];
|
|
9194
9303
|
if (!value) {
|
|
9195
9304
|
throw new Error(`No value for binding ${binding.name} in ${this.id}`);
|
|
@@ -9197,11 +9306,11 @@ ${formattedLog}`)();
|
|
|
9197
9306
|
switch (binding.type) {
|
|
9198
9307
|
case "uniform":
|
|
9199
9308
|
const {
|
|
9200
|
-
name
|
|
9309
|
+
name: name2
|
|
9201
9310
|
} = binding;
|
|
9202
|
-
const location = gl2.getUniformBlockIndex(this.handle,
|
|
9311
|
+
const location = gl2.getUniformBlockIndex(this.handle, name2);
|
|
9203
9312
|
if (location === GL.INVALID_INDEX) {
|
|
9204
|
-
throw new Error(`Invalid uniform block name ${
|
|
9313
|
+
throw new Error(`Invalid uniform block name ${name2}`);
|
|
9205
9314
|
}
|
|
9206
9315
|
gl2.uniformBlockBinding(this.handle, uniformBufferIndex, location);
|
|
9207
9316
|
if (value instanceof WEBGLBuffer) {
|
|
@@ -9228,37 +9337,26 @@ ${formattedLog}`)();
|
|
|
9228
9337
|
}
|
|
9229
9338
|
}
|
|
9230
9339
|
}
|
|
9340
|
+
/**
|
|
9341
|
+
* Due to program sharing, uniforms need to be reset before every draw call
|
|
9342
|
+
* (though caching will avoid redundant WebGL calls)
|
|
9343
|
+
*/
|
|
9231
9344
|
_applyUniforms() {
|
|
9232
|
-
for (const uniformLayout of this.
|
|
9345
|
+
for (const uniformLayout of this.shaderLayout.uniforms || []) {
|
|
9233
9346
|
const {
|
|
9234
|
-
name,
|
|
9347
|
+
name: name2,
|
|
9235
9348
|
location,
|
|
9236
9349
|
type,
|
|
9237
9350
|
textureUnit
|
|
9238
9351
|
} = uniformLayout;
|
|
9239
|
-
const value = this.uniforms[
|
|
9352
|
+
const value = this.uniforms[name2] ?? textureUnit;
|
|
9240
9353
|
if (value !== void 0) {
|
|
9241
9354
|
setUniform(this.device.gl, location, type, value);
|
|
9242
9355
|
}
|
|
9243
9356
|
}
|
|
9244
9357
|
}
|
|
9245
|
-
/**
|
|
9246
|
-
* Constant attributes are only supported in WebGL, not in WebGPU
|
|
9247
|
-
* Any attribute that is disabled in the current vertex array object
|
|
9248
|
-
* is read from the context's global constant value for that attribute location.
|
|
9249
|
-
*/
|
|
9250
|
-
_applyConstantAttributes() {
|
|
9251
|
-
for (const [name, value] of Object.entries(this.constantAttributes)) {
|
|
9252
|
-
const attribute = getAttributeLayout(this.layout, name);
|
|
9253
|
-
if (!attribute) {
|
|
9254
|
-
log.warn(`Ignoring constant value supplied for unknown attribute "${name}" in pipeline "${this.id}"`)();
|
|
9255
|
-
continue;
|
|
9256
|
-
}
|
|
9257
|
-
this.vertexArrayObject.setConstant(attribute.location, value);
|
|
9258
|
-
}
|
|
9259
|
-
}
|
|
9260
9358
|
};
|
|
9261
|
-
function
|
|
9359
|
+
function getGLDrawMode(topology) {
|
|
9262
9360
|
switch (topology) {
|
|
9263
9361
|
case "point-list":
|
|
9264
9362
|
return GL.POINTS;
|
|
@@ -9298,9 +9396,6 @@ ${formattedLog}`)();
|
|
|
9298
9396
|
throw new Error(topology);
|
|
9299
9397
|
}
|
|
9300
9398
|
}
|
|
9301
|
-
function getAttributeLayout(layout, name) {
|
|
9302
|
-
return layout.attributes.find((binding) => binding.name === name) || null;
|
|
9303
|
-
}
|
|
9304
9399
|
|
|
9305
9400
|
// src/adapter/resources/webgl-command-buffer.ts
|
|
9306
9401
|
function cast2(value) {
|
|
@@ -9501,7 +9596,7 @@ ${formattedLog}`)();
|
|
|
9501
9596
|
// src/adapter/resources/webgl-command-encoder.ts
|
|
9502
9597
|
var WEBGLCommandEncoder = class extends CommandEncoder {
|
|
9503
9598
|
constructor(device, props) {
|
|
9504
|
-
super(props);
|
|
9599
|
+
super(device, props);
|
|
9505
9600
|
this.device = device;
|
|
9506
9601
|
this.commandBuffer = new WEBGLCommandBuffer(device);
|
|
9507
9602
|
}
|