@luma.gl/webgl 9.0.0-beta.5 → 9.0.0-beta.6
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/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +71 -11
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +3 -2
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
- package/dist/adapter/converters/shader-formats.js +40 -20
- package/dist/adapter/converters/texture-formats.d.ts +10 -7
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +76 -64
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +2 -1
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +18 -5
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +77 -43
- package/dist/adapter/device-helpers/webgl-device-info.d.ts +2 -1
- package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-info.js +17 -14
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts +33 -48
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-limits.js +42 -87
- package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -1
- package/dist/adapter/helpers/decode-webgl-types.js +2 -1
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +6 -5
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js +3 -2
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +2 -1
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js +2 -1
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +2 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +2 -2
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +24 -11
- package/dist/adapter/objects/webgl-resource.d.ts +2 -24
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +6 -100
- package/dist/adapter/resources/webgl-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +2 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +7 -6
- package/dist/adapter/resources/webgl-command-encoder.d.ts +8 -3
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +4 -2
- package/dist/adapter/resources/webgl-external-texture.js +3 -2
- package/dist/adapter/resources/webgl-framebuffer.d.ts +6 -8
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +25 -23
- package/dist/adapter/resources/webgl-query-set.d.ts +44 -0
- package/dist/adapter/resources/webgl-query-set.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-query-set.js +136 -0
- package/dist/adapter/resources/webgl-render-pass.d.ts +3 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +15 -7
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +4 -5
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +34 -49
- package/dist/adapter/resources/webgl-sampler.d.ts +1 -1
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +3 -2
- package/dist/adapter/resources/webgl-shader.d.ts +3 -2
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +12 -6
- package/dist/adapter/resources/webgl-texture-view.d.ts +14 -0
- package/dist/adapter/resources/webgl-texture-view.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-texture-view.js +18 -0
- package/dist/adapter/resources/webgl-texture.d.ts +4 -3
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +12 -7
- package/dist/adapter/resources/webgl-transform-feedback.d.ts +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +2 -2
- package/dist/adapter/resources/webgl-vertex-array.d.ts +3 -3
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +5 -4
- package/dist/adapter/webgl-canvas-context.d.ts +2 -2
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +3 -2
- package/dist/adapter/webgl-device.d.ts +29 -27
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +90 -94
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +4 -3
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +3 -2
- package/dist/classic/copy-and-blit.d.ts +1 -1
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +5 -4
- package/dist/classic/format-utils.d.ts +2 -2
- package/dist/classic/format-utils.d.ts.map +1 -1
- package/dist/classic/format-utils.js +2 -1
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +2 -1
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +2 -1
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +7 -6
- package/dist/context/helpers/create-browser-context.d.ts +35 -0
- package/dist/context/helpers/create-browser-context.d.ts.map +1 -0
- package/dist/context/helpers/create-browser-context.js +67 -0
- package/dist/context/helpers/webgl-context-data.d.ts +13 -0
- package/dist/context/helpers/webgl-context-data.d.ts.map +1 -0
- package/dist/context/helpers/webgl-context-data.js +21 -0
- package/dist/context/helpers/webgl-extensions.d.ts +4 -0
- package/dist/context/helpers/webgl-extensions.d.ts.map +1 -0
- package/dist/context/helpers/webgl-extensions.js +10 -0
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +4 -3
- package/dist/context/parameters/webgl-parameter-tables.d.ts +10 -0
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +29 -16
- package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.js +2 -1
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +5 -4
- package/dist/context/state-tracker/with-parameters.d.ts +1 -1
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +5 -4
- package/dist/dist.dev.js +941 -730
- package/dist/index.cjs +732 -565
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +25 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -23
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist.min.js +5 -5
- package/package.json +4 -4
- package/src/adapter/converters/device-parameters.ts +105 -16
- package/src/adapter/converters/sampler-parameters.ts +12 -3
- package/src/adapter/converters/shader-formats.ts +47 -22
- package/src/adapter/converters/texture-formats.ts +87 -66
- package/src/adapter/converters/vertex-formats.ts +3 -3
- package/src/adapter/device-helpers/webgl-device-features.ts +83 -51
- package/src/adapter/device-helpers/webgl-device-info.ts +28 -19
- package/src/adapter/device-helpers/webgl-device-limits.ts +46 -150
- package/src/adapter/helpers/decode-webgl-types.ts +13 -7
- package/src/adapter/helpers/get-shader-layout.ts +4 -3
- package/src/adapter/helpers/parse-shader-compiler-log.ts +10 -6
- package/src/adapter/helpers/set-uniform.ts +2 -1
- package/src/adapter/helpers/webgl-topology-utils.ts +10 -3
- package/src/adapter/objects/constants-to-keys.ts +2 -1
- package/src/adapter/objects/webgl-renderbuffer.ts +35 -13
- package/src/adapter/objects/webgl-resource.ts +6 -124
- package/src/adapter/resources/webgl-buffer.ts +4 -3
- package/src/adapter/resources/webgl-command-buffer.ts +5 -5
- package/src/adapter/resources/webgl-command-encoder.ts +14 -11
- package/src/adapter/resources/webgl-external-texture.ts +3 -2
- package/src/adapter/resources/webgl-framebuffer.ts +34 -29
- package/src/adapter/resources/webgl-query-set.ts +171 -0
- package/src/adapter/resources/webgl-render-pass.ts +17 -8
- package/src/adapter/resources/webgl-render-pipeline.ts +41 -48
- package/src/adapter/resources/webgl-sampler.ts +2 -1
- package/src/adapter/resources/webgl-shader.ts +12 -5
- package/src/adapter/resources/webgl-texture-view.ts +28 -0
- package/src/adapter/resources/webgl-texture.ts +9 -2
- package/src/adapter/resources/webgl-transform-feedback.ts +2 -7
- package/src/adapter/resources/webgl-vertex-array.ts +4 -3
- package/src/adapter/webgl-canvas-context.ts +6 -4
- package/src/adapter/webgl-device.ts +94 -90
- package/src/classic/accessor.ts +5 -4
- package/src/classic/clear.ts +12 -6
- package/src/classic/copy-and-blit.ts +11 -4
- package/src/classic/format-utils.ts +2 -1
- package/src/classic/typed-array-utils.ts +3 -7
- package/src/context/debug/spector.ts +9 -6
- package/src/context/debug/webgl-developer-tools.ts +27 -14
- package/src/context/{context → helpers}/create-browser-context.ts +3 -2
- package/src/context/helpers/webgl-context-data.ts +31 -0
- package/src/context/helpers/webgl-extensions.ts +17 -0
- package/src/context/parameters/unified-parameter-api.ts +2 -1
- package/src/context/parameters/webgl-parameter-tables.ts +69 -32
- package/src/context/state-tracker/deep-array-equal.ts +2 -1
- package/src/context/state-tracker/track-context-state.ts +11 -6
- package/src/context/state-tracker/with-parameters.ts +7 -2
- package/src/index.ts +3 -2
- package/src/types.ts +2 -1
- package/src/context/context/context-data.ts +0 -44
package/dist/dist.dev.js
CHANGED
|
@@ -856,7 +856,9 @@ var __exports__ = (() => {
|
|
|
856
856
|
const VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "running from source";
|
|
857
857
|
const STARTUP_MESSAGE = "set luma.log.level=1 (or higher) to trace rendering";
|
|
858
858
|
if (globalThis.luma && globalThis.luma.VERSION !== VERSION3) {
|
|
859
|
-
throw new Error(
|
|
859
|
+
throw new Error(
|
|
860
|
+
`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${VERSION3}`
|
|
861
|
+
);
|
|
860
862
|
}
|
|
861
863
|
if (!globalThis.luma) {
|
|
862
864
|
if (isBrowser()) {
|
|
@@ -952,20 +954,20 @@ var __exports__ = (() => {
|
|
|
952
954
|
return this.props;
|
|
953
955
|
}
|
|
954
956
|
// ATTACHED RESOURCES
|
|
955
|
-
/**
|
|
957
|
+
/**
|
|
956
958
|
* Attaches a resource. Attached resources are auto destroyed when this resource is destroyed
|
|
957
959
|
* Called automatically when sub resources are auto created but can be called by application
|
|
958
960
|
*/
|
|
959
961
|
attachResource(resource) {
|
|
960
962
|
this._attachedResources.add(resource);
|
|
961
963
|
}
|
|
962
|
-
/**
|
|
964
|
+
/**
|
|
963
965
|
* Detach an attached resource. The resource will no longer be auto-destroyed when this resource is destroyed.
|
|
964
966
|
*/
|
|
965
967
|
detachResource(resource) {
|
|
966
968
|
this._attachedResources.delete(resource);
|
|
967
969
|
}
|
|
968
|
-
/**
|
|
970
|
+
/**
|
|
969
971
|
* Destroys a resource (only if owned), and removes from the owned (auto-destroy) list for this resource.
|
|
970
972
|
*/
|
|
971
973
|
destroyAttachedResource(resource) {
|
|
@@ -1063,7 +1065,10 @@ var __exports__ = (() => {
|
|
|
1063
1065
|
/** This doesn't handle partial non-zero offset updates correctly */
|
|
1064
1066
|
_setDebugData(data, byteOffset, byteLength) {
|
|
1065
1067
|
const buffer = ArrayBuffer.isView(data) ? data.buffer : data;
|
|
1066
|
-
const debugDataLength = Math.min(
|
|
1068
|
+
const debugDataLength = Math.min(
|
|
1069
|
+
data ? data.byteLength : byteLength,
|
|
1070
|
+
_Buffer.DEBUG_DATA_MAX_LENGTH
|
|
1071
|
+
);
|
|
1067
1072
|
if (data === null) {
|
|
1068
1073
|
this.debugData = new ArrayBuffer(debugDataLength);
|
|
1069
1074
|
} else if (byteOffset === 0 && byteLength === data.byteLength) {
|
|
@@ -1103,7 +1108,140 @@ var __exports__ = (() => {
|
|
|
1103
1108
|
/** Max amount of debug data saved. Two vec4's */
|
|
1104
1109
|
__publicField(Buffer2, "DEBUG_DATA_MAX_LENGTH", 32);
|
|
1105
1110
|
|
|
1111
|
+
// ../core/src/adapter/type-utils/decode-data-type.ts
|
|
1112
|
+
function decodeVertexType(type) {
|
|
1113
|
+
const dataType = TYPE_MAP[type];
|
|
1114
|
+
const bytes = getDataTypeBytes(dataType);
|
|
1115
|
+
const normalized = type.includes("norm");
|
|
1116
|
+
const integer = !normalized && !type.startsWith("float");
|
|
1117
|
+
const signed = type.startsWith("s");
|
|
1118
|
+
return {
|
|
1119
|
+
dataType: TYPE_MAP[type],
|
|
1120
|
+
byteLength: bytes,
|
|
1121
|
+
integer,
|
|
1122
|
+
signed,
|
|
1123
|
+
normalized
|
|
1124
|
+
};
|
|
1125
|
+
}
|
|
1126
|
+
function getDataTypeBytes(type) {
|
|
1127
|
+
const bytes = TYPE_SIZES[type];
|
|
1128
|
+
return bytes;
|
|
1129
|
+
}
|
|
1130
|
+
var TYPE_MAP = {
|
|
1131
|
+
uint8: "uint8",
|
|
1132
|
+
sint8: "sint8",
|
|
1133
|
+
unorm8: "uint8",
|
|
1134
|
+
snorm8: "sint8",
|
|
1135
|
+
uint16: "uint16",
|
|
1136
|
+
sint16: "sint16",
|
|
1137
|
+
unorm16: "uint16",
|
|
1138
|
+
snorm16: "sint16",
|
|
1139
|
+
float16: "float16",
|
|
1140
|
+
float32: "float32",
|
|
1141
|
+
uint32: "uint32",
|
|
1142
|
+
sint32: "sint32"
|
|
1143
|
+
};
|
|
1144
|
+
var TYPE_SIZES = {
|
|
1145
|
+
uint8: 1,
|
|
1146
|
+
sint8: 1,
|
|
1147
|
+
uint16: 2,
|
|
1148
|
+
sint16: 2,
|
|
1149
|
+
float16: 2,
|
|
1150
|
+
float32: 4,
|
|
1151
|
+
uint32: 4,
|
|
1152
|
+
sint32: 4
|
|
1153
|
+
};
|
|
1154
|
+
|
|
1155
|
+
// ../core/src/adapter/type-utils/decode-texture-format.ts
|
|
1156
|
+
var COMPRESSED_TEXTURE_FORMAT_PREFIXES = [
|
|
1157
|
+
"bc1",
|
|
1158
|
+
"bc2",
|
|
1159
|
+
"bc3",
|
|
1160
|
+
"bc4",
|
|
1161
|
+
"bc5",
|
|
1162
|
+
"bc6",
|
|
1163
|
+
"bc7",
|
|
1164
|
+
"etc1",
|
|
1165
|
+
"etc2",
|
|
1166
|
+
"eac",
|
|
1167
|
+
"atc",
|
|
1168
|
+
"astc",
|
|
1169
|
+
"pvrtc"
|
|
1170
|
+
];
|
|
1171
|
+
var REGEX = /^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;
|
|
1172
|
+
function isTextureFormatCompressed(textureFormat) {
|
|
1173
|
+
return COMPRESSED_TEXTURE_FORMAT_PREFIXES.some((prefix) => textureFormat.startsWith(prefix));
|
|
1174
|
+
}
|
|
1175
|
+
function decodeTextureFormat(format) {
|
|
1176
|
+
const matches = REGEX.exec(format);
|
|
1177
|
+
if (matches) {
|
|
1178
|
+
const [, format2, length, type, srgb, suffix] = matches;
|
|
1179
|
+
if (format2) {
|
|
1180
|
+
const dataType = `${type}${length}`;
|
|
1181
|
+
const decodedType = decodeVertexType(dataType);
|
|
1182
|
+
return {
|
|
1183
|
+
format: format2,
|
|
1184
|
+
components: format2.length,
|
|
1185
|
+
// dataType - overwritten by decodedType
|
|
1186
|
+
srgb: srgb === "-srgb",
|
|
1187
|
+
unsized: suffix === "-unsized",
|
|
1188
|
+
webgl: suffix === "-webgl",
|
|
1189
|
+
...decodedType
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
return decodeNonStandardFormat(format);
|
|
1194
|
+
}
|
|
1195
|
+
var EXCEPTIONS = {
|
|
1196
|
+
// Packed 16 bit formats
|
|
1197
|
+
"rgba4unorm-webgl": { format: "rgba", bpp: 2 },
|
|
1198
|
+
"rgb565unorm-webgl": { format: "rgb", bpp: 2 },
|
|
1199
|
+
"rgb5a1unorm-webgl": { format: "rgba", bbp: 2 },
|
|
1200
|
+
// Packed 32 bit formats
|
|
1201
|
+
rgb9e5ufloat: { format: "rgb", bbp: 4 },
|
|
1202
|
+
rg11b10ufloat: { format: "rgb", bbp: 4 },
|
|
1203
|
+
rgb10a2unorm: { format: "rgba", bbp: 4 },
|
|
1204
|
+
"rgb10a2uint-webgl": { format: "rgba", bbp: 4 },
|
|
1205
|
+
// Depth/stencil
|
|
1206
|
+
stencil8: { components: 1, bpp: 1, a: "stencil" },
|
|
1207
|
+
depth16unorm: { components: 1, bpp: 2, a: "depth" },
|
|
1208
|
+
depth24plus: { components: 1, bpp: 3, a: "depth" },
|
|
1209
|
+
depth32float: { components: 1, bpp: 4, a: "depth" },
|
|
1210
|
+
"depth24plus-stencil8": { components: 2, bpp: 4, a: "depth-stencil" },
|
|
1211
|
+
// "depth24unorm-stencil8" feature
|
|
1212
|
+
"depth24unorm-stencil8": { components: 2, bpp: 4, a: "depth-stencil" },
|
|
1213
|
+
// "depth32float-stencil8" feature
|
|
1214
|
+
"depth32float-stencil8": { components: 2, bpp: 4, a: "depth-stencil" }
|
|
1215
|
+
};
|
|
1216
|
+
function decodeNonStandardFormat(format) {
|
|
1217
|
+
const data = EXCEPTIONS[format];
|
|
1218
|
+
if (!data) {
|
|
1219
|
+
throw new Error(`Unknown format ${format}`);
|
|
1220
|
+
}
|
|
1221
|
+
return {
|
|
1222
|
+
format: data.format || "",
|
|
1223
|
+
components: data.components || data.format?.length || 1,
|
|
1224
|
+
byteLength: data.bpp || 1,
|
|
1225
|
+
srgb: false,
|
|
1226
|
+
unsized: false
|
|
1227
|
+
};
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1106
1230
|
// ../core/src/adapter/device.ts
|
|
1231
|
+
var DeviceLimits = class {
|
|
1232
|
+
};
|
|
1233
|
+
var DeviceFeatures = class {
|
|
1234
|
+
features;
|
|
1235
|
+
constructor(features = []) {
|
|
1236
|
+
this.features = new Set(features);
|
|
1237
|
+
}
|
|
1238
|
+
*[Symbol.iterator]() {
|
|
1239
|
+
yield* this.features;
|
|
1240
|
+
}
|
|
1241
|
+
has(feature) {
|
|
1242
|
+
return this.features.has(feature);
|
|
1243
|
+
}
|
|
1244
|
+
};
|
|
1107
1245
|
var _Device = class {
|
|
1108
1246
|
get [Symbol.toStringTag]() {
|
|
1109
1247
|
return "Device";
|
|
@@ -1122,6 +1260,10 @@ var __exports__ = (() => {
|
|
|
1122
1260
|
userData = {};
|
|
1123
1261
|
/** Used by other luma.gl modules to store data on the device */
|
|
1124
1262
|
_lumaData = {};
|
|
1263
|
+
/** Check if a specific texture format is GPU compressed */
|
|
1264
|
+
isTextureFormatCompressed(format) {
|
|
1265
|
+
return isTextureFormatCompressed(format);
|
|
1266
|
+
}
|
|
1125
1267
|
/**
|
|
1126
1268
|
* Trigger device loss.
|
|
1127
1269
|
* @returns `true` if context loss could actually be triggered.
|
|
@@ -1172,7 +1314,12 @@ var __exports__ = (() => {
|
|
|
1172
1314
|
clearWebGL(options) {
|
|
1173
1315
|
throw new Error("not implemented");
|
|
1174
1316
|
}
|
|
1175
|
-
//
|
|
1317
|
+
// IMPLEMENTATION
|
|
1318
|
+
// Error Handling
|
|
1319
|
+
/** Report unhandled device errors */
|
|
1320
|
+
onError(error) {
|
|
1321
|
+
this.props.onError(error);
|
|
1322
|
+
}
|
|
1176
1323
|
_getBufferProps(props) {
|
|
1177
1324
|
if (props instanceof ArrayBuffer || ArrayBuffer.isView(props)) {
|
|
1178
1325
|
props = { data: props };
|
|
@@ -1200,8 +1347,11 @@ var __exports__ = (() => {
|
|
|
1200
1347
|
width: 800,
|
|
1201
1348
|
// width are height are only used by headless gl
|
|
1202
1349
|
height: 600,
|
|
1350
|
+
requestMaximalLimits: true,
|
|
1203
1351
|
debug: Boolean(log.get("debug")),
|
|
1204
1352
|
// Instrument context (at the expense of performance)
|
|
1353
|
+
spector: Boolean(log.get("spector")),
|
|
1354
|
+
// Initialize the SpectorJS WebGL debugger
|
|
1205
1355
|
break: [],
|
|
1206
1356
|
// alpha: undefined,
|
|
1207
1357
|
// depth: undefined,
|
|
@@ -1210,7 +1360,9 @@ var __exports__ = (() => {
|
|
|
1210
1360
|
// premultipliedAlpha: undefined,
|
|
1211
1361
|
// preserveDrawingBuffer: undefined,
|
|
1212
1362
|
// failIfMajorPerformanceCaveat: undefined
|
|
1213
|
-
gl: null
|
|
1363
|
+
gl: null,
|
|
1364
|
+
// Callbacks
|
|
1365
|
+
onError: (error) => log.error(error.message)
|
|
1214
1366
|
});
|
|
1215
1367
|
__publicField(Device, "VERSION", VERSION2);
|
|
1216
1368
|
|
|
@@ -1530,7 +1682,6 @@ var __exports__ = (() => {
|
|
|
1530
1682
|
height: void 0,
|
|
1531
1683
|
depth: 1,
|
|
1532
1684
|
mipmaps: true,
|
|
1533
|
-
sampler: {},
|
|
1534
1685
|
// type: undefined,
|
|
1535
1686
|
compressed: false,
|
|
1536
1687
|
// mipLevels: 1,
|
|
@@ -1538,7 +1689,9 @@ var __exports__ = (() => {
|
|
|
1538
1689
|
// usage: GPUTextureUsage.COPY_DST
|
|
1539
1690
|
mipLevels: void 0,
|
|
1540
1691
|
samples: void 0,
|
|
1541
|
-
type: void 0
|
|
1692
|
+
type: void 0,
|
|
1693
|
+
sampler: {},
|
|
1694
|
+
view: void 0
|
|
1542
1695
|
});
|
|
1543
1696
|
__publicField(Texture, "COPY_SRC", 1);
|
|
1544
1697
|
__publicField(Texture, "COPY_DST", 2);
|
|
@@ -1546,6 +1699,28 @@ var __exports__ = (() => {
|
|
|
1546
1699
|
__publicField(Texture, "STORAGE_BINDING", 8);
|
|
1547
1700
|
__publicField(Texture, "RENDER_ATTACHMENT", 16);
|
|
1548
1701
|
|
|
1702
|
+
// ../core/src/adapter/resources/texture-view.ts
|
|
1703
|
+
var _TextureView = class extends Resource {
|
|
1704
|
+
get [Symbol.toStringTag]() {
|
|
1705
|
+
return "TextureView";
|
|
1706
|
+
}
|
|
1707
|
+
/** Should not be constructed directly. Use `texture.createView(props)` */
|
|
1708
|
+
constructor(device, props) {
|
|
1709
|
+
super(device, props, _TextureView.defaultProps);
|
|
1710
|
+
}
|
|
1711
|
+
};
|
|
1712
|
+
var TextureView = _TextureView;
|
|
1713
|
+
__publicField(TextureView, "defaultProps", {
|
|
1714
|
+
...Resource.defaultProps,
|
|
1715
|
+
format: void 0,
|
|
1716
|
+
dimension: void 0,
|
|
1717
|
+
aspect: "all",
|
|
1718
|
+
baseMipLevel: 0,
|
|
1719
|
+
mipLevelCount: void 0,
|
|
1720
|
+
baseArrayLayer: 0,
|
|
1721
|
+
arrayLayerCount: void 0
|
|
1722
|
+
});
|
|
1723
|
+
|
|
1549
1724
|
// ../core/src/lib/compiler-log/format-compiler-log.ts
|
|
1550
1725
|
function formatCompilerLog(shaderLog, source, options) {
|
|
1551
1726
|
let formattedLog = "";
|
|
@@ -1658,10 +1833,14 @@ ${numberedLines}${positionIndicator}${message2.type.toUpperCase()}: ${message2.m
|
|
|
1658
1833
|
getCompilationInfoSync() {
|
|
1659
1834
|
return null;
|
|
1660
1835
|
}
|
|
1836
|
+
/** Get translated shader source in host platform's native language (HLSL, GLSL, and even GLSL ES), if available */
|
|
1837
|
+
getTranslatedSource() {
|
|
1838
|
+
return null;
|
|
1839
|
+
}
|
|
1661
1840
|
// PORTABLE HELPERS
|
|
1662
1841
|
/** In browser logging of errors */
|
|
1663
|
-
async debugShader() {
|
|
1664
|
-
switch (
|
|
1842
|
+
async debugShader(trigger = this.props.debug) {
|
|
1843
|
+
switch (trigger) {
|
|
1665
1844
|
case "never":
|
|
1666
1845
|
return;
|
|
1667
1846
|
case "errors":
|
|
@@ -1687,7 +1866,11 @@ ${numberedLines}${positionIndicator}${message2.type.toUpperCase()}: ${message2.m
|
|
|
1687
1866
|
}
|
|
1688
1867
|
const shaderName = getShaderInfo(this.source).name;
|
|
1689
1868
|
const shaderTitle = `${this.stage} ${shaderName}`;
|
|
1690
|
-
|
|
1869
|
+
let htmlLog = formatCompilerLog(messages, this.source, { showSourceCode: "all", html: true });
|
|
1870
|
+
const translatedSource = this.getTranslatedSource();
|
|
1871
|
+
if (translatedSource) {
|
|
1872
|
+
htmlLog += `<br /><br /><h1>Translated Source</h1><br /><br /><code style="user-select:text;"><pre>${translatedSource}</pre></code>`;
|
|
1873
|
+
}
|
|
1691
1874
|
const button = document.createElement("Button");
|
|
1692
1875
|
button.innerHTML = `
|
|
1693
1876
|
<h1>Shader Compilation Error in ${shaderTitle}</h1><br /><br />
|
|
@@ -1782,67 +1965,29 @@ ${htmlLog}
|
|
|
1782
1965
|
this.resizeAttachments(this.width, this.height);
|
|
1783
1966
|
}
|
|
1784
1967
|
}
|
|
1785
|
-
// /** Returns fully populated attachment object. */
|
|
1786
|
-
// protected normalizeColorAttachment(
|
|
1787
|
-
// attachment: Texture | ColorTextureFormat
|
|
1788
|
-
// ): Required<ColorAttachment> {
|
|
1789
|
-
// const COLOR_ATTACHMENT_DEFAULTS: Required<ColorAttachment> = {
|
|
1790
|
-
// texture: undefined!,
|
|
1791
|
-
// format: undefined!,
|
|
1792
|
-
// clearValue: [0.0, 0.0, 0.0, 0.0],
|
|
1793
|
-
// loadOp: 'clear',
|
|
1794
|
-
// storeOp: 'store'
|
|
1795
|
-
// };
|
|
1796
|
-
// if (attachment instanceof Texture) {
|
|
1797
|
-
// return {...COLOR_ATTACHMENT_DEFAULTS, texture: attachment};
|
|
1798
|
-
// }
|
|
1799
|
-
// if (typeof attachment === 'string') {
|
|
1800
|
-
// return {...COLOR_ATTACHMENT_DEFAULTS, format: attachment};
|
|
1801
|
-
// }
|
|
1802
|
-
// return {...COLOR_ATTACHMENT_DEFAULTS, ...attachment};
|
|
1803
|
-
// }
|
|
1804
|
-
// /** Wraps texture inside fully populated attachment object. */
|
|
1805
|
-
// protected normalizeDepthStencilAttachment(
|
|
1806
|
-
// attachment: DepthStencilAttachment | Texture | DepthStencilTextureFormat
|
|
1807
|
-
// ): Required<DepthStencilAttachment> {
|
|
1808
|
-
// const DEPTH_STENCIL_ATTACHMENT_DEFAULTS: Required<DepthStencilAttachment> = {
|
|
1809
|
-
// texture: undefined!,
|
|
1810
|
-
// format: undefined!,
|
|
1811
|
-
// depthClearValue: 1.0,
|
|
1812
|
-
// depthLoadOp: 'clear',
|
|
1813
|
-
// depthStoreOp: 'store',
|
|
1814
|
-
// depthReadOnly: false,
|
|
1815
|
-
// stencilClearValue: 0,
|
|
1816
|
-
// stencilLoadOp: 'clear',
|
|
1817
|
-
// stencilStoreOp: 'store',
|
|
1818
|
-
// stencilReadOnly: false
|
|
1819
|
-
// };
|
|
1820
|
-
// if (typeof attachment === 'string') {
|
|
1821
|
-
// return {...DEPTH_STENCIL_ATTACHMENT_DEFAULTS, format: attachment};
|
|
1822
|
-
// }
|
|
1823
|
-
// // @ts-expect-error attachment instanceof Texture doesn't cover Renderbuffer
|
|
1824
|
-
// if (attachment.handle || attachment instanceof Texture) {
|
|
1825
|
-
// return {...DEPTH_STENCIL_ATTACHMENT_DEFAULTS, texture: attachment as Texture};
|
|
1826
|
-
// }
|
|
1827
|
-
// return {...DEPTH_STENCIL_ATTACHMENT_DEFAULTS, ...attachment};
|
|
1828
|
-
// }
|
|
1829
1968
|
/** Auto creates any textures */
|
|
1830
1969
|
autoCreateAttachmentTextures() {
|
|
1831
|
-
this.colorAttachments = this.props.colorAttachments.map((
|
|
1832
|
-
if (typeof
|
|
1833
|
-
const texture = this.createColorTexture(
|
|
1970
|
+
this.colorAttachments = this.props.colorAttachments.map((attachment2) => {
|
|
1971
|
+
if (typeof attachment2 === "string") {
|
|
1972
|
+
const texture = this.createColorTexture(attachment2);
|
|
1834
1973
|
this.attachResource(texture);
|
|
1835
|
-
return texture;
|
|
1974
|
+
return texture.view;
|
|
1836
1975
|
}
|
|
1837
|
-
|
|
1976
|
+
if (attachment2 instanceof Texture) {
|
|
1977
|
+
return attachment2.view;
|
|
1978
|
+
}
|
|
1979
|
+
return attachment2;
|
|
1838
1980
|
});
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1981
|
+
const attachment = this.props.depthStencilAttachment;
|
|
1982
|
+
if (attachment) {
|
|
1983
|
+
if (typeof attachment === "string") {
|
|
1984
|
+
const texture = this.createDepthStencilTexture(attachment);
|
|
1842
1985
|
this.attachResource(texture);
|
|
1843
|
-
this.depthStencilAttachment = texture;
|
|
1986
|
+
this.depthStencilAttachment = texture.view;
|
|
1987
|
+
} else if (attachment instanceof Texture) {
|
|
1988
|
+
this.depthStencilAttachment = attachment.view;
|
|
1844
1989
|
} else {
|
|
1845
|
-
this.depthStencilAttachment =
|
|
1990
|
+
this.depthStencilAttachment = attachment;
|
|
1846
1991
|
}
|
|
1847
1992
|
}
|
|
1848
1993
|
}
|
|
@@ -1880,8 +2025,8 @@ ${htmlLog}
|
|
|
1880
2025
|
height
|
|
1881
2026
|
});
|
|
1882
2027
|
this.destroyAttachedResource(this.colorAttachments[i]);
|
|
1883
|
-
this.colorAttachments[i] = resizedTexture;
|
|
1884
|
-
this.attachResource(resizedTexture);
|
|
2028
|
+
this.colorAttachments[i] = resizedTexture.view;
|
|
2029
|
+
this.attachResource(resizedTexture.view);
|
|
1885
2030
|
}
|
|
1886
2031
|
}
|
|
1887
2032
|
if (this.depthStencilAttachment) {
|
|
@@ -1891,41 +2036,10 @@ ${htmlLog}
|
|
|
1891
2036
|
height
|
|
1892
2037
|
});
|
|
1893
2038
|
this.destroyAttachedResource(this.depthStencilAttachment);
|
|
1894
|
-
this.depthStencilAttachment = resizedTexture;
|
|
2039
|
+
this.depthStencilAttachment = resizedTexture.view;
|
|
1895
2040
|
this.attachResource(resizedTexture);
|
|
1896
2041
|
}
|
|
1897
2042
|
}
|
|
1898
|
-
/** Create a color attachment for WebGL *
|
|
1899
|
-
protected override createColorTexture(colorAttachment: Required<ColorAttachment>): Required<ColorAttachment> {
|
|
1900
|
-
return this.device._createTexture({
|
|
1901
|
-
id: `${this.id}-color`,
|
|
1902
|
-
data: null, // reserves texture memory, but texels are undefined
|
|
1903
|
-
format,
|
|
1904
|
-
// type: GL.UNSIGNED_BYTE,
|
|
1905
|
-
width: this.width,
|
|
1906
|
-
height: this.height,
|
|
1907
|
-
// Note: Mipmapping can be disabled by texture resource when we resize the texture
|
|
1908
|
-
// to a non-power-of-two dimenstion (NPOT texture) under WebGL1. To have consistant
|
|
1909
|
-
// behavior we always disable mipmaps.
|
|
1910
|
-
mipmaps: false,
|
|
1911
|
-
// Set MIN and MAG filtering parameters so mipmaps are not used in sampling.
|
|
1912
|
-
// Use LINEAR so subpixel algos like fxaa work.
|
|
1913
|
-
// Set WRAP modes that support NPOT textures too.
|
|
1914
|
-
sampler: {
|
|
1915
|
-
minFilter: 'linear',
|
|
1916
|
-
magFilter: 'linear',
|
|
1917
|
-
addressModeU: 'clamp-to-edge',
|
|
1918
|
-
addressModeV: 'clamp-to-edge'
|
|
1919
|
-
}
|
|
1920
|
-
// parameters: {
|
|
1921
|
-
// [GL.TEXTURE_MIN_FILTER]: GL.LINEAR,
|
|
1922
|
-
// [GL.TEXTURE_MAG_FILTER]: GL.LINEAR,
|
|
1923
|
-
// [GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,
|
|
1924
|
-
// [GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE
|
|
1925
|
-
// }
|
|
1926
|
-
});
|
|
1927
|
-
}
|
|
1928
|
-
*/
|
|
1929
2043
|
};
|
|
1930
2044
|
var Framebuffer = _Framebuffer;
|
|
1931
2045
|
__publicField(Framebuffer, "defaultProps", {
|
|
@@ -1943,18 +2057,29 @@ ${htmlLog}
|
|
|
1943
2057
|
get [Symbol.toStringTag]() {
|
|
1944
2058
|
return "RenderPipeline";
|
|
1945
2059
|
}
|
|
1946
|
-
hash = "";
|
|
1947
2060
|
/** The merged layout */
|
|
1948
2061
|
shaderLayout;
|
|
1949
2062
|
/** Buffer map describing buffer interleaving etc */
|
|
1950
2063
|
bufferLayout;
|
|
1951
2064
|
/** The linking status of the pipeline. 'pending' if linking is asynchronous, and on production */
|
|
1952
2065
|
linkStatus = "pending";
|
|
2066
|
+
/** The hash of the pipeline */
|
|
2067
|
+
hash = "";
|
|
1953
2068
|
constructor(device, props) {
|
|
1954
2069
|
super(device, props, _RenderPipeline.defaultProps);
|
|
1955
2070
|
this.shaderLayout = this.props.shaderLayout;
|
|
1956
2071
|
this.bufferLayout = this.props.bufferLayout || [];
|
|
1957
2072
|
}
|
|
2073
|
+
// DEPRECATED METHODS
|
|
2074
|
+
/**
|
|
2075
|
+
* Uniforms
|
|
2076
|
+
* @deprecated Use uniforms buffers
|
|
2077
|
+
* @note textures, samplers and uniform buffers should be set via `setBindings()`, these are not considered uniforms.
|
|
2078
|
+
* @note In WebGL uniforms have a performance penalty, they are reset before each call to enable pipeline sharing.
|
|
2079
|
+
*/
|
|
2080
|
+
setUniformsWebGL(uniforms) {
|
|
2081
|
+
throw new Error("Use uniform blocks");
|
|
2082
|
+
}
|
|
1958
2083
|
};
|
|
1959
2084
|
var RenderPipeline = _RenderPipeline;
|
|
1960
2085
|
__publicField(RenderPipeline, "defaultProps", {
|
|
@@ -1985,41 +2110,17 @@ ${htmlLog}
|
|
|
1985
2110
|
constructor(device, props) {
|
|
1986
2111
|
super(device, props, _RenderPass.defaultProps);
|
|
1987
2112
|
}
|
|
1988
|
-
//
|
|
1989
|
-
//
|
|
1990
|
-
//
|
|
1991
|
-
//
|
|
1992
|
-
//
|
|
1993
|
-
//
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
indexFormat: 'uint16' | 'uint32',
|
|
2000
|
-
offset?: number,
|
|
2001
|
-
size?: number
|
|
2002
|
-
): void {}
|
|
2003
|
-
|
|
2004
|
-
abstract setVertexBuffer(slot: number, buffer: Buffer, offset: number): void;
|
|
2005
|
-
|
|
2006
|
-
abstract setBindings(bindings: Record<string, Binding>): void;
|
|
2007
|
-
|
|
2008
|
-
abstract setParameters(parameters: RenderPassParameters);
|
|
2009
|
-
|
|
2010
|
-
draw(options: {
|
|
2011
|
-
vertexCount?: number; // Either vertexCount or indexCount must be provided
|
|
2012
|
-
indexCount?: number; // Activates indexed drawing (call setIndexBuffer())
|
|
2013
|
-
instanceCount?: number; //
|
|
2014
|
-
firstVertex?: number;
|
|
2015
|
-
firstIndex?: number; // requires device.features.has('indirect-first-instance')?
|
|
2016
|
-
firstInstance?: number;
|
|
2017
|
-
baseVertex?: number;
|
|
2018
|
-
}): void {}
|
|
2019
|
-
|
|
2020
|
-
drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
|
|
2021
|
-
drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
|
|
2022
|
-
*/
|
|
2113
|
+
// In WebGPU the following methods are on the renderpass instead of the renderpipeline
|
|
2114
|
+
// luma.gl keeps them on the pipeline for now.
|
|
2115
|
+
// TODO - Can we align WebGL implementation with WebGPU API?
|
|
2116
|
+
// abstract setPipeline(pipeline: RenderPipeline): void {}
|
|
2117
|
+
// abstract setIndexBuffer()
|
|
2118
|
+
// abstract setVertexBuffer(slot: number, buffer: Buffer, offset: number): void;
|
|
2119
|
+
// abstract setBindings(bindings: Record<string, Binding>): void;
|
|
2120
|
+
// abstract setParameters(parameters: RenderPassParameters);
|
|
2121
|
+
// abstract draw(options: {
|
|
2122
|
+
// abstract drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
|
|
2123
|
+
// abstract drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
|
|
2023
2124
|
};
|
|
2024
2125
|
var RenderPass = _RenderPass;
|
|
2025
2126
|
/** Default properties for RenderPass */
|
|
@@ -2032,7 +2133,11 @@ ${htmlLog}
|
|
|
2032
2133
|
clearStencil: 0,
|
|
2033
2134
|
depthReadOnly: false,
|
|
2034
2135
|
stencilReadOnly: false,
|
|
2035
|
-
discard: false
|
|
2136
|
+
discard: false,
|
|
2137
|
+
occlusionQuerySet: void 0,
|
|
2138
|
+
timestampQuerySet: void 0,
|
|
2139
|
+
beginTimestampIndex: void 0,
|
|
2140
|
+
endTimestampIndex: void 0
|
|
2036
2141
|
});
|
|
2037
2142
|
|
|
2038
2143
|
// ../core/src/adapter/resources/command-encoder.ts
|
|
@@ -2043,20 +2148,9 @@ ${htmlLog}
|
|
|
2043
2148
|
constructor(device, props) {
|
|
2044
2149
|
super(device, props, _CommandEncoder.defaultProps);
|
|
2045
2150
|
}
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
}
|
|
2050
|
-
insertDebugMarker(markerLabel) {
|
|
2051
|
-
}
|
|
2052
|
-
// writeTimestamp(querySet: Query, queryIndex: number): void;
|
|
2053
|
-
// resolveQuerySet(options: {
|
|
2054
|
-
// querySet: GPUQuerySet,
|
|
2055
|
-
// firstQuery: number,
|
|
2056
|
-
// queryCount: number,
|
|
2057
|
-
// destination: Buffer,
|
|
2058
|
-
// destinationOffset?: number;
|
|
2059
|
-
// }): void;
|
|
2151
|
+
// TODO - luma.gl has these on the device, should we align with WebGPU API?
|
|
2152
|
+
// beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;
|
|
2153
|
+
// beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;
|
|
2060
2154
|
};
|
|
2061
2155
|
var CommandEncoder = _CommandEncoder;
|
|
2062
2156
|
__publicField(CommandEncoder, "defaultProps", {
|
|
@@ -2083,7 +2177,7 @@ ${htmlLog}
|
|
|
2083
2177
|
const [dataType, components] = TYPE_INFO[attributeType];
|
|
2084
2178
|
const integer = dataType === "i32" || dataType === "u32";
|
|
2085
2179
|
const signed = dataType !== "u32";
|
|
2086
|
-
const byteLength =
|
|
2180
|
+
const byteLength = TYPE_SIZES2[dataType] * components;
|
|
2087
2181
|
const defaultVertexFormat = getCompatibleVertexFormat(dataType, components);
|
|
2088
2182
|
return {
|
|
2089
2183
|
dataType,
|
|
@@ -2132,56 +2226,12 @@ ${htmlLog}
|
|
|
2132
2226
|
"vec3<u32>": ["u32", 3],
|
|
2133
2227
|
"vec4<u32>": ["u32", 4]
|
|
2134
2228
|
};
|
|
2135
|
-
var
|
|
2229
|
+
var TYPE_SIZES2 = {
|
|
2136
2230
|
f32: 4,
|
|
2137
2231
|
f16: 2,
|
|
2138
2232
|
i32: 4,
|
|
2139
2233
|
u32: 4
|
|
2140
|
-
// 'bool-webgl': 4,
|
|
2141
|
-
};
|
|
2142
|
-
|
|
2143
|
-
// ../core/src/adapter/type-utils/decode-data-type.ts
|
|
2144
|
-
function decodeVertexType(type) {
|
|
2145
|
-
const dataType = TYPE_MAP[type];
|
|
2146
|
-
const bytes = getDataTypeBytes(dataType);
|
|
2147
|
-
const normalized = type.includes("norm");
|
|
2148
|
-
const integer = !normalized && !type.startsWith("float");
|
|
2149
|
-
const signed = type.startsWith("s");
|
|
2150
|
-
return {
|
|
2151
|
-
dataType: TYPE_MAP[type],
|
|
2152
|
-
byteLength: bytes,
|
|
2153
|
-
integer,
|
|
2154
|
-
signed,
|
|
2155
|
-
normalized
|
|
2156
|
-
};
|
|
2157
|
-
}
|
|
2158
|
-
function getDataTypeBytes(type) {
|
|
2159
|
-
const bytes = TYPE_SIZES2[type];
|
|
2160
|
-
return bytes;
|
|
2161
|
-
}
|
|
2162
|
-
var TYPE_MAP = {
|
|
2163
|
-
uint8: "uint8",
|
|
2164
|
-
sint8: "sint8",
|
|
2165
|
-
unorm8: "uint8",
|
|
2166
|
-
snorm8: "sint8",
|
|
2167
|
-
uint16: "uint16",
|
|
2168
|
-
sint16: "sint16",
|
|
2169
|
-
unorm16: "uint16",
|
|
2170
|
-
snorm16: "sint16",
|
|
2171
|
-
float16: "float16",
|
|
2172
|
-
float32: "float32",
|
|
2173
|
-
uint32: "uint32",
|
|
2174
|
-
sint32: "sint32"
|
|
2175
|
-
};
|
|
2176
|
-
var TYPE_SIZES2 = {
|
|
2177
|
-
uint8: 1,
|
|
2178
|
-
sint8: 1,
|
|
2179
|
-
uint16: 2,
|
|
2180
|
-
sint16: 2,
|
|
2181
|
-
float16: 2,
|
|
2182
|
-
float32: 4,
|
|
2183
|
-
uint32: 4,
|
|
2184
|
-
sint32: 4
|
|
2234
|
+
// 'bool-webgl': 4,
|
|
2185
2235
|
};
|
|
2186
2236
|
|
|
2187
2237
|
// ../core/src/adapter/type-utils/decode-vertex-format.ts
|
|
@@ -2363,6 +2413,11 @@ ${htmlLog}
|
|
|
2363
2413
|
this.maxVertexAttributes
|
|
2364
2414
|
);
|
|
2365
2415
|
}
|
|
2416
|
+
// DEPRECATED METHODS
|
|
2417
|
+
/** @deprecated Set constant attributes (WebGL only) */
|
|
2418
|
+
setConstantWebGL(location, value) {
|
|
2419
|
+
throw new Error("constant attributes not supported");
|
|
2420
|
+
}
|
|
2366
2421
|
};
|
|
2367
2422
|
var VertexArray = _VertexArray;
|
|
2368
2423
|
__publicField(VertexArray, "defaultProps", {
|
|
@@ -2386,6 +2441,22 @@ ${htmlLog}
|
|
|
2386
2441
|
buffers: {}
|
|
2387
2442
|
});
|
|
2388
2443
|
|
|
2444
|
+
// ../core/src/adapter/resources/query-set.ts
|
|
2445
|
+
var _QuerySet = class extends Resource {
|
|
2446
|
+
get [Symbol.toStringTag]() {
|
|
2447
|
+
return "QuerySet";
|
|
2448
|
+
}
|
|
2449
|
+
constructor(device, props) {
|
|
2450
|
+
super(device, props, _QuerySet.defaultProps);
|
|
2451
|
+
}
|
|
2452
|
+
};
|
|
2453
|
+
var QuerySet = _QuerySet;
|
|
2454
|
+
__publicField(QuerySet, "defaultProps", {
|
|
2455
|
+
...Resource.defaultProps,
|
|
2456
|
+
type: void 0,
|
|
2457
|
+
count: void 0
|
|
2458
|
+
});
|
|
2459
|
+
|
|
2389
2460
|
// ../core/src/utils/array-utils-flat.ts
|
|
2390
2461
|
var arrayBuffer;
|
|
2391
2462
|
function getScratchArrayBuffer(byteLength) {
|
|
@@ -2418,63 +2489,6 @@ ${htmlLog}
|
|
|
2418
2489
|
return options.target;
|
|
2419
2490
|
}
|
|
2420
2491
|
|
|
2421
|
-
// ../core/src/adapter/type-utils/decode-texture-format.ts
|
|
2422
|
-
var REGEX = /^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;
|
|
2423
|
-
function decodeTextureFormat(format) {
|
|
2424
|
-
const matches = REGEX.exec(format);
|
|
2425
|
-
if (matches) {
|
|
2426
|
-
const [, format2, length, type, srgb, suffix] = matches;
|
|
2427
|
-
if (format2) {
|
|
2428
|
-
const dataType = `${type}${length}`;
|
|
2429
|
-
const decodedType = decodeVertexType(dataType);
|
|
2430
|
-
return {
|
|
2431
|
-
format: format2,
|
|
2432
|
-
components: format2.length,
|
|
2433
|
-
// dataType - overwritten by decodedType
|
|
2434
|
-
srgb: srgb === "-srgb",
|
|
2435
|
-
unsized: suffix === "-unsized",
|
|
2436
|
-
webgl: suffix === "-webgl",
|
|
2437
|
-
...decodedType
|
|
2438
|
-
};
|
|
2439
|
-
}
|
|
2440
|
-
}
|
|
2441
|
-
return decodeNonStandardFormat(format);
|
|
2442
|
-
}
|
|
2443
|
-
var EXCEPTIONS = {
|
|
2444
|
-
// Packed 16 bit formats
|
|
2445
|
-
"rgba4unorm-webgl": { format: "rgba", bpp: 2 },
|
|
2446
|
-
"rgb565unorm-webgl": { format: "rgb", bpp: 2 },
|
|
2447
|
-
"rgb5a1unorm-webgl": { format: "rgba", bbp: 2 },
|
|
2448
|
-
// Packed 32 bit formats
|
|
2449
|
-
"rgb9e5ufloat": { format: "rgb", bbp: 4 },
|
|
2450
|
-
"rg11b10ufloat": { format: "rgb", bbp: 4 },
|
|
2451
|
-
"rgb10a2unorm": { format: "rgba", bbp: 4 },
|
|
2452
|
-
"rgb10a2unorm-webgl": { format: "rgba", bbp: 4 },
|
|
2453
|
-
// Depth/stencil
|
|
2454
|
-
"stencil8": { components: 1, bpp: 1, a: "stencil" },
|
|
2455
|
-
"depth16unorm": { components: 1, bpp: 2, a: "depth" },
|
|
2456
|
-
"depth24plus": { components: 1, bpp: 3, a: "depth" },
|
|
2457
|
-
"depth32float": { components: 1, bpp: 4, a: "depth" },
|
|
2458
|
-
"depth24plus-stencil8": { components: 2, bpp: 4, a: "depth-stencil" },
|
|
2459
|
-
// "depth24unorm-stencil8" feature
|
|
2460
|
-
"depth24unorm-stencil8": { components: 2, bpp: 4, a: "depth-stencil" },
|
|
2461
|
-
// "depth32float-stencil8" feature
|
|
2462
|
-
"depth32float-stencil8": { components: 2, bpp: 4, a: "depth-stencil" }
|
|
2463
|
-
};
|
|
2464
|
-
function decodeNonStandardFormat(format) {
|
|
2465
|
-
const data = EXCEPTIONS[format];
|
|
2466
|
-
if (!data) {
|
|
2467
|
-
throw new Error(`Unknown format ${format}`);
|
|
2468
|
-
}
|
|
2469
|
-
return {
|
|
2470
|
-
format: data.format || "",
|
|
2471
|
-
components: data.components || data.format?.length || 1,
|
|
2472
|
-
byteLength: data.bpp || 1,
|
|
2473
|
-
srgb: false,
|
|
2474
|
-
unsized: false
|
|
2475
|
-
};
|
|
2476
|
-
}
|
|
2477
|
-
|
|
2478
2492
|
// ../core/src/utils/cast.ts
|
|
2479
2493
|
function cast(value) {
|
|
2480
2494
|
return value;
|
|
@@ -2543,7 +2557,7 @@ ${htmlLog}
|
|
|
2543
2557
|
// ../core/src/utils/load-file.ts
|
|
2544
2558
|
var pathPrefix = "";
|
|
2545
2559
|
async function loadImage(url, opts) {
|
|
2546
|
-
return new Promise((resolve, reject) => {
|
|
2560
|
+
return await new Promise((resolve, reject) => {
|
|
2547
2561
|
try {
|
|
2548
2562
|
const image = new Image();
|
|
2549
2563
|
image.onload = () => resolve(image);
|
|
@@ -2633,14 +2647,6 @@ ${htmlLog}
|
|
|
2633
2647
|
[import_constants.GL.STENCIL_BACK_PASS_DEPTH_PASS]: import_constants.GL.KEEP,
|
|
2634
2648
|
// Dynamic value: We use [0, 0, 1024, 1024] as default, but usually this is updated in each frame.
|
|
2635
2649
|
[import_constants.GL.VIEWPORT]: [0, 0, 1024, 1024],
|
|
2636
|
-
// WEBGL1 PIXEL PACK/UNPACK MODES
|
|
2637
|
-
[import_constants.GL.PACK_ALIGNMENT]: 4,
|
|
2638
|
-
[import_constants.GL.UNPACK_ALIGNMENT]: 4,
|
|
2639
|
-
[import_constants.GL.UNPACK_FLIP_Y_WEBGL]: false,
|
|
2640
|
-
[import_constants.GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]: false,
|
|
2641
|
-
[import_constants.GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]: import_constants.GL.BROWSER_DEFAULT_WEBGL,
|
|
2642
|
-
// WEBGL2 / EXTENSIONS
|
|
2643
|
-
// gl1: 'OES_standard_derivatives'
|
|
2644
2650
|
[import_constants.GL.TRANSFORM_FEEDBACK_BINDING]: null,
|
|
2645
2651
|
[import_constants.GL.COPY_READ_BUFFER_BINDING]: null,
|
|
2646
2652
|
[import_constants.GL.COPY_WRITE_BUFFER_BINDING]: null,
|
|
@@ -2649,6 +2655,11 @@ ${htmlLog}
|
|
|
2649
2655
|
[import_constants.GL.FRAGMENT_SHADER_DERIVATIVE_HINT]: import_constants.GL.DONT_CARE,
|
|
2650
2656
|
[import_constants.GL.READ_FRAMEBUFFER_BINDING]: null,
|
|
2651
2657
|
[import_constants.GL.RASTERIZER_DISCARD]: false,
|
|
2658
|
+
[import_constants.GL.PACK_ALIGNMENT]: 4,
|
|
2659
|
+
[import_constants.GL.UNPACK_ALIGNMENT]: 4,
|
|
2660
|
+
[import_constants.GL.UNPACK_FLIP_Y_WEBGL]: false,
|
|
2661
|
+
[import_constants.GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]: false,
|
|
2662
|
+
[import_constants.GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]: import_constants.GL.BROWSER_DEFAULT_WEBGL,
|
|
2652
2663
|
[import_constants.GL.PACK_ROW_LENGTH]: 0,
|
|
2653
2664
|
[import_constants.GL.PACK_SKIP_PIXELS]: 0,
|
|
2654
2665
|
[import_constants.GL.PACK_SKIP_ROWS]: 0,
|
|
@@ -2742,14 +2753,29 @@ ${htmlLog}
|
|
|
2742
2753
|
[import_constants.GL.STENCIL_BACK_PASS_DEPTH_FAIL]: "stencilOpBack",
|
|
2743
2754
|
[import_constants.GL.STENCIL_BACK_PASS_DEPTH_PASS]: "stencilOpBack",
|
|
2744
2755
|
[import_constants.GL.VIEWPORT]: (gl, value) => gl.viewport(...value),
|
|
2745
|
-
//
|
|
2756
|
+
// WEBGL2 EXTENSIONS
|
|
2757
|
+
// EXT_depth_clamp https://registry.khronos.org/webgl/extensions/EXT_depth_clamp/
|
|
2758
|
+
[import_constants.GL.DEPTH_CLAMP_EXT]: enable,
|
|
2759
|
+
// WEBGL_provoking_vertex https://registry.khronos.org/webgl/extensions/WEBGL_provoking_vertex/
|
|
2760
|
+
// [GL.PROVOKING_VERTEX_WEBL]: TODO - extension function needed
|
|
2761
|
+
// WEBGL_polygon_mode https://registry.khronos.org/webgl/extensions/WEBGL_polygon_mode/
|
|
2762
|
+
// POLYGON_MODE_WEBGL TODO - extension function needed
|
|
2763
|
+
[import_constants.GL.POLYGON_OFFSET_LINE_WEBGL]: enable,
|
|
2764
|
+
// WEBGL_clip_cull_distance https://registry.khronos.org/webgl/extensions/WEBGL_clip_cull_distance/
|
|
2765
|
+
[import_constants.GL.CLIP_DISTANCE0_WEBGL]: enable,
|
|
2766
|
+
[import_constants.GL.CLIP_DISTANCE1_WEBGL]: enable,
|
|
2767
|
+
[import_constants.GL.CLIP_DISTANCE2_WEBGL]: enable,
|
|
2768
|
+
[import_constants.GL.CLIP_DISTANCE3_WEBGL]: enable,
|
|
2769
|
+
[import_constants.GL.CLIP_DISTANCE4_WEBGL]: enable,
|
|
2770
|
+
[import_constants.GL.CLIP_DISTANCE5_WEBGL]: enable,
|
|
2771
|
+
[import_constants.GL.CLIP_DISTANCE6_WEBGL]: enable,
|
|
2772
|
+
[import_constants.GL.CLIP_DISTANCE7_WEBGL]: enable,
|
|
2773
|
+
// PIXEL PACK/UNPACK MODES
|
|
2746
2774
|
[import_constants.GL.PACK_ALIGNMENT]: pixelStorei,
|
|
2747
2775
|
[import_constants.GL.UNPACK_ALIGNMENT]: pixelStorei,
|
|
2748
2776
|
[import_constants.GL.UNPACK_FLIP_Y_WEBGL]: pixelStorei,
|
|
2749
2777
|
[import_constants.GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]: pixelStorei,
|
|
2750
2778
|
[import_constants.GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]: pixelStorei,
|
|
2751
|
-
// WEBGL2 PIXEL PACK/UNPACK MODES
|
|
2752
|
-
// RASTERIZER_DISCARD ...
|
|
2753
2779
|
[import_constants.GL.PACK_ROW_LENGTH]: pixelStorei,
|
|
2754
2780
|
[import_constants.GL.PACK_SKIP_PIXELS]: pixelStorei,
|
|
2755
2781
|
[import_constants.GL.PACK_SKIP_ROWS]: pixelStorei,
|
|
@@ -3283,7 +3309,7 @@ ${htmlLog}
|
|
|
3283
3309
|
};
|
|
3284
3310
|
}
|
|
3285
3311
|
|
|
3286
|
-
// src/context/
|
|
3312
|
+
// src/context/helpers/create-browser-context.ts
|
|
3287
3313
|
var DEFAULT_CONTEXT_PROPS = {
|
|
3288
3314
|
powerPreference: "high-performance",
|
|
3289
3315
|
// After all, most apps are using WebGL for performance reasons
|
|
@@ -3320,10 +3346,21 @@ ${htmlLog}
|
|
|
3320
3346
|
|
|
3321
3347
|
// src/adapter/device-helpers/webgl-device-info.ts
|
|
3322
3348
|
var import_constants2 = __toESM(require_constants(), 1);
|
|
3323
|
-
|
|
3349
|
+
|
|
3350
|
+
// src/context/helpers/webgl-extensions.ts
|
|
3351
|
+
function getWebGLExtension(gl, name2, extensions) {
|
|
3352
|
+
if (extensions[name2] === void 0) {
|
|
3353
|
+
extensions[name2] = gl.getExtension(name2) || null;
|
|
3354
|
+
}
|
|
3355
|
+
return extensions[name2];
|
|
3356
|
+
}
|
|
3357
|
+
|
|
3358
|
+
// src/adapter/device-helpers/webgl-device-info.ts
|
|
3359
|
+
function getDeviceInfo(gl, extensions) {
|
|
3324
3360
|
const vendorMasked = gl.getParameter(import_constants2.GL.VENDOR);
|
|
3325
3361
|
const rendererMasked = gl.getParameter(import_constants2.GL.RENDERER);
|
|
3326
|
-
|
|
3362
|
+
getWebGLExtension(gl, "WEBGL_debug_renderer_info", extensions);
|
|
3363
|
+
const ext = extensions.WEBGL_debug_renderer_info;
|
|
3327
3364
|
const vendorUnmasked = gl.getParameter(ext ? ext.UNMASKED_VENDOR_WEBGL : import_constants2.GL.VENDOR);
|
|
3328
3365
|
const rendererUnmasked = gl.getParameter(ext ? ext.UNMASKED_RENDERER_WEBGL : import_constants2.GL.RENDERER);
|
|
3329
3366
|
const vendor = vendorUnmasked || vendorMasked;
|
|
@@ -3432,6 +3469,14 @@ ${htmlLog}
|
|
|
3432
3469
|
var texture_compression_etc1_webgl = "texture-compression-etc1-webgl";
|
|
3433
3470
|
var texture_compression_pvrtc_webgl = "texture-compression-pvrtc-webgl";
|
|
3434
3471
|
var texture_compression_atc_webgl = "texture-compression-atc-webgl";
|
|
3472
|
+
var float32_renderable = "float32-renderable-webgl";
|
|
3473
|
+
var float16_renderable = "float16-renderable-webgl";
|
|
3474
|
+
var rgb9e5ufloat_renderable = "rgb9e5ufloat_renderable-webgl";
|
|
3475
|
+
var snorm8_renderable = "snorm8-renderable-webgl";
|
|
3476
|
+
var norm16_renderable = "norm16-renderable-webgl";
|
|
3477
|
+
var snorm16_renderable = "snorm16-renderable-webgl";
|
|
3478
|
+
var float32_filterable = "float32-filterable";
|
|
3479
|
+
var float16_filterable = "float16-filterable-webgl";
|
|
3435
3480
|
var X_S3TC = "WEBGL_compressed_texture_s3tc";
|
|
3436
3481
|
var X_S3TC_SRGB = "WEBGL_compressed_texture_s3tc_srgb";
|
|
3437
3482
|
var X_RGTC = "EXT_texture_compression_rgtc";
|
|
@@ -3441,15 +3486,18 @@ ${htmlLog}
|
|
|
3441
3486
|
var X_ETC1 = "WEBGL_compressed_texture_etc1";
|
|
3442
3487
|
var X_PVRTC = "WEBGL_compressed_texture_pvrtc";
|
|
3443
3488
|
var X_ATC = "WEBGL_compressed_texture_atc";
|
|
3444
|
-
var
|
|
3445
|
-
var
|
|
3446
|
-
var
|
|
3489
|
+
var EXT_texture_norm16 = "EXT_texture_norm16";
|
|
3490
|
+
var EXT_render_snorm = "EXT_render_snorm";
|
|
3491
|
+
var EXT_color_buffer_float = "EXT_color_buffer_float";
|
|
3492
|
+
var TEXTURE_FEATURES = {
|
|
3447
3493
|
"float32-renderable-webgl": ["EXT_color_buffer_float"],
|
|
3448
|
-
// [false, 'EXT_color_buffer_float'],
|
|
3449
3494
|
"float16-renderable-webgl": ["EXT_color_buffer_half_float"],
|
|
3450
|
-
"
|
|
3451
|
-
"
|
|
3452
|
-
"
|
|
3495
|
+
"rgb9e5ufloat_renderable-webgl": ["WEBGL_render_shared_exponent"],
|
|
3496
|
+
"snorm8-renderable-webgl": [EXT_render_snorm],
|
|
3497
|
+
"norm16-renderable-webgl": [EXT_texture_norm16],
|
|
3498
|
+
"snorm16-renderable-webgl": [EXT_texture_norm16, EXT_render_snorm],
|
|
3499
|
+
"float32-filterable": ["OES_texture_float_linear"],
|
|
3500
|
+
"float16-filterable-webgl": ["OES_texture_half_float_linear"],
|
|
3453
3501
|
"texture-filterable-anisotropic-webgl": ["EXT_texture_filter_anisotropic"],
|
|
3454
3502
|
"texture-blend-float-webgl": ["EXT_float_blend"],
|
|
3455
3503
|
"texture-compression-bc": [X_S3TC, X_S3TC_SRGB, X_RGTC, X_BPTC],
|
|
@@ -3463,13 +3511,12 @@ ${htmlLog}
|
|
|
3463
3511
|
"texture-compression-pvrtc-webgl": [X_PVRTC],
|
|
3464
3512
|
"texture-compression-atc-webgl": [X_ATC]
|
|
3465
3513
|
};
|
|
3466
|
-
function
|
|
3467
|
-
|
|
3468
|
-
return extensions.every((extension) => gl.getExtension(extension));
|
|
3514
|
+
function isTextureFeature(feature) {
|
|
3515
|
+
return feature in TEXTURE_FEATURES;
|
|
3469
3516
|
}
|
|
3470
|
-
function
|
|
3471
|
-
const
|
|
3472
|
-
return
|
|
3517
|
+
function checkTextureFeature(gl, feature, extensions) {
|
|
3518
|
+
const textureExtensions = TEXTURE_FEATURES[feature] || [];
|
|
3519
|
+
return textureExtensions.every((extension) => getWebGLExtension(gl, extension, extensions));
|
|
3473
3520
|
}
|
|
3474
3521
|
var TEXTURE_FORMATS = {
|
|
3475
3522
|
// Unsized formats that leave the precision up to the driver.
|
|
@@ -3495,19 +3542,19 @@ ${htmlLog}
|
|
|
3495
3542
|
// 'rgba8unorm-srgb-unsized': {gl: GL.SRGB_ALPHA_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
|
|
3496
3543
|
// 8-bit formats
|
|
3497
3544
|
"r8unorm": { gl: import_constants4.GL.R8, b: 1, c: 1, renderbuffer: true },
|
|
3498
|
-
"r8snorm": { gl: import_constants4.GL.R8_SNORM, b: 1, c: 1 },
|
|
3545
|
+
"r8snorm": { gl: import_constants4.GL.R8_SNORM, b: 1, c: 1, render: snorm8_renderable },
|
|
3499
3546
|
"r8uint": { gl: import_constants4.GL.R8UI, b: 1, c: 1, renderbuffer: true },
|
|
3500
3547
|
"r8sint": { gl: import_constants4.GL.R8I, b: 1, c: 1, renderbuffer: true },
|
|
3501
3548
|
// 16-bit formats
|
|
3502
3549
|
"rg8unorm": { gl: import_constants4.GL.RG8, b: 2, c: 2, renderbuffer: true },
|
|
3503
|
-
"rg8snorm": { gl: import_constants4.GL.RG8_SNORM, b: 2, c: 2 },
|
|
3550
|
+
"rg8snorm": { gl: import_constants4.GL.RG8_SNORM, b: 2, c: 2, render: snorm8_renderable },
|
|
3504
3551
|
"rg8uint": { gl: import_constants4.GL.RG8UI, b: 2, c: 2, renderbuffer: true },
|
|
3505
3552
|
"rg8sint": { gl: import_constants4.GL.RG8I, b: 2, c: 2, renderbuffer: true },
|
|
3506
3553
|
"r16uint": { gl: import_constants4.GL.R16UI, b: 2, c: 1, renderbuffer: true },
|
|
3507
3554
|
"r16sint": { gl: import_constants4.GL.R16I, b: 2, c: 1, renderbuffer: true },
|
|
3508
|
-
"r16float": { gl: import_constants4.GL.R16F, b: 2, c: 1, render:
|
|
3509
|
-
"r16unorm-webgl": { gl: import_constants4.GL.R16_EXT, b: 2, c: 1, f:
|
|
3510
|
-
"r16snorm-webgl": { gl: import_constants4.GL.R16_SNORM_EXT, b: 2, c: 1, f:
|
|
3555
|
+
"r16float": { gl: import_constants4.GL.R16F, b: 2, c: 1, render: float16_renderable, filter: "float16-filterable-webgl", renderbuffer: true },
|
|
3556
|
+
"r16unorm-webgl": { gl: import_constants4.GL.R16_EXT, b: 2, c: 1, f: norm16_renderable, renderbuffer: true },
|
|
3557
|
+
"r16snorm-webgl": { gl: import_constants4.GL.R16_SNORM_EXT, b: 2, c: 1, f: snorm16_renderable },
|
|
3511
3558
|
// Packed 16-bit formats
|
|
3512
3559
|
"rgba4unorm-webgl": { gl: import_constants4.GL.RGBA4, b: 2, c: 4, wgpu: false, renderbuffer: true },
|
|
3513
3560
|
"rgb565unorm-webgl": { gl: import_constants4.GL.RGB565, b: 2, c: 4, wgpu: false, renderbuffer: true },
|
|
@@ -3518,7 +3565,7 @@ ${htmlLog}
|
|
|
3518
3565
|
// 32-bit formats
|
|
3519
3566
|
"rgba8unorm": { gl: import_constants4.GL.RGBA8, b: 4, c: 2, bpp: 4 },
|
|
3520
3567
|
"rgba8unorm-srgb": { gl: import_constants4.GL.SRGB8_ALPHA8, b: 4, c: 4, bpp: 4 },
|
|
3521
|
-
"rgba8snorm": { gl: import_constants4.GL.RGBA8_SNORM, b: 4, c: 4 },
|
|
3568
|
+
"rgba8snorm": { gl: import_constants4.GL.RGBA8_SNORM, b: 4, c: 4, render: snorm8_renderable },
|
|
3522
3569
|
"rgba8uint": { gl: import_constants4.GL.RGBA8UI, b: 4, c: 4, bpp: 4 },
|
|
3523
3570
|
"rgba8sint": { gl: import_constants4.GL.RGBA8I, b: 4, c: 4, bpp: 4 },
|
|
3524
3571
|
// reverse colors, webgpu only
|
|
@@ -3527,42 +3574,45 @@ ${htmlLog}
|
|
|
3527
3574
|
"rg16uint": { gl: import_constants4.GL.RG16UI, b: 4, c: 1, bpp: 4 },
|
|
3528
3575
|
"rg16sint": { gl: import_constants4.GL.RG16I, b: 4, c: 2, bpp: 4 },
|
|
3529
3576
|
// When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
|
|
3530
|
-
"rg16float": { gl: import_constants4.GL.RG16F, bpp: 4, b: 4, c: 2, render:
|
|
3531
|
-
"rg16unorm-webgl": { gl: import_constants4.GL.RG16_EXT, b: 2, c: 2,
|
|
3532
|
-
"rg16snorm-webgl": { gl: import_constants4.GL.RG16_SNORM_EXT, b: 2, c: 2,
|
|
3577
|
+
"rg16float": { gl: import_constants4.GL.RG16F, bpp: 4, b: 4, c: 2, render: float16_renderable, filter: float16_filterable, renderbuffer: true },
|
|
3578
|
+
"rg16unorm-webgl": { gl: import_constants4.GL.RG16_EXT, b: 2, c: 2, render: norm16_renderable },
|
|
3579
|
+
"rg16snorm-webgl": { gl: import_constants4.GL.RG16_SNORM_EXT, b: 2, c: 2, render: snorm16_renderable },
|
|
3533
3580
|
"r32uint": { gl: import_constants4.GL.R32UI, b: 4, c: 1, bpp: 4, renderbuffer: true },
|
|
3534
3581
|
"r32sint": { gl: import_constants4.GL.R32I, b: 4, c: 1, bpp: 4, renderbuffer: true },
|
|
3535
|
-
"r32float": { gl: import_constants4.GL.R32F, bpp: 4, b: 4, c: 1, render:
|
|
3582
|
+
"r32float": { gl: import_constants4.GL.R32F, bpp: 4, b: 4, c: 1, render: float32_renderable, filter: float32_filterable },
|
|
3536
3583
|
// Packed 32-bit formats
|
|
3537
|
-
"rgb9e5ufloat": { gl: import_constants4.GL.RGB9_E5, b: 4, c: 3, p: 1, render:
|
|
3538
|
-
|
|
3584
|
+
"rgb9e5ufloat": { gl: import_constants4.GL.RGB9_E5, b: 4, c: 3, p: 1, render: rgb9e5ufloat_renderable },
|
|
3585
|
+
// , filter: true},
|
|
3586
|
+
"rg11b10ufloat": { gl: import_constants4.GL.R11F_G11F_B10F, b: 4, c: 3, p: 1, render: float32_renderable, renderbuffer: true },
|
|
3539
3587
|
"rgb10a2unorm": { gl: import_constants4.GL.RGB10_A2, b: 4, c: 4, p: 1, renderbuffer: true },
|
|
3540
|
-
"
|
|
3588
|
+
"rgb10a2uint-webgl": { b: 4, c: 4, gl: import_constants4.GL.RGB10_A2UI, p: 1, wgpu: false, bpp: 4, renderbuffer: true },
|
|
3541
3589
|
// 48-bit formats
|
|
3542
|
-
"rgb16unorm-webgl": { gl: import_constants4.GL.RGB16_EXT, b: 2, c: 3, f:
|
|
3543
|
-
|
|
3590
|
+
"rgb16unorm-webgl": { gl: import_constants4.GL.RGB16_EXT, b: 2, c: 3, f: norm16_renderable },
|
|
3591
|
+
// rgb not renderable
|
|
3592
|
+
"rgb16snorm-webgl": { gl: import_constants4.GL.RGB16_SNORM_EXT, b: 2, c: 3, f: norm16_renderable },
|
|
3593
|
+
// rgb not renderable
|
|
3544
3594
|
// 64-bit formats
|
|
3545
3595
|
"rg32uint": { gl: import_constants4.GL.RG32UI, b: 8, c: 2, renderbuffer: true },
|
|
3546
3596
|
"rg32sint": { gl: import_constants4.GL.RG32I, b: 8, c: 2, renderbuffer: true },
|
|
3547
|
-
"rg32float": { gl: import_constants4.GL.RG32F, b: 8, c: 2, render:
|
|
3597
|
+
"rg32float": { gl: import_constants4.GL.RG32F, b: 8, c: 2, render: float32_renderable, filter: float32_filterable, renderbuffer: true },
|
|
3548
3598
|
"rgba16uint": { gl: import_constants4.GL.RGBA16UI, b: 8, c: 4, renderbuffer: true },
|
|
3549
3599
|
"rgba16sint": { gl: import_constants4.GL.RGBA16I, b: 8, c: 4, renderbuffer: true },
|
|
3550
|
-
"rgba16float": { gl: import_constants4.GL.RGBA16F, b: 8, c: 4, render:
|
|
3551
|
-
"rgba16unorm-webgl": { gl: import_constants4.GL.RGBA16_EXT, b: 2, c: 4,
|
|
3552
|
-
"rgba16snorm-webgl": { gl: import_constants4.GL.RGBA16_SNORM_EXT, b: 2, c: 4,
|
|
3600
|
+
"rgba16float": { gl: import_constants4.GL.RGBA16F, b: 8, c: 4, render: float16_renderable, filter: float16_filterable },
|
|
3601
|
+
"rgba16unorm-webgl": { gl: import_constants4.GL.RGBA16_EXT, b: 2, c: 4, render: norm16_renderable, renderbuffer: true },
|
|
3602
|
+
"rgba16snorm-webgl": { gl: import_constants4.GL.RGBA16_SNORM_EXT, b: 2, c: 4, render: snorm16_renderable },
|
|
3553
3603
|
// 96-bit formats (deprecated!)
|
|
3554
3604
|
"rgb32float-webgl": {
|
|
3555
3605
|
gl: import_constants4.GL.RGB32F,
|
|
3556
|
-
render:
|
|
3557
|
-
filter:
|
|
3558
|
-
gl2ext:
|
|
3606
|
+
render: float32_renderable,
|
|
3607
|
+
filter: float32_filterable,
|
|
3608
|
+
gl2ext: EXT_color_buffer_float,
|
|
3559
3609
|
dataFormat: import_constants4.GL.RGB,
|
|
3560
3610
|
types: [import_constants4.GL.FLOAT]
|
|
3561
3611
|
},
|
|
3562
3612
|
// 128-bit formats
|
|
3563
3613
|
"rgba32uint": { gl: import_constants4.GL.RGBA32UI, b: 16, c: 4, renderbuffer: true },
|
|
3564
3614
|
"rgba32sint": { gl: import_constants4.GL.RGBA32I, b: 16, c: 4, renderbuffer: true },
|
|
3565
|
-
"rgba32float": { gl: import_constants4.GL.RGBA32F, b: 16, c: 4, render:
|
|
3615
|
+
"rgba32float": { gl: import_constants4.GL.RGBA32F, b: 16, c: 4, render: float32_renderable, filter: float32_filterable, renderbuffer: true },
|
|
3566
3616
|
// Depth and stencil formats
|
|
3567
3617
|
"stencil8": { gl: import_constants4.GL.STENCIL_INDEX8, b: 1, c: 1, attachment: import_constants4.GL.STENCIL_ATTACHMENT, renderbuffer: true },
|
|
3568
3618
|
// 8 stencil bits
|
|
@@ -3671,7 +3721,7 @@ ${htmlLog}
|
|
|
3671
3721
|
[import_constants4.GL.BYTE]: 1,
|
|
3672
3722
|
[import_constants4.GL.UNSIGNED_BYTE]: 1
|
|
3673
3723
|
};
|
|
3674
|
-
function isTextureFormatSupported(gl, formatOrGL) {
|
|
3724
|
+
function isTextureFormatSupported(gl, formatOrGL, extensions) {
|
|
3675
3725
|
const format = convertGLToTextureFormat(formatOrGL);
|
|
3676
3726
|
const info = TEXTURE_FORMATS[format];
|
|
3677
3727
|
if (!info) {
|
|
@@ -3682,12 +3732,12 @@ ${htmlLog}
|
|
|
3682
3732
|
}
|
|
3683
3733
|
const extension = info.x || info.gl2ext;
|
|
3684
3734
|
if (extension) {
|
|
3685
|
-
return Boolean(gl
|
|
3735
|
+
return Boolean(getWebGLExtension(gl, extension, extensions));
|
|
3686
3736
|
}
|
|
3687
3737
|
return true;
|
|
3688
3738
|
}
|
|
3689
|
-
function isRenderbufferFormatSupported(gl, format) {
|
|
3690
|
-
return isTextureFormatSupported(gl, format) && TEXTURE_FORMATS[format]?.renderbuffer;
|
|
3739
|
+
function isRenderbufferFormatSupported(gl, format, extensions) {
|
|
3740
|
+
return isTextureFormatSupported(gl, format, extensions) && TEXTURE_FORMATS[format]?.renderbuffer;
|
|
3691
3741
|
}
|
|
3692
3742
|
function convertGLToTextureFormat(format) {
|
|
3693
3743
|
if (typeof format === "string") {
|
|
@@ -3707,9 +3757,9 @@ ${htmlLog}
|
|
|
3707
3757
|
}
|
|
3708
3758
|
return webglFormat;
|
|
3709
3759
|
}
|
|
3710
|
-
function isTextureFormatFilterable(gl, formatOrGL) {
|
|
3760
|
+
function isTextureFormatFilterable(gl, formatOrGL, extensions) {
|
|
3711
3761
|
const format = convertGLToTextureFormat(formatOrGL);
|
|
3712
|
-
if (!isTextureFormatSupported(gl, format)) {
|
|
3762
|
+
if (!isTextureFormatSupported(gl, format, extensions)) {
|
|
3713
3763
|
return false;
|
|
3714
3764
|
}
|
|
3715
3765
|
try {
|
|
@@ -3721,16 +3771,16 @@ ${htmlLog}
|
|
|
3721
3771
|
return false;
|
|
3722
3772
|
}
|
|
3723
3773
|
if (format.endsWith("32float")) {
|
|
3724
|
-
return Boolean(gl
|
|
3774
|
+
return Boolean(getWebGLExtension(gl, "OES_texture_float_linear, extensions", extensions));
|
|
3725
3775
|
}
|
|
3726
3776
|
if (format.endsWith("16float")) {
|
|
3727
|
-
return Boolean(gl
|
|
3777
|
+
return Boolean(getWebGLExtension(gl, "OES_texture_half_float_linear, extensions", extensions));
|
|
3728
3778
|
}
|
|
3729
3779
|
return true;
|
|
3730
3780
|
}
|
|
3731
|
-
function isTextureFormatRenderable(gl, formatOrGL) {
|
|
3781
|
+
function isTextureFormatRenderable(gl, formatOrGL, extensions) {
|
|
3732
3782
|
const format = convertGLToTextureFormat(formatOrGL);
|
|
3733
|
-
if (!isTextureFormatSupported(gl, format)) {
|
|
3783
|
+
if (!isTextureFormatSupported(gl, format, extensions)) {
|
|
3734
3784
|
return false;
|
|
3735
3785
|
}
|
|
3736
3786
|
if (typeof format === "number") {
|
|
@@ -3789,183 +3839,177 @@ ${htmlLog}
|
|
|
3789
3839
|
}
|
|
3790
3840
|
|
|
3791
3841
|
// src/adapter/device-helpers/webgl-device-features.ts
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3842
|
+
var WEBGL_FEATURES = {
|
|
3843
|
+
// optional WebGPU features
|
|
3844
|
+
"depth-clip-control": "EXT_depth_clamp",
|
|
3845
|
+
// TODO these seem subtly different
|
|
3846
|
+
// 'timestamp-query' // GPUQueryType "timestamp-query"
|
|
3847
|
+
// "indirect-first-instance"
|
|
3848
|
+
// Textures are handled by getTextureFeatures()
|
|
3849
|
+
// 'depth24unorm-stencil8' // GPUTextureFormat 'depth24unorm-stencil8'
|
|
3850
|
+
// 'depth32float-stencil8' // GPUTextureFormat 'depth32float-stencil8'
|
|
3851
|
+
// optional WebGL features
|
|
3852
|
+
"timer-query-webgl": "EXT_disjoint_timer_query_webgl2",
|
|
3853
|
+
"compilation-status-async-webgl": "KHR_parallel_shader_compile",
|
|
3854
|
+
"polygon-mode-webgl": "WEBGL_polygon_mode",
|
|
3855
|
+
"provoking-vertex-webgl": "WEBGL_provoking_vertex",
|
|
3856
|
+
"shader-clip-cull-distance-webgl": "WEBGL_clip_cull_distance",
|
|
3857
|
+
"shader-noperspective-interpolation-webgl": "NV_shader_noperspective_interpolation",
|
|
3858
|
+
"shader-conservative-depth-webgl": "EXT_conservative_depth"
|
|
3859
|
+
// Textures are handled by getTextureFeatures()
|
|
3860
|
+
};
|
|
3861
|
+
var WebGLDeviceFeatures = class extends DeviceFeatures {
|
|
3862
|
+
gl;
|
|
3863
|
+
extensions;
|
|
3864
|
+
testedFeatures = /* @__PURE__ */ new Set();
|
|
3865
|
+
constructor(gl, extensions) {
|
|
3866
|
+
super();
|
|
3867
|
+
this.gl = gl;
|
|
3868
|
+
this.extensions = extensions;
|
|
3869
|
+
getWebGLExtension(gl, "EXT_color_buffer_float", extensions);
|
|
3796
3870
|
}
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3871
|
+
*[Symbol.iterator]() {
|
|
3872
|
+
for (const feature of Object.keys(WEBGL_FEATURES)) {
|
|
3873
|
+
if (this.has(feature)) {
|
|
3874
|
+
yield feature;
|
|
3875
|
+
}
|
|
3876
|
+
}
|
|
3877
|
+
for (const feature of Object.keys(TEXTURE_FEATURES)) {
|
|
3878
|
+
if (this.has(feature)) {
|
|
3879
|
+
yield feature;
|
|
3880
|
+
}
|
|
3805
3881
|
}
|
|
3882
|
+
return [];
|
|
3883
|
+
}
|
|
3884
|
+
has(feature) {
|
|
3885
|
+
if (!this.testedFeatures.has(feature)) {
|
|
3886
|
+
this.testedFeatures.add(feature);
|
|
3887
|
+
if (isTextureFeature(feature) && checkTextureFeature(this.gl, feature, this.extensions)) {
|
|
3888
|
+
this.features.add(feature);
|
|
3889
|
+
}
|
|
3890
|
+
if (this.getWebGLFeature(feature)) {
|
|
3891
|
+
this.features.add(feature);
|
|
3892
|
+
}
|
|
3893
|
+
}
|
|
3894
|
+
return this.features.has(feature);
|
|
3895
|
+
}
|
|
3896
|
+
/** Extract all WebGL features */
|
|
3897
|
+
getWebGLFeature(feature) {
|
|
3898
|
+
const featureInfo = WEBGL_FEATURES[feature];
|
|
3899
|
+
const isSupported = typeof featureInfo === "string" ? Boolean(getWebGLExtension(this.gl, featureInfo, this.extensions)) : Boolean(featureInfo);
|
|
3900
|
+
return isSupported;
|
|
3806
3901
|
}
|
|
3807
|
-
return features;
|
|
3808
|
-
}
|
|
3809
|
-
function isFeatureSupported(gl, feature) {
|
|
3810
|
-
const featureInfo = WEBGL_FEATURES[feature];
|
|
3811
|
-
return typeof featureInfo === "string" ? Boolean(gl.getExtension(featureInfo)) : Boolean(featureInfo);
|
|
3812
|
-
}
|
|
3813
|
-
var WEBGL_FEATURES = {
|
|
3814
|
-
webgl: true,
|
|
3815
|
-
glsl: true,
|
|
3816
|
-
"uniforms-webgl": true,
|
|
3817
|
-
"transform-feedback-webgl": true,
|
|
3818
|
-
"constant-attributes-webgl": true,
|
|
3819
|
-
"timer-query-webgl": "EXT_disjoint_timer_query_webgl2",
|
|
3820
|
-
"shader-status-async-webgl": "KHR_parallel_shader_compile"
|
|
3821
|
-
// Textures are handled by getTextureFeatures()
|
|
3822
3902
|
};
|
|
3823
3903
|
|
|
3824
3904
|
// src/adapter/device-helpers/webgl-device-limits.ts
|
|
3825
3905
|
var import_constants5 = __toESM(require_constants(), 1);
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
// WebGL does not support 1D textures
|
|
3830
|
-
maxTextureDimension2D: gl.getParameter(import_constants5.GL.MAX_TEXTURE_SIZE),
|
|
3831
|
-
maxTextureDimension3D: gl.getParameter(import_constants5.GL.MAX_3D_TEXTURE_SIZE),
|
|
3832
|
-
maxTextureArrayLayers: gl.getParameter(import_constants5.GL.MAX_ARRAY_TEXTURE_LAYERS),
|
|
3833
|
-
maxBindGroups: 1,
|
|
3834
|
-
// TBD - if we emulate bind groups we could support any number...
|
|
3835
|
-
maxDynamicUniformBuffersPerPipelineLayout: 0,
|
|
3836
|
-
// TBD
|
|
3837
|
-
maxDynamicStorageBuffersPerPipelineLayout: 0,
|
|
3838
|
-
// TBD
|
|
3839
|
-
maxSampledTexturesPerShaderStage: gl.getParameter(import_constants5.GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS),
|
|
3840
|
-
// TBD
|
|
3841
|
-
maxSamplersPerShaderStage: gl.getParameter(import_constants5.GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS),
|
|
3842
|
-
maxStorageBuffersPerShaderStage: 0,
|
|
3843
|
-
// TBD
|
|
3844
|
-
maxStorageTexturesPerShaderStage: 0,
|
|
3845
|
-
// TBD
|
|
3846
|
-
maxUniformBuffersPerShaderStage: gl.getParameter(import_constants5.GL.MAX_UNIFORM_BUFFER_BINDINGS),
|
|
3847
|
-
maxUniformBufferBindingSize: gl.getParameter(import_constants5.GL.MAX_UNIFORM_BLOCK_SIZE),
|
|
3848
|
-
maxStorageBufferBindingSize: 0,
|
|
3849
|
-
minUniformBufferOffsetAlignment: gl.getParameter(import_constants5.GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT),
|
|
3850
|
-
minStorageBufferOffsetAlignment: 0,
|
|
3851
|
-
// TBD
|
|
3852
|
-
maxVertexBuffers: 0,
|
|
3853
|
-
maxVertexAttributes: gl.getParameter(import_constants5.GL.MAX_VERTEX_ATTRIBS),
|
|
3854
|
-
maxVertexBufferArrayStride: 2048,
|
|
3855
|
-
// TBD, this is just the default value from WebGPU
|
|
3856
|
-
maxInterStageShaderComponents: gl.getParameter(import_constants5.GL.MAX_VARYING_COMPONENTS),
|
|
3857
|
-
maxComputeWorkgroupStorageSize: 0,
|
|
3858
|
-
// WebGL does not support compute shaders
|
|
3859
|
-
maxComputeInvocationsPerWorkgroup: 0,
|
|
3860
|
-
// WebGL does not support compute shaders
|
|
3861
|
-
maxComputeWorkgroupSizeX: 0,
|
|
3862
|
-
// WebGL does not support compute shaders
|
|
3863
|
-
maxComputeWorkgroupSizeY: 0,
|
|
3864
|
-
// WebGL does not support compute shaders
|
|
3865
|
-
maxComputeWorkgroupSizeZ: 0,
|
|
3866
|
-
// WebGL does not support compute shaders
|
|
3867
|
-
maxComputeWorkgroupsPerDimension: 0
|
|
3868
|
-
// WebGL does not support compute shaders
|
|
3869
|
-
};
|
|
3870
|
-
}
|
|
3871
|
-
function getWebGLLimits(gl) {
|
|
3872
|
-
function get(pname) {
|
|
3873
|
-
return gl.getParameter(pname);
|
|
3906
|
+
var WebGLDeviceLimits = class extends DeviceLimits {
|
|
3907
|
+
get maxTextureDimension1D() {
|
|
3908
|
+
return 0;
|
|
3874
3909
|
}
|
|
3875
|
-
|
|
3876
|
-
|
|
3910
|
+
// WebGL does not support 1D textures
|
|
3911
|
+
get maxTextureDimension2D() {
|
|
3912
|
+
return this.getParameter(import_constants5.GL.MAX_TEXTURE_SIZE);
|
|
3877
3913
|
}
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
)
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3914
|
+
get maxTextureDimension3D() {
|
|
3915
|
+
return this.getParameter(import_constants5.GL.MAX_3D_TEXTURE_SIZE);
|
|
3916
|
+
}
|
|
3917
|
+
get maxTextureArrayLayers() {
|
|
3918
|
+
return this.getParameter(import_constants5.GL.MAX_ARRAY_TEXTURE_LAYERS);
|
|
3919
|
+
}
|
|
3920
|
+
get maxBindGroups() {
|
|
3921
|
+
return 0;
|
|
3922
|
+
}
|
|
3923
|
+
get maxDynamicUniformBuffersPerPipelineLayout() {
|
|
3924
|
+
return 0;
|
|
3925
|
+
}
|
|
3926
|
+
// TBD
|
|
3927
|
+
get maxDynamicStorageBuffersPerPipelineLayout() {
|
|
3928
|
+
return 0;
|
|
3929
|
+
}
|
|
3930
|
+
// TBD
|
|
3931
|
+
get maxSampledTexturesPerShaderStage() {
|
|
3932
|
+
return this.getParameter(import_constants5.GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
|
|
3933
|
+
}
|
|
3934
|
+
// ) TBD
|
|
3935
|
+
get maxSamplersPerShaderStage() {
|
|
3936
|
+
return this.getParameter(import_constants5.GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
|
|
3937
|
+
}
|
|
3938
|
+
get maxStorageBuffersPerShaderStage() {
|
|
3939
|
+
return 0;
|
|
3940
|
+
}
|
|
3941
|
+
// TBD
|
|
3942
|
+
get maxStorageTexturesPerShaderStage() {
|
|
3943
|
+
return 0;
|
|
3944
|
+
}
|
|
3945
|
+
// TBD
|
|
3946
|
+
get maxUniformBuffersPerShaderStage() {
|
|
3947
|
+
return this.getParameter(import_constants5.GL.MAX_UNIFORM_BUFFER_BINDINGS);
|
|
3948
|
+
}
|
|
3949
|
+
get maxUniformBufferBindingSize() {
|
|
3950
|
+
return this.getParameter(import_constants5.GL.MAX_UNIFORM_BLOCK_SIZE);
|
|
3951
|
+
}
|
|
3952
|
+
get maxStorageBufferBindingSize() {
|
|
3953
|
+
return 0;
|
|
3954
|
+
}
|
|
3955
|
+
get minUniformBufferOffsetAlignment() {
|
|
3956
|
+
return this.getParameter(import_constants5.GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT);
|
|
3957
|
+
}
|
|
3958
|
+
get minStorageBufferOffsetAlignment() {
|
|
3959
|
+
return 0;
|
|
3960
|
+
}
|
|
3961
|
+
get maxVertexBuffers() {
|
|
3962
|
+
return 16;
|
|
3963
|
+
}
|
|
3964
|
+
// WebGL 2 supports 16 buffers, see https://github.com/gpuweb/gpuweb/issues/4284
|
|
3965
|
+
get maxVertexAttributes() {
|
|
3966
|
+
return this.getParameter(import_constants5.GL.MAX_VERTEX_ATTRIBS);
|
|
3967
|
+
}
|
|
3968
|
+
get maxVertexBufferArrayStride() {
|
|
3969
|
+
return 2048;
|
|
3970
|
+
}
|
|
3971
|
+
// TBD, this is just the default value from WebGPU
|
|
3972
|
+
get maxInterStageShaderComponents() {
|
|
3973
|
+
return this.getParameter(import_constants5.GL.MAX_VARYING_COMPONENTS);
|
|
3974
|
+
}
|
|
3975
|
+
get maxComputeWorkgroupStorageSize() {
|
|
3976
|
+
return 0;
|
|
3977
|
+
}
|
|
3978
|
+
// WebGL does not support compute shaders
|
|
3979
|
+
get maxComputeInvocationsPerWorkgroup() {
|
|
3980
|
+
return 0;
|
|
3981
|
+
}
|
|
3982
|
+
// WebGL does not support compute shaders
|
|
3983
|
+
get maxComputeWorkgroupSizeX() {
|
|
3984
|
+
return 0;
|
|
3985
|
+
}
|
|
3986
|
+
// WebGL does not support compute shaders
|
|
3987
|
+
get maxComputeWorkgroupSizeY() {
|
|
3988
|
+
return 0;
|
|
3989
|
+
}
|
|
3990
|
+
// WebGL does not support compute shaders
|
|
3991
|
+
get maxComputeWorkgroupSizeZ() {
|
|
3992
|
+
return 0;
|
|
3993
|
+
}
|
|
3994
|
+
// WebGL does not support compute shaders
|
|
3995
|
+
get maxComputeWorkgroupsPerDimension() {
|
|
3996
|
+
return 0;
|
|
3997
|
+
}
|
|
3998
|
+
// WebGL does not support compute shaders
|
|
3999
|
+
// PRIVATE
|
|
4000
|
+
gl;
|
|
4001
|
+
limits = {};
|
|
4002
|
+
constructor(gl) {
|
|
4003
|
+
super();
|
|
4004
|
+
this.gl = gl;
|
|
4005
|
+
}
|
|
4006
|
+
getParameter(parameter) {
|
|
4007
|
+
if (this.limits[parameter] === void 0) {
|
|
4008
|
+
this.limits[parameter] = this.gl.getParameter(parameter);
|
|
4009
|
+
}
|
|
4010
|
+
return this.limits[parameter];
|
|
4011
|
+
}
|
|
4012
|
+
};
|
|
3969
4013
|
|
|
3970
4014
|
// src/adapter/resources/webgl-framebuffer.ts
|
|
3971
4015
|
var import_constants12 = __toESM(require_constants(), 1);
|
|
@@ -4059,9 +4103,66 @@ ${htmlLog}
|
|
|
4059
4103
|
})
|
|
4060
4104
|
);
|
|
4061
4105
|
}
|
|
4106
|
+
if (parameters.unclippedDepth) {
|
|
4107
|
+
if (device.features.has("depth-clip-control")) {
|
|
4108
|
+
gl.enable(import_constants6.GL.DEPTH_CLAMP_EXT);
|
|
4109
|
+
}
|
|
4110
|
+
}
|
|
4062
4111
|
if (parameters.depthBias !== void 0) {
|
|
4063
4112
|
gl.polygonOffset(parameters.depthBias, parameters.depthBiasSlopeScale || 0);
|
|
4064
4113
|
}
|
|
4114
|
+
if (device.features.has("provoking-vertex-webgl")) {
|
|
4115
|
+
const extensions = webglDevice.getExtension("WEBGL_provoking_vertex");
|
|
4116
|
+
const ext = extensions.WEBGL_provoking_vertex;
|
|
4117
|
+
if (parameters.provokingVertex) {
|
|
4118
|
+
const vertex = map("provokingVertex", parameters.provokingVertex, {
|
|
4119
|
+
first: import_constants6.GL.FIRST_VERTEX_CONVENTION_WEBGL,
|
|
4120
|
+
last: import_constants6.GL.LAST_VERTEX_CONVENTION_WEBGL
|
|
4121
|
+
});
|
|
4122
|
+
ext?.provokingVertexWEBGL(vertex);
|
|
4123
|
+
}
|
|
4124
|
+
}
|
|
4125
|
+
if (device.features.has("polygon-mode-webgl")) {
|
|
4126
|
+
const extensions = webglDevice.getExtension("WEBGL_polygon_mode");
|
|
4127
|
+
const ext = extensions.WEBGL_polygon_mode;
|
|
4128
|
+
if (parameters.polygonMode) {
|
|
4129
|
+
const mode = map("polygonMode", parameters.provokingVertex, {
|
|
4130
|
+
fill: import_constants6.GL.FILL_WEBGL,
|
|
4131
|
+
lint: import_constants6.GL.LINE_WEBGL
|
|
4132
|
+
});
|
|
4133
|
+
ext?.polygonModeWEBGL(import_constants6.GL.FRONT, mode);
|
|
4134
|
+
ext?.polygonModeWEBGL(import_constants6.GL.BACK, mode);
|
|
4135
|
+
}
|
|
4136
|
+
if (parameters.polygonOffsetLine) {
|
|
4137
|
+
gl.enable(import_constants6.GL.POLYGON_OFFSET_LINE_WEBGL);
|
|
4138
|
+
}
|
|
4139
|
+
}
|
|
4140
|
+
if (device.features.has("shader-clip-cull-distance-webgl")) {
|
|
4141
|
+
if (parameters.clipDistance0) {
|
|
4142
|
+
gl.enable(import_constants6.GL.CLIP_DISTANCE0_WEBGL);
|
|
4143
|
+
}
|
|
4144
|
+
if (parameters.clipDistance1) {
|
|
4145
|
+
gl.enable(import_constants6.GL.CLIP_DISTANCE1_WEBGL);
|
|
4146
|
+
}
|
|
4147
|
+
if (parameters.clipDistance2) {
|
|
4148
|
+
gl.enable(import_constants6.GL.CLIP_DISTANCE2_WEBGL);
|
|
4149
|
+
}
|
|
4150
|
+
if (parameters.clipDistance3) {
|
|
4151
|
+
gl.enable(import_constants6.GL.CLIP_DISTANCE3_WEBGL);
|
|
4152
|
+
}
|
|
4153
|
+
if (parameters.clipDistance4) {
|
|
4154
|
+
gl.enable(import_constants6.GL.CLIP_DISTANCE4_WEBGL);
|
|
4155
|
+
}
|
|
4156
|
+
if (parameters.clipDistance5) {
|
|
4157
|
+
gl.enable(import_constants6.GL.CLIP_DISTANCE5_WEBGL);
|
|
4158
|
+
}
|
|
4159
|
+
if (parameters.clipDistance6) {
|
|
4160
|
+
gl.enable(import_constants6.GL.CLIP_DISTANCE6_WEBGL);
|
|
4161
|
+
}
|
|
4162
|
+
if (parameters.clipDistance7) {
|
|
4163
|
+
gl.enable(import_constants6.GL.CLIP_DISTANCE7_WEBGL);
|
|
4164
|
+
}
|
|
4165
|
+
}
|
|
4065
4166
|
if (parameters.depthWriteEnabled !== void 0) {
|
|
4066
4167
|
gl.depthMask(mapBoolean("depthWriteEnabled", parameters.depthWriteEnabled));
|
|
4067
4168
|
}
|
|
@@ -4096,13 +4197,31 @@ ${htmlLog}
|
|
|
4096
4197
|
}
|
|
4097
4198
|
if (parameters.blendColorOperation || parameters.blendAlphaOperation) {
|
|
4098
4199
|
gl.enable(import_constants6.GL.BLEND);
|
|
4099
|
-
const colorEquation = convertBlendOperationToEquation(
|
|
4100
|
-
|
|
4200
|
+
const colorEquation = convertBlendOperationToEquation(
|
|
4201
|
+
"blendColorOperation",
|
|
4202
|
+
parameters.blendColorOperation || "add"
|
|
4203
|
+
);
|
|
4204
|
+
const alphaEquation = convertBlendOperationToEquation(
|
|
4205
|
+
"blendAlphaOperation",
|
|
4206
|
+
parameters.blendAlphaOperation || "add"
|
|
4207
|
+
);
|
|
4101
4208
|
gl.blendEquationSeparate(colorEquation, alphaEquation);
|
|
4102
|
-
const colorSrcFactor = convertBlendFactorToFunction(
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4209
|
+
const colorSrcFactor = convertBlendFactorToFunction(
|
|
4210
|
+
"blendColorSrcFactor",
|
|
4211
|
+
parameters.blendColorSrcFactor || "one"
|
|
4212
|
+
);
|
|
4213
|
+
const colorDstFactor = convertBlendFactorToFunction(
|
|
4214
|
+
"blendColorDstFactor",
|
|
4215
|
+
parameters.blendColorDstFactor || "zero"
|
|
4216
|
+
);
|
|
4217
|
+
const alphaSrcFactor = convertBlendFactorToFunction(
|
|
4218
|
+
"blendAlphaSrcFactor",
|
|
4219
|
+
parameters.blendAlphaSrcFactor || "one"
|
|
4220
|
+
);
|
|
4221
|
+
const alphaDstFactor = convertBlendFactorToFunction(
|
|
4222
|
+
"blendAlphaDstFactor",
|
|
4223
|
+
parameters.blendAlphaDstFactor || "zero"
|
|
4224
|
+
);
|
|
4106
4225
|
gl.blendFuncSeparate(colorSrcFactor, colorDstFactor, alphaSrcFactor, alphaDstFactor);
|
|
4107
4226
|
}
|
|
4108
4227
|
}
|
|
@@ -4132,17 +4251,17 @@ ${htmlLog}
|
|
|
4132
4251
|
}
|
|
4133
4252
|
function convertBlendOperationToEquation(parameter, value) {
|
|
4134
4253
|
return map(parameter, value, {
|
|
4135
|
-
|
|
4136
|
-
|
|
4254
|
+
add: import_constants6.GL.FUNC_ADD,
|
|
4255
|
+
subtract: import_constants6.GL.FUNC_SUBTRACT,
|
|
4137
4256
|
"reverse-subtract": import_constants6.GL.FUNC_REVERSE_SUBTRACT,
|
|
4138
|
-
|
|
4139
|
-
|
|
4257
|
+
min: import_constants6.GL.MIN,
|
|
4258
|
+
max: import_constants6.GL.MAX
|
|
4140
4259
|
});
|
|
4141
4260
|
}
|
|
4142
4261
|
function convertBlendFactorToFunction(parameter, value) {
|
|
4143
4262
|
return map(parameter, value, {
|
|
4144
|
-
|
|
4145
|
-
|
|
4263
|
+
one: import_constants6.GL.ONE,
|
|
4264
|
+
zero: import_constants6.GL.ZERO,
|
|
4146
4265
|
"src-color": import_constants6.GL.SRC_COLOR,
|
|
4147
4266
|
"one-minus-src-color": import_constants6.GL.ONE_MINUS_SRC_COLOR,
|
|
4148
4267
|
"dst-color": import_constants6.GL.DST_COLOR,
|
|
@@ -4398,6 +4517,21 @@ ${htmlLog}
|
|
|
4398
4517
|
}
|
|
4399
4518
|
};
|
|
4400
4519
|
|
|
4520
|
+
// src/adapter/resources/webgl-texture-view.ts
|
|
4521
|
+
var WEBGLTextureView = class extends TextureView {
|
|
4522
|
+
device;
|
|
4523
|
+
gl;
|
|
4524
|
+
handle;
|
|
4525
|
+
texture;
|
|
4526
|
+
constructor(device, props) {
|
|
4527
|
+
super(device, { ...Texture.defaultProps, ...props });
|
|
4528
|
+
this.device = device;
|
|
4529
|
+
this.gl = this.device.gl;
|
|
4530
|
+
this.handle = null;
|
|
4531
|
+
this.texture = props.texture;
|
|
4532
|
+
}
|
|
4533
|
+
};
|
|
4534
|
+
|
|
4401
4535
|
// src/adapter/resources/webgl-texture.ts
|
|
4402
4536
|
var DEFAULT_WEBGL_TEXTURE_PROPS = {
|
|
4403
4537
|
// deprecated
|
|
@@ -4414,8 +4548,9 @@ ${htmlLog}
|
|
|
4414
4548
|
device;
|
|
4415
4549
|
gl;
|
|
4416
4550
|
handle;
|
|
4417
|
-
|
|
4551
|
+
// (TODO - currently unused in WebGL, but WebGL 2 does support sampler objects) */
|
|
4418
4552
|
sampler = void 0;
|
|
4553
|
+
view = void 0;
|
|
4419
4554
|
// data;
|
|
4420
4555
|
glFormat = void 0;
|
|
4421
4556
|
type = void 0;
|
|
@@ -4530,6 +4665,7 @@ ${htmlLog}
|
|
|
4530
4665
|
});
|
|
4531
4666
|
this.setSampler(props.sampler);
|
|
4532
4667
|
this._setSamplerParameters(parameters);
|
|
4668
|
+
this.view = new WEBGLTextureView(this.device, { ...this.props, texture: this });
|
|
4533
4669
|
if (mipmaps) {
|
|
4534
4670
|
this.generateMipmap();
|
|
4535
4671
|
}
|
|
@@ -5088,21 +5224,6 @@ ${htmlLog}
|
|
|
5088
5224
|
// src/adapter/objects/webgl-renderbuffer.ts
|
|
5089
5225
|
var import_constants11 = __toESM(require_constants(), 1);
|
|
5090
5226
|
|
|
5091
|
-
// src/adapter/objects/constants-to-keys.ts
|
|
5092
|
-
function getKeyValue(gl, name2) {
|
|
5093
|
-
if (typeof name2 !== "string") {
|
|
5094
|
-
return name2;
|
|
5095
|
-
}
|
|
5096
|
-
const number = Number(name2);
|
|
5097
|
-
if (!isNaN(number)) {
|
|
5098
|
-
return number;
|
|
5099
|
-
}
|
|
5100
|
-
name2 = name2.replace(/^.*\./, "");
|
|
5101
|
-
const value = gl[name2];
|
|
5102
|
-
assert2(value !== void 0, `Accessing undefined constant GL.${name2}`);
|
|
5103
|
-
return value;
|
|
5104
|
-
}
|
|
5105
|
-
|
|
5106
5227
|
// src/adapter/objects/webgl-resource.ts
|
|
5107
5228
|
var ERR_RESOURCE_METHOD_UNDEFINED = "Resource subclass must define virtual methods";
|
|
5108
5229
|
var WebGLResource = class extends Resource {
|
|
@@ -5164,82 +5285,6 @@ ${htmlLog}
|
|
|
5164
5285
|
unbind() {
|
|
5165
5286
|
this.bind(null);
|
|
5166
5287
|
}
|
|
5167
|
-
/**
|
|
5168
|
-
* Query a Resource parameter
|
|
5169
|
-
*
|
|
5170
|
-
* @param name
|
|
5171
|
-
* @return param
|
|
5172
|
-
*/
|
|
5173
|
-
getParameter(pname, props = {}) {
|
|
5174
|
-
pname = getKeyValue(this.gl, pname);
|
|
5175
|
-
assert2(pname);
|
|
5176
|
-
const parameters = this.constructor.PARAMETERS || {};
|
|
5177
|
-
const parameter = parameters[pname];
|
|
5178
|
-
if (parameter) {
|
|
5179
|
-
const parameterAvailable = !("extension" in parameter) || this.gl.getExtension(parameter.extension);
|
|
5180
|
-
if (!parameterAvailable) {
|
|
5181
|
-
return parameter.webgl2;
|
|
5182
|
-
}
|
|
5183
|
-
}
|
|
5184
|
-
return this._getParameter(pname, props);
|
|
5185
|
-
}
|
|
5186
|
-
// Many resources support a getParameter call -
|
|
5187
|
-
// getParameters will get all parameters - slow but useful for debugging
|
|
5188
|
-
// eslint-disable-next-line complexity
|
|
5189
|
-
getParameters(options = {}) {
|
|
5190
|
-
const { parameters, keys } = options;
|
|
5191
|
-
const PARAMETERS = this.constructor.PARAMETERS || {};
|
|
5192
|
-
const values = {};
|
|
5193
|
-
const parameterKeys = parameters || Object.keys(PARAMETERS);
|
|
5194
|
-
for (const pname of parameterKeys) {
|
|
5195
|
-
const parameter = PARAMETERS[pname];
|
|
5196
|
-
const parameterAvailable = parameter && (!("extension" in parameter) || this.gl.getExtension(parameter.extension));
|
|
5197
|
-
if (parameterAvailable) {
|
|
5198
|
-
const key = keys ? this.device.getGLKey(pname) : pname;
|
|
5199
|
-
values[key] = this.getParameter(pname, options);
|
|
5200
|
-
if (keys && parameter.type === "GLenum") {
|
|
5201
|
-
values[key] = this.device.getGLKey(values[key]);
|
|
5202
|
-
}
|
|
5203
|
-
}
|
|
5204
|
-
}
|
|
5205
|
-
return values;
|
|
5206
|
-
}
|
|
5207
|
-
/**
|
|
5208
|
-
* Update a Resource setting
|
|
5209
|
-
*
|
|
5210
|
-
* @todo - cache parameter to avoid issuing WebGL calls?
|
|
5211
|
-
*
|
|
5212
|
-
* @param pname - parameter (GL constant, value or key)
|
|
5213
|
-
* @param value {GLint|GLfloat|GLenum}
|
|
5214
|
-
* @return returns self to enable chaining
|
|
5215
|
-
*/
|
|
5216
|
-
setParameter(pname, value) {
|
|
5217
|
-
pname = getKeyValue(this.gl, pname);
|
|
5218
|
-
assert2(pname);
|
|
5219
|
-
const parameters = this.constructor.PARAMETERS || {};
|
|
5220
|
-
const parameter = parameters[pname];
|
|
5221
|
-
if (parameter) {
|
|
5222
|
-
const parameterAvailable = !("extension" in parameter) || this.gl.getExtension(parameter.extension);
|
|
5223
|
-
if (!parameterAvailable) {
|
|
5224
|
-
throw new Error("Parameter not available on this platform");
|
|
5225
|
-
}
|
|
5226
|
-
if (parameter.type === "GLenum") {
|
|
5227
|
-
value = getKeyValue(value);
|
|
5228
|
-
}
|
|
5229
|
-
}
|
|
5230
|
-
this._setParameter(pname, value);
|
|
5231
|
-
return this;
|
|
5232
|
-
}
|
|
5233
|
-
/*
|
|
5234
|
-
* Batch update resource parameters
|
|
5235
|
-
* Assumes the subclass supports a setParameter call
|
|
5236
|
-
*/
|
|
5237
|
-
setParameters(parameters) {
|
|
5238
|
-
for (const pname in parameters) {
|
|
5239
|
-
this.setParameter(pname, parameters[pname]);
|
|
5240
|
-
}
|
|
5241
|
-
return this;
|
|
5242
|
-
}
|
|
5243
5288
|
// Install stubs for removed methods
|
|
5244
5289
|
stubRemovedMethods(className, version, methodNames) {
|
|
5245
5290
|
return stubRemovedMethods(this, className, version, methodNames);
|
|
@@ -5325,7 +5370,7 @@ ${htmlLog}
|
|
|
5325
5370
|
/** WebGL format constant */
|
|
5326
5371
|
glFormat;
|
|
5327
5372
|
static isTextureFormatSupported(device, format) {
|
|
5328
|
-
return isRenderbufferFormatSupported(device.gl, format);
|
|
5373
|
+
return isRenderbufferFormatSupported(device.gl, format, device._extensions);
|
|
5329
5374
|
}
|
|
5330
5375
|
constructor(device, props) {
|
|
5331
5376
|
if (typeof props.format === "number") {
|
|
@@ -5349,7 +5394,13 @@ ${htmlLog}
|
|
|
5349
5394
|
this.trackDeallocatedMemory();
|
|
5350
5395
|
this.gl.bindRenderbuffer(import_constants11.GL.RENDERBUFFER, this.handle);
|
|
5351
5396
|
if (samples !== 0) {
|
|
5352
|
-
this.gl.renderbufferStorageMultisample(
|
|
5397
|
+
this.gl.renderbufferStorageMultisample(
|
|
5398
|
+
import_constants11.GL.RENDERBUFFER,
|
|
5399
|
+
samples,
|
|
5400
|
+
this.glFormat,
|
|
5401
|
+
width,
|
|
5402
|
+
height
|
|
5403
|
+
);
|
|
5353
5404
|
} else {
|
|
5354
5405
|
this.gl.renderbufferStorage(import_constants11.GL.RENDERBUFFER, this.glFormat, width, height);
|
|
5355
5406
|
}
|
|
@@ -5409,15 +5460,18 @@ ${htmlLog}
|
|
|
5409
5460
|
}
|
|
5410
5461
|
if (this.depthStencilAttachment) {
|
|
5411
5462
|
this._attachOne(
|
|
5412
|
-
getDepthStencilAttachmentWebGL(this.depthStencilAttachment.format),
|
|
5463
|
+
getDepthStencilAttachmentWebGL(this.depthStencilAttachment.props.format),
|
|
5413
5464
|
this.depthStencilAttachment
|
|
5414
5465
|
);
|
|
5415
5466
|
}
|
|
5467
|
+
if (props.check !== false) {
|
|
5468
|
+
const status = this.gl.checkFramebufferStatus(import_constants12.GL.FRAMEBUFFER);
|
|
5469
|
+
if (status !== import_constants12.GL.FRAMEBUFFER_COMPLETE) {
|
|
5470
|
+
throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
|
|
5471
|
+
}
|
|
5472
|
+
}
|
|
5416
5473
|
this.gl.bindFramebuffer(import_constants12.GL.FRAMEBUFFER, null);
|
|
5417
5474
|
}
|
|
5418
|
-
if (props.check !== false) {
|
|
5419
|
-
this._checkStatus();
|
|
5420
|
-
}
|
|
5421
5475
|
}
|
|
5422
5476
|
/** destroys any auto created resources etc. */
|
|
5423
5477
|
destroy() {
|
|
@@ -5427,16 +5481,6 @@ ${htmlLog}
|
|
|
5427
5481
|
}
|
|
5428
5482
|
}
|
|
5429
5483
|
// PRIVATE
|
|
5430
|
-
/** Check the status */
|
|
5431
|
-
_checkStatus() {
|
|
5432
|
-
const { gl } = this;
|
|
5433
|
-
const prevHandle = gl.bindFramebuffer(import_constants12.GL.FRAMEBUFFER, this.handle);
|
|
5434
|
-
const status = gl.checkFramebufferStatus(import_constants12.GL.FRAMEBUFFER);
|
|
5435
|
-
gl.bindFramebuffer(import_constants12.GL.FRAMEBUFFER, prevHandle || null);
|
|
5436
|
-
if (status !== gl.FRAMEBUFFER_COMPLETE) {
|
|
5437
|
-
throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
|
|
5438
|
-
}
|
|
5439
|
-
}
|
|
5440
5484
|
/** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */
|
|
5441
5485
|
createDepthStencilTexture(format) {
|
|
5442
5486
|
return new WEBGLRenderbuffer(this.device, {
|
|
@@ -5449,8 +5493,8 @@ ${htmlLog}
|
|
|
5449
5493
|
height: this.height
|
|
5450
5494
|
});
|
|
5451
5495
|
}
|
|
5452
|
-
/**
|
|
5453
|
-
* Attachment resize is expected to be a noop if size is same
|
|
5496
|
+
/**
|
|
5497
|
+
* Attachment resize is expected to be a noop if size is same
|
|
5454
5498
|
*/
|
|
5455
5499
|
resizeAttachments(width, height) {
|
|
5456
5500
|
if (this.handle === null) {
|
|
@@ -5465,10 +5509,10 @@ ${htmlLog}
|
|
|
5465
5509
|
height = this.gl.drawingBufferHeight;
|
|
5466
5510
|
}
|
|
5467
5511
|
for (const colorAttachment of this.colorAttachments) {
|
|
5468
|
-
colorAttachment.resize({ width, height });
|
|
5512
|
+
colorAttachment.texture.resize({ width, height });
|
|
5469
5513
|
}
|
|
5470
5514
|
if (this.depthStencilAttachment) {
|
|
5471
|
-
this.depthStencilAttachment.resize({ width, height });
|
|
5515
|
+
this.depthStencilAttachment.texture.resize({ width, height });
|
|
5472
5516
|
}
|
|
5473
5517
|
return this;
|
|
5474
5518
|
}
|
|
@@ -5484,6 +5528,15 @@ ${htmlLog}
|
|
|
5484
5528
|
} else if (attachment instanceof WEBGLTexture) {
|
|
5485
5529
|
this._attachTexture(attachmentPoint, attachment, 0, 0);
|
|
5486
5530
|
return attachment;
|
|
5531
|
+
} else if (attachment instanceof WEBGLTextureView) {
|
|
5532
|
+
const textureView = attachment;
|
|
5533
|
+
this._attachTexture(
|
|
5534
|
+
attachmentPoint,
|
|
5535
|
+
textureView.texture,
|
|
5536
|
+
textureView.props.baseMipLevel,
|
|
5537
|
+
textureView.props.baseArrayLayer
|
|
5538
|
+
);
|
|
5539
|
+
return attachment.texture;
|
|
5487
5540
|
}
|
|
5488
5541
|
throw new Error("attach");
|
|
5489
5542
|
}
|
|
@@ -5630,7 +5683,9 @@ ${htmlLog}
|
|
|
5630
5683
|
if (!initialized) {
|
|
5631
5684
|
initialized = true;
|
|
5632
5685
|
spector.spyCanvases();
|
|
5633
|
-
spector?.onCaptureStarted.add(
|
|
5686
|
+
spector?.onCaptureStarted.add(
|
|
5687
|
+
(capture) => log.info("Spector capture started:", capture)()
|
|
5688
|
+
);
|
|
5634
5689
|
spector?.onCapture.add((capture) => {
|
|
5635
5690
|
log.info("Spector capture complete:", capture)();
|
|
5636
5691
|
spector?.getResultUI();
|
|
@@ -5654,7 +5709,7 @@ ${htmlLog}
|
|
|
5654
5709
|
// src/context/debug/webgl-developer-tools.ts
|
|
5655
5710
|
var import_constants13 = __toESM(require_constants(), 1);
|
|
5656
5711
|
var WEBGL_DEBUG_CDN_URL = "https://unpkg.com/webgl-debug@2.0.1/index.js";
|
|
5657
|
-
function
|
|
5712
|
+
function getWebGLContextData(gl) {
|
|
5658
5713
|
gl.luma = gl.luma || {};
|
|
5659
5714
|
return gl.luma;
|
|
5660
5715
|
}
|
|
@@ -5672,7 +5727,7 @@ ${htmlLog}
|
|
|
5672
5727
|
return props.debug ? getDebugContext(gl, props) : getRealContext(gl);
|
|
5673
5728
|
}
|
|
5674
5729
|
function getRealContext(gl) {
|
|
5675
|
-
const data =
|
|
5730
|
+
const data = getWebGLContextData(gl);
|
|
5676
5731
|
return data.realContext ? data.realContext : gl;
|
|
5677
5732
|
}
|
|
5678
5733
|
function getDebugContext(gl, props) {
|
|
@@ -5680,7 +5735,7 @@ ${htmlLog}
|
|
|
5680
5735
|
log.warn("webgl-debug not loaded")();
|
|
5681
5736
|
return gl;
|
|
5682
5737
|
}
|
|
5683
|
-
const data =
|
|
5738
|
+
const data = getWebGLContextData(gl);
|
|
5684
5739
|
if (data.debugContext) {
|
|
5685
5740
|
return data.debugContext;
|
|
5686
5741
|
}
|
|
@@ -5730,7 +5785,9 @@ ${htmlLog}
|
|
|
5730
5785
|
}
|
|
5731
5786
|
if (props.break && props.break.length > 0) {
|
|
5732
5787
|
functionString = functionString || getFunctionString(functionName, functionArgs);
|
|
5733
|
-
const isBreakpoint = props.break.every(
|
|
5788
|
+
const isBreakpoint = props.break.every(
|
|
5789
|
+
(breakOn) => functionString.indexOf(breakOn) !== -1
|
|
5790
|
+
);
|
|
5734
5791
|
if (isBreakpoint) {
|
|
5735
5792
|
debugger;
|
|
5736
5793
|
}
|
|
@@ -5829,6 +5886,11 @@ ${htmlLog}
|
|
|
5829
5886
|
const log2 = this.device.gl.getShaderInfoLog(this.handle);
|
|
5830
5887
|
return parseShaderCompilerLog(log2);
|
|
5831
5888
|
}
|
|
5889
|
+
getTranslatedSource() {
|
|
5890
|
+
const extensions = this.device.getExtension("WEBGL_debug_shaders");
|
|
5891
|
+
const ext = extensions.WEBGL_debug_shaders;
|
|
5892
|
+
return ext?.getTranslatedShaderSource(this.handle);
|
|
5893
|
+
}
|
|
5832
5894
|
// PRIVATE METHODS
|
|
5833
5895
|
/** Compile a shader and get compilation status */
|
|
5834
5896
|
async _compile(source) {
|
|
@@ -5842,7 +5904,7 @@ ${source2}`;
|
|
|
5842
5904
|
this.compilationStatus = "pending";
|
|
5843
5905
|
return;
|
|
5844
5906
|
}
|
|
5845
|
-
if (!this.device.features.has("
|
|
5907
|
+
if (!this.device.features.has("compilation-status-async-webgl")) {
|
|
5846
5908
|
this._getCompilationStatus();
|
|
5847
5909
|
if (this.compilationStatus === "error") {
|
|
5848
5910
|
throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);
|
|
@@ -5860,13 +5922,13 @@ ${source2}`;
|
|
|
5860
5922
|
async _waitForCompilationComplete() {
|
|
5861
5923
|
const waitMs = async (ms) => await new Promise((resolve) => setTimeout(resolve, ms));
|
|
5862
5924
|
const DELAY_MS = 10;
|
|
5863
|
-
if (!this.device.features.has("
|
|
5925
|
+
if (!this.device.features.has("compilation-status-async-webgl")) {
|
|
5864
5926
|
await waitMs(DELAY_MS);
|
|
5865
5927
|
return;
|
|
5866
5928
|
}
|
|
5867
5929
|
const { gl } = this.device;
|
|
5868
5930
|
for (; ; ) {
|
|
5869
|
-
const complete = gl.getShaderParameter(this.handle, import_constants14.GL.
|
|
5931
|
+
const complete = gl.getShaderParameter(this.handle, import_constants14.GL.COMPLETION_STATUS_KHR);
|
|
5870
5932
|
if (complete) {
|
|
5871
5933
|
return;
|
|
5872
5934
|
}
|
|
@@ -5877,7 +5939,7 @@ ${source2}`;
|
|
|
5877
5939
|
* Get the shader compilation status
|
|
5878
5940
|
* TODO - Load log even when no error reported, to catch warnings?
|
|
5879
5941
|
* https://gamedev.stackexchange.com/questions/30429/how-to-detect-glsl-warnings
|
|
5880
|
-
|
|
5942
|
+
*/
|
|
5881
5943
|
_getCompilationStatus() {
|
|
5882
5944
|
this.compilationStatus = this.device.gl.getShaderParameter(this.handle, import_constants14.GL.COMPILE_STATUS) ? "success" : "error";
|
|
5883
5945
|
}
|
|
@@ -5912,7 +5974,6 @@ ${source2}`;
|
|
|
5912
5974
|
}
|
|
5913
5975
|
insertDebugMarker(markerLabel) {
|
|
5914
5976
|
}
|
|
5915
|
-
// writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
|
|
5916
5977
|
// beginOcclusionQuery(queryIndex: number): void;
|
|
5917
5978
|
// endOcclusionQuery(): void;
|
|
5918
5979
|
// executeBundles(bundles: Iterable<GPURenderBundle>): void;
|
|
@@ -5951,7 +6012,15 @@ ${source2}`;
|
|
|
5951
6012
|
this.glParameters = glParameters;
|
|
5952
6013
|
setGLParameters(this.device, glParameters);
|
|
5953
6014
|
}
|
|
5954
|
-
|
|
6015
|
+
beginOcclusionQuery(queryIndex) {
|
|
6016
|
+
const webglQuerySet = this.props.occlusionQuerySet;
|
|
6017
|
+
webglQuerySet?.beginOcclusionQuery();
|
|
6018
|
+
}
|
|
6019
|
+
endOcclusionQuery() {
|
|
6020
|
+
const webglQuerySet = this.props.occlusionQuerySet;
|
|
6021
|
+
webglQuerySet?.endOcclusionQuery();
|
|
6022
|
+
}
|
|
6023
|
+
// PRIVATE
|
|
5955
6024
|
/**
|
|
5956
6025
|
* Optionally clears depth, color and stencil buffers based on parameters
|
|
5957
6026
|
*/
|
|
@@ -5976,8 +6045,8 @@ ${source2}`;
|
|
|
5976
6045
|
});
|
|
5977
6046
|
}
|
|
5978
6047
|
}
|
|
5979
|
-
/**
|
|
5980
|
-
* WebGL2 - clear a specific color buffer
|
|
6048
|
+
/**
|
|
6049
|
+
* WebGL2 - clear a specific color buffer
|
|
5981
6050
|
*/
|
|
5982
6051
|
clearColorBuffer(drawBuffer = 0, value = [0, 0, 0, 0]) {
|
|
5983
6052
|
withGLParameters(this.device.gl, { framebuffer: this.props.framebuffer }, () => {
|
|
@@ -6658,7 +6727,9 @@ ${source2}`;
|
|
|
6658
6727
|
this.device.gl.transformFeedbackVaryings(this.handle, varyings, bufferMode);
|
|
6659
6728
|
}
|
|
6660
6729
|
this._linkShaders();
|
|
6730
|
+
log.time(0, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
6661
6731
|
this.introspectedLayout = getShaderLayout(this.device.gl, this.handle);
|
|
6732
|
+
log.timeEnd(0, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
6662
6733
|
this.shaderLayout = mergeShaderLayout(this.introspectedLayout, props.shaderLayout);
|
|
6663
6734
|
switch (this.props.topology) {
|
|
6664
6735
|
case "triangle-fan-webgl":
|
|
@@ -6700,7 +6771,7 @@ ${source2}`;
|
|
|
6700
6771
|
}
|
|
6701
6772
|
break;
|
|
6702
6773
|
case "texture":
|
|
6703
|
-
if (!(value instanceof WEBGLTexture || value instanceof WEBGLFramebuffer)) {
|
|
6774
|
+
if (!(value instanceof WEBGLTextureView || value instanceof WEBGLTexture || value instanceof WEBGLFramebuffer)) {
|
|
6704
6775
|
throw new Error("texture value");
|
|
6705
6776
|
}
|
|
6706
6777
|
break;
|
|
@@ -6713,18 +6784,6 @@ ${source2}`;
|
|
|
6713
6784
|
this.bindings[name2] = value;
|
|
6714
6785
|
}
|
|
6715
6786
|
}
|
|
6716
|
-
/** This function is @deprecated, use uniform buffers */
|
|
6717
|
-
setUniforms(uniforms) {
|
|
6718
|
-
const { bindings } = splitUniformsAndBindings(uniforms);
|
|
6719
|
-
Object.keys(bindings).forEach((name2) => {
|
|
6720
|
-
log.warn(
|
|
6721
|
-
`Unsupported value "${JSON.stringify(
|
|
6722
|
-
bindings[name2]
|
|
6723
|
-
)}" used in setUniforms() for key ${name2}. Use setBindings() instead?`
|
|
6724
|
-
)();
|
|
6725
|
-
});
|
|
6726
|
-
Object.assign(this.uniforms, uniforms);
|
|
6727
|
-
}
|
|
6728
6787
|
/** @todo needed for portable model
|
|
6729
6788
|
* @note The WebGL API is offers many ways to draw things
|
|
6730
6789
|
* This function unifies those ways into a single call using common parameters with sane defaults
|
|
@@ -6794,6 +6853,18 @@ ${source2}`;
|
|
|
6794
6853
|
vertexArray.unbindAfterRender(renderPass);
|
|
6795
6854
|
return true;
|
|
6796
6855
|
}
|
|
6856
|
+
// DEPRECATED METHODS
|
|
6857
|
+
setUniformsWebGL(uniforms) {
|
|
6858
|
+
const { bindings } = splitUniformsAndBindings(uniforms);
|
|
6859
|
+
Object.keys(bindings).forEach((name2) => {
|
|
6860
|
+
log.warn(
|
|
6861
|
+
`Unsupported value "${JSON.stringify(
|
|
6862
|
+
bindings[name2]
|
|
6863
|
+
)}" used in setUniforms() for key ${name2}. Use setBindings() instead?`
|
|
6864
|
+
)();
|
|
6865
|
+
});
|
|
6866
|
+
Object.assign(this.uniforms, uniforms);
|
|
6867
|
+
}
|
|
6797
6868
|
// PRIVATE METHODS
|
|
6798
6869
|
// setAttributes(attributes: Record<string, Buffer>): void {}
|
|
6799
6870
|
// setBindings(bindings: Record<string, Binding>): void {}
|
|
@@ -6806,7 +6877,7 @@ ${source2}`;
|
|
|
6806
6877
|
log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
|
|
6807
6878
|
if (log.level === 0) {
|
|
6808
6879
|
}
|
|
6809
|
-
if (!this.device.features.has("
|
|
6880
|
+
if (!this.device.features.has("compilation-status-async-webgl")) {
|
|
6810
6881
|
const status2 = this._getLinkStatus();
|
|
6811
6882
|
this._reportLinkStatus(status2);
|
|
6812
6883
|
return;
|
|
@@ -6859,13 +6930,13 @@ ${source2}`;
|
|
|
6859
6930
|
async _waitForLinkComplete() {
|
|
6860
6931
|
const waitMs = async (ms) => await new Promise((resolve) => setTimeout(resolve, ms));
|
|
6861
6932
|
const DELAY_MS = 10;
|
|
6862
|
-
if (!this.device.features.has("
|
|
6933
|
+
if (!this.device.features.has("compilation-status-async-webgl")) {
|
|
6863
6934
|
await waitMs(DELAY_MS);
|
|
6864
6935
|
return;
|
|
6865
6936
|
}
|
|
6866
6937
|
const { gl } = this.device;
|
|
6867
6938
|
for (; ; ) {
|
|
6868
|
-
const complete = gl.getProgramParameter(this.handle, import_constants22.GL.
|
|
6939
|
+
const complete = gl.getProgramParameter(this.handle, import_constants22.GL.COMPLETION_STATUS_KHR);
|
|
6869
6940
|
if (complete) {
|
|
6870
6941
|
return;
|
|
6871
6942
|
}
|
|
@@ -6926,11 +6997,13 @@ ${source2}`;
|
|
|
6926
6997
|
uniformBufferIndex += 1;
|
|
6927
6998
|
break;
|
|
6928
6999
|
case "texture":
|
|
6929
|
-
if (!(value instanceof WEBGLTexture || value instanceof WEBGLFramebuffer)) {
|
|
7000
|
+
if (!(value instanceof WEBGLTextureView || value instanceof WEBGLTexture || value instanceof WEBGLFramebuffer)) {
|
|
6930
7001
|
throw new Error("texture");
|
|
6931
7002
|
}
|
|
6932
7003
|
let texture;
|
|
6933
|
-
if (value instanceof
|
|
7004
|
+
if (value instanceof WEBGLTextureView) {
|
|
7005
|
+
texture = value.texture;
|
|
7006
|
+
} else if (value instanceof WEBGLTexture) {
|
|
6934
7007
|
texture = value;
|
|
6935
7008
|
} else if (value instanceof WEBGLFramebuffer && value.colorAttachments[0] instanceof WEBGLTexture) {
|
|
6936
7009
|
log.warn(
|
|
@@ -7058,7 +7131,7 @@ ${source2}`;
|
|
|
7058
7131
|
const webglBuffer = destination;
|
|
7059
7132
|
const sourceWidth = width || framebuffer.width;
|
|
7060
7133
|
const sourceHeight = height || framebuffer.height;
|
|
7061
|
-
const sourceParams = getWebGLTextureParameters(framebuffer.texture.format);
|
|
7134
|
+
const sourceParams = getWebGLTextureParameters(framebuffer.texture.props.format);
|
|
7062
7135
|
const sourceFormat = sourceParams.dataFormat;
|
|
7063
7136
|
const sourceType = sourceParams.type;
|
|
7064
7137
|
device.gl.bindBuffer(import_constants23.GL.PIXEL_PACK_BUFFER, webglBuffer.handle);
|
|
@@ -7192,14 +7265,8 @@ ${source2}`;
|
|
|
7192
7265
|
}
|
|
7193
7266
|
insertDebugMarker(markerLabel) {
|
|
7194
7267
|
}
|
|
7195
|
-
|
|
7196
|
-
|
|
7197
|
-
// querySet: GPUQuerySet,
|
|
7198
|
-
// firstQuery: number,
|
|
7199
|
-
// queryCount: number,
|
|
7200
|
-
// destination: Buffer,
|
|
7201
|
-
// destinationOffset?: number;
|
|
7202
|
-
// }): void;
|
|
7268
|
+
resolveQuerySet(querySet, destination, options) {
|
|
7269
|
+
}
|
|
7203
7270
|
};
|
|
7204
7271
|
|
|
7205
7272
|
// src/adapter/resources/webgl-vertex-array.ts
|
|
@@ -7267,7 +7334,7 @@ ${source2}`;
|
|
|
7267
7334
|
this.attributes[location] = buffer;
|
|
7268
7335
|
}
|
|
7269
7336
|
/** Set a location in vertex attributes array to a constant value, disables the location */
|
|
7270
|
-
|
|
7337
|
+
setConstantWebGL(location, value) {
|
|
7271
7338
|
this._enable(location, false);
|
|
7272
7339
|
this.attributes[location] = value;
|
|
7273
7340
|
}
|
|
@@ -7295,7 +7362,7 @@ ${source2}`;
|
|
|
7295
7362
|
for (let location = 0; location < this.maxVertexAttributes; ++location) {
|
|
7296
7363
|
const constant = this.attributes[location];
|
|
7297
7364
|
if (ArrayBuffer.isView(constant)) {
|
|
7298
|
-
this.device.
|
|
7365
|
+
this.device.setConstantAttributeWebGL(location, constant);
|
|
7299
7366
|
}
|
|
7300
7367
|
}
|
|
7301
7368
|
}
|
|
@@ -7552,25 +7619,159 @@ ${source2}`;
|
|
|
7552
7619
|
return /^\d+$/.test(value);
|
|
7553
7620
|
}
|
|
7554
7621
|
|
|
7622
|
+
// src/adapter/resources/webgl-query-set.ts
|
|
7623
|
+
var import_constants26 = __toESM(require_constants(), 1);
|
|
7624
|
+
var WEBGLQuerySet = class extends QuerySet {
|
|
7625
|
+
device;
|
|
7626
|
+
handle;
|
|
7627
|
+
target = null;
|
|
7628
|
+
_queryPending = false;
|
|
7629
|
+
_pollingPromise = null;
|
|
7630
|
+
get [Symbol.toStringTag]() {
|
|
7631
|
+
return "Query";
|
|
7632
|
+
}
|
|
7633
|
+
// Create a query class
|
|
7634
|
+
constructor(device, props) {
|
|
7635
|
+
super(device, props);
|
|
7636
|
+
this.device = device;
|
|
7637
|
+
if (props.count > 1) {
|
|
7638
|
+
throw new Error("WebGL QuerySet can only have one value");
|
|
7639
|
+
}
|
|
7640
|
+
this.handle = this.device.gl.createQuery();
|
|
7641
|
+
Object.seal(this);
|
|
7642
|
+
}
|
|
7643
|
+
destroy() {
|
|
7644
|
+
this.device.gl.deleteQuery(this.handle);
|
|
7645
|
+
}
|
|
7646
|
+
// FOR RENDER PASS AND COMMAND ENCODER
|
|
7647
|
+
/**
|
|
7648
|
+
* Shortcut for timer query (dependent on extension in both WebGL1 and 2)
|
|
7649
|
+
* Measures GPU time delta between this call and a matching `end` call in the
|
|
7650
|
+
* GPU instruction stream.
|
|
7651
|
+
*/
|
|
7652
|
+
beginTimestampQuery() {
|
|
7653
|
+
return this._begin(import_constants26.GL.TIME_ELAPSED_EXT);
|
|
7654
|
+
}
|
|
7655
|
+
endTimestampQuery() {
|
|
7656
|
+
this._end();
|
|
7657
|
+
}
|
|
7658
|
+
// Shortcut for occlusion queries
|
|
7659
|
+
beginOcclusionQuery(options) {
|
|
7660
|
+
return this._begin(
|
|
7661
|
+
options?.conservative ? import_constants26.GL.ANY_SAMPLES_PASSED_CONSERVATIVE : import_constants26.GL.ANY_SAMPLES_PASSED
|
|
7662
|
+
);
|
|
7663
|
+
}
|
|
7664
|
+
endOcclusionQuery() {
|
|
7665
|
+
this._end();
|
|
7666
|
+
}
|
|
7667
|
+
// Shortcut for transformFeedbackQuery
|
|
7668
|
+
beginTransformFeedbackQuery() {
|
|
7669
|
+
return this._begin(import_constants26.GL.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
|
|
7670
|
+
}
|
|
7671
|
+
endTransformFeedbackQuery() {
|
|
7672
|
+
this._end();
|
|
7673
|
+
}
|
|
7674
|
+
async resolveQuery() {
|
|
7675
|
+
const value = await this.pollQuery();
|
|
7676
|
+
return [value];
|
|
7677
|
+
}
|
|
7678
|
+
// PRIVATE METHODS
|
|
7679
|
+
/**
|
|
7680
|
+
* Due to OpenGL API limitations, after calling `begin()` on one Query
|
|
7681
|
+
* instance, `end()` must be called on that same instance before
|
|
7682
|
+
* calling `begin()` on another query. While there can be multiple
|
|
7683
|
+
* outstanding queries representing disjoint `begin()`/`end()` intervals.
|
|
7684
|
+
* It is not possible to interleave or overlap `begin` and `end` calls.
|
|
7685
|
+
*/
|
|
7686
|
+
_begin(target) {
|
|
7687
|
+
if (this._queryPending) {
|
|
7688
|
+
return;
|
|
7689
|
+
}
|
|
7690
|
+
this.target = target;
|
|
7691
|
+
this.device.gl.beginQuery(this.target, this.handle);
|
|
7692
|
+
return;
|
|
7693
|
+
}
|
|
7694
|
+
// ends the current query
|
|
7695
|
+
_end() {
|
|
7696
|
+
if (this._queryPending) {
|
|
7697
|
+
return;
|
|
7698
|
+
}
|
|
7699
|
+
if (this.target) {
|
|
7700
|
+
this.device.gl.endQuery(this.target);
|
|
7701
|
+
this.target = null;
|
|
7702
|
+
this._queryPending = true;
|
|
7703
|
+
}
|
|
7704
|
+
return;
|
|
7705
|
+
}
|
|
7706
|
+
// Returns true if the query result is available
|
|
7707
|
+
isResultAvailable() {
|
|
7708
|
+
if (!this._queryPending) {
|
|
7709
|
+
return false;
|
|
7710
|
+
}
|
|
7711
|
+
const resultAvailable = this.device.gl.getQueryParameter(
|
|
7712
|
+
this.handle,
|
|
7713
|
+
import_constants26.GL.QUERY_RESULT_AVAILABLE
|
|
7714
|
+
);
|
|
7715
|
+
if (resultAvailable) {
|
|
7716
|
+
this._queryPending = false;
|
|
7717
|
+
}
|
|
7718
|
+
return resultAvailable;
|
|
7719
|
+
}
|
|
7720
|
+
// Timing query is disjoint, i.e. results are invalid
|
|
7721
|
+
isTimerDisjoint() {
|
|
7722
|
+
return this.device.gl.getParameter(import_constants26.GL.GPU_DISJOINT_EXT);
|
|
7723
|
+
}
|
|
7724
|
+
// Returns query result.
|
|
7725
|
+
getResult() {
|
|
7726
|
+
return this.device.gl.getQueryParameter(this.handle, import_constants26.GL.QUERY_RESULT);
|
|
7727
|
+
}
|
|
7728
|
+
// Returns the query result, converted to milliseconds to match JavaScript conventions.
|
|
7729
|
+
getTimerMilliseconds() {
|
|
7730
|
+
return this.getResult() / 1e6;
|
|
7731
|
+
}
|
|
7732
|
+
// Polls the query
|
|
7733
|
+
pollQuery(limit = Number.POSITIVE_INFINITY) {
|
|
7734
|
+
if (this._pollingPromise) {
|
|
7735
|
+
return this._pollingPromise;
|
|
7736
|
+
}
|
|
7737
|
+
let counter = 0;
|
|
7738
|
+
this._pollingPromise = new Promise((resolve, reject) => {
|
|
7739
|
+
const poll = () => {
|
|
7740
|
+
if (this.isResultAvailable()) {
|
|
7741
|
+
resolve(this.getResult());
|
|
7742
|
+
this._pollingPromise = null;
|
|
7743
|
+
} else if (counter++ > limit) {
|
|
7744
|
+
reject("Timed out");
|
|
7745
|
+
this._pollingPromise = null;
|
|
7746
|
+
} else {
|
|
7747
|
+
requestAnimationFrame(poll);
|
|
7748
|
+
}
|
|
7749
|
+
};
|
|
7750
|
+
requestAnimationFrame(poll);
|
|
7751
|
+
});
|
|
7752
|
+
return this._pollingPromise;
|
|
7753
|
+
}
|
|
7754
|
+
};
|
|
7755
|
+
|
|
7555
7756
|
// src/classic/copy-and-blit.ts
|
|
7556
|
-
var
|
|
7757
|
+
var import_constants28 = __toESM(require_constants(), 1);
|
|
7557
7758
|
|
|
7558
7759
|
// src/classic/format-utils.ts
|
|
7559
|
-
var
|
|
7760
|
+
var import_constants27 = __toESM(require_constants(), 1);
|
|
7560
7761
|
function glFormatToComponents(format) {
|
|
7561
7762
|
switch (format) {
|
|
7562
|
-
case
|
|
7563
|
-
case
|
|
7564
|
-
case
|
|
7763
|
+
case import_constants27.GL.ALPHA:
|
|
7764
|
+
case import_constants27.GL.R32F:
|
|
7765
|
+
case import_constants27.GL.RED:
|
|
7565
7766
|
return 1;
|
|
7566
|
-
case
|
|
7567
|
-
case
|
|
7767
|
+
case import_constants27.GL.RG32F:
|
|
7768
|
+
case import_constants27.GL.RG:
|
|
7568
7769
|
return 2;
|
|
7569
|
-
case
|
|
7570
|
-
case
|
|
7770
|
+
case import_constants27.GL.RGB:
|
|
7771
|
+
case import_constants27.GL.RGB32F:
|
|
7571
7772
|
return 3;
|
|
7572
|
-
case
|
|
7573
|
-
case
|
|
7773
|
+
case import_constants27.GL.RGBA:
|
|
7774
|
+
case import_constants27.GL.RGBA32F:
|
|
7574
7775
|
return 4;
|
|
7575
7776
|
default:
|
|
7576
7777
|
assert2(false);
|
|
@@ -7579,13 +7780,13 @@ ${source2}`;
|
|
|
7579
7780
|
}
|
|
7580
7781
|
function glTypeToBytes(type) {
|
|
7581
7782
|
switch (type) {
|
|
7582
|
-
case
|
|
7783
|
+
case import_constants27.GL.UNSIGNED_BYTE:
|
|
7583
7784
|
return 1;
|
|
7584
|
-
case
|
|
7585
|
-
case
|
|
7586
|
-
case
|
|
7785
|
+
case import_constants27.GL.UNSIGNED_SHORT_5_6_5:
|
|
7786
|
+
case import_constants27.GL.UNSIGNED_SHORT_4_4_4_4:
|
|
7787
|
+
case import_constants27.GL.UNSIGNED_SHORT_5_5_5_1:
|
|
7587
7788
|
return 2;
|
|
7588
|
-
case
|
|
7789
|
+
case import_constants27.GL.FLOAT:
|
|
7589
7790
|
return 4;
|
|
7590
7791
|
default:
|
|
7591
7792
|
assert2(false);
|
|
@@ -7598,8 +7799,8 @@ ${source2}`;
|
|
|
7598
7799
|
const {
|
|
7599
7800
|
sourceX = 0,
|
|
7600
7801
|
sourceY = 0,
|
|
7601
|
-
sourceFormat =
|
|
7602
|
-
sourceAttachment =
|
|
7802
|
+
sourceFormat = import_constants28.GL.RGBA,
|
|
7803
|
+
sourceAttachment = import_constants28.GL.COLOR_ATTACHMENT0
|
|
7603
7804
|
// TODO - support gl.readBuffer
|
|
7604
7805
|
} = options || {};
|
|
7605
7806
|
let {
|
|
@@ -7614,27 +7815,33 @@ ${source2}`;
|
|
|
7614
7815
|
const { gl, handle } = framebuffer;
|
|
7615
7816
|
sourceWidth = sourceWidth || framebuffer.width;
|
|
7616
7817
|
sourceHeight = sourceHeight || framebuffer.height;
|
|
7617
|
-
const attachment = sourceAttachment -
|
|
7618
|
-
sourceType = sourceType || framebuffer.colorAttachments[attachment]?.type ||
|
|
7818
|
+
const attachment = sourceAttachment - import_constants28.GL.COLOR_ATTACHMENT0;
|
|
7819
|
+
sourceType = sourceType || framebuffer.colorAttachments[attachment]?.texture?.type || import_constants28.GL.UNSIGNED_BYTE;
|
|
7619
7820
|
target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight);
|
|
7620
7821
|
sourceType = sourceType || getGLTypeFromTypedArray(target);
|
|
7621
|
-
const prevHandle = gl.bindFramebuffer(
|
|
7822
|
+
const prevHandle = gl.bindFramebuffer(import_constants28.GL.FRAMEBUFFER, handle);
|
|
7622
7823
|
gl.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);
|
|
7623
|
-
gl.bindFramebuffer(
|
|
7824
|
+
gl.bindFramebuffer(import_constants28.GL.FRAMEBUFFER, prevHandle || null);
|
|
7624
7825
|
if (deleteFramebuffer) {
|
|
7625
7826
|
framebuffer.destroy();
|
|
7626
7827
|
}
|
|
7627
7828
|
return target;
|
|
7628
7829
|
}
|
|
7629
7830
|
function readPixelsToBuffer(source, options) {
|
|
7630
|
-
const {
|
|
7831
|
+
const {
|
|
7832
|
+
target,
|
|
7833
|
+
sourceX = 0,
|
|
7834
|
+
sourceY = 0,
|
|
7835
|
+
sourceFormat = import_constants28.GL.RGBA,
|
|
7836
|
+
targetByteOffset = 0
|
|
7837
|
+
} = options || {};
|
|
7631
7838
|
let { sourceWidth, sourceHeight, sourceType } = options || {};
|
|
7632
7839
|
const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
|
|
7633
7840
|
assert2(framebuffer);
|
|
7634
7841
|
sourceWidth = sourceWidth || framebuffer.width;
|
|
7635
7842
|
sourceHeight = sourceHeight || framebuffer.height;
|
|
7636
7843
|
const webglFramebuffer = framebuffer;
|
|
7637
|
-
sourceType = sourceType ||
|
|
7844
|
+
sourceType = sourceType || import_constants28.GL.UNSIGNED_BYTE;
|
|
7638
7845
|
let webglBufferTarget = target;
|
|
7639
7846
|
if (!webglBufferTarget) {
|
|
7640
7847
|
const components = glFormatToComponents(sourceFormat);
|
|
@@ -7678,7 +7885,7 @@ ${source2}`;
|
|
|
7678
7885
|
if (pixelArray) {
|
|
7679
7886
|
return pixelArray;
|
|
7680
7887
|
}
|
|
7681
|
-
type = type ||
|
|
7888
|
+
type = type || import_constants28.GL.UNSIGNED_BYTE;
|
|
7682
7889
|
const ArrayType = getTypedArrayFromGLType(type, { clamped: false });
|
|
7683
7890
|
const components = glFormatToComponents(format);
|
|
7684
7891
|
return new ArrayType(width * height * components);
|
|
@@ -7727,21 +7934,14 @@ ${source2}`;
|
|
|
7727
7934
|
static isSupported() {
|
|
7728
7935
|
return typeof WebGL2RenderingContext !== "undefined";
|
|
7729
7936
|
}
|
|
7937
|
+
/** The underlying WebGL context */
|
|
7938
|
+
handle;
|
|
7939
|
+
features;
|
|
7940
|
+
limits;
|
|
7730
7941
|
info;
|
|
7731
7942
|
canvasContext;
|
|
7732
|
-
handle;
|
|
7733
|
-
get features() {
|
|
7734
|
-
this._features = this._features || getDeviceFeatures(this.gl);
|
|
7735
|
-
return this._features;
|
|
7736
|
-
}
|
|
7737
|
-
get limits() {
|
|
7738
|
-
this._limits = this._limits || getDeviceLimits(this.gl);
|
|
7739
|
-
return this._limits;
|
|
7740
|
-
}
|
|
7741
7943
|
lost;
|
|
7742
7944
|
_resolveContextLost;
|
|
7743
|
-
_features;
|
|
7744
|
-
_limits;
|
|
7745
7945
|
//
|
|
7746
7946
|
// Static methods, expected to be present by `luma.createDevice()`
|
|
7747
7947
|
//
|
|
@@ -7765,18 +7965,19 @@ ${source2}`;
|
|
|
7765
7965
|
}
|
|
7766
7966
|
static async create(props = {}) {
|
|
7767
7967
|
log.groupCollapsed(LOG_LEVEL2, "WebGLDevice created")();
|
|
7768
|
-
|
|
7769
|
-
|
|
7968
|
+
const promises = [];
|
|
7969
|
+
if (props.debug) {
|
|
7970
|
+
promises.push(loadWebGLDeveloperTools());
|
|
7770
7971
|
}
|
|
7771
|
-
if (
|
|
7772
|
-
|
|
7972
|
+
if (props.spector) {
|
|
7973
|
+
promises.push(loadSpectorJS());
|
|
7773
7974
|
}
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
await loadSpectorJS();
|
|
7975
|
+
if (typeof props.canvas === "string") {
|
|
7976
|
+
promises.push(CanvasContext.pageLoaded);
|
|
7777
7977
|
}
|
|
7978
|
+
await Promise.all(promises);
|
|
7778
7979
|
log.probe(LOG_LEVEL2 + 1, "DOM is loaded")();
|
|
7779
|
-
if (props.gl
|
|
7980
|
+
if (props.gl?.device) {
|
|
7780
7981
|
return _WebGLDevice.attach(props.gl);
|
|
7781
7982
|
}
|
|
7782
7983
|
const device = new _WebGLDevice(props);
|
|
@@ -7795,46 +7996,49 @@ ${source2}`;
|
|
|
7795
7996
|
if (device) {
|
|
7796
7997
|
throw new Error(`WebGL context already attached to device ${device.id}`);
|
|
7797
7998
|
}
|
|
7798
|
-
const canvas = props.canvas || props.
|
|
7999
|
+
const canvas = props.gl?.canvas || props.canvas;
|
|
7799
8000
|
this.canvasContext = new WebGLCanvasContext(this, { ...props, canvas });
|
|
7800
8001
|
this.lost = new Promise((resolve) => {
|
|
7801
8002
|
this._resolveContextLost = resolve;
|
|
7802
8003
|
});
|
|
7803
|
-
const onContextLost = (event) => this._resolveContextLost?.({
|
|
7804
|
-
reason: "destroyed",
|
|
7805
|
-
message: "Computer entered sleep mode, or too many apps or browser tabs are using the GPU."
|
|
7806
|
-
});
|
|
7807
8004
|
let gl = props.gl || null;
|
|
7808
|
-
gl
|
|
8005
|
+
gl ||= createBrowserContext(this.canvasContext.canvas, {
|
|
8006
|
+
...props,
|
|
8007
|
+
onContextLost: (event) => this._resolveContextLost?.({
|
|
8008
|
+
reason: "destroyed",
|
|
8009
|
+
message: "Entered sleep mode, or too many apps or browser tabs are using the GPU."
|
|
8010
|
+
})
|
|
8011
|
+
});
|
|
7809
8012
|
if (!gl) {
|
|
7810
8013
|
throw new Error("WebGL context creation failed");
|
|
7811
8014
|
}
|
|
7812
8015
|
this.handle = gl;
|
|
7813
|
-
this.gl =
|
|
7814
|
-
this.canvasContext.resize();
|
|
7815
|
-
this.info = getDeviceInfo(this.gl);
|
|
8016
|
+
this.gl = gl;
|
|
7816
8017
|
this.gl.device = this;
|
|
7817
|
-
this.gl._version =
|
|
8018
|
+
this.gl._version = 2;
|
|
8019
|
+
this.info = getDeviceInfo(this.gl, this._extensions);
|
|
8020
|
+
this.features = new WebGLDeviceFeatures(this.gl, this._extensions);
|
|
8021
|
+
this.limits = new WebGLDeviceLimits(this.gl);
|
|
8022
|
+
this.canvasContext.resize();
|
|
7818
8023
|
const { enable: enable2 = true, copyState = false } = props;
|
|
7819
8024
|
trackContextState(this.gl, {
|
|
7820
8025
|
enable: enable2,
|
|
7821
8026
|
copyState,
|
|
7822
8027
|
log: (...args) => log.log(1, ...args)()
|
|
7823
8028
|
});
|
|
7824
|
-
if (
|
|
8029
|
+
if (props.debug) {
|
|
7825
8030
|
this.gl = makeDebugContext(this.gl, { ...props, throwOnError: true });
|
|
7826
8031
|
this.debug = true;
|
|
7827
8032
|
log.level = Math.max(log.level, 1);
|
|
7828
8033
|
log.warn("WebGL debug mode activated. Performance reduced.")();
|
|
7829
8034
|
}
|
|
7830
|
-
if (
|
|
7831
|
-
|
|
7832
|
-
this.spector = initializeSpectorJS({ ...this.props, canvas: canvas2 });
|
|
8035
|
+
if (props.spector) {
|
|
8036
|
+
this.spectorJS = initializeSpectorJS({ ...this.props, canvas: this.handle.canvas });
|
|
7833
8037
|
}
|
|
7834
8038
|
}
|
|
7835
8039
|
/**
|
|
7836
8040
|
* Destroys the context
|
|
7837
|
-
* @note Has no effect for browser contexts, there is no browser API for destroying contexts
|
|
8041
|
+
* @note Has no effect for WebGL browser contexts, there is no browser API for destroying contexts
|
|
7838
8042
|
*/
|
|
7839
8043
|
destroy() {
|
|
7840
8044
|
}
|
|
@@ -7845,13 +8049,13 @@ ${source2}`;
|
|
|
7845
8049
|
return [this.gl.drawingBufferWidth, this.gl.drawingBufferHeight];
|
|
7846
8050
|
}
|
|
7847
8051
|
isTextureFormatSupported(format) {
|
|
7848
|
-
return isTextureFormatSupported(this.gl, format);
|
|
8052
|
+
return isTextureFormatSupported(this.gl, format, this._extensions);
|
|
7849
8053
|
}
|
|
7850
8054
|
isTextureFormatFilterable(format) {
|
|
7851
|
-
return isTextureFormatFilterable(this.gl, format);
|
|
8055
|
+
return isTextureFormatFilterable(this.gl, format, this._extensions);
|
|
7852
8056
|
}
|
|
7853
8057
|
isTextureFormatRenderable(format) {
|
|
7854
|
-
return isTextureFormatRenderable(this.gl, format);
|
|
8058
|
+
return isTextureFormatRenderable(this.gl, format, this._extensions);
|
|
7855
8059
|
}
|
|
7856
8060
|
// IMPLEMENTATION OF ABSTRACT DEVICE
|
|
7857
8061
|
createCanvasContext(props) {
|
|
@@ -7876,12 +8080,18 @@ ${source2}`;
|
|
|
7876
8080
|
createFramebuffer(props) {
|
|
7877
8081
|
return new WEBGLFramebuffer(this, props);
|
|
7878
8082
|
}
|
|
7879
|
-
createRenderPipeline(props) {
|
|
7880
|
-
return new WEBGLRenderPipeline(this, props);
|
|
7881
|
-
}
|
|
7882
8083
|
createVertexArray(props) {
|
|
7883
8084
|
return new WEBGLVertexArray(this, props);
|
|
7884
8085
|
}
|
|
8086
|
+
createTransformFeedback(props) {
|
|
8087
|
+
return new WEBGLTransformFeedback(this, props);
|
|
8088
|
+
}
|
|
8089
|
+
createQuerySet(props) {
|
|
8090
|
+
return new WEBGLQuerySet(this, props);
|
|
8091
|
+
}
|
|
8092
|
+
createRenderPipeline(props) {
|
|
8093
|
+
return new WEBGLRenderPipeline(this, props);
|
|
8094
|
+
}
|
|
7885
8095
|
beginRenderPass(props) {
|
|
7886
8096
|
return new WEBGLRenderPass(this, props);
|
|
7887
8097
|
}
|
|
@@ -7891,9 +8101,6 @@ ${source2}`;
|
|
|
7891
8101
|
beginComputePass(props) {
|
|
7892
8102
|
throw new Error("ComputePass not supported in WebGL");
|
|
7893
8103
|
}
|
|
7894
|
-
createTransformFeedback(props) {
|
|
7895
|
-
return new WEBGLTransformFeedback(this, props);
|
|
7896
|
-
}
|
|
7897
8104
|
renderPass = null;
|
|
7898
8105
|
getDefaultRenderPass() {
|
|
7899
8106
|
this.renderPass = this.renderPass || this.beginRenderPass({
|
|
@@ -7915,7 +8122,7 @@ ${source2}`;
|
|
|
7915
8122
|
}
|
|
7916
8123
|
//
|
|
7917
8124
|
// TEMPORARY HACKS - will be removed in v9.1
|
|
7918
|
-
//
|
|
8125
|
+
//
|
|
7919
8126
|
/** @deprecated - should use command encoder */
|
|
7920
8127
|
readPixelsToArrayWebGL(source, options) {
|
|
7921
8128
|
return readPixelsToArray(source, options);
|
|
@@ -7948,20 +8155,15 @@ ${source2}`;
|
|
|
7948
8155
|
_extensions = {};
|
|
7949
8156
|
_polyfilled = false;
|
|
7950
8157
|
/** Instance of Spector.js (if initialized) */
|
|
7951
|
-
|
|
7952
|
-
_webglLimits;
|
|
7953
|
-
/** Return WebGL specific limits */
|
|
7954
|
-
get webglLimits() {
|
|
7955
|
-
this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);
|
|
7956
|
-
return this._webglLimits;
|
|
7957
|
-
}
|
|
8158
|
+
spectorJS;
|
|
7958
8159
|
/**
|
|
7959
8160
|
* Triggers device (or WebGL context) loss.
|
|
7960
8161
|
* @note primarily intended for testing how application reacts to device loss
|
|
7961
8162
|
*/
|
|
7962
8163
|
loseDevice() {
|
|
7963
8164
|
let deviceLossTriggered = false;
|
|
7964
|
-
const
|
|
8165
|
+
const extensions = this.getExtension("WEBGL_lose_context");
|
|
8166
|
+
const ext = extensions.WEBGL_lose_context;
|
|
7965
8167
|
if (ext) {
|
|
7966
8168
|
deviceLossTriggered = true;
|
|
7967
8169
|
ext.loseContext();
|
|
@@ -8010,11 +8212,15 @@ ${source2}`;
|
|
|
8010
8212
|
* so they need to be updated before every render
|
|
8011
8213
|
* @todo - remember/cache values to avoid setting them unnecessarily?
|
|
8012
8214
|
*/
|
|
8013
|
-
|
|
8014
|
-
|
|
8215
|
+
setConstantAttributeWebGL(location, constant) {
|
|
8216
|
+
const maxVertexAttributes = this.limits.maxVertexAttributes;
|
|
8217
|
+
this._constants = this._constants || new Array(maxVertexAttributes).fill(null);
|
|
8015
8218
|
const currentConstant = this._constants[location];
|
|
8016
8219
|
if (currentConstant && compareConstantArrayValues2(currentConstant, constant)) {
|
|
8017
|
-
log.info(
|
|
8220
|
+
log.info(
|
|
8221
|
+
1,
|
|
8222
|
+
`setConstantAttributeWebGL(${location}) could have been skipped, value unchanged`
|
|
8223
|
+
)();
|
|
8018
8224
|
}
|
|
8019
8225
|
this._constants[location] = constant;
|
|
8020
8226
|
switch (constant.constructor) {
|
|
@@ -8031,6 +8237,11 @@ ${source2}`;
|
|
|
8031
8237
|
assert2(false);
|
|
8032
8238
|
}
|
|
8033
8239
|
}
|
|
8240
|
+
/** Ensure extensions are only requested once */
|
|
8241
|
+
getExtension(name2) {
|
|
8242
|
+
getWebGLExtension(this.gl, name2, this._extensions);
|
|
8243
|
+
return this._extensions;
|
|
8244
|
+
}
|
|
8034
8245
|
};
|
|
8035
8246
|
var WebGLDevice = _WebGLDevice;
|
|
8036
8247
|
//
|