@luma.gl/webgl 9.0.0-beta.5 → 9.0.0-beta.7
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 +128 -71
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +20 -19
- 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 +16 -11
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +224 -205
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +22 -21
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +19 -5
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +89 -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 +22 -19
- 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 +47 -46
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +35 -34
- 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 +42 -41
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js +40 -39
- 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 +30 -17
- 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 -101
- 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 +16 -15
- 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 +32 -31
- 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 +6 -5
- package/dist/adapter/resources/webgl-framebuffer.d.ts +6 -10
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +60 -53
- 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 +20 -12
- 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 +52 -61
- 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 +5 -4
- 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 +15 -9
- 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 +6 -4
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +39 -32
- 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 +10 -10
- 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 +10 -9
- 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 +35 -30
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +110 -109
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +8 -7
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +5 -4
- 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 +19 -19
- package/dist/classic/format-utils.d.ts.map +1 -1
- package/dist/classic/format-utils.js +16 -15
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +20 -19
- 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/{context → helpers}/create-browser-context.d.ts.map +1 -1
- package/dist/context/{context → helpers}/create-browser-context.js +2 -1
- package/dist/context/{context/context-data.d.ts → helpers/webgl-context-data.d.ts} +2 -3
- 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 +3 -4
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +7 -11
- package/dist/context/parameters/webgl-parameter-tables.d.ts +12 -13
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +302 -295
- 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 +2 -3
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +6 -8
- package/dist/dist.dev.js +1635 -1387
- package/dist/index.cjs +1766 -1534
- 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 +6 -6
- package/package.json +4 -4
- package/src/adapter/converters/device-parameters.ts +114 -27
- 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 +138 -114
- package/src/adapter/converters/vertex-formats.ts +3 -3
- package/src/adapter/device-helpers/webgl-device-features.ts +102 -50
- 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 +36 -14
- package/src/adapter/objects/webgl-resource.ts +7 -125
- 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 +6 -5
- package/src/adapter/resources/webgl-framebuffer.ts +61 -53
- package/src/adapter/resources/webgl-query-set.ts +171 -0
- package/src/adapter/resources/webgl-render-pass.ts +20 -11
- package/src/adapter/resources/webgl-render-pipeline.ts +54 -54
- 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 +14 -3
- 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 +116 -107
- package/src/classic/accessor.ts +5 -4
- package/src/classic/clear.ts +14 -8
- 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 +6 -17
- 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 +8 -8
- package/src/index.ts +7 -6
- package/src/types.ts +2 -1
- package/dist/adapter/device-helpers/device-features.d.ts +0 -6
- package/dist/adapter/device-helpers/device-features.d.ts.map +0 -1
- package/dist/adapter/device-helpers/device-features.js +0 -65
- package/dist/adapter/device-helpers/device-limits.d.ts +0 -50
- package/dist/adapter/device-helpers/device-limits.d.ts.map +0 -1
- package/dist/adapter/device-helpers/device-limits.js +0 -92
- package/dist/adapter/device-helpers/get-device-info.d.ts +0 -4
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +0 -1
- package/dist/adapter/device-helpers/get-device-info.js +0 -87
- package/dist/context/context/context-data.d.ts.map +0 -1
- package/dist/context/context/context-data.js +0 -33
- package/src/context/context/context-data.ts +0 -44
- /package/dist/context/{context → helpers}/create-browser-context.d.ts +0 -0
package/dist/dist.dev.js
CHANGED
|
@@ -57,7 +57,6 @@ var __exports__ = (() => {
|
|
|
57
57
|
WEBGLFramebuffer: () => WEBGLFramebuffer,
|
|
58
58
|
WEBGLRenderPass: () => WEBGLRenderPass,
|
|
59
59
|
WEBGLRenderPipeline: () => WEBGLRenderPipeline,
|
|
60
|
-
WEBGLRenderbuffer: () => WEBGLRenderbuffer,
|
|
61
60
|
WEBGLResource: () => WebGLResource,
|
|
62
61
|
WEBGLSampler: () => WEBGLSampler,
|
|
63
62
|
WEBGLShader: () => WEBGLShader,
|
|
@@ -68,6 +67,7 @@ var __exports__ = (() => {
|
|
|
68
67
|
WebGLDevice: () => WebGLDevice,
|
|
69
68
|
WebGLResource: () => WebGLResource,
|
|
70
69
|
_TEXTURE_FORMATS: () => TEXTURE_FORMATS,
|
|
70
|
+
_WEBGLRenderbuffer: () => WEBGLRenderbuffer,
|
|
71
71
|
convertGLToTextureFormat: () => convertGLToTextureFormat,
|
|
72
72
|
getGLParameters: () => getGLParameters,
|
|
73
73
|
getShaderLayout: () => getShaderLayout,
|
|
@@ -83,10 +83,12 @@ var __exports__ = (() => {
|
|
|
83
83
|
|
|
84
84
|
// ../../node_modules/@probe.gl/env/dist/lib/is-electron.js
|
|
85
85
|
function isElectron(mockUserAgent) {
|
|
86
|
-
if (typeof window !== "undefined" && typeof window.process === "object" &&
|
|
86
|
+
if (typeof window !== "undefined" && typeof window.process === "object" && // @ts-expect-error
|
|
87
|
+
window.process.type === "renderer") {
|
|
87
88
|
return true;
|
|
88
89
|
}
|
|
89
|
-
if (typeof process !== "undefined" && typeof process.versions === "object" &&
|
|
90
|
+
if (typeof process !== "undefined" && typeof process.versions === "object" && // eslint-disable-next-line
|
|
91
|
+
Boolean(process.versions["electron"])) {
|
|
90
92
|
return true;
|
|
91
93
|
}
|
|
92
94
|
const realUserAgent = typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent;
|
|
@@ -99,7 +101,10 @@ var __exports__ = (() => {
|
|
|
99
101
|
|
|
100
102
|
// ../../node_modules/@probe.gl/env/dist/lib/is-browser.js
|
|
101
103
|
function isBrowser() {
|
|
102
|
-
const isNode =
|
|
104
|
+
const isNode = (
|
|
105
|
+
// @ts-expect-error
|
|
106
|
+
typeof process === "object" && String(process) === "[object process]" && !process.browser
|
|
107
|
+
);
|
|
103
108
|
return !isNode || isElectron();
|
|
104
109
|
}
|
|
105
110
|
|
|
@@ -112,7 +117,7 @@ var __exports__ = (() => {
|
|
|
112
117
|
var navigator_ = globalThis.navigator || {};
|
|
113
118
|
|
|
114
119
|
// ../../node_modules/@probe.gl/env/dist/utils/globals.js
|
|
115
|
-
var VERSION =
|
|
120
|
+
var VERSION = true ? "4.0.6" : "untranspiled source";
|
|
116
121
|
var isBrowser2 = isBrowser();
|
|
117
122
|
|
|
118
123
|
// ../../node_modules/@probe.gl/env/dist/lib/get-browser.js
|
|
@@ -158,11 +163,7 @@ var __exports__ = (() => {
|
|
|
158
163
|
}
|
|
159
164
|
}
|
|
160
165
|
var LocalStorage = class {
|
|
161
|
-
constructor(id, defaultConfig) {
|
|
162
|
-
let type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "sessionStorage";
|
|
163
|
-
this.storage = void 0;
|
|
164
|
-
this.id = void 0;
|
|
165
|
-
this.config = void 0;
|
|
166
|
+
constructor(id, defaultConfig, type = "sessionStorage") {
|
|
166
167
|
this.storage = getStorage(type);
|
|
167
168
|
this.id = id;
|
|
168
169
|
this.config = defaultConfig;
|
|
@@ -178,6 +179,7 @@ var __exports__ = (() => {
|
|
|
178
179
|
this.storage.setItem(this.id, serialized);
|
|
179
180
|
}
|
|
180
181
|
}
|
|
182
|
+
// Get config from persistent store, if available
|
|
181
183
|
_loadConfiguration() {
|
|
182
184
|
let configuration = {};
|
|
183
185
|
if (this.storage) {
|
|
@@ -203,20 +205,25 @@ var __exports__ = (() => {
|
|
|
203
205
|
}
|
|
204
206
|
return formatted;
|
|
205
207
|
}
|
|
206
|
-
function leftPad(string) {
|
|
207
|
-
let length = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8;
|
|
208
|
+
function leftPad(string, length = 8) {
|
|
208
209
|
const padLength = Math.max(length - string.length, 0);
|
|
209
210
|
return `${" ".repeat(padLength)}${string}`;
|
|
210
211
|
}
|
|
211
|
-
function formatImage(image, message2, scale) {
|
|
212
|
-
let maxWidth = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 600;
|
|
212
|
+
function formatImage(image, message2, scale, maxWidth = 600) {
|
|
213
213
|
const imageUrl = image.src.replace(/\(/g, "%28").replace(/\)/g, "%29");
|
|
214
214
|
if (image.width > maxWidth) {
|
|
215
215
|
scale = Math.min(scale, maxWidth / image.width);
|
|
216
216
|
}
|
|
217
217
|
const width = image.width * scale;
|
|
218
218
|
const height = image.height * scale;
|
|
219
|
-
const style = [
|
|
219
|
+
const style = [
|
|
220
|
+
"font-size:1px;",
|
|
221
|
+
`padding:${Math.floor(height / 2)}px ${Math.floor(width / 2)}px;`,
|
|
222
|
+
`line-height:${height}px;`,
|
|
223
|
+
`background:url(${imageUrl});`,
|
|
224
|
+
`background-size:${width}px ${height}px;`,
|
|
225
|
+
"color:transparent;"
|
|
226
|
+
].join("");
|
|
220
227
|
return [`${message2} %c+`, style];
|
|
221
228
|
}
|
|
222
229
|
|
|
@@ -263,8 +270,7 @@ var __exports__ = (() => {
|
|
|
263
270
|
}
|
|
264
271
|
|
|
265
272
|
// ../../node_modules/@probe.gl/log/dist/utils/autobind.js
|
|
266
|
-
function autobind(obj) {
|
|
267
|
-
let predefined = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ["constructor"];
|
|
273
|
+
function autobind(obj, predefined = ["constructor"]) {
|
|
268
274
|
const proto = Object.getPrototypeOf(obj);
|
|
269
275
|
const propNames = Object.getOwnPropertyNames(proto);
|
|
270
276
|
const object = obj;
|
|
@@ -289,11 +295,9 @@ var __exports__ = (() => {
|
|
|
289
295
|
function getHiResTimestamp() {
|
|
290
296
|
let timestamp;
|
|
291
297
|
if (isBrowser() && window_.performance) {
|
|
292
|
-
|
|
293
|
-
timestamp = window_ === null || window_ === void 0 ? void 0 : (_window$performance = window_.performance) === null || _window$performance === void 0 ? void 0 : (_window$performance$n = _window$performance.now) === null || _window$performance$n === void 0 ? void 0 : _window$performance$n.call(_window$performance);
|
|
298
|
+
timestamp = window_?.performance?.now?.();
|
|
294
299
|
} else if ("hrtime" in process_) {
|
|
295
|
-
|
|
296
|
-
const timeParts = process_ === null || process_ === void 0 ? void 0 : (_process$hrtime = process_.hrtime) === null || _process$hrtime === void 0 ? void 0 : _process$hrtime.call(process_);
|
|
300
|
+
const timeParts = process_?.hrtime?.();
|
|
297
301
|
timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
|
|
298
302
|
} else {
|
|
299
303
|
timestamp = Date.now();
|
|
@@ -316,21 +320,12 @@ var __exports__ = (() => {
|
|
|
316
320
|
function noop() {
|
|
317
321
|
}
|
|
318
322
|
var cache = {};
|
|
319
|
-
var ONCE = {
|
|
320
|
-
once: true
|
|
321
|
-
};
|
|
323
|
+
var ONCE = { once: true };
|
|
322
324
|
var Log = class {
|
|
323
|
-
constructor() {
|
|
324
|
-
let {
|
|
325
|
-
id
|
|
326
|
-
} = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
|
|
327
|
-
id: ""
|
|
328
|
-
};
|
|
329
|
-
this.id = void 0;
|
|
325
|
+
constructor({ id } = { id: "" }) {
|
|
330
326
|
this.VERSION = VERSION;
|
|
331
327
|
this._startTs = getHiResTimestamp();
|
|
332
328
|
this._deltaTs = getHiResTimestamp();
|
|
333
|
-
this._storage = void 0;
|
|
334
329
|
this.userData = {};
|
|
335
330
|
this.LOG_THROTTLE_TIMEOUT = 0;
|
|
336
331
|
this.id = id;
|
|
@@ -352,42 +347,44 @@ var __exports__ = (() => {
|
|
|
352
347
|
getLevel() {
|
|
353
348
|
return this._storage.config.level;
|
|
354
349
|
}
|
|
350
|
+
/** @return milliseconds, with fractions */
|
|
355
351
|
getTotal() {
|
|
356
352
|
return Number((getHiResTimestamp() - this._startTs).toPrecision(10));
|
|
357
353
|
}
|
|
354
|
+
/** @return milliseconds, with fractions */
|
|
358
355
|
getDelta() {
|
|
359
356
|
return Number((getHiResTimestamp() - this._deltaTs).toPrecision(10));
|
|
360
357
|
}
|
|
358
|
+
/** @deprecated use logLevel */
|
|
361
359
|
set priority(newPriority) {
|
|
362
360
|
this.level = newPriority;
|
|
363
361
|
}
|
|
362
|
+
/** @deprecated use logLevel */
|
|
364
363
|
get priority() {
|
|
365
364
|
return this.level;
|
|
366
365
|
}
|
|
366
|
+
/** @deprecated use logLevel */
|
|
367
367
|
getPriority() {
|
|
368
368
|
return this.level;
|
|
369
369
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
this._storage.setConfiguration({
|
|
373
|
-
enabled
|
|
374
|
-
});
|
|
370
|
+
// Configure
|
|
371
|
+
enable(enabled = true) {
|
|
372
|
+
this._storage.setConfiguration({ enabled });
|
|
375
373
|
return this;
|
|
376
374
|
}
|
|
377
375
|
setLevel(level) {
|
|
378
|
-
this._storage.setConfiguration({
|
|
379
|
-
level
|
|
380
|
-
});
|
|
376
|
+
this._storage.setConfiguration({ level });
|
|
381
377
|
return this;
|
|
382
378
|
}
|
|
379
|
+
/** return the current status of the setting */
|
|
383
380
|
get(setting) {
|
|
384
381
|
return this._storage.config[setting];
|
|
385
382
|
}
|
|
383
|
+
// update the status of the setting
|
|
386
384
|
set(setting, value) {
|
|
387
|
-
this._storage.setConfiguration({
|
|
388
|
-
[setting]: value
|
|
389
|
-
});
|
|
385
|
+
this._storage.setConfiguration({ [setting]: value });
|
|
390
386
|
}
|
|
387
|
+
/** Logs the current settings as a table */
|
|
391
388
|
settings() {
|
|
392
389
|
if (console.table) {
|
|
393
390
|
console.table(this._storage.config);
|
|
@@ -395,6 +392,7 @@ var __exports__ = (() => {
|
|
|
395
392
|
console.log(this._storage.config);
|
|
396
393
|
}
|
|
397
394
|
}
|
|
395
|
+
// Unconditional logging
|
|
398
396
|
assert(condition, message2) {
|
|
399
397
|
assert(condition, message2);
|
|
400
398
|
}
|
|
@@ -404,9 +402,11 @@ var __exports__ = (() => {
|
|
|
404
402
|
error(message2) {
|
|
405
403
|
return this._getLogFunction(0, message2, originalConsole.error, arguments);
|
|
406
404
|
}
|
|
405
|
+
/** Print a deprecation warning */
|
|
407
406
|
deprecated(oldUsage, newUsage) {
|
|
408
407
|
return this.warn(`\`${oldUsage}\` is deprecated and will be removed in a later version. Use \`${newUsage}\` instead`);
|
|
409
408
|
}
|
|
409
|
+
/** Print a removal warning */
|
|
410
410
|
removed(oldUsage, newUsage) {
|
|
411
411
|
return this.error(`\`${oldUsage}\` has been removed. Use \`${newUsage}\` instead`);
|
|
412
412
|
}
|
|
@@ -425,6 +425,7 @@ var __exports__ = (() => {
|
|
|
425
425
|
once(logLevel, message2) {
|
|
426
426
|
return this._getLogFunction(logLevel, message2, originalConsole.debug || originalConsole.info, arguments, ONCE);
|
|
427
427
|
}
|
|
428
|
+
/** Logs an object as a table */
|
|
428
429
|
table(logLevel, table, columns) {
|
|
429
430
|
if (table) {
|
|
430
431
|
return this._getLogFunction(logLevel, table, console.table || noop, columns && [columns], {
|
|
@@ -433,26 +434,12 @@ var __exports__ = (() => {
|
|
|
433
434
|
}
|
|
434
435
|
return noop;
|
|
435
436
|
}
|
|
436
|
-
image
|
|
437
|
-
|
|
438
|
-
logLevel,
|
|
439
|
-
priority,
|
|
440
|
-
image,
|
|
441
|
-
message: message2 = "",
|
|
442
|
-
scale = 1
|
|
443
|
-
} = _ref;
|
|
437
|
+
/** logs an image under Chrome */
|
|
438
|
+
image({ logLevel, priority, image, message: message2 = "", scale = 1 }) {
|
|
444
439
|
if (!this._shouldLog(logLevel || priority)) {
|
|
445
440
|
return noop;
|
|
446
441
|
}
|
|
447
|
-
return isBrowser() ? logImageInBrowser({
|
|
448
|
-
image,
|
|
449
|
-
message: message2,
|
|
450
|
-
scale
|
|
451
|
-
}) : logImageInNode({
|
|
452
|
-
image,
|
|
453
|
-
message: message2,
|
|
454
|
-
scale
|
|
455
|
-
});
|
|
442
|
+
return isBrowser() ? logImageInBrowser({ image, message: message2, scale }) : logImageInNode({ image, message: message2, scale });
|
|
456
443
|
}
|
|
457
444
|
time(logLevel, message2) {
|
|
458
445
|
return this._getLogFunction(logLevel, message2, console.time ? console.time : console.info);
|
|
@@ -463,30 +450,19 @@ var __exports__ = (() => {
|
|
|
463
450
|
timeStamp(logLevel, message2) {
|
|
464
451
|
return this._getLogFunction(logLevel, message2, console.timeStamp || noop);
|
|
465
452
|
}
|
|
466
|
-
group(logLevel, message2) {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
};
|
|
470
|
-
const options = normalizeArguments({
|
|
471
|
-
logLevel,
|
|
472
|
-
message: message2,
|
|
473
|
-
opts
|
|
474
|
-
});
|
|
475
|
-
const {
|
|
476
|
-
collapsed
|
|
477
|
-
} = opts;
|
|
453
|
+
group(logLevel, message2, opts = { collapsed: false }) {
|
|
454
|
+
const options = normalizeArguments({ logLevel, message: message2, opts });
|
|
455
|
+
const { collapsed } = opts;
|
|
478
456
|
options.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
|
|
479
457
|
return this._getLogFunction(options);
|
|
480
458
|
}
|
|
481
|
-
groupCollapsed(logLevel, message2) {
|
|
482
|
-
|
|
483
|
-
return this.group(logLevel, message2, Object.assign({}, opts, {
|
|
484
|
-
collapsed: true
|
|
485
|
-
}));
|
|
459
|
+
groupCollapsed(logLevel, message2, opts = {}) {
|
|
460
|
+
return this.group(logLevel, message2, Object.assign({}, opts, { collapsed: true }));
|
|
486
461
|
}
|
|
487
462
|
groupEnd(logLevel) {
|
|
488
463
|
return this._getLogFunction(logLevel, "", console.groupEnd || noop);
|
|
489
464
|
}
|
|
465
|
+
// EXPERIMENTAL
|
|
490
466
|
withGroup(logLevel, message2, func) {
|
|
491
467
|
this.group(logLevel, message2)();
|
|
492
468
|
try {
|
|
@@ -500,17 +476,14 @@ var __exports__ = (() => {
|
|
|
500
476
|
console.trace();
|
|
501
477
|
}
|
|
502
478
|
}
|
|
479
|
+
// PRIVATE METHODS
|
|
480
|
+
/** Deduces log level from a variety of arguments */
|
|
503
481
|
_shouldLog(logLevel) {
|
|
504
482
|
return this.isEnabled() && this.getLevel() >= normalizeLogLevel(logLevel);
|
|
505
483
|
}
|
|
506
484
|
_getLogFunction(logLevel, message2, method, args, opts) {
|
|
507
485
|
if (this._shouldLog(logLevel)) {
|
|
508
|
-
opts = normalizeArguments({
|
|
509
|
-
logLevel,
|
|
510
|
-
message: message2,
|
|
511
|
-
args,
|
|
512
|
-
opts
|
|
513
|
-
});
|
|
486
|
+
opts = normalizeArguments({ logLevel, message: message2, args, opts });
|
|
514
487
|
method = method || opts.method;
|
|
515
488
|
assert(method);
|
|
516
489
|
opts.total = this.getTotal();
|
|
@@ -550,10 +523,7 @@ var __exports__ = (() => {
|
|
|
550
523
|
return resolvedLevel;
|
|
551
524
|
}
|
|
552
525
|
function normalizeArguments(opts) {
|
|
553
|
-
const {
|
|
554
|
-
logLevel,
|
|
555
|
-
message: message2
|
|
556
|
-
} = opts;
|
|
526
|
+
const { logLevel, message: message2 } = opts;
|
|
557
527
|
opts.logLevel = normalizeLogLevel(logLevel);
|
|
558
528
|
const args = opts.args ? Array.from(opts.args) : [];
|
|
559
529
|
while (args.length && args.shift() !== message2) {
|
|
@@ -576,9 +546,7 @@ var __exports__ = (() => {
|
|
|
576
546
|
}
|
|
577
547
|
const messageType = typeof opts.message;
|
|
578
548
|
assert(messageType === "string" || messageType === "object");
|
|
579
|
-
return Object.assign(opts, {
|
|
580
|
-
args
|
|
581
|
-
}, opts.opts);
|
|
549
|
+
return Object.assign(opts, { args }, opts.opts);
|
|
582
550
|
}
|
|
583
551
|
function decorateMessage(id, message2, opts) {
|
|
584
552
|
if (typeof message2 === "string") {
|
|
@@ -588,21 +556,11 @@ var __exports__ = (() => {
|
|
|
588
556
|
}
|
|
589
557
|
return message2;
|
|
590
558
|
}
|
|
591
|
-
function logImageInNode(
|
|
592
|
-
let {
|
|
593
|
-
image,
|
|
594
|
-
message: message2 = "",
|
|
595
|
-
scale = 1
|
|
596
|
-
} = _ref2;
|
|
559
|
+
function logImageInNode({ image, message: message2 = "", scale = 1 }) {
|
|
597
560
|
console.warn("removed");
|
|
598
561
|
return noop;
|
|
599
562
|
}
|
|
600
|
-
function logImageInBrowser(
|
|
601
|
-
let {
|
|
602
|
-
image,
|
|
603
|
-
message: message2 = "",
|
|
604
|
-
scale = 1
|
|
605
|
-
} = _ref3;
|
|
563
|
+
function logImageInBrowser({ image, message: message2 = "", scale = 1 }) {
|
|
606
564
|
if (typeof image === "string") {
|
|
607
565
|
const img = new Image();
|
|
608
566
|
img.onload = () => {
|
|
@@ -638,9 +596,7 @@ var __exports__ = (() => {
|
|
|
638
596
|
globalThis.probe = {};
|
|
639
597
|
|
|
640
598
|
// ../../node_modules/@probe.gl/log/dist/index.js
|
|
641
|
-
var dist_default = new Log({
|
|
642
|
-
id: "@probe.gl/log"
|
|
643
|
-
});
|
|
599
|
+
var dist_default = new Log({ id: "@probe.gl/log" });
|
|
644
600
|
|
|
645
601
|
// ../core/src/utils/log.ts
|
|
646
602
|
var log = new Log({ id: "luma.gl" });
|
|
@@ -662,8 +618,6 @@ var __exports__ = (() => {
|
|
|
662
618
|
// ../../node_modules/@probe.gl/stats/dist/lib/stat.js
|
|
663
619
|
var Stat = class {
|
|
664
620
|
constructor(name2, type) {
|
|
665
|
-
this.name = void 0;
|
|
666
|
-
this.type = void 0;
|
|
667
621
|
this.sampleSize = 1;
|
|
668
622
|
this.time = 0;
|
|
669
623
|
this.count = 0;
|
|
@@ -698,26 +652,31 @@ var __exports__ = (() => {
|
|
|
698
652
|
this.sampleSize = samples;
|
|
699
653
|
return this;
|
|
700
654
|
}
|
|
655
|
+
/** Call to increment count (+1) */
|
|
701
656
|
incrementCount() {
|
|
702
657
|
this.addCount(1);
|
|
703
658
|
return this;
|
|
704
659
|
}
|
|
660
|
+
/** Call to decrement count (-1) */
|
|
705
661
|
decrementCount() {
|
|
706
662
|
this.subtractCount(1);
|
|
707
663
|
return this;
|
|
708
664
|
}
|
|
665
|
+
/** Increase count */
|
|
709
666
|
addCount(value) {
|
|
710
667
|
this._count += value;
|
|
711
668
|
this._samples++;
|
|
712
669
|
this._checkSampling();
|
|
713
670
|
return this;
|
|
714
671
|
}
|
|
672
|
+
/** Decrease count */
|
|
715
673
|
subtractCount(value) {
|
|
716
674
|
this._count -= value;
|
|
717
675
|
this._samples++;
|
|
718
676
|
this._checkSampling();
|
|
719
677
|
return this;
|
|
720
678
|
}
|
|
679
|
+
/** Add an arbitrary timing and bump the count */
|
|
721
680
|
addTime(time) {
|
|
722
681
|
this._time += time;
|
|
723
682
|
this.lastTiming = time;
|
|
@@ -725,11 +684,13 @@ var __exports__ = (() => {
|
|
|
725
684
|
this._checkSampling();
|
|
726
685
|
return this;
|
|
727
686
|
}
|
|
687
|
+
/** Start a timer */
|
|
728
688
|
timeStart() {
|
|
729
689
|
this._startTime = getHiResTimestamp2();
|
|
730
690
|
this._timerPending = true;
|
|
731
691
|
return this;
|
|
732
692
|
}
|
|
693
|
+
/** End a timer. Adds to time and bumps the timing count. */
|
|
733
694
|
timeEnd() {
|
|
734
695
|
if (!this._timerPending) {
|
|
735
696
|
return this;
|
|
@@ -742,18 +703,22 @@ var __exports__ = (() => {
|
|
|
742
703
|
getSampleAverageCount() {
|
|
743
704
|
return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0;
|
|
744
705
|
}
|
|
706
|
+
/** Calculate average time / count for the previous window */
|
|
745
707
|
getSampleAverageTime() {
|
|
746
708
|
return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0;
|
|
747
709
|
}
|
|
710
|
+
/** Calculate counts per second for the previous window */
|
|
748
711
|
getSampleHz() {
|
|
749
712
|
return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1e3) : 0;
|
|
750
713
|
}
|
|
751
714
|
getAverageCount() {
|
|
752
715
|
return this.samples > 0 ? this.count / this.samples : 0;
|
|
753
716
|
}
|
|
717
|
+
/** Calculate average time / count */
|
|
754
718
|
getAverageTime() {
|
|
755
719
|
return this.samples > 0 ? this.time / this.samples : 0;
|
|
756
720
|
}
|
|
721
|
+
/** Calculate counts per second */
|
|
757
722
|
getHz() {
|
|
758
723
|
return this.time > 0 ? this.samples / (this.time / 1e3) : 0;
|
|
759
724
|
}
|
|
@@ -774,23 +739,20 @@ var __exports__ = (() => {
|
|
|
774
739
|
// ../../node_modules/@probe.gl/stats/dist/lib/stats.js
|
|
775
740
|
var Stats = class {
|
|
776
741
|
constructor(options) {
|
|
777
|
-
this.id = void 0;
|
|
778
742
|
this.stats = {};
|
|
779
743
|
this.id = options.id;
|
|
780
744
|
this.stats = {};
|
|
781
745
|
this._initializeStats(options.stats);
|
|
782
746
|
Object.seal(this);
|
|
783
747
|
}
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
return this._getOrCreate({
|
|
787
|
-
name: name2,
|
|
788
|
-
type
|
|
789
|
-
});
|
|
748
|
+
/** Acquire a stat. Create if it doesn't exist. */
|
|
749
|
+
get(name2, type = "count") {
|
|
750
|
+
return this._getOrCreate({ name: name2, type });
|
|
790
751
|
}
|
|
791
752
|
get size() {
|
|
792
753
|
return Object.keys(this.stats).length;
|
|
793
754
|
}
|
|
755
|
+
/** Reset all stats */
|
|
794
756
|
reset() {
|
|
795
757
|
for (const stat of Object.values(this.stats)) {
|
|
796
758
|
stat.reset();
|
|
@@ -814,15 +776,11 @@ var __exports__ = (() => {
|
|
|
814
776
|
});
|
|
815
777
|
return table;
|
|
816
778
|
}
|
|
817
|
-
_initializeStats() {
|
|
818
|
-
let stats = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
|
|
779
|
+
_initializeStats(stats = []) {
|
|
819
780
|
stats.forEach((stat) => this._getOrCreate(stat));
|
|
820
781
|
}
|
|
821
782
|
_getOrCreate(stat) {
|
|
822
|
-
const {
|
|
823
|
-
name: name2,
|
|
824
|
-
type
|
|
825
|
-
} = stat;
|
|
783
|
+
const { name: name2, type } = stat;
|
|
826
784
|
let result = this.stats[name2];
|
|
827
785
|
if (!result) {
|
|
828
786
|
if (stat instanceof Stat) {
|
|
@@ -856,7 +814,9 @@ var __exports__ = (() => {
|
|
|
856
814
|
const VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "running from source";
|
|
857
815
|
const STARTUP_MESSAGE = "set luma.log.level=1 (or higher) to trace rendering";
|
|
858
816
|
if (globalThis.luma && globalThis.luma.VERSION !== VERSION3) {
|
|
859
|
-
throw new Error(
|
|
817
|
+
throw new Error(
|
|
818
|
+
`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${VERSION3}`
|
|
819
|
+
);
|
|
860
820
|
}
|
|
861
821
|
if (!globalThis.luma) {
|
|
862
822
|
if (isBrowser()) {
|
|
@@ -952,20 +912,20 @@ var __exports__ = (() => {
|
|
|
952
912
|
return this.props;
|
|
953
913
|
}
|
|
954
914
|
// ATTACHED RESOURCES
|
|
955
|
-
/**
|
|
915
|
+
/**
|
|
956
916
|
* Attaches a resource. Attached resources are auto destroyed when this resource is destroyed
|
|
957
917
|
* Called automatically when sub resources are auto created but can be called by application
|
|
958
918
|
*/
|
|
959
919
|
attachResource(resource) {
|
|
960
920
|
this._attachedResources.add(resource);
|
|
961
921
|
}
|
|
962
|
-
/**
|
|
922
|
+
/**
|
|
963
923
|
* Detach an attached resource. The resource will no longer be auto-destroyed when this resource is destroyed.
|
|
964
924
|
*/
|
|
965
925
|
detachResource(resource) {
|
|
966
926
|
this._attachedResources.delete(resource);
|
|
967
927
|
}
|
|
968
|
-
/**
|
|
928
|
+
/**
|
|
969
929
|
* Destroys a resource (only if owned), and removes from the owned (auto-destroy) list for this resource.
|
|
970
930
|
*/
|
|
971
931
|
destroyAttachedResource(resource) {
|
|
@@ -1041,6 +1001,8 @@ var __exports__ = (() => {
|
|
|
1041
1001
|
usage;
|
|
1042
1002
|
/** For index buffers, whether indices are 16 or 32 bit */
|
|
1043
1003
|
indexType;
|
|
1004
|
+
/** "Time" of last update */
|
|
1005
|
+
updateTimestamp;
|
|
1044
1006
|
constructor(device, props) {
|
|
1045
1007
|
const deducedProps = { ...props };
|
|
1046
1008
|
if ((props.usage || 0) & _Buffer.INDEX && !props.indexType) {
|
|
@@ -1053,6 +1015,7 @@ var __exports__ = (() => {
|
|
|
1053
1015
|
super(device, deducedProps, _Buffer.defaultProps);
|
|
1054
1016
|
this.usage = props.usage || 0;
|
|
1055
1017
|
this.indexType = deducedProps.indexType;
|
|
1018
|
+
this.updateTimestamp = device.incrementTimestamp();
|
|
1056
1019
|
}
|
|
1057
1020
|
/** Read data synchronously. @note WebGL2 only */
|
|
1058
1021
|
readSyncWebGL(byteOffset, byteLength) {
|
|
@@ -1063,7 +1026,10 @@ var __exports__ = (() => {
|
|
|
1063
1026
|
/** This doesn't handle partial non-zero offset updates correctly */
|
|
1064
1027
|
_setDebugData(data, byteOffset, byteLength) {
|
|
1065
1028
|
const buffer = ArrayBuffer.isView(data) ? data.buffer : data;
|
|
1066
|
-
const debugDataLength = Math.min(
|
|
1029
|
+
const debugDataLength = Math.min(
|
|
1030
|
+
data ? data.byteLength : byteLength,
|
|
1031
|
+
_Buffer.DEBUG_DATA_MAX_LENGTH
|
|
1032
|
+
);
|
|
1067
1033
|
if (data === null) {
|
|
1068
1034
|
this.debugData = new ArrayBuffer(debugDataLength);
|
|
1069
1035
|
} else if (byteOffset === 0 && byteLength === data.byteLength) {
|
|
@@ -1103,7 +1069,142 @@ var __exports__ = (() => {
|
|
|
1103
1069
|
/** Max amount of debug data saved. Two vec4's */
|
|
1104
1070
|
__publicField(Buffer2, "DEBUG_DATA_MAX_LENGTH", 32);
|
|
1105
1071
|
|
|
1072
|
+
// ../core/src/adapter/type-utils/decode-data-type.ts
|
|
1073
|
+
function decodeVertexType(type) {
|
|
1074
|
+
const dataType = TYPE_MAP[type];
|
|
1075
|
+
const bytes = getDataTypeBytes(dataType);
|
|
1076
|
+
const normalized = type.includes("norm");
|
|
1077
|
+
const integer = !normalized && !type.startsWith("float");
|
|
1078
|
+
const signed = type.startsWith("s");
|
|
1079
|
+
return {
|
|
1080
|
+
dataType: TYPE_MAP[type],
|
|
1081
|
+
byteLength: bytes,
|
|
1082
|
+
integer,
|
|
1083
|
+
signed,
|
|
1084
|
+
normalized
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
function getDataTypeBytes(type) {
|
|
1088
|
+
const bytes = TYPE_SIZES[type];
|
|
1089
|
+
return bytes;
|
|
1090
|
+
}
|
|
1091
|
+
var TYPE_MAP = {
|
|
1092
|
+
uint8: "uint8",
|
|
1093
|
+
sint8: "sint8",
|
|
1094
|
+
unorm8: "uint8",
|
|
1095
|
+
snorm8: "sint8",
|
|
1096
|
+
uint16: "uint16",
|
|
1097
|
+
sint16: "sint16",
|
|
1098
|
+
unorm16: "uint16",
|
|
1099
|
+
snorm16: "sint16",
|
|
1100
|
+
float16: "float16",
|
|
1101
|
+
float32: "float32",
|
|
1102
|
+
uint32: "uint32",
|
|
1103
|
+
sint32: "sint32"
|
|
1104
|
+
};
|
|
1105
|
+
var TYPE_SIZES = {
|
|
1106
|
+
uint8: 1,
|
|
1107
|
+
sint8: 1,
|
|
1108
|
+
uint16: 2,
|
|
1109
|
+
sint16: 2,
|
|
1110
|
+
float16: 2,
|
|
1111
|
+
float32: 4,
|
|
1112
|
+
uint32: 4,
|
|
1113
|
+
sint32: 4
|
|
1114
|
+
};
|
|
1115
|
+
|
|
1116
|
+
// ../core/src/adapter/type-utils/decode-texture-format.ts
|
|
1117
|
+
var COMPRESSED_TEXTURE_FORMAT_PREFIXES = [
|
|
1118
|
+
"bc1",
|
|
1119
|
+
"bc2",
|
|
1120
|
+
"bc3",
|
|
1121
|
+
"bc4",
|
|
1122
|
+
"bc5",
|
|
1123
|
+
"bc6",
|
|
1124
|
+
"bc7",
|
|
1125
|
+
"etc1",
|
|
1126
|
+
"etc2",
|
|
1127
|
+
"eac",
|
|
1128
|
+
"atc",
|
|
1129
|
+
"astc",
|
|
1130
|
+
"pvrtc"
|
|
1131
|
+
];
|
|
1132
|
+
var REGEX = /^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;
|
|
1133
|
+
function isTextureFormatCompressed(textureFormat) {
|
|
1134
|
+
return COMPRESSED_TEXTURE_FORMAT_PREFIXES.some((prefix) => textureFormat.startsWith(prefix));
|
|
1135
|
+
}
|
|
1136
|
+
function decodeTextureFormat(format) {
|
|
1137
|
+
const matches = REGEX.exec(format);
|
|
1138
|
+
if (matches) {
|
|
1139
|
+
const [, format2, length, type, srgb, suffix] = matches;
|
|
1140
|
+
if (format2) {
|
|
1141
|
+
const dataType = `${type}${length}`;
|
|
1142
|
+
const decodedType = decodeVertexType(dataType);
|
|
1143
|
+
return {
|
|
1144
|
+
format: format2,
|
|
1145
|
+
components: format2.length,
|
|
1146
|
+
// dataType - overwritten by decodedType
|
|
1147
|
+
srgb: srgb === "-srgb",
|
|
1148
|
+
unsized: suffix === "-unsized",
|
|
1149
|
+
webgl: suffix === "-webgl",
|
|
1150
|
+
...decodedType
|
|
1151
|
+
};
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
return decodeNonStandardFormat(format);
|
|
1155
|
+
}
|
|
1156
|
+
var EXCEPTIONS = {
|
|
1157
|
+
// Packed 16 bit formats
|
|
1158
|
+
"rgba4unorm-webgl": { format: "rgba", bpp: 2 },
|
|
1159
|
+
"rgb565unorm-webgl": { format: "rgb", bpp: 2 },
|
|
1160
|
+
"rgb5a1unorm-webgl": { format: "rgba", bbp: 2 },
|
|
1161
|
+
// Packed 32 bit formats
|
|
1162
|
+
rgb9e5ufloat: { format: "rgb", bbp: 4 },
|
|
1163
|
+
rg11b10ufloat: { format: "rgb", bbp: 4 },
|
|
1164
|
+
rgb10a2unorm: { format: "rgba", bbp: 4 },
|
|
1165
|
+
"rgb10a2uint-webgl": { format: "rgba", bbp: 4 },
|
|
1166
|
+
// Depth/stencil
|
|
1167
|
+
stencil8: { components: 1, bpp: 1, a: "stencil" },
|
|
1168
|
+
depth16unorm: { components: 1, bpp: 2, a: "depth" },
|
|
1169
|
+
depth24plus: { components: 1, bpp: 3, a: "depth" },
|
|
1170
|
+
depth32float: { components: 1, bpp: 4, a: "depth" },
|
|
1171
|
+
"depth24plus-stencil8": { components: 2, bpp: 4, a: "depth-stencil" },
|
|
1172
|
+
// "depth24unorm-stencil8" feature
|
|
1173
|
+
"depth24unorm-stencil8": { components: 2, bpp: 4, a: "depth-stencil" },
|
|
1174
|
+
// "depth32float-stencil8" feature
|
|
1175
|
+
"depth32float-stencil8": { components: 2, bpp: 4, a: "depth-stencil" }
|
|
1176
|
+
};
|
|
1177
|
+
function decodeNonStandardFormat(format) {
|
|
1178
|
+
const data = EXCEPTIONS[format];
|
|
1179
|
+
if (!data) {
|
|
1180
|
+
throw new Error(`Unknown format ${format}`);
|
|
1181
|
+
}
|
|
1182
|
+
return {
|
|
1183
|
+
format: data.format || "",
|
|
1184
|
+
components: data.components || data.format?.length || 1,
|
|
1185
|
+
byteLength: data.bpp || 1,
|
|
1186
|
+
srgb: false,
|
|
1187
|
+
unsized: false
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1106
1191
|
// ../core/src/adapter/device.ts
|
|
1192
|
+
var DeviceLimits = class {
|
|
1193
|
+
};
|
|
1194
|
+
var DeviceFeatures = class {
|
|
1195
|
+
features;
|
|
1196
|
+
disabledFeatures;
|
|
1197
|
+
constructor(features = [], disabledFeatures) {
|
|
1198
|
+
this.features = new Set(features);
|
|
1199
|
+
this.disabledFeatures = disabledFeatures || {};
|
|
1200
|
+
}
|
|
1201
|
+
*[Symbol.iterator]() {
|
|
1202
|
+
yield* this.features;
|
|
1203
|
+
}
|
|
1204
|
+
has(feature) {
|
|
1205
|
+
return !this.disabledFeatures[feature] && this.features.has(feature);
|
|
1206
|
+
}
|
|
1207
|
+
};
|
|
1107
1208
|
var _Device = class {
|
|
1108
1209
|
get [Symbol.toStringTag]() {
|
|
1109
1210
|
return "Device";
|
|
@@ -1114,14 +1215,18 @@ var __exports__ = (() => {
|
|
|
1114
1215
|
}
|
|
1115
1216
|
/** id of this device, primarily for debugging */
|
|
1116
1217
|
id;
|
|
1117
|
-
/** stats */
|
|
1118
|
-
statsManager = lumaStats;
|
|
1119
1218
|
/** A copy of the device props */
|
|
1120
1219
|
props;
|
|
1121
1220
|
/** Available for the application to store data on the device */
|
|
1122
1221
|
userData = {};
|
|
1222
|
+
/** stats */
|
|
1223
|
+
statsManager = lumaStats;
|
|
1123
1224
|
/** Used by other luma.gl modules to store data on the device */
|
|
1124
1225
|
_lumaData = {};
|
|
1226
|
+
/** Check if a specific texture format is GPU compressed */
|
|
1227
|
+
isTextureFormatCompressed(format) {
|
|
1228
|
+
return isTextureFormatCompressed(format);
|
|
1229
|
+
}
|
|
1125
1230
|
/**
|
|
1126
1231
|
* Trigger device loss.
|
|
1127
1232
|
* @returns `true` if context loss could actually be triggered.
|
|
@@ -1172,7 +1277,17 @@ var __exports__ = (() => {
|
|
|
1172
1277
|
clearWebGL(options) {
|
|
1173
1278
|
throw new Error("not implemented");
|
|
1174
1279
|
}
|
|
1175
|
-
|
|
1280
|
+
timestamp = 0;
|
|
1281
|
+
/** A monotonic counter for tracking buffer and texture updates */
|
|
1282
|
+
incrementTimestamp() {
|
|
1283
|
+
return this.timestamp++;
|
|
1284
|
+
}
|
|
1285
|
+
// Error Handling
|
|
1286
|
+
/** Report unhandled device errors */
|
|
1287
|
+
onError(error) {
|
|
1288
|
+
this.props.onError(error);
|
|
1289
|
+
}
|
|
1290
|
+
// IMPLEMENTATION
|
|
1176
1291
|
_getBufferProps(props) {
|
|
1177
1292
|
if (props instanceof ArrayBuffer || ArrayBuffer.isView(props)) {
|
|
1178
1293
|
props = { data: props };
|
|
@@ -1193,16 +1308,23 @@ var __exports__ = (() => {
|
|
|
1193
1308
|
var Device = _Device;
|
|
1194
1309
|
__publicField(Device, "defaultProps", {
|
|
1195
1310
|
id: null,
|
|
1196
|
-
type: "best-available",
|
|
1197
1311
|
canvas: null,
|
|
1198
1312
|
container: null,
|
|
1199
1313
|
manageState: true,
|
|
1200
1314
|
width: 800,
|
|
1201
1315
|
// width are height are only used by headless gl
|
|
1202
1316
|
height: 600,
|
|
1317
|
+
requestMaxLimits: true,
|
|
1203
1318
|
debug: Boolean(log.get("debug")),
|
|
1204
1319
|
// Instrument context (at the expense of performance)
|
|
1320
|
+
spector: Boolean(log.get("spector")),
|
|
1321
|
+
// Initialize the SpectorJS WebGL debugger
|
|
1205
1322
|
break: [],
|
|
1323
|
+
// TODO - Change these after confirming things work as expected
|
|
1324
|
+
initalizeFeatures: true,
|
|
1325
|
+
disabledFeatures: {
|
|
1326
|
+
"compilation-status-async-webgl": true
|
|
1327
|
+
},
|
|
1206
1328
|
// alpha: undefined,
|
|
1207
1329
|
// depth: undefined,
|
|
1208
1330
|
// stencil: undefined,
|
|
@@ -1210,7 +1332,9 @@ var __exports__ = (() => {
|
|
|
1210
1332
|
// premultipliedAlpha: undefined,
|
|
1211
1333
|
// preserveDrawingBuffer: undefined,
|
|
1212
1334
|
// failIfMajorPerformanceCaveat: undefined
|
|
1213
|
-
gl: null
|
|
1335
|
+
gl: null,
|
|
1336
|
+
// Callbacks
|
|
1337
|
+
onError: (error) => log.error(error.message)
|
|
1214
1338
|
});
|
|
1215
1339
|
__publicField(Device, "VERSION", VERSION2);
|
|
1216
1340
|
|
|
@@ -1511,6 +1635,9 @@ var __exports__ = (() => {
|
|
|
1511
1635
|
height;
|
|
1512
1636
|
/** depth of this texture */
|
|
1513
1637
|
depth;
|
|
1638
|
+
/** "Time" of last update. Monotonically increasing timestamp */
|
|
1639
|
+
updateTimestamp;
|
|
1640
|
+
/** Do not use directly. Create with device.createTexture() */
|
|
1514
1641
|
constructor(device, props, defaultProps = _Texture.defaultProps) {
|
|
1515
1642
|
super(device, props, defaultProps);
|
|
1516
1643
|
this.dimension = this.props.dimension;
|
|
@@ -1518,6 +1645,7 @@ var __exports__ = (() => {
|
|
|
1518
1645
|
this.width = this.props.width;
|
|
1519
1646
|
this.height = this.props.height;
|
|
1520
1647
|
this.depth = this.props.depth;
|
|
1648
|
+
this.updateTimestamp = device.incrementTimestamp();
|
|
1521
1649
|
}
|
|
1522
1650
|
};
|
|
1523
1651
|
var Texture = _Texture;
|
|
@@ -1530,7 +1658,6 @@ var __exports__ = (() => {
|
|
|
1530
1658
|
height: void 0,
|
|
1531
1659
|
depth: 1,
|
|
1532
1660
|
mipmaps: true,
|
|
1533
|
-
sampler: {},
|
|
1534
1661
|
// type: undefined,
|
|
1535
1662
|
compressed: false,
|
|
1536
1663
|
// mipLevels: 1,
|
|
@@ -1538,7 +1665,9 @@ var __exports__ = (() => {
|
|
|
1538
1665
|
// usage: GPUTextureUsage.COPY_DST
|
|
1539
1666
|
mipLevels: void 0,
|
|
1540
1667
|
samples: void 0,
|
|
1541
|
-
type: void 0
|
|
1668
|
+
type: void 0,
|
|
1669
|
+
sampler: {},
|
|
1670
|
+
view: void 0
|
|
1542
1671
|
});
|
|
1543
1672
|
__publicField(Texture, "COPY_SRC", 1);
|
|
1544
1673
|
__publicField(Texture, "COPY_DST", 2);
|
|
@@ -1546,6 +1675,28 @@ var __exports__ = (() => {
|
|
|
1546
1675
|
__publicField(Texture, "STORAGE_BINDING", 8);
|
|
1547
1676
|
__publicField(Texture, "RENDER_ATTACHMENT", 16);
|
|
1548
1677
|
|
|
1678
|
+
// ../core/src/adapter/resources/texture-view.ts
|
|
1679
|
+
var _TextureView = class extends Resource {
|
|
1680
|
+
get [Symbol.toStringTag]() {
|
|
1681
|
+
return "TextureView";
|
|
1682
|
+
}
|
|
1683
|
+
/** Should not be constructed directly. Use `texture.createView(props)` */
|
|
1684
|
+
constructor(device, props) {
|
|
1685
|
+
super(device, props, _TextureView.defaultProps);
|
|
1686
|
+
}
|
|
1687
|
+
};
|
|
1688
|
+
var TextureView = _TextureView;
|
|
1689
|
+
__publicField(TextureView, "defaultProps", {
|
|
1690
|
+
...Resource.defaultProps,
|
|
1691
|
+
format: void 0,
|
|
1692
|
+
dimension: void 0,
|
|
1693
|
+
aspect: "all",
|
|
1694
|
+
baseMipLevel: 0,
|
|
1695
|
+
mipLevelCount: void 0,
|
|
1696
|
+
baseArrayLayer: 0,
|
|
1697
|
+
arrayLayerCount: void 0
|
|
1698
|
+
});
|
|
1699
|
+
|
|
1549
1700
|
// ../core/src/lib/compiler-log/format-compiler-log.ts
|
|
1550
1701
|
function formatCompilerLog(shaderLog, source, options) {
|
|
1551
1702
|
let formattedLog = "";
|
|
@@ -1658,10 +1809,14 @@ ${numberedLines}${positionIndicator}${message2.type.toUpperCase()}: ${message2.m
|
|
|
1658
1809
|
getCompilationInfoSync() {
|
|
1659
1810
|
return null;
|
|
1660
1811
|
}
|
|
1812
|
+
/** Get translated shader source in host platform's native language (HLSL, GLSL, and even GLSL ES), if available */
|
|
1813
|
+
getTranslatedSource() {
|
|
1814
|
+
return null;
|
|
1815
|
+
}
|
|
1661
1816
|
// PORTABLE HELPERS
|
|
1662
1817
|
/** In browser logging of errors */
|
|
1663
|
-
async debugShader() {
|
|
1664
|
-
switch (
|
|
1818
|
+
async debugShader(trigger = this.props.debug) {
|
|
1819
|
+
switch (trigger) {
|
|
1665
1820
|
case "never":
|
|
1666
1821
|
return;
|
|
1667
1822
|
case "errors":
|
|
@@ -1687,7 +1842,11 @@ ${numberedLines}${positionIndicator}${message2.type.toUpperCase()}: ${message2.m
|
|
|
1687
1842
|
}
|
|
1688
1843
|
const shaderName = getShaderInfo(this.source).name;
|
|
1689
1844
|
const shaderTitle = `${this.stage} ${shaderName}`;
|
|
1690
|
-
|
|
1845
|
+
let htmlLog = formatCompilerLog(messages, this.source, { showSourceCode: "all", html: true });
|
|
1846
|
+
const translatedSource = this.getTranslatedSource();
|
|
1847
|
+
if (translatedSource) {
|
|
1848
|
+
htmlLog += `<br /><br /><h1>Translated Source</h1><br /><br /><code style="user-select:text;"><pre>${translatedSource}</pre></code>`;
|
|
1849
|
+
}
|
|
1691
1850
|
const button = document.createElement("Button");
|
|
1692
1851
|
button.innerHTML = `
|
|
1693
1852
|
<h1>Shader Compilation Error in ${shaderTitle}</h1><br /><br />
|
|
@@ -1715,7 +1874,7 @@ ${htmlLog}
|
|
|
1715
1874
|
__publicField(Shader, "defaultProps", {
|
|
1716
1875
|
...Resource.defaultProps,
|
|
1717
1876
|
language: "auto",
|
|
1718
|
-
stage:
|
|
1877
|
+
stage: void 0,
|
|
1719
1878
|
source: "",
|
|
1720
1879
|
sourceMap: null,
|
|
1721
1880
|
entryPoint: "main",
|
|
@@ -1782,67 +1941,32 @@ ${htmlLog}
|
|
|
1782
1941
|
this.resizeAttachments(this.width, this.height);
|
|
1783
1942
|
}
|
|
1784
1943
|
}
|
|
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
1944
|
/** Auto creates any textures */
|
|
1830
1945
|
autoCreateAttachmentTextures() {
|
|
1831
|
-
this.colorAttachments
|
|
1832
|
-
|
|
1833
|
-
|
|
1946
|
+
if (this.props.colorAttachments.length === 0 && !this.props.depthStencilAttachment) {
|
|
1947
|
+
throw new Error("Framebuffer has noattachments");
|
|
1948
|
+
}
|
|
1949
|
+
this.colorAttachments = this.props.colorAttachments.map((attachment2) => {
|
|
1950
|
+
if (typeof attachment2 === "string") {
|
|
1951
|
+
const texture = this.createColorTexture(attachment2);
|
|
1834
1952
|
this.attachResource(texture);
|
|
1835
|
-
return texture;
|
|
1953
|
+
return texture.view;
|
|
1836
1954
|
}
|
|
1837
|
-
|
|
1955
|
+
if (attachment2 instanceof Texture) {
|
|
1956
|
+
return attachment2.view;
|
|
1957
|
+
}
|
|
1958
|
+
return attachment2;
|
|
1838
1959
|
});
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1960
|
+
const attachment = this.props.depthStencilAttachment;
|
|
1961
|
+
if (attachment) {
|
|
1962
|
+
if (typeof attachment === "string") {
|
|
1963
|
+
const texture = this.createDepthStencilTexture(attachment);
|
|
1842
1964
|
this.attachResource(texture);
|
|
1843
|
-
this.depthStencilAttachment = texture;
|
|
1965
|
+
this.depthStencilAttachment = texture.view;
|
|
1966
|
+
} else if (attachment instanceof Texture) {
|
|
1967
|
+
this.depthStencilAttachment = attachment.view;
|
|
1844
1968
|
} else {
|
|
1845
|
-
this.depthStencilAttachment =
|
|
1969
|
+
this.depthStencilAttachment = attachment;
|
|
1846
1970
|
}
|
|
1847
1971
|
}
|
|
1848
1972
|
}
|
|
@@ -1880,8 +2004,8 @@ ${htmlLog}
|
|
|
1880
2004
|
height
|
|
1881
2005
|
});
|
|
1882
2006
|
this.destroyAttachedResource(this.colorAttachments[i]);
|
|
1883
|
-
this.colorAttachments[i] = resizedTexture;
|
|
1884
|
-
this.attachResource(resizedTexture);
|
|
2007
|
+
this.colorAttachments[i] = resizedTexture.view;
|
|
2008
|
+
this.attachResource(resizedTexture.view);
|
|
1885
2009
|
}
|
|
1886
2010
|
}
|
|
1887
2011
|
if (this.depthStencilAttachment) {
|
|
@@ -1891,41 +2015,10 @@ ${htmlLog}
|
|
|
1891
2015
|
height
|
|
1892
2016
|
});
|
|
1893
2017
|
this.destroyAttachedResource(this.depthStencilAttachment);
|
|
1894
|
-
this.depthStencilAttachment = resizedTexture;
|
|
2018
|
+
this.depthStencilAttachment = resizedTexture.view;
|
|
1895
2019
|
this.attachResource(resizedTexture);
|
|
1896
2020
|
}
|
|
1897
2021
|
}
|
|
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
2022
|
};
|
|
1930
2023
|
var Framebuffer = _Framebuffer;
|
|
1931
2024
|
__publicField(Framebuffer, "defaultProps", {
|
|
@@ -1933,7 +2026,7 @@ ${htmlLog}
|
|
|
1933
2026
|
width: 1,
|
|
1934
2027
|
height: 1,
|
|
1935
2028
|
colorAttachments: [],
|
|
1936
|
-
// ['rgba8unorm
|
|
2029
|
+
// ['rgba8unorm'],
|
|
1937
2030
|
depthStencilAttachment: null
|
|
1938
2031
|
// 'depth24plus-stencil8'
|
|
1939
2032
|
});
|
|
@@ -1943,29 +2036,38 @@ ${htmlLog}
|
|
|
1943
2036
|
get [Symbol.toStringTag]() {
|
|
1944
2037
|
return "RenderPipeline";
|
|
1945
2038
|
}
|
|
1946
|
-
hash = "";
|
|
1947
2039
|
/** The merged layout */
|
|
1948
2040
|
shaderLayout;
|
|
1949
2041
|
/** Buffer map describing buffer interleaving etc */
|
|
1950
2042
|
bufferLayout;
|
|
1951
2043
|
/** The linking status of the pipeline. 'pending' if linking is asynchronous, and on production */
|
|
1952
2044
|
linkStatus = "pending";
|
|
2045
|
+
/** The hash of the pipeline */
|
|
2046
|
+
hash = "";
|
|
1953
2047
|
constructor(device, props) {
|
|
1954
2048
|
super(device, props, _RenderPipeline.defaultProps);
|
|
1955
2049
|
this.shaderLayout = this.props.shaderLayout;
|
|
1956
2050
|
this.bufferLayout = this.props.bufferLayout || [];
|
|
1957
2051
|
}
|
|
2052
|
+
// DEPRECATED METHODS
|
|
2053
|
+
/**
|
|
2054
|
+
* Uniforms
|
|
2055
|
+
* @deprecated Use uniforms buffers
|
|
2056
|
+
* @note textures, samplers and uniform buffers should be set via `setBindings()`, these are not considered uniforms.
|
|
2057
|
+
* @note In WebGL uniforms have a performance penalty, they are reset before each call to enable pipeline sharing.
|
|
2058
|
+
*/
|
|
2059
|
+
setUniformsWebGL(uniforms) {
|
|
2060
|
+
throw new Error("Use uniform blocks");
|
|
2061
|
+
}
|
|
1958
2062
|
};
|
|
1959
2063
|
var RenderPipeline = _RenderPipeline;
|
|
1960
2064
|
__publicField(RenderPipeline, "defaultProps", {
|
|
1961
2065
|
...Resource.defaultProps,
|
|
1962
2066
|
vs: null,
|
|
1963
|
-
|
|
1964
|
-
// main
|
|
2067
|
+
vertexEntryPoint: "vertexMain",
|
|
1965
2068
|
vsConstants: {},
|
|
1966
2069
|
fs: null,
|
|
1967
|
-
|
|
1968
|
-
// main
|
|
2070
|
+
fragmentEntryPoint: "fragmentMain",
|
|
1969
2071
|
fsConstants: {},
|
|
1970
2072
|
shaderLayout: null,
|
|
1971
2073
|
bufferLayout: [],
|
|
@@ -1985,41 +2087,17 @@ ${htmlLog}
|
|
|
1985
2087
|
constructor(device, props) {
|
|
1986
2088
|
super(device, props, _RenderPass.defaultProps);
|
|
1987
2089
|
}
|
|
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
|
-
*/
|
|
2090
|
+
// In WebGPU the following methods are on the renderpass instead of the renderpipeline
|
|
2091
|
+
// luma.gl keeps them on the pipeline for now.
|
|
2092
|
+
// TODO - Can we align WebGL implementation with WebGPU API?
|
|
2093
|
+
// abstract setPipeline(pipeline: RenderPipeline): void {}
|
|
2094
|
+
// abstract setIndexBuffer()
|
|
2095
|
+
// abstract setVertexBuffer(slot: number, buffer: Buffer, offset: number): void;
|
|
2096
|
+
// abstract setBindings(bindings: Record<string, Binding>): void;
|
|
2097
|
+
// abstract setParameters(parameters: RenderPassParameters);
|
|
2098
|
+
// abstract draw(options: {
|
|
2099
|
+
// abstract drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
|
|
2100
|
+
// abstract drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
|
|
2023
2101
|
};
|
|
2024
2102
|
var RenderPass = _RenderPass;
|
|
2025
2103
|
/** Default properties for RenderPass */
|
|
@@ -2032,7 +2110,11 @@ ${htmlLog}
|
|
|
2032
2110
|
clearStencil: 0,
|
|
2033
2111
|
depthReadOnly: false,
|
|
2034
2112
|
stencilReadOnly: false,
|
|
2035
|
-
discard: false
|
|
2113
|
+
discard: false,
|
|
2114
|
+
occlusionQuerySet: void 0,
|
|
2115
|
+
timestampQuerySet: void 0,
|
|
2116
|
+
beginTimestampIndex: void 0,
|
|
2117
|
+
endTimestampIndex: void 0
|
|
2036
2118
|
});
|
|
2037
2119
|
|
|
2038
2120
|
// ../core/src/adapter/resources/command-encoder.ts
|
|
@@ -2043,20 +2125,9 @@ ${htmlLog}
|
|
|
2043
2125
|
constructor(device, props) {
|
|
2044
2126
|
super(device, props, _CommandEncoder.defaultProps);
|
|
2045
2127
|
}
|
|
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;
|
|
2128
|
+
// TODO - luma.gl has these on the device, should we align with WebGPU API?
|
|
2129
|
+
// beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;
|
|
2130
|
+
// beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;
|
|
2060
2131
|
};
|
|
2061
2132
|
var CommandEncoder = _CommandEncoder;
|
|
2062
2133
|
__publicField(CommandEncoder, "defaultProps", {
|
|
@@ -2083,7 +2154,7 @@ ${htmlLog}
|
|
|
2083
2154
|
const [dataType, components] = TYPE_INFO[attributeType];
|
|
2084
2155
|
const integer = dataType === "i32" || dataType === "u32";
|
|
2085
2156
|
const signed = dataType !== "u32";
|
|
2086
|
-
const byteLength =
|
|
2157
|
+
const byteLength = TYPE_SIZES2[dataType] * components;
|
|
2087
2158
|
const defaultVertexFormat = getCompatibleVertexFormat(dataType, components);
|
|
2088
2159
|
return {
|
|
2089
2160
|
dataType,
|
|
@@ -2132,56 +2203,12 @@ ${htmlLog}
|
|
|
2132
2203
|
"vec3<u32>": ["u32", 3],
|
|
2133
2204
|
"vec4<u32>": ["u32", 4]
|
|
2134
2205
|
};
|
|
2135
|
-
var
|
|
2206
|
+
var TYPE_SIZES2 = {
|
|
2136
2207
|
f32: 4,
|
|
2137
2208
|
f16: 2,
|
|
2138
2209
|
i32: 4,
|
|
2139
2210
|
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
|
|
2211
|
+
// 'bool-webgl': 4,
|
|
2185
2212
|
};
|
|
2186
2213
|
|
|
2187
2214
|
// ../core/src/adapter/type-utils/decode-vertex-format.ts
|
|
@@ -2363,6 +2390,11 @@ ${htmlLog}
|
|
|
2363
2390
|
this.maxVertexAttributes
|
|
2364
2391
|
);
|
|
2365
2392
|
}
|
|
2393
|
+
// DEPRECATED METHODS
|
|
2394
|
+
/** @deprecated Set constant attributes (WebGL only) */
|
|
2395
|
+
setConstantWebGL(location, value) {
|
|
2396
|
+
throw new Error("constant attributes not supported");
|
|
2397
|
+
}
|
|
2366
2398
|
};
|
|
2367
2399
|
var VertexArray = _VertexArray;
|
|
2368
2400
|
__publicField(VertexArray, "defaultProps", {
|
|
@@ -2386,6 +2418,22 @@ ${htmlLog}
|
|
|
2386
2418
|
buffers: {}
|
|
2387
2419
|
});
|
|
2388
2420
|
|
|
2421
|
+
// ../core/src/adapter/resources/query-set.ts
|
|
2422
|
+
var _QuerySet = class extends Resource {
|
|
2423
|
+
get [Symbol.toStringTag]() {
|
|
2424
|
+
return "QuerySet";
|
|
2425
|
+
}
|
|
2426
|
+
constructor(device, props) {
|
|
2427
|
+
super(device, props, _QuerySet.defaultProps);
|
|
2428
|
+
}
|
|
2429
|
+
};
|
|
2430
|
+
var QuerySet = _QuerySet;
|
|
2431
|
+
__publicField(QuerySet, "defaultProps", {
|
|
2432
|
+
...Resource.defaultProps,
|
|
2433
|
+
type: void 0,
|
|
2434
|
+
count: void 0
|
|
2435
|
+
});
|
|
2436
|
+
|
|
2389
2437
|
// ../core/src/utils/array-utils-flat.ts
|
|
2390
2438
|
var arrayBuffer;
|
|
2391
2439
|
function getScratchArrayBuffer(byteLength) {
|
|
@@ -2418,63 +2466,6 @@ ${htmlLog}
|
|
|
2418
2466
|
return options.target;
|
|
2419
2467
|
}
|
|
2420
2468
|
|
|
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
2469
|
// ../core/src/utils/cast.ts
|
|
2479
2470
|
function cast(value) {
|
|
2480
2471
|
return value;
|
|
@@ -2543,7 +2534,7 @@ ${htmlLog}
|
|
|
2543
2534
|
// ../core/src/utils/load-file.ts
|
|
2544
2535
|
var pathPrefix = "";
|
|
2545
2536
|
async function loadImage(url, opts) {
|
|
2546
|
-
return new Promise((resolve, reject) => {
|
|
2537
|
+
return await new Promise((resolve, reject) => {
|
|
2547
2538
|
try {
|
|
2548
2539
|
const image = new Image();
|
|
2549
2540
|
image.onload = () => resolve(image);
|
|
@@ -2633,14 +2624,6 @@ ${htmlLog}
|
|
|
2633
2624
|
[import_constants.GL.STENCIL_BACK_PASS_DEPTH_PASS]: import_constants.GL.KEEP,
|
|
2634
2625
|
// Dynamic value: We use [0, 0, 1024, 1024] as default, but usually this is updated in each frame.
|
|
2635
2626
|
[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
2627
|
[import_constants.GL.TRANSFORM_FEEDBACK_BINDING]: null,
|
|
2645
2628
|
[import_constants.GL.COPY_READ_BUFFER_BINDING]: null,
|
|
2646
2629
|
[import_constants.GL.COPY_WRITE_BUFFER_BINDING]: null,
|
|
@@ -2649,6 +2632,11 @@ ${htmlLog}
|
|
|
2649
2632
|
[import_constants.GL.FRAGMENT_SHADER_DERIVATIVE_HINT]: import_constants.GL.DONT_CARE,
|
|
2650
2633
|
[import_constants.GL.READ_FRAMEBUFFER_BINDING]: null,
|
|
2651
2634
|
[import_constants.GL.RASTERIZER_DISCARD]: false,
|
|
2635
|
+
[import_constants.GL.PACK_ALIGNMENT]: 4,
|
|
2636
|
+
[import_constants.GL.UNPACK_ALIGNMENT]: 4,
|
|
2637
|
+
[import_constants.GL.UNPACK_FLIP_Y_WEBGL]: false,
|
|
2638
|
+
[import_constants.GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]: false,
|
|
2639
|
+
[import_constants.GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]: import_constants.GL.BROWSER_DEFAULT_WEBGL,
|
|
2652
2640
|
[import_constants.GL.PACK_ROW_LENGTH]: 0,
|
|
2653
2641
|
[import_constants.GL.PACK_SKIP_PIXELS]: 0,
|
|
2654
2642
|
[import_constants.GL.PACK_SKIP_ROWS]: 0,
|
|
@@ -2742,14 +2730,29 @@ ${htmlLog}
|
|
|
2742
2730
|
[import_constants.GL.STENCIL_BACK_PASS_DEPTH_FAIL]: "stencilOpBack",
|
|
2743
2731
|
[import_constants.GL.STENCIL_BACK_PASS_DEPTH_PASS]: "stencilOpBack",
|
|
2744
2732
|
[import_constants.GL.VIEWPORT]: (gl, value) => gl.viewport(...value),
|
|
2745
|
-
//
|
|
2733
|
+
// WEBGL2 EXTENSIONS
|
|
2734
|
+
// EXT_depth_clamp https://registry.khronos.org/webgl/extensions/EXT_depth_clamp/
|
|
2735
|
+
[import_constants.GL.DEPTH_CLAMP_EXT]: enable,
|
|
2736
|
+
// WEBGL_provoking_vertex https://registry.khronos.org/webgl/extensions/WEBGL_provoking_vertex/
|
|
2737
|
+
// [GL.PROVOKING_VERTEX_WEBL]: TODO - extension function needed
|
|
2738
|
+
// WEBGL_polygon_mode https://registry.khronos.org/webgl/extensions/WEBGL_polygon_mode/
|
|
2739
|
+
// POLYGON_MODE_WEBGL TODO - extension function needed
|
|
2740
|
+
[import_constants.GL.POLYGON_OFFSET_LINE_WEBGL]: enable,
|
|
2741
|
+
// WEBGL_clip_cull_distance https://registry.khronos.org/webgl/extensions/WEBGL_clip_cull_distance/
|
|
2742
|
+
[import_constants.GL.CLIP_DISTANCE0_WEBGL]: enable,
|
|
2743
|
+
[import_constants.GL.CLIP_DISTANCE1_WEBGL]: enable,
|
|
2744
|
+
[import_constants.GL.CLIP_DISTANCE2_WEBGL]: enable,
|
|
2745
|
+
[import_constants.GL.CLIP_DISTANCE3_WEBGL]: enable,
|
|
2746
|
+
[import_constants.GL.CLIP_DISTANCE4_WEBGL]: enable,
|
|
2747
|
+
[import_constants.GL.CLIP_DISTANCE5_WEBGL]: enable,
|
|
2748
|
+
[import_constants.GL.CLIP_DISTANCE6_WEBGL]: enable,
|
|
2749
|
+
[import_constants.GL.CLIP_DISTANCE7_WEBGL]: enable,
|
|
2750
|
+
// PIXEL PACK/UNPACK MODES
|
|
2746
2751
|
[import_constants.GL.PACK_ALIGNMENT]: pixelStorei,
|
|
2747
2752
|
[import_constants.GL.UNPACK_ALIGNMENT]: pixelStorei,
|
|
2748
2753
|
[import_constants.GL.UNPACK_FLIP_Y_WEBGL]: pixelStorei,
|
|
2749
2754
|
[import_constants.GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]: pixelStorei,
|
|
2750
2755
|
[import_constants.GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]: pixelStorei,
|
|
2751
|
-
// WEBGL2 PIXEL PACK/UNPACK MODES
|
|
2752
|
-
// RASTERIZER_DISCARD ...
|
|
2753
2756
|
[import_constants.GL.PACK_ROW_LENGTH]: pixelStorei,
|
|
2754
2757
|
[import_constants.GL.PACK_SKIP_PIXELS]: pixelStorei,
|
|
2755
2758
|
[import_constants.GL.PACK_SKIP_ROWS]: pixelStorei,
|
|
@@ -3072,9 +3075,7 @@ ${htmlLog}
|
|
|
3072
3075
|
]);
|
|
3073
3076
|
|
|
3074
3077
|
// src/context/parameters/unified-parameter-api.ts
|
|
3075
|
-
function setGLParameters(
|
|
3076
|
-
const webglDevice = WebGLDevice.attach(device);
|
|
3077
|
-
const gl = webglDevice.gl;
|
|
3078
|
+
function setGLParameters(gl, parameters) {
|
|
3078
3079
|
if (isObjectEmpty2(parameters)) {
|
|
3079
3080
|
return;
|
|
3080
3081
|
}
|
|
@@ -3098,9 +3099,7 @@ ${htmlLog}
|
|
|
3098
3099
|
}
|
|
3099
3100
|
}
|
|
3100
3101
|
}
|
|
3101
|
-
function getGLParameters(
|
|
3102
|
-
const webglDevice = WebGLDevice.attach(device);
|
|
3103
|
-
const gl = webglDevice.gl;
|
|
3102
|
+
function getGLParameters(gl, parameters = GL_PARAMETER_DEFAULTS) {
|
|
3104
3103
|
if (typeof parameters === "number") {
|
|
3105
3104
|
const key = parameters;
|
|
3106
3105
|
const getter = GL_PARAMETER_GETTERS[key];
|
|
@@ -3114,8 +3113,8 @@ ${htmlLog}
|
|
|
3114
3113
|
}
|
|
3115
3114
|
return state;
|
|
3116
3115
|
}
|
|
3117
|
-
function resetGLParameters(
|
|
3118
|
-
setGLParameters(
|
|
3116
|
+
function resetGLParameters(gl) {
|
|
3117
|
+
setGLParameters(gl, GL_PARAMETER_DEFAULTS);
|
|
3119
3118
|
}
|
|
3120
3119
|
function isObjectEmpty2(object) {
|
|
3121
3120
|
for (const key in object) {
|
|
@@ -3283,7 +3282,7 @@ ${htmlLog}
|
|
|
3283
3282
|
};
|
|
3284
3283
|
}
|
|
3285
3284
|
|
|
3286
|
-
// src/context/
|
|
3285
|
+
// src/context/helpers/create-browser-context.ts
|
|
3287
3286
|
var DEFAULT_CONTEXT_PROPS = {
|
|
3288
3287
|
powerPreference: "high-performance",
|
|
3289
3288
|
// After all, most apps are using WebGL for performance reasons
|
|
@@ -3320,10 +3319,21 @@ ${htmlLog}
|
|
|
3320
3319
|
|
|
3321
3320
|
// src/adapter/device-helpers/webgl-device-info.ts
|
|
3322
3321
|
var import_constants2 = __toESM(require_constants(), 1);
|
|
3323
|
-
|
|
3322
|
+
|
|
3323
|
+
// src/context/helpers/webgl-extensions.ts
|
|
3324
|
+
function getWebGLExtension(gl, name2, extensions) {
|
|
3325
|
+
if (extensions[name2] === void 0) {
|
|
3326
|
+
extensions[name2] = gl.getExtension(name2) || null;
|
|
3327
|
+
}
|
|
3328
|
+
return extensions[name2];
|
|
3329
|
+
}
|
|
3330
|
+
|
|
3331
|
+
// src/adapter/device-helpers/webgl-device-info.ts
|
|
3332
|
+
function getDeviceInfo(gl, extensions) {
|
|
3324
3333
|
const vendorMasked = gl.getParameter(import_constants2.GL.VENDOR);
|
|
3325
3334
|
const rendererMasked = gl.getParameter(import_constants2.GL.RENDERER);
|
|
3326
|
-
|
|
3335
|
+
getWebGLExtension(gl, "WEBGL_debug_renderer_info", extensions);
|
|
3336
|
+
const ext = extensions.WEBGL_debug_renderer_info;
|
|
3327
3337
|
const vendorUnmasked = gl.getParameter(ext ? ext.UNMASKED_VENDOR_WEBGL : import_constants2.GL.VENDOR);
|
|
3328
3338
|
const rendererUnmasked = gl.getParameter(ext ? ext.UNMASKED_RENDERER_WEBGL : import_constants2.GL.RENDERER);
|
|
3329
3339
|
const vendor = vendorUnmasked || vendorMasked;
|
|
@@ -3432,6 +3442,14 @@ ${htmlLog}
|
|
|
3432
3442
|
var texture_compression_etc1_webgl = "texture-compression-etc1-webgl";
|
|
3433
3443
|
var texture_compression_pvrtc_webgl = "texture-compression-pvrtc-webgl";
|
|
3434
3444
|
var texture_compression_atc_webgl = "texture-compression-atc-webgl";
|
|
3445
|
+
var float32_renderable = "float32-renderable-webgl";
|
|
3446
|
+
var float16_renderable = "float16-renderable-webgl";
|
|
3447
|
+
var rgb9e5ufloat_renderable = "rgb9e5ufloat_renderable-webgl";
|
|
3448
|
+
var snorm8_renderable = "snorm8-renderable-webgl";
|
|
3449
|
+
var norm16_renderable = "norm16-renderable-webgl";
|
|
3450
|
+
var snorm16_renderable = "snorm16-renderable-webgl";
|
|
3451
|
+
var float32_filterable = "float32-filterable";
|
|
3452
|
+
var float16_filterable = "float16-filterable-webgl";
|
|
3435
3453
|
var X_S3TC = "WEBGL_compressed_texture_s3tc";
|
|
3436
3454
|
var X_S3TC_SRGB = "WEBGL_compressed_texture_s3tc_srgb";
|
|
3437
3455
|
var X_RGTC = "EXT_texture_compression_rgtc";
|
|
@@ -3441,15 +3459,18 @@ ${htmlLog}
|
|
|
3441
3459
|
var X_ETC1 = "WEBGL_compressed_texture_etc1";
|
|
3442
3460
|
var X_PVRTC = "WEBGL_compressed_texture_pvrtc";
|
|
3443
3461
|
var X_ATC = "WEBGL_compressed_texture_atc";
|
|
3444
|
-
var
|
|
3445
|
-
var
|
|
3446
|
-
var
|
|
3462
|
+
var EXT_texture_norm16 = "EXT_texture_norm16";
|
|
3463
|
+
var EXT_render_snorm = "EXT_render_snorm";
|
|
3464
|
+
var EXT_color_buffer_float = "EXT_color_buffer_float";
|
|
3465
|
+
var TEXTURE_FEATURES = {
|
|
3447
3466
|
"float32-renderable-webgl": ["EXT_color_buffer_float"],
|
|
3448
|
-
// [false, 'EXT_color_buffer_float'],
|
|
3449
3467
|
"float16-renderable-webgl": ["EXT_color_buffer_half_float"],
|
|
3450
|
-
"
|
|
3451
|
-
"
|
|
3452
|
-
"
|
|
3468
|
+
"rgb9e5ufloat_renderable-webgl": ["WEBGL_render_shared_exponent"],
|
|
3469
|
+
"snorm8-renderable-webgl": [EXT_render_snorm],
|
|
3470
|
+
"norm16-renderable-webgl": [EXT_texture_norm16],
|
|
3471
|
+
"snorm16-renderable-webgl": [EXT_texture_norm16, EXT_render_snorm],
|
|
3472
|
+
"float32-filterable": ["OES_texture_float_linear"],
|
|
3473
|
+
"float16-filterable-webgl": ["OES_texture_half_float_linear"],
|
|
3453
3474
|
"texture-filterable-anisotropic-webgl": ["EXT_texture_filter_anisotropic"],
|
|
3454
3475
|
"texture-blend-float-webgl": ["EXT_float_blend"],
|
|
3455
3476
|
"texture-compression-bc": [X_S3TC, X_S3TC_SRGB, X_RGTC, X_BPTC],
|
|
@@ -3463,18 +3484,15 @@ ${htmlLog}
|
|
|
3463
3484
|
"texture-compression-pvrtc-webgl": [X_PVRTC],
|
|
3464
3485
|
"texture-compression-atc-webgl": [X_ATC]
|
|
3465
3486
|
};
|
|
3466
|
-
function
|
|
3467
|
-
|
|
3468
|
-
return extensions.every((extension) => gl.getExtension(extension));
|
|
3487
|
+
function isTextureFeature(feature) {
|
|
3488
|
+
return feature in TEXTURE_FEATURES;
|
|
3469
3489
|
}
|
|
3470
|
-
function
|
|
3471
|
-
const
|
|
3472
|
-
return
|
|
3490
|
+
function checkTextureFeature(gl, feature, extensions) {
|
|
3491
|
+
const textureExtensions = TEXTURE_FEATURES[feature] || [];
|
|
3492
|
+
return textureExtensions.every((extension) => getWebGLExtension(gl, extension, extensions));
|
|
3473
3493
|
}
|
|
3474
3494
|
var TEXTURE_FORMATS = {
|
|
3475
|
-
// Unsized formats that leave the precision up to the driver.
|
|
3476
|
-
// TODO - Fix bpp constants
|
|
3477
|
-
// 'r8unorm-unsized': {gl: GL.LUMINANCE, b: 4, c: 2, bpp: 4},
|
|
3495
|
+
// Unsized formats that leave the precision up to the driver. TODO - Fix bpp constants
|
|
3478
3496
|
"rgb8unorm-unsized": {
|
|
3479
3497
|
gl: import_constants4.GL.RGB,
|
|
3480
3498
|
b: 4,
|
|
@@ -3491,34 +3509,35 @@ ${htmlLog}
|
|
|
3491
3509
|
dataFormat: import_constants4.GL.RGBA,
|
|
3492
3510
|
types: [import_constants4.GL.UNSIGNED_BYTE, import_constants4.GL.UNSIGNED_SHORT_4_4_4_4, import_constants4.GL.UNSIGNED_SHORT_5_5_5_1]
|
|
3493
3511
|
},
|
|
3512
|
+
// 'r8unorm-unsized': {gl: GL.LUMINANCE, b: 4, c: 2, bpp: 4},
|
|
3494
3513
|
// 'rgb8unorm-srgb-unsized': {gl: GL.SRGB_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
|
|
3495
3514
|
// 'rgba8unorm-srgb-unsized': {gl: GL.SRGB_ALPHA_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
|
|
3496
3515
|
// 8-bit formats
|
|
3497
|
-
"r8unorm": { gl: import_constants4.GL.R8, b: 1, c: 1,
|
|
3498
|
-
"r8snorm": { gl: import_constants4.GL.R8_SNORM, b: 1, c: 1 },
|
|
3499
|
-
"r8uint": { gl: import_constants4.GL.R8UI, b: 1, c: 1,
|
|
3500
|
-
"r8sint": { gl: import_constants4.GL.R8I, b: 1, c: 1,
|
|
3516
|
+
"r8unorm": { gl: import_constants4.GL.R8, b: 1, c: 1, rb: true },
|
|
3517
|
+
"r8snorm": { gl: import_constants4.GL.R8_SNORM, b: 1, c: 1, render: snorm8_renderable },
|
|
3518
|
+
"r8uint": { gl: import_constants4.GL.R8UI, b: 1, c: 1, rb: true },
|
|
3519
|
+
"r8sint": { gl: import_constants4.GL.R8I, b: 1, c: 1, rb: true },
|
|
3501
3520
|
// 16-bit formats
|
|
3502
|
-
"rg8unorm": { gl: import_constants4.GL.RG8, b: 2, c: 2,
|
|
3503
|
-
"rg8snorm": { gl: import_constants4.GL.RG8_SNORM, b: 2, c: 2 },
|
|
3504
|
-
"rg8uint": { gl: import_constants4.GL.RG8UI, b: 2, c: 2,
|
|
3505
|
-
"rg8sint": { gl: import_constants4.GL.RG8I, b: 2, c: 2,
|
|
3506
|
-
"r16uint": { gl: import_constants4.GL.R16UI, b: 2, c: 1,
|
|
3507
|
-
"r16sint": { gl: import_constants4.GL.R16I, b: 2, c: 1,
|
|
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:
|
|
3521
|
+
"rg8unorm": { gl: import_constants4.GL.RG8, b: 2, c: 2, rb: true },
|
|
3522
|
+
"rg8snorm": { gl: import_constants4.GL.RG8_SNORM, b: 2, c: 2, render: snorm8_renderable },
|
|
3523
|
+
"rg8uint": { gl: import_constants4.GL.RG8UI, b: 2, c: 2, rb: true },
|
|
3524
|
+
"rg8sint": { gl: import_constants4.GL.RG8I, b: 2, c: 2, rb: true },
|
|
3525
|
+
"r16uint": { gl: import_constants4.GL.R16UI, b: 2, c: 1, rb: true },
|
|
3526
|
+
"r16sint": { gl: import_constants4.GL.R16I, b: 2, c: 1, rb: true },
|
|
3527
|
+
"r16float": { gl: import_constants4.GL.R16F, b: 2, c: 1, render: float16_renderable, filter: "float16-filterable-webgl", rb: true },
|
|
3528
|
+
"r16unorm-webgl": { gl: import_constants4.GL.R16_EXT, b: 2, c: 1, f: norm16_renderable, rb: true },
|
|
3529
|
+
"r16snorm-webgl": { gl: import_constants4.GL.R16_SNORM_EXT, b: 2, c: 1, f: snorm16_renderable },
|
|
3511
3530
|
// Packed 16-bit formats
|
|
3512
|
-
"rgba4unorm-webgl": { gl: import_constants4.GL.RGBA4, b: 2, c: 4, wgpu: false,
|
|
3513
|
-
"rgb565unorm-webgl": { gl: import_constants4.GL.RGB565, b: 2, c: 4, wgpu: false,
|
|
3514
|
-
"rgb5a1unorm-webgl": { gl: import_constants4.GL.RGB5_A1, b: 2, c: 4, wgpu: false,
|
|
3531
|
+
"rgba4unorm-webgl": { gl: import_constants4.GL.RGBA4, b: 2, c: 4, wgpu: false, rb: true },
|
|
3532
|
+
"rgb565unorm-webgl": { gl: import_constants4.GL.RGB565, b: 2, c: 4, wgpu: false, rb: true },
|
|
3533
|
+
"rgb5a1unorm-webgl": { gl: import_constants4.GL.RGB5_A1, b: 2, c: 4, wgpu: false, rb: true },
|
|
3515
3534
|
// 24-bit formats
|
|
3516
3535
|
"rgb8unorm-webgl": { gl: import_constants4.GL.RGB8, b: 3, c: 3, wgpu: false },
|
|
3517
3536
|
"rgb8snorm-webgl": { gl: import_constants4.GL.RGB8_SNORM, b: 3, c: 3, wgpu: false },
|
|
3518
3537
|
// 32-bit formats
|
|
3519
3538
|
"rgba8unorm": { gl: import_constants4.GL.RGBA8, b: 4, c: 2, bpp: 4 },
|
|
3520
3539
|
"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 },
|
|
3540
|
+
"rgba8snorm": { gl: import_constants4.GL.RGBA8_SNORM, b: 4, c: 4, render: snorm8_renderable },
|
|
3522
3541
|
"rgba8uint": { gl: import_constants4.GL.RGBA8UI, b: 4, c: 4, bpp: 4 },
|
|
3523
3542
|
"rgba8sint": { gl: import_constants4.GL.RGBA8I, b: 4, c: 4, bpp: 4 },
|
|
3524
3543
|
// reverse colors, webgpu only
|
|
@@ -3527,55 +3546,109 @@ ${htmlLog}
|
|
|
3527
3546
|
"rg16uint": { gl: import_constants4.GL.RG16UI, b: 4, c: 1, bpp: 4 },
|
|
3528
3547
|
"rg16sint": { gl: import_constants4.GL.RG16I, b: 4, c: 2, bpp: 4 },
|
|
3529
3548
|
// 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,
|
|
3533
|
-
"r32uint": { gl: import_constants4.GL.R32UI, b: 4, c: 1, bpp: 4,
|
|
3534
|
-
"r32sint": { gl: import_constants4.GL.R32I, b: 4, c: 1, bpp: 4,
|
|
3535
|
-
"r32float": { gl: import_constants4.GL.R32F, bpp: 4, b: 4, c: 1, render:
|
|
3549
|
+
"rg16float": { gl: import_constants4.GL.RG16F, bpp: 4, b: 4, c: 2, render: float16_renderable, filter: float16_filterable, rb: true },
|
|
3550
|
+
"rg16unorm-webgl": { gl: import_constants4.GL.RG16_EXT, b: 2, c: 2, render: norm16_renderable },
|
|
3551
|
+
"rg16snorm-webgl": { gl: import_constants4.GL.RG16_SNORM_EXT, b: 2, c: 2, render: snorm16_renderable },
|
|
3552
|
+
"r32uint": { gl: import_constants4.GL.R32UI, b: 4, c: 1, bpp: 4, rb: true },
|
|
3553
|
+
"r32sint": { gl: import_constants4.GL.R32I, b: 4, c: 1, bpp: 4, rb: true },
|
|
3554
|
+
"r32float": { gl: import_constants4.GL.R32F, bpp: 4, b: 4, c: 1, render: float32_renderable, filter: float32_filterable },
|
|
3536
3555
|
// Packed 32-bit formats
|
|
3537
|
-
"rgb9e5ufloat": { gl: import_constants4.GL.RGB9_E5, b: 4, c: 3, p: 1, render:
|
|
3538
|
-
|
|
3539
|
-
"
|
|
3540
|
-
"rgb10a2unorm
|
|
3556
|
+
"rgb9e5ufloat": { gl: import_constants4.GL.RGB9_E5, b: 4, c: 3, p: 1, render: rgb9e5ufloat_renderable },
|
|
3557
|
+
// , filter: true},
|
|
3558
|
+
"rg11b10ufloat": { gl: import_constants4.GL.R11F_G11F_B10F, b: 4, c: 3, p: 1, render: float32_renderable, rb: true },
|
|
3559
|
+
"rgb10a2unorm": { gl: import_constants4.GL.RGB10_A2, b: 4, c: 4, p: 1, rb: true },
|
|
3560
|
+
"rgb10a2uint-webgl": { b: 4, c: 4, gl: import_constants4.GL.RGB10_A2UI, p: 1, wgpu: false, bpp: 4, rb: true },
|
|
3541
3561
|
// 48-bit formats
|
|
3542
|
-
"rgb16unorm-webgl": { gl: import_constants4.GL.RGB16_EXT, b: 2, c: 3, f:
|
|
3543
|
-
|
|
3562
|
+
"rgb16unorm-webgl": { gl: import_constants4.GL.RGB16_EXT, b: 2, c: 3, f: norm16_renderable },
|
|
3563
|
+
// rgb not renderable
|
|
3564
|
+
"rgb16snorm-webgl": { gl: import_constants4.GL.RGB16_SNORM_EXT, b: 2, c: 3, f: norm16_renderable },
|
|
3565
|
+
// rgb not renderable
|
|
3544
3566
|
// 64-bit formats
|
|
3545
|
-
"rg32uint": { gl: import_constants4.GL.RG32UI, b: 8, c: 2,
|
|
3546
|
-
"rg32sint": { gl: import_constants4.GL.RG32I, b: 8, c: 2,
|
|
3547
|
-
"rg32float": { gl: import_constants4.GL.RG32F, b: 8, c: 2, render:
|
|
3548
|
-
"rgba16uint": { gl: import_constants4.GL.RGBA16UI, b: 8, c: 4,
|
|
3549
|
-
"rgba16sint": { gl: import_constants4.GL.RGBA16I, b: 8, c: 4,
|
|
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,
|
|
3567
|
+
"rg32uint": { gl: import_constants4.GL.RG32UI, b: 8, c: 2, rb: true },
|
|
3568
|
+
"rg32sint": { gl: import_constants4.GL.RG32I, b: 8, c: 2, rb: true },
|
|
3569
|
+
"rg32float": { gl: import_constants4.GL.RG32F, b: 8, c: 2, render: float32_renderable, filter: float32_filterable, rb: true },
|
|
3570
|
+
"rgba16uint": { gl: import_constants4.GL.RGBA16UI, b: 8, c: 4, rb: true },
|
|
3571
|
+
"rgba16sint": { gl: import_constants4.GL.RGBA16I, b: 8, c: 4, rb: true },
|
|
3572
|
+
"rgba16float": { gl: import_constants4.GL.RGBA16F, b: 8, c: 4, render: float16_renderable, filter: float16_filterable },
|
|
3573
|
+
"rgba16unorm-webgl": { gl: import_constants4.GL.RGBA16_EXT, b: 2, c: 4, render: norm16_renderable, rb: true },
|
|
3574
|
+
"rgba16snorm-webgl": { gl: import_constants4.GL.RGBA16_SNORM_EXT, b: 2, c: 4, render: snorm16_renderable },
|
|
3553
3575
|
// 96-bit formats (deprecated!)
|
|
3554
3576
|
"rgb32float-webgl": {
|
|
3555
3577
|
gl: import_constants4.GL.RGB32F,
|
|
3556
|
-
render:
|
|
3557
|
-
filter:
|
|
3558
|
-
gl2ext:
|
|
3578
|
+
render: float32_renderable,
|
|
3579
|
+
filter: float32_filterable,
|
|
3580
|
+
gl2ext: EXT_color_buffer_float,
|
|
3559
3581
|
dataFormat: import_constants4.GL.RGB,
|
|
3560
3582
|
types: [import_constants4.GL.FLOAT]
|
|
3561
3583
|
},
|
|
3562
3584
|
// 128-bit formats
|
|
3563
|
-
"rgba32uint": { gl: import_constants4.GL.RGBA32UI, b: 16, c: 4,
|
|
3564
|
-
"rgba32sint": { gl: import_constants4.GL.RGBA32I, b: 16, c: 4,
|
|
3565
|
-
"rgba32float": { gl: import_constants4.GL.RGBA32F, b: 16, c: 4, render:
|
|
3585
|
+
"rgba32uint": { gl: import_constants4.GL.RGBA32UI, b: 16, c: 4, rb: true },
|
|
3586
|
+
"rgba32sint": { gl: import_constants4.GL.RGBA32I, b: 16, c: 4, rb: true },
|
|
3587
|
+
"rgba32float": { gl: import_constants4.GL.RGBA32F, b: 16, c: 4, render: float32_renderable, filter: float32_filterable, rb: true },
|
|
3566
3588
|
// Depth and stencil formats
|
|
3567
|
-
"stencil8": { gl: import_constants4.GL.STENCIL_INDEX8, b: 1, c: 1, attachment: import_constants4.GL.STENCIL_ATTACHMENT,
|
|
3589
|
+
"stencil8": { gl: import_constants4.GL.STENCIL_INDEX8, b: 1, c: 1, attachment: import_constants4.GL.STENCIL_ATTACHMENT, rb: true },
|
|
3568
3590
|
// 8 stencil bits
|
|
3569
|
-
"depth16unorm": {
|
|
3591
|
+
"depth16unorm": {
|
|
3592
|
+
gl: import_constants4.GL.DEPTH_COMPONENT16,
|
|
3593
|
+
b: 2,
|
|
3594
|
+
c: 1,
|
|
3595
|
+
attachment: import_constants4.GL.DEPTH_ATTACHMENT,
|
|
3596
|
+
dataFormat: import_constants4.GL.DEPTH_COMPONENT,
|
|
3597
|
+
types: [import_constants4.GL.UNSIGNED_SHORT],
|
|
3598
|
+
rb: true
|
|
3599
|
+
},
|
|
3570
3600
|
// 16 depth bits
|
|
3571
|
-
"depth24plus": {
|
|
3572
|
-
|
|
3601
|
+
"depth24plus": {
|
|
3602
|
+
gl: import_constants4.GL.DEPTH_COMPONENT24,
|
|
3603
|
+
b: 3,
|
|
3604
|
+
c: 1,
|
|
3605
|
+
attachment: import_constants4.GL.DEPTH_ATTACHMENT,
|
|
3606
|
+
dataFormat: import_constants4.GL.DEPTH_COMPONENT,
|
|
3607
|
+
types: [import_constants4.GL.UNSIGNED_INT]
|
|
3608
|
+
},
|
|
3609
|
+
"depth32float": {
|
|
3610
|
+
gl: import_constants4.GL.DEPTH_COMPONENT32F,
|
|
3611
|
+
b: 4,
|
|
3612
|
+
c: 1,
|
|
3613
|
+
attachment: import_constants4.GL.DEPTH_ATTACHMENT,
|
|
3614
|
+
dataFormat: import_constants4.GL.DEPTH_COMPONENT,
|
|
3615
|
+
types: [import_constants4.GL.FLOAT],
|
|
3616
|
+
rb: true
|
|
3617
|
+
},
|
|
3573
3618
|
// The depth component of the "depth24plus" and "depth24plus-stencil8" formats may be implemented as either a 24-bit depth value or a "depth32float" value.
|
|
3574
|
-
"depth24plus-stencil8": {
|
|
3619
|
+
"depth24plus-stencil8": {
|
|
3620
|
+
gl: import_constants4.GL.DEPTH24_STENCIL8,
|
|
3621
|
+
b: 4,
|
|
3622
|
+
c: 2,
|
|
3623
|
+
p: 1,
|
|
3624
|
+
attachment: import_constants4.GL.DEPTH_STENCIL_ATTACHMENT,
|
|
3625
|
+
rb: true,
|
|
3626
|
+
depthTexture: true,
|
|
3627
|
+
dataFormat: import_constants4.GL.DEPTH_STENCIL,
|
|
3628
|
+
types: [import_constants4.GL.UNSIGNED_INT_24_8]
|
|
3629
|
+
},
|
|
3575
3630
|
// "depth24unorm-stencil8" feature
|
|
3576
|
-
"depth24unorm-stencil8": {
|
|
3577
|
-
|
|
3578
|
-
|
|
3631
|
+
"depth24unorm-stencil8": {
|
|
3632
|
+
gl: import_constants4.GL.DEPTH24_STENCIL8,
|
|
3633
|
+
b: 4,
|
|
3634
|
+
c: 2,
|
|
3635
|
+
p: 1,
|
|
3636
|
+
attachment: import_constants4.GL.DEPTH_STENCIL_ATTACHMENT,
|
|
3637
|
+
dataFormat: import_constants4.GL.DEPTH_STENCIL,
|
|
3638
|
+
types: [import_constants4.GL.UNSIGNED_INT_24_8],
|
|
3639
|
+
rb: true
|
|
3640
|
+
},
|
|
3641
|
+
// "depth32float-stencil8" feature - TODO below is render buffer only?
|
|
3642
|
+
"depth32float-stencil8": {
|
|
3643
|
+
gl: import_constants4.GL.DEPTH32F_STENCIL8,
|
|
3644
|
+
b: 5,
|
|
3645
|
+
c: 2,
|
|
3646
|
+
p: 1,
|
|
3647
|
+
attachment: import_constants4.GL.DEPTH_STENCIL_ATTACHMENT,
|
|
3648
|
+
dataFormat: import_constants4.GL.DEPTH_STENCIL,
|
|
3649
|
+
types: [import_constants4.GL.FLOAT_32_UNSIGNED_INT_24_8_REV],
|
|
3650
|
+
rb: true
|
|
3651
|
+
},
|
|
3579
3652
|
// BC compressed formats: check device.features.has("texture-compression-bc");
|
|
3580
3653
|
"bc1-rgb-unorm-webgl": { gl: import_constants4.GL.COMPRESSED_RGB_S3TC_DXT1_EXT, x: X_S3TC, f: texture_compression_bc },
|
|
3581
3654
|
"bc1-rgb-unorm-srgb-webgl": { gl: import_constants4.GL.COMPRESSED_SRGB_S3TC_DXT1_EXT, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
@@ -3671,8 +3744,7 @@ ${htmlLog}
|
|
|
3671
3744
|
[import_constants4.GL.BYTE]: 1,
|
|
3672
3745
|
[import_constants4.GL.UNSIGNED_BYTE]: 1
|
|
3673
3746
|
};
|
|
3674
|
-
function isTextureFormatSupported(gl,
|
|
3675
|
-
const format = convertGLToTextureFormat(formatOrGL);
|
|
3747
|
+
function isTextureFormatSupported(gl, format, extensions) {
|
|
3676
3748
|
const info = TEXTURE_FORMATS[format];
|
|
3677
3749
|
if (!info) {
|
|
3678
3750
|
return false;
|
|
@@ -3682,12 +3754,12 @@ ${htmlLog}
|
|
|
3682
3754
|
}
|
|
3683
3755
|
const extension = info.x || info.gl2ext;
|
|
3684
3756
|
if (extension) {
|
|
3685
|
-
return Boolean(gl
|
|
3757
|
+
return Boolean(getWebGLExtension(gl, extension, extensions));
|
|
3686
3758
|
}
|
|
3687
3759
|
return true;
|
|
3688
3760
|
}
|
|
3689
|
-
function isRenderbufferFormatSupported(gl, format) {
|
|
3690
|
-
return isTextureFormatSupported(gl, format) && TEXTURE_FORMATS[format]?.
|
|
3761
|
+
function isRenderbufferFormatSupported(gl, format, extensions) {
|
|
3762
|
+
return isTextureFormatSupported(gl, format, extensions) && TEXTURE_FORMATS[format]?.rb;
|
|
3691
3763
|
}
|
|
3692
3764
|
function convertGLToTextureFormat(format) {
|
|
3693
3765
|
if (typeof format === "string") {
|
|
@@ -3707,9 +3779,11 @@ ${htmlLog}
|
|
|
3707
3779
|
}
|
|
3708
3780
|
return webglFormat;
|
|
3709
3781
|
}
|
|
3710
|
-
function isTextureFormatFilterable(gl,
|
|
3711
|
-
|
|
3712
|
-
|
|
3782
|
+
function isTextureFormatFilterable(gl, format, extensions) {
|
|
3783
|
+
if (!isTextureFormatSupported(gl, format, extensions)) {
|
|
3784
|
+
return false;
|
|
3785
|
+
}
|
|
3786
|
+
if (format.startsWith("depth") || format.startsWith("stencil")) {
|
|
3713
3787
|
return false;
|
|
3714
3788
|
}
|
|
3715
3789
|
try {
|
|
@@ -3721,16 +3795,15 @@ ${htmlLog}
|
|
|
3721
3795
|
return false;
|
|
3722
3796
|
}
|
|
3723
3797
|
if (format.endsWith("32float")) {
|
|
3724
|
-
return Boolean(gl
|
|
3798
|
+
return Boolean(getWebGLExtension(gl, "OES_texture_float_linear, extensions", extensions));
|
|
3725
3799
|
}
|
|
3726
3800
|
if (format.endsWith("16float")) {
|
|
3727
|
-
return Boolean(gl
|
|
3801
|
+
return Boolean(getWebGLExtension(gl, "OES_texture_half_float_linear, extensions", extensions));
|
|
3728
3802
|
}
|
|
3729
3803
|
return true;
|
|
3730
3804
|
}
|
|
3731
|
-
function isTextureFormatRenderable(gl,
|
|
3732
|
-
|
|
3733
|
-
if (!isTextureFormatSupported(gl, format)) {
|
|
3805
|
+
function isTextureFormatRenderable(gl, format, extensions) {
|
|
3806
|
+
if (!isTextureFormatSupported(gl, format, extensions)) {
|
|
3734
3807
|
return false;
|
|
3735
3808
|
}
|
|
3736
3809
|
if (typeof format === "number") {
|
|
@@ -3738,20 +3811,15 @@ ${htmlLog}
|
|
|
3738
3811
|
}
|
|
3739
3812
|
return true;
|
|
3740
3813
|
}
|
|
3741
|
-
function getWebGLTextureParameters(
|
|
3742
|
-
const
|
|
3814
|
+
function getWebGLTextureParameters(format) {
|
|
3815
|
+
const formatData = TEXTURE_FORMATS[format];
|
|
3743
3816
|
const webglFormat = convertTextureFormatToGL(format);
|
|
3744
3817
|
const decoded = decodeTextureFormat(format);
|
|
3745
3818
|
return {
|
|
3746
3819
|
format: webglFormat,
|
|
3747
|
-
dataFormat: getWebGLPixelDataFormat(
|
|
3748
|
-
decoded.format,
|
|
3749
|
-
decoded.integer,
|
|
3750
|
-
decoded.normalized,
|
|
3751
|
-
webglFormat
|
|
3752
|
-
),
|
|
3820
|
+
dataFormat: formatData?.dataFormat || getWebGLPixelDataFormat(decoded.format, decoded.integer, decoded.normalized, webglFormat),
|
|
3753
3821
|
// depth formats don't have a type
|
|
3754
|
-
type: decoded.dataType ? getGLFromVertexType(decoded.dataType) : import_constants4.GL.UNSIGNED_BYTE,
|
|
3822
|
+
type: decoded.dataType ? getGLFromVertexType(decoded.dataType) : formatData?.types?.[0] || import_constants4.GL.UNSIGNED_BYTE,
|
|
3755
3823
|
// @ts-expect-error
|
|
3756
3824
|
compressed: decoded.compressed
|
|
3757
3825
|
};
|
|
@@ -3763,8 +3831,7 @@ ${htmlLog}
|
|
|
3763
3831
|
}
|
|
3764
3832
|
return info.attachment;
|
|
3765
3833
|
}
|
|
3766
|
-
function getTextureFormatBytesPerPixel(
|
|
3767
|
-
const format = convertGLToTextureFormat(formatOrGL);
|
|
3834
|
+
function getTextureFormatBytesPerPixel(format) {
|
|
3768
3835
|
const params = getWebGLTextureParameters(format);
|
|
3769
3836
|
const channels = DATA_FORMAT_CHANNELS[params.dataFormat] || 4;
|
|
3770
3837
|
const channelSize = TYPE_SIZES3[params.type] || 1;
|
|
@@ -3789,196 +3856,197 @@ ${htmlLog}
|
|
|
3789
3856
|
}
|
|
3790
3857
|
|
|
3791
3858
|
// src/adapter/device-helpers/webgl-device-features.ts
|
|
3792
|
-
function getDeviceFeatures(gl) {
|
|
3793
|
-
const features = getWebGLFeatures(gl);
|
|
3794
|
-
for (const textureFeature of getTextureFeatures(gl)) {
|
|
3795
|
-
features.add(textureFeature);
|
|
3796
|
-
}
|
|
3797
|
-
return features;
|
|
3798
|
-
}
|
|
3799
|
-
function getWebGLFeatures(gl) {
|
|
3800
|
-
gl.getExtension("EXT_color_buffer_float");
|
|
3801
|
-
const features = /* @__PURE__ */ new Set();
|
|
3802
|
-
for (const feature of Object.keys(WEBGL_FEATURES)) {
|
|
3803
|
-
if (isFeatureSupported(gl, feature)) {
|
|
3804
|
-
features.add(feature);
|
|
3805
|
-
}
|
|
3806
|
-
}
|
|
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
3859
|
var WEBGL_FEATURES = {
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
"
|
|
3818
|
-
"
|
|
3860
|
+
// optional WebGPU features
|
|
3861
|
+
"depth-clip-control": "EXT_depth_clamp",
|
|
3862
|
+
// TODO these seem subtly different
|
|
3863
|
+
// 'timestamp-query' // GPUQueryType "timestamp-query"
|
|
3864
|
+
// "indirect-first-instance"
|
|
3865
|
+
// Textures are handled by getTextureFeatures()
|
|
3866
|
+
// 'depth24unorm-stencil8' // GPUTextureFormat 'depth24unorm-stencil8'
|
|
3867
|
+
// 'depth32float-stencil8' // GPUTextureFormat 'depth32float-stencil8'
|
|
3868
|
+
// optional WebGL features
|
|
3819
3869
|
"timer-query-webgl": "EXT_disjoint_timer_query_webgl2",
|
|
3820
|
-
"
|
|
3870
|
+
"compilation-status-async-webgl": "KHR_parallel_shader_compile",
|
|
3871
|
+
"polygon-mode-webgl": "WEBGL_polygon_mode",
|
|
3872
|
+
"provoking-vertex-webgl": "WEBGL_provoking_vertex",
|
|
3873
|
+
"shader-clip-cull-distance-webgl": "WEBGL_clip_cull_distance",
|
|
3874
|
+
"shader-noperspective-interpolation-webgl": "NV_shader_noperspective_interpolation",
|
|
3875
|
+
"shader-conservative-depth-webgl": "EXT_conservative_depth"
|
|
3821
3876
|
// Textures are handled by getTextureFeatures()
|
|
3822
3877
|
};
|
|
3878
|
+
var WebGLDeviceFeatures = class extends DeviceFeatures {
|
|
3879
|
+
gl;
|
|
3880
|
+
extensions;
|
|
3881
|
+
testedFeatures = /* @__PURE__ */ new Set();
|
|
3882
|
+
constructor(gl, extensions, disabledFeatures) {
|
|
3883
|
+
super([], disabledFeatures);
|
|
3884
|
+
this.gl = gl;
|
|
3885
|
+
this.extensions = extensions;
|
|
3886
|
+
getWebGLExtension(gl, "EXT_color_buffer_float", extensions);
|
|
3887
|
+
}
|
|
3888
|
+
*[Symbol.iterator]() {
|
|
3889
|
+
for (const feature of Object.keys(WEBGL_FEATURES)) {
|
|
3890
|
+
if (this.has(feature)) {
|
|
3891
|
+
yield feature;
|
|
3892
|
+
}
|
|
3893
|
+
}
|
|
3894
|
+
for (const feature of Object.keys(TEXTURE_FEATURES)) {
|
|
3895
|
+
if (this.has(feature)) {
|
|
3896
|
+
yield feature;
|
|
3897
|
+
}
|
|
3898
|
+
}
|
|
3899
|
+
return [];
|
|
3900
|
+
}
|
|
3901
|
+
has(feature) {
|
|
3902
|
+
if (this.disabledFeatures[feature]) {
|
|
3903
|
+
return false;
|
|
3904
|
+
}
|
|
3905
|
+
if (!this.testedFeatures.has(feature)) {
|
|
3906
|
+
this.testedFeatures.add(feature);
|
|
3907
|
+
if (isTextureFeature(feature) && checkTextureFeature(this.gl, feature, this.extensions)) {
|
|
3908
|
+
this.features.add(feature);
|
|
3909
|
+
}
|
|
3910
|
+
if (this.getWebGLFeature(feature)) {
|
|
3911
|
+
this.features.add(feature);
|
|
3912
|
+
}
|
|
3913
|
+
}
|
|
3914
|
+
return this.features.has(feature);
|
|
3915
|
+
}
|
|
3916
|
+
// FOR DEVICE
|
|
3917
|
+
initializeFeatures() {
|
|
3918
|
+
for (const feature of this) {
|
|
3919
|
+
}
|
|
3920
|
+
}
|
|
3921
|
+
// IMPLEMENTATION
|
|
3922
|
+
/** Extract all WebGL features */
|
|
3923
|
+
getWebGLFeature(feature) {
|
|
3924
|
+
const featureInfo = WEBGL_FEATURES[feature];
|
|
3925
|
+
const isSupported = typeof featureInfo === "string" ? Boolean(getWebGLExtension(this.gl, featureInfo, this.extensions)) : Boolean(featureInfo);
|
|
3926
|
+
return isSupported;
|
|
3927
|
+
}
|
|
3928
|
+
};
|
|
3823
3929
|
|
|
3824
3930
|
// src/adapter/device-helpers/webgl-device-limits.ts
|
|
3825
3931
|
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);
|
|
3932
|
+
var WebGLDeviceLimits = class extends DeviceLimits {
|
|
3933
|
+
get maxTextureDimension1D() {
|
|
3934
|
+
return 0;
|
|
3874
3935
|
}
|
|
3875
|
-
|
|
3876
|
-
|
|
3936
|
+
// WebGL does not support 1D textures
|
|
3937
|
+
get maxTextureDimension2D() {
|
|
3938
|
+
return this.getParameter(import_constants5.GL.MAX_TEXTURE_SIZE);
|
|
3877
3939
|
}
|
|
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
|
-
|
|
3940
|
+
get maxTextureDimension3D() {
|
|
3941
|
+
return this.getParameter(import_constants5.GL.MAX_3D_TEXTURE_SIZE);
|
|
3942
|
+
}
|
|
3943
|
+
get maxTextureArrayLayers() {
|
|
3944
|
+
return this.getParameter(import_constants5.GL.MAX_ARRAY_TEXTURE_LAYERS);
|
|
3945
|
+
}
|
|
3946
|
+
get maxBindGroups() {
|
|
3947
|
+
return 0;
|
|
3948
|
+
}
|
|
3949
|
+
get maxDynamicUniformBuffersPerPipelineLayout() {
|
|
3950
|
+
return 0;
|
|
3951
|
+
}
|
|
3952
|
+
// TBD
|
|
3953
|
+
get maxDynamicStorageBuffersPerPipelineLayout() {
|
|
3954
|
+
return 0;
|
|
3955
|
+
}
|
|
3956
|
+
// TBD
|
|
3957
|
+
get maxSampledTexturesPerShaderStage() {
|
|
3958
|
+
return this.getParameter(import_constants5.GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
|
|
3959
|
+
}
|
|
3960
|
+
// ) TBD
|
|
3961
|
+
get maxSamplersPerShaderStage() {
|
|
3962
|
+
return this.getParameter(import_constants5.GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
|
|
3963
|
+
}
|
|
3964
|
+
get maxStorageBuffersPerShaderStage() {
|
|
3965
|
+
return 0;
|
|
3966
|
+
}
|
|
3967
|
+
// TBD
|
|
3968
|
+
get maxStorageTexturesPerShaderStage() {
|
|
3969
|
+
return 0;
|
|
3970
|
+
}
|
|
3971
|
+
// TBD
|
|
3972
|
+
get maxUniformBuffersPerShaderStage() {
|
|
3973
|
+
return this.getParameter(import_constants5.GL.MAX_UNIFORM_BUFFER_BINDINGS);
|
|
3974
|
+
}
|
|
3975
|
+
get maxUniformBufferBindingSize() {
|
|
3976
|
+
return this.getParameter(import_constants5.GL.MAX_UNIFORM_BLOCK_SIZE);
|
|
3977
|
+
}
|
|
3978
|
+
get maxStorageBufferBindingSize() {
|
|
3979
|
+
return 0;
|
|
3980
|
+
}
|
|
3981
|
+
get minUniformBufferOffsetAlignment() {
|
|
3982
|
+
return this.getParameter(import_constants5.GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT);
|
|
3983
|
+
}
|
|
3984
|
+
get minStorageBufferOffsetAlignment() {
|
|
3985
|
+
return 0;
|
|
3986
|
+
}
|
|
3987
|
+
get maxVertexBuffers() {
|
|
3988
|
+
return 16;
|
|
3989
|
+
}
|
|
3990
|
+
// WebGL 2 supports 16 buffers, see https://github.com/gpuweb/gpuweb/issues/4284
|
|
3991
|
+
get maxVertexAttributes() {
|
|
3992
|
+
return this.getParameter(import_constants5.GL.MAX_VERTEX_ATTRIBS);
|
|
3993
|
+
}
|
|
3994
|
+
get maxVertexBufferArrayStride() {
|
|
3995
|
+
return 2048;
|
|
3996
|
+
}
|
|
3997
|
+
// TBD, this is just the default value from WebGPU
|
|
3998
|
+
get maxInterStageShaderComponents() {
|
|
3999
|
+
return this.getParameter(import_constants5.GL.MAX_VARYING_COMPONENTS);
|
|
4000
|
+
}
|
|
4001
|
+
get maxComputeWorkgroupStorageSize() {
|
|
4002
|
+
return 0;
|
|
4003
|
+
}
|
|
4004
|
+
// WebGL does not support compute shaders
|
|
4005
|
+
get maxComputeInvocationsPerWorkgroup() {
|
|
4006
|
+
return 0;
|
|
4007
|
+
}
|
|
4008
|
+
// WebGL does not support compute shaders
|
|
4009
|
+
get maxComputeWorkgroupSizeX() {
|
|
4010
|
+
return 0;
|
|
4011
|
+
}
|
|
4012
|
+
// WebGL does not support compute shaders
|
|
4013
|
+
get maxComputeWorkgroupSizeY() {
|
|
4014
|
+
return 0;
|
|
4015
|
+
}
|
|
4016
|
+
// WebGL does not support compute shaders
|
|
4017
|
+
get maxComputeWorkgroupSizeZ() {
|
|
4018
|
+
return 0;
|
|
4019
|
+
}
|
|
4020
|
+
// WebGL does not support compute shaders
|
|
4021
|
+
get maxComputeWorkgroupsPerDimension() {
|
|
4022
|
+
return 0;
|
|
4023
|
+
}
|
|
4024
|
+
// WebGL does not support compute shaders
|
|
4025
|
+
// PRIVATE
|
|
4026
|
+
gl;
|
|
4027
|
+
limits = {};
|
|
4028
|
+
constructor(gl) {
|
|
4029
|
+
super();
|
|
4030
|
+
this.gl = gl;
|
|
4031
|
+
}
|
|
4032
|
+
getParameter(parameter) {
|
|
4033
|
+
if (this.limits[parameter] === void 0) {
|
|
4034
|
+
this.limits[parameter] = this.gl.getParameter(parameter);
|
|
4035
|
+
}
|
|
4036
|
+
return this.limits[parameter];
|
|
4037
|
+
}
|
|
4038
|
+
};
|
|
3969
4039
|
|
|
3970
4040
|
// src/adapter/resources/webgl-framebuffer.ts
|
|
3971
|
-
var
|
|
4041
|
+
var import_constants11 = __toESM(require_constants(), 1);
|
|
3972
4042
|
|
|
3973
4043
|
// src/adapter/resources/webgl-texture.ts
|
|
3974
4044
|
var import_constants10 = __toESM(require_constants(), 1);
|
|
3975
4045
|
|
|
3976
4046
|
// src/context/state-tracker/with-parameters.ts
|
|
3977
|
-
function withGLParameters(
|
|
3978
|
-
const webglDevice = WebGLDevice.attach(device);
|
|
3979
|
-
const gl = webglDevice.gl;
|
|
4047
|
+
function withGLParameters(gl, parameters, func) {
|
|
3980
4048
|
if (isObjectEmpty3(parameters)) {
|
|
3981
|
-
return func(
|
|
4049
|
+
return func(gl);
|
|
3982
4050
|
}
|
|
3983
4051
|
const { nocatch = true } = parameters;
|
|
3984
4052
|
pushContextState(gl);
|
|
@@ -4012,13 +4080,14 @@ ${htmlLog}
|
|
|
4012
4080
|
if (isObjectEmpty(parameters)) {
|
|
4013
4081
|
return func(device);
|
|
4014
4082
|
}
|
|
4015
|
-
|
|
4083
|
+
const webglDevice = device;
|
|
4084
|
+
pushContextState(webglDevice.gl);
|
|
4016
4085
|
try {
|
|
4017
4086
|
setDeviceParameters(device, parameters);
|
|
4018
|
-
setGLParameters(
|
|
4087
|
+
setGLParameters(webglDevice.gl, glParameters);
|
|
4019
4088
|
return func(device);
|
|
4020
4089
|
} finally {
|
|
4021
|
-
popContextState(
|
|
4090
|
+
popContextState(webglDevice.gl);
|
|
4022
4091
|
}
|
|
4023
4092
|
}
|
|
4024
4093
|
function withDeviceParameters(device, parameters, func) {
|
|
@@ -4034,7 +4103,7 @@ ${htmlLog}
|
|
|
4034
4103
|
}
|
|
4035
4104
|
}
|
|
4036
4105
|
function setDeviceParameters(device, parameters) {
|
|
4037
|
-
const webglDevice =
|
|
4106
|
+
const webglDevice = device;
|
|
4038
4107
|
const { gl } = webglDevice;
|
|
4039
4108
|
if (parameters.cullMode) {
|
|
4040
4109
|
switch (parameters.cullMode) {
|
|
@@ -4059,9 +4128,66 @@ ${htmlLog}
|
|
|
4059
4128
|
})
|
|
4060
4129
|
);
|
|
4061
4130
|
}
|
|
4131
|
+
if (parameters.unclippedDepth) {
|
|
4132
|
+
if (device.features.has("depth-clip-control")) {
|
|
4133
|
+
gl.enable(import_constants6.GL.DEPTH_CLAMP_EXT);
|
|
4134
|
+
}
|
|
4135
|
+
}
|
|
4062
4136
|
if (parameters.depthBias !== void 0) {
|
|
4063
4137
|
gl.polygonOffset(parameters.depthBias, parameters.depthBiasSlopeScale || 0);
|
|
4064
4138
|
}
|
|
4139
|
+
if (device.features.has("provoking-vertex-webgl")) {
|
|
4140
|
+
const extensions = webglDevice.getExtension("WEBGL_provoking_vertex");
|
|
4141
|
+
const ext = extensions.WEBGL_provoking_vertex;
|
|
4142
|
+
if (parameters.provokingVertex) {
|
|
4143
|
+
const vertex = map("provokingVertex", parameters.provokingVertex, {
|
|
4144
|
+
first: import_constants6.GL.FIRST_VERTEX_CONVENTION_WEBGL,
|
|
4145
|
+
last: import_constants6.GL.LAST_VERTEX_CONVENTION_WEBGL
|
|
4146
|
+
});
|
|
4147
|
+
ext?.provokingVertexWEBGL(vertex);
|
|
4148
|
+
}
|
|
4149
|
+
}
|
|
4150
|
+
if (device.features.has("polygon-mode-webgl")) {
|
|
4151
|
+
const extensions = webglDevice.getExtension("WEBGL_polygon_mode");
|
|
4152
|
+
const ext = extensions.WEBGL_polygon_mode;
|
|
4153
|
+
if (parameters.polygonMode) {
|
|
4154
|
+
const mode = map("polygonMode", parameters.provokingVertex, {
|
|
4155
|
+
fill: import_constants6.GL.FILL_WEBGL,
|
|
4156
|
+
lint: import_constants6.GL.LINE_WEBGL
|
|
4157
|
+
});
|
|
4158
|
+
ext?.polygonModeWEBGL(import_constants6.GL.FRONT, mode);
|
|
4159
|
+
ext?.polygonModeWEBGL(import_constants6.GL.BACK, mode);
|
|
4160
|
+
}
|
|
4161
|
+
if (parameters.polygonOffsetLine) {
|
|
4162
|
+
gl.enable(import_constants6.GL.POLYGON_OFFSET_LINE_WEBGL);
|
|
4163
|
+
}
|
|
4164
|
+
}
|
|
4165
|
+
if (device.features.has("shader-clip-cull-distance-webgl")) {
|
|
4166
|
+
if (parameters.clipDistance0) {
|
|
4167
|
+
gl.enable(import_constants6.GL.CLIP_DISTANCE0_WEBGL);
|
|
4168
|
+
}
|
|
4169
|
+
if (parameters.clipDistance1) {
|
|
4170
|
+
gl.enable(import_constants6.GL.CLIP_DISTANCE1_WEBGL);
|
|
4171
|
+
}
|
|
4172
|
+
if (parameters.clipDistance2) {
|
|
4173
|
+
gl.enable(import_constants6.GL.CLIP_DISTANCE2_WEBGL);
|
|
4174
|
+
}
|
|
4175
|
+
if (parameters.clipDistance3) {
|
|
4176
|
+
gl.enable(import_constants6.GL.CLIP_DISTANCE3_WEBGL);
|
|
4177
|
+
}
|
|
4178
|
+
if (parameters.clipDistance4) {
|
|
4179
|
+
gl.enable(import_constants6.GL.CLIP_DISTANCE4_WEBGL);
|
|
4180
|
+
}
|
|
4181
|
+
if (parameters.clipDistance5) {
|
|
4182
|
+
gl.enable(import_constants6.GL.CLIP_DISTANCE5_WEBGL);
|
|
4183
|
+
}
|
|
4184
|
+
if (parameters.clipDistance6) {
|
|
4185
|
+
gl.enable(import_constants6.GL.CLIP_DISTANCE6_WEBGL);
|
|
4186
|
+
}
|
|
4187
|
+
if (parameters.clipDistance7) {
|
|
4188
|
+
gl.enable(import_constants6.GL.CLIP_DISTANCE7_WEBGL);
|
|
4189
|
+
}
|
|
4190
|
+
}
|
|
4065
4191
|
if (parameters.depthWriteEnabled !== void 0) {
|
|
4066
4192
|
gl.depthMask(mapBoolean("depthWriteEnabled", parameters.depthWriteEnabled));
|
|
4067
4193
|
}
|
|
@@ -4096,13 +4222,31 @@ ${htmlLog}
|
|
|
4096
4222
|
}
|
|
4097
4223
|
if (parameters.blendColorOperation || parameters.blendAlphaOperation) {
|
|
4098
4224
|
gl.enable(import_constants6.GL.BLEND);
|
|
4099
|
-
const colorEquation = convertBlendOperationToEquation(
|
|
4100
|
-
|
|
4225
|
+
const colorEquation = convertBlendOperationToEquation(
|
|
4226
|
+
"blendColorOperation",
|
|
4227
|
+
parameters.blendColorOperation || "add"
|
|
4228
|
+
);
|
|
4229
|
+
const alphaEquation = convertBlendOperationToEquation(
|
|
4230
|
+
"blendAlphaOperation",
|
|
4231
|
+
parameters.blendAlphaOperation || "add"
|
|
4232
|
+
);
|
|
4101
4233
|
gl.blendEquationSeparate(colorEquation, alphaEquation);
|
|
4102
|
-
const colorSrcFactor = convertBlendFactorToFunction(
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4234
|
+
const colorSrcFactor = convertBlendFactorToFunction(
|
|
4235
|
+
"blendColorSrcFactor",
|
|
4236
|
+
parameters.blendColorSrcFactor || "one"
|
|
4237
|
+
);
|
|
4238
|
+
const colorDstFactor = convertBlendFactorToFunction(
|
|
4239
|
+
"blendColorDstFactor",
|
|
4240
|
+
parameters.blendColorDstFactor || "zero"
|
|
4241
|
+
);
|
|
4242
|
+
const alphaSrcFactor = convertBlendFactorToFunction(
|
|
4243
|
+
"blendAlphaSrcFactor",
|
|
4244
|
+
parameters.blendAlphaSrcFactor || "one"
|
|
4245
|
+
);
|
|
4246
|
+
const alphaDstFactor = convertBlendFactorToFunction(
|
|
4247
|
+
"blendAlphaDstFactor",
|
|
4248
|
+
parameters.blendAlphaDstFactor || "zero"
|
|
4249
|
+
);
|
|
4106
4250
|
gl.blendFuncSeparate(colorSrcFactor, colorDstFactor, alphaSrcFactor, alphaDstFactor);
|
|
4107
4251
|
}
|
|
4108
4252
|
}
|
|
@@ -4132,17 +4276,17 @@ ${htmlLog}
|
|
|
4132
4276
|
}
|
|
4133
4277
|
function convertBlendOperationToEquation(parameter, value) {
|
|
4134
4278
|
return map(parameter, value, {
|
|
4135
|
-
|
|
4136
|
-
|
|
4279
|
+
add: import_constants6.GL.FUNC_ADD,
|
|
4280
|
+
subtract: import_constants6.GL.FUNC_SUBTRACT,
|
|
4137
4281
|
"reverse-subtract": import_constants6.GL.FUNC_REVERSE_SUBTRACT,
|
|
4138
|
-
|
|
4139
|
-
|
|
4282
|
+
min: import_constants6.GL.MIN,
|
|
4283
|
+
max: import_constants6.GL.MAX
|
|
4140
4284
|
});
|
|
4141
4285
|
}
|
|
4142
4286
|
function convertBlendFactorToFunction(parameter, value) {
|
|
4143
4287
|
return map(parameter, value, {
|
|
4144
|
-
|
|
4145
|
-
|
|
4288
|
+
one: import_constants6.GL.ONE,
|
|
4289
|
+
zero: import_constants6.GL.ZERO,
|
|
4146
4290
|
"src-color": import_constants6.GL.SRC_COLOR,
|
|
4147
4291
|
"one-minus-src-color": import_constants6.GL.ONE_MINUS_SRC_COLOR,
|
|
4148
4292
|
"dst-color": import_constants6.GL.DST_COLOR,
|
|
@@ -4398,6 +4542,21 @@ ${htmlLog}
|
|
|
4398
4542
|
}
|
|
4399
4543
|
};
|
|
4400
4544
|
|
|
4545
|
+
// src/adapter/resources/webgl-texture-view.ts
|
|
4546
|
+
var WEBGLTextureView = class extends TextureView {
|
|
4547
|
+
device;
|
|
4548
|
+
gl;
|
|
4549
|
+
handle;
|
|
4550
|
+
texture;
|
|
4551
|
+
constructor(device, props) {
|
|
4552
|
+
super(device, { ...Texture.defaultProps, ...props });
|
|
4553
|
+
this.device = device;
|
|
4554
|
+
this.gl = this.device.gl;
|
|
4555
|
+
this.handle = null;
|
|
4556
|
+
this.texture = props.texture;
|
|
4557
|
+
}
|
|
4558
|
+
};
|
|
4559
|
+
|
|
4401
4560
|
// src/adapter/resources/webgl-texture.ts
|
|
4402
4561
|
var DEFAULT_WEBGL_TEXTURE_PROPS = {
|
|
4403
4562
|
// deprecated
|
|
@@ -4414,8 +4573,9 @@ ${htmlLog}
|
|
|
4414
4573
|
device;
|
|
4415
4574
|
gl;
|
|
4416
4575
|
handle;
|
|
4417
|
-
|
|
4576
|
+
// (TODO - currently unused in WebGL, but WebGL 2 does support sampler objects) */
|
|
4418
4577
|
sampler = void 0;
|
|
4578
|
+
view = void 0;
|
|
4419
4579
|
// data;
|
|
4420
4580
|
glFormat = void 0;
|
|
4421
4581
|
type = void 0;
|
|
@@ -4465,6 +4625,9 @@ ${htmlLog}
|
|
|
4465
4625
|
toString() {
|
|
4466
4626
|
return `Texture(${this.id},${this.width}x${this.height})`;
|
|
4467
4627
|
}
|
|
4628
|
+
createView(props) {
|
|
4629
|
+
return new WEBGLTextureView(this.device, { ...props, texture: this });
|
|
4630
|
+
}
|
|
4468
4631
|
// eslint-disable-next-line max-statements
|
|
4469
4632
|
initialize(props = {}) {
|
|
4470
4633
|
if (this.props.dimension === "cube") {
|
|
@@ -4530,7 +4693,8 @@ ${htmlLog}
|
|
|
4530
4693
|
});
|
|
4531
4694
|
this.setSampler(props.sampler);
|
|
4532
4695
|
this._setSamplerParameters(parameters);
|
|
4533
|
-
|
|
4696
|
+
this.view = this.createView({ ...this.props, mipLevelCount: 1, arrayLayerCount: 1 });
|
|
4697
|
+
if (mipmaps && this.device.isTextureFormatFilterable(props.format)) {
|
|
4534
4698
|
this.generateMipmap();
|
|
4535
4699
|
}
|
|
4536
4700
|
if (isVideo) {
|
|
@@ -5085,372 +5249,66 @@ ${htmlLog}
|
|
|
5085
5249
|
log.log(1, "texture sampler parameters", parameters)();
|
|
5086
5250
|
}
|
|
5087
5251
|
|
|
5088
|
-
// src/adapter/
|
|
5089
|
-
var
|
|
5090
|
-
|
|
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
|
-
// src/adapter/objects/webgl-resource.ts
|
|
5107
|
-
var ERR_RESOURCE_METHOD_UNDEFINED = "Resource subclass must define virtual methods";
|
|
5108
|
-
var WebGLResource = class extends Resource {
|
|
5252
|
+
// src/adapter/resources/webgl-framebuffer.ts
|
|
5253
|
+
var WEBGLFramebuffer = class extends Framebuffer {
|
|
5109
5254
|
device;
|
|
5110
5255
|
gl;
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
// Only meaningful for resources that allocate GPU memory
|
|
5115
|
-
byteLength = 0;
|
|
5116
|
-
constructor(device, props, defaultProps) {
|
|
5117
|
-
super(device, props, defaultProps);
|
|
5118
|
-
this.device = WebGLDevice.attach(device);
|
|
5119
|
-
const gl = this.device.gl;
|
|
5120
|
-
const { id } = props || {};
|
|
5121
|
-
this.gl = gl;
|
|
5122
|
-
this.gl2 = gl;
|
|
5123
|
-
this.id = id || uid(this.constructor.name);
|
|
5124
|
-
this._handle = props?.handle;
|
|
5125
|
-
if (this._handle === void 0) {
|
|
5126
|
-
this._handle = this._createHandle();
|
|
5127
|
-
}
|
|
5128
|
-
this.byteLength = 0;
|
|
5256
|
+
handle;
|
|
5257
|
+
get texture() {
|
|
5258
|
+
return this.colorAttachments[0];
|
|
5129
5259
|
}
|
|
5130
|
-
|
|
5131
|
-
|
|
5260
|
+
constructor(device, props) {
|
|
5261
|
+
super(device, props);
|
|
5262
|
+
const isDefaultFramebuffer = props.handle === null;
|
|
5263
|
+
this.device = device;
|
|
5264
|
+
this.gl = device.gl;
|
|
5265
|
+
this.handle = this.props.handle || isDefaultFramebuffer ? this.props.handle : this.gl.createFramebuffer();
|
|
5266
|
+
if (!isDefaultFramebuffer) {
|
|
5267
|
+
device.setSpectorMetadata(this.handle, { id: this.props.id, props: this.props });
|
|
5268
|
+
this.autoCreateAttachmentTextures();
|
|
5269
|
+
this.gl.bindFramebuffer(import_constants11.GL.FRAMEBUFFER, this.handle);
|
|
5270
|
+
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
5271
|
+
const attachment = this.colorAttachments[i];
|
|
5272
|
+
const attachmentPoint = import_constants11.GL.COLOR_ATTACHMENT0 + i;
|
|
5273
|
+
if (attachment) {
|
|
5274
|
+
this._attachOne(attachmentPoint, attachment);
|
|
5275
|
+
}
|
|
5276
|
+
}
|
|
5277
|
+
if (this.depthStencilAttachment) {
|
|
5278
|
+
this._attachOne(
|
|
5279
|
+
getDepthStencilAttachmentWebGL(this.depthStencilAttachment.props.format),
|
|
5280
|
+
this.depthStencilAttachment
|
|
5281
|
+
);
|
|
5282
|
+
}
|
|
5283
|
+
if (props.check !== false) {
|
|
5284
|
+
const status = this.gl.checkFramebufferStatus(import_constants11.GL.FRAMEBUFFER);
|
|
5285
|
+
if (status !== import_constants11.GL.FRAMEBUFFER_COMPLETE) {
|
|
5286
|
+
throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
|
|
5287
|
+
}
|
|
5288
|
+
}
|
|
5289
|
+
this.gl.bindFramebuffer(import_constants11.GL.FRAMEBUFFER, null);
|
|
5290
|
+
}
|
|
5132
5291
|
}
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
this.removeStats();
|
|
5140
|
-
}
|
|
5141
|
-
this._handle = null;
|
|
5142
|
-
if (children && deleteChildren) {
|
|
5143
|
-
children.filter(Boolean).forEach((child) => child.destroy());
|
|
5144
|
-
}
|
|
5145
|
-
return this;
|
|
5146
|
-
}
|
|
5147
|
-
bind(funcOrHandle = this.handle) {
|
|
5148
|
-
if (typeof funcOrHandle !== "function") {
|
|
5149
|
-
this._bindHandle(funcOrHandle);
|
|
5150
|
-
return this;
|
|
5151
|
-
}
|
|
5152
|
-
let value;
|
|
5153
|
-
if (!this._bound) {
|
|
5154
|
-
this._bindHandle(this.handle);
|
|
5155
|
-
this._bound = true;
|
|
5156
|
-
value = funcOrHandle();
|
|
5157
|
-
this._bound = false;
|
|
5158
|
-
this._bindHandle(null);
|
|
5159
|
-
} else {
|
|
5160
|
-
value = funcOrHandle();
|
|
5161
|
-
}
|
|
5162
|
-
return value;
|
|
5163
|
-
}
|
|
5164
|
-
unbind() {
|
|
5165
|
-
this.bind(null);
|
|
5166
|
-
}
|
|
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
|
-
// Install stubs for removed methods
|
|
5244
|
-
stubRemovedMethods(className, version, methodNames) {
|
|
5245
|
-
return stubRemovedMethods(this, className, version, methodNames);
|
|
5246
|
-
}
|
|
5247
|
-
// PUBLIC VIRTUAL METHODS
|
|
5248
|
-
initialize(props) {
|
|
5249
|
-
}
|
|
5250
|
-
// PROTECTED METHODS - These must be overridden by subclass
|
|
5251
|
-
_createHandle() {
|
|
5252
|
-
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
5253
|
-
}
|
|
5254
|
-
_deleteHandle() {
|
|
5255
|
-
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
5256
|
-
}
|
|
5257
|
-
_bindHandle(handle) {
|
|
5258
|
-
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
5259
|
-
}
|
|
5260
|
-
_getOptsFromHandle() {
|
|
5261
|
-
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
5262
|
-
}
|
|
5263
|
-
_getParameter(pname, props) {
|
|
5264
|
-
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
5265
|
-
}
|
|
5266
|
-
_setParameter(pname, value) {
|
|
5267
|
-
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
5268
|
-
}
|
|
5269
|
-
// PRIVATE METHODS
|
|
5270
|
-
/*
|
|
5271
|
-
_addStats() {
|
|
5272
|
-
const name = this.constructor.name;
|
|
5273
|
-
const stats = lumaStats.get('Resource Counts');
|
|
5274
|
-
|
|
5275
|
-
stats.get('Resources Created').incrementCount();
|
|
5276
|
-
stats.get(`${name}s Created`).incrementCount();
|
|
5277
|
-
stats.get(`${name}s Active`).incrementCount();
|
|
5278
|
-
}
|
|
5279
|
-
|
|
5280
|
-
_removeStats() {
|
|
5281
|
-
const name = this.constructor.name;
|
|
5282
|
-
const stats = lumaStats.get('Resource Counts');
|
|
5283
|
-
|
|
5284
|
-
stats.get(`${name}s Active`).decrementCount();
|
|
5285
|
-
}
|
|
5286
|
-
|
|
5287
|
-
trackAllocatedMemory(bytes, name = this.constructor.name) {
|
|
5288
|
-
const stats = lumaStats.get('Memory Usage');
|
|
5289
|
-
|
|
5290
|
-
stats.get('GPU Memory').addCount(bytes);
|
|
5291
|
-
stats.get(`${name} Memory`).addCount(bytes);
|
|
5292
|
-
this.byteLength = bytes;
|
|
5293
|
-
}
|
|
5294
|
-
|
|
5295
|
-
trackDeallocatedMemory(name = this.constructor.name) {
|
|
5296
|
-
const stats = lumaStats.get('Memory Usage');
|
|
5297
|
-
|
|
5298
|
-
stats.get('GPU Memory').subtractCount(this.byteLength);
|
|
5299
|
-
stats.get(`${name} Memory`).subtractCount(this.byteLength);
|
|
5300
|
-
this.byteLength = 0;
|
|
5301
|
-
}
|
|
5302
|
-
*/
|
|
5303
|
-
};
|
|
5304
|
-
|
|
5305
|
-
// src/adapter/objects/webgl-renderbuffer.ts
|
|
5306
|
-
var _WEBGLRenderbuffer = class extends WebGLResource {
|
|
5307
|
-
get [Symbol.toStringTag]() {
|
|
5308
|
-
return "Renderbuffer";
|
|
5309
|
-
}
|
|
5310
|
-
get width() {
|
|
5311
|
-
return this.props.width;
|
|
5312
|
-
}
|
|
5313
|
-
get height() {
|
|
5314
|
-
return this.props.height;
|
|
5315
|
-
}
|
|
5316
|
-
get format() {
|
|
5317
|
-
return this.props.format;
|
|
5318
|
-
}
|
|
5319
|
-
get samples() {
|
|
5320
|
-
return this.props.samples;
|
|
5321
|
-
}
|
|
5322
|
-
get attachment() {
|
|
5323
|
-
return;
|
|
5324
|
-
}
|
|
5325
|
-
/** WebGL format constant */
|
|
5326
|
-
glFormat;
|
|
5327
|
-
static isTextureFormatSupported(device, format) {
|
|
5328
|
-
return isRenderbufferFormatSupported(device.gl, format);
|
|
5329
|
-
}
|
|
5330
|
-
constructor(device, props) {
|
|
5331
|
-
if (typeof props.format === "number") {
|
|
5332
|
-
throw new Error("Renderbuffer");
|
|
5333
|
-
}
|
|
5334
|
-
super(device, props, _WEBGLRenderbuffer.defaultProps);
|
|
5335
|
-
this.glFormat = convertTextureFormatToGL(this.props.format);
|
|
5336
|
-
this._initialize(this.props);
|
|
5337
|
-
}
|
|
5338
|
-
resize(size) {
|
|
5339
|
-
if (size.width !== this.width || size.height !== this.height) {
|
|
5340
|
-
Object.assign(this.props, { ...size, format: this.format, samples: this.samples });
|
|
5341
|
-
this._initialize(this.props);
|
|
5342
|
-
}
|
|
5343
|
-
}
|
|
5344
|
-
// PRIVATE METHODS
|
|
5345
|
-
/** Creates and initializes a renderbuffer object's data store */
|
|
5346
|
-
_initialize(props) {
|
|
5347
|
-
const { format, width, height, samples } = props;
|
|
5348
|
-
assert2(format, "Needs format");
|
|
5349
|
-
this.trackDeallocatedMemory();
|
|
5350
|
-
this.gl.bindRenderbuffer(import_constants11.GL.RENDERBUFFER, this.handle);
|
|
5351
|
-
if (samples !== 0) {
|
|
5352
|
-
this.gl.renderbufferStorageMultisample(import_constants11.GL.RENDERBUFFER, samples, this.glFormat, width, height);
|
|
5353
|
-
} else {
|
|
5354
|
-
this.gl.renderbufferStorage(import_constants11.GL.RENDERBUFFER, this.glFormat, width, height);
|
|
5355
|
-
}
|
|
5356
|
-
this.gl.bindRenderbuffer(import_constants11.GL.RENDERBUFFER, null);
|
|
5357
|
-
this.trackAllocatedMemory(
|
|
5358
|
-
width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat)
|
|
5359
|
-
);
|
|
5360
|
-
}
|
|
5361
|
-
// RESOURCE IMPLEMENTATION
|
|
5362
|
-
_createHandle() {
|
|
5363
|
-
return this.gl.createRenderbuffer();
|
|
5364
|
-
}
|
|
5365
|
-
_deleteHandle() {
|
|
5366
|
-
this.gl.deleteRenderbuffer(this.handle);
|
|
5367
|
-
this.trackDeallocatedMemory();
|
|
5368
|
-
}
|
|
5369
|
-
_bindHandle(handle) {
|
|
5370
|
-
this.gl.bindRenderbuffer(import_constants11.GL.RENDERBUFFER, handle);
|
|
5371
|
-
}
|
|
5372
|
-
};
|
|
5373
|
-
var WEBGLRenderbuffer = _WEBGLRenderbuffer;
|
|
5374
|
-
__publicField(WEBGLRenderbuffer, "defaultProps", {
|
|
5375
|
-
id: void 0,
|
|
5376
|
-
handle: void 0,
|
|
5377
|
-
userData: void 0,
|
|
5378
|
-
format: void 0,
|
|
5379
|
-
// 'depth16unorm'
|
|
5380
|
-
width: 1,
|
|
5381
|
-
height: 1,
|
|
5382
|
-
samples: 0
|
|
5383
|
-
});
|
|
5384
|
-
|
|
5385
|
-
// src/adapter/resources/webgl-framebuffer.ts
|
|
5386
|
-
var WEBGLFramebuffer = class extends Framebuffer {
|
|
5387
|
-
device;
|
|
5388
|
-
gl;
|
|
5389
|
-
handle;
|
|
5390
|
-
get texture() {
|
|
5391
|
-
return this.colorAttachments[0];
|
|
5392
|
-
}
|
|
5393
|
-
constructor(device, props) {
|
|
5394
|
-
super(device, props);
|
|
5395
|
-
const isDefaultFramebuffer = props.handle === null;
|
|
5396
|
-
this.device = device;
|
|
5397
|
-
this.gl = device.gl;
|
|
5398
|
-
this.handle = this.props.handle || isDefaultFramebuffer ? this.props.handle : this.gl.createFramebuffer();
|
|
5399
|
-
if (!isDefaultFramebuffer) {
|
|
5400
|
-
device.setSpectorMetadata(this.handle, { id: this.props.id, props: this.props });
|
|
5401
|
-
this.autoCreateAttachmentTextures();
|
|
5402
|
-
this.gl.bindFramebuffer(import_constants12.GL.FRAMEBUFFER, this.handle);
|
|
5403
|
-
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
5404
|
-
const attachment = this.colorAttachments[i];
|
|
5405
|
-
const attachmentPoint = import_constants12.GL.COLOR_ATTACHMENT0 + i;
|
|
5406
|
-
if (attachment) {
|
|
5407
|
-
this._attachOne(attachmentPoint, attachment);
|
|
5408
|
-
}
|
|
5409
|
-
}
|
|
5410
|
-
if (this.depthStencilAttachment) {
|
|
5411
|
-
this._attachOne(
|
|
5412
|
-
getDepthStencilAttachmentWebGL(this.depthStencilAttachment.format),
|
|
5413
|
-
this.depthStencilAttachment
|
|
5414
|
-
);
|
|
5415
|
-
}
|
|
5416
|
-
this.gl.bindFramebuffer(import_constants12.GL.FRAMEBUFFER, null);
|
|
5417
|
-
}
|
|
5418
|
-
if (props.check !== false) {
|
|
5419
|
-
this._checkStatus();
|
|
5420
|
-
}
|
|
5421
|
-
}
|
|
5422
|
-
/** destroys any auto created resources etc. */
|
|
5423
|
-
destroy() {
|
|
5424
|
-
super.destroy();
|
|
5425
|
-
if (!this.destroyed && this.handle !== null) {
|
|
5426
|
-
this.gl.deleteFramebuffer(this.handle);
|
|
5427
|
-
}
|
|
5292
|
+
/** destroys any auto created resources etc. */
|
|
5293
|
+
destroy() {
|
|
5294
|
+
super.destroy();
|
|
5295
|
+
if (!this.destroyed && this.handle !== null) {
|
|
5296
|
+
this.gl.deleteFramebuffer(this.handle);
|
|
5297
|
+
}
|
|
5428
5298
|
}
|
|
5429
5299
|
// 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
5300
|
/** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */
|
|
5441
5301
|
createDepthStencilTexture(format) {
|
|
5442
|
-
return new
|
|
5302
|
+
return new WEBGLTexture(this.device, {
|
|
5443
5303
|
id: `${this.id}-depth-stencil`,
|
|
5444
|
-
// TODO misleading if not depth and stencil?
|
|
5445
5304
|
format,
|
|
5446
|
-
// dataFormat: GL.DEPTH_STENCIL,
|
|
5447
|
-
// type: GL.UNSIGNED_INT_24_8,
|
|
5448
5305
|
width: this.width,
|
|
5449
|
-
height: this.height
|
|
5306
|
+
height: this.height,
|
|
5307
|
+
mipmaps: false
|
|
5450
5308
|
});
|
|
5451
5309
|
}
|
|
5452
|
-
/**
|
|
5453
|
-
* Attachment resize is expected to be a noop if size is same
|
|
5310
|
+
/**
|
|
5311
|
+
* Attachment resize is expected to be a noop if size is same
|
|
5454
5312
|
*/
|
|
5455
5313
|
resizeAttachments(width, height) {
|
|
5456
5314
|
if (this.handle === null) {
|
|
@@ -5465,36 +5323,45 @@ ${htmlLog}
|
|
|
5465
5323
|
height = this.gl.drawingBufferHeight;
|
|
5466
5324
|
}
|
|
5467
5325
|
for (const colorAttachment of this.colorAttachments) {
|
|
5468
|
-
colorAttachment.resize({ width, height });
|
|
5326
|
+
colorAttachment.texture.resize({ width, height });
|
|
5469
5327
|
}
|
|
5470
5328
|
if (this.depthStencilAttachment) {
|
|
5471
|
-
this.depthStencilAttachment.resize({ width, height });
|
|
5329
|
+
this.depthStencilAttachment.texture.resize({ width, height });
|
|
5472
5330
|
}
|
|
5473
5331
|
return this;
|
|
5474
5332
|
}
|
|
5475
5333
|
/** Attach one attachment */
|
|
5476
5334
|
_attachOne(attachmentPoint, attachment) {
|
|
5477
|
-
if (attachment
|
|
5478
|
-
this._attachWEBGLRenderbuffer(attachmentPoint, attachment);
|
|
5479
|
-
return attachment;
|
|
5480
|
-
} else if (Array.isArray(attachment)) {
|
|
5335
|
+
if (Array.isArray(attachment)) {
|
|
5481
5336
|
const [texture, layer = 0, level = 0] = attachment;
|
|
5482
5337
|
this._attachTexture(attachmentPoint, texture, layer, level);
|
|
5483
5338
|
return texture;
|
|
5484
|
-
}
|
|
5339
|
+
}
|
|
5340
|
+
if (attachment instanceof WEBGLTexture) {
|
|
5485
5341
|
this._attachTexture(attachmentPoint, attachment, 0, 0);
|
|
5486
5342
|
return attachment;
|
|
5487
5343
|
}
|
|
5344
|
+
if (attachment instanceof WEBGLTextureView) {
|
|
5345
|
+
const textureView = attachment;
|
|
5346
|
+
this._attachTexture(
|
|
5347
|
+
attachmentPoint,
|
|
5348
|
+
textureView.texture,
|
|
5349
|
+
textureView.props.baseMipLevel,
|
|
5350
|
+
textureView.props.baseArrayLayer
|
|
5351
|
+
);
|
|
5352
|
+
return attachment.texture;
|
|
5353
|
+
}
|
|
5488
5354
|
throw new Error("attach");
|
|
5489
5355
|
}
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5356
|
+
// TODO - we do not seem to need render buffers in WebGL 2
|
|
5357
|
+
// protected _attachWEBGLRenderbuffer(attachment: GL, renderbuffer: WEBGLRenderbuffer): void {
|
|
5358
|
+
// this.gl.framebufferRenderbuffer(
|
|
5359
|
+
// GL.FRAMEBUFFER,
|
|
5360
|
+
// attachment,
|
|
5361
|
+
// GL.RENDERBUFFER,
|
|
5362
|
+
// renderbuffer.handle
|
|
5363
|
+
// );
|
|
5364
|
+
// }
|
|
5498
5365
|
/**
|
|
5499
5366
|
* @param attachment
|
|
5500
5367
|
* @param texture
|
|
@@ -5505,16 +5372,16 @@ ${htmlLog}
|
|
|
5505
5372
|
const { gl } = this.device;
|
|
5506
5373
|
gl.bindTexture(texture.target, texture.handle);
|
|
5507
5374
|
switch (texture.target) {
|
|
5508
|
-
case
|
|
5509
|
-
case
|
|
5510
|
-
gl.framebufferTextureLayer(
|
|
5375
|
+
case import_constants11.GL.TEXTURE_2D_ARRAY:
|
|
5376
|
+
case import_constants11.GL.TEXTURE_3D:
|
|
5377
|
+
gl.framebufferTextureLayer(import_constants11.GL.FRAMEBUFFER, attachment, texture.target, level, layer);
|
|
5511
5378
|
break;
|
|
5512
|
-
case
|
|
5379
|
+
case import_constants11.GL.TEXTURE_CUBE_MAP:
|
|
5513
5380
|
const face = mapIndexToCubeMapFace(layer);
|
|
5514
|
-
gl.framebufferTexture2D(
|
|
5381
|
+
gl.framebufferTexture2D(import_constants11.GL.FRAMEBUFFER, attachment, face, texture.handle, level);
|
|
5515
5382
|
break;
|
|
5516
|
-
case
|
|
5517
|
-
gl.framebufferTexture2D(
|
|
5383
|
+
case import_constants11.GL.TEXTURE_2D:
|
|
5384
|
+
gl.framebufferTexture2D(import_constants11.GL.FRAMEBUFFER, attachment, import_constants11.GL.TEXTURE_2D, texture.handle, level);
|
|
5518
5385
|
break;
|
|
5519
5386
|
default:
|
|
5520
5387
|
assert2(false, "Illegal texture type");
|
|
@@ -5523,21 +5390,21 @@ ${htmlLog}
|
|
|
5523
5390
|
}
|
|
5524
5391
|
};
|
|
5525
5392
|
function mapIndexToCubeMapFace(layer) {
|
|
5526
|
-
return layer <
|
|
5393
|
+
return layer < import_constants11.GL.TEXTURE_CUBE_MAP_POSITIVE_X ? layer + import_constants11.GL.TEXTURE_CUBE_MAP_POSITIVE_X : layer;
|
|
5527
5394
|
}
|
|
5528
5395
|
function _getFrameBufferStatus(status) {
|
|
5529
5396
|
switch (status) {
|
|
5530
|
-
case
|
|
5397
|
+
case import_constants11.GL.FRAMEBUFFER_COMPLETE:
|
|
5531
5398
|
return "success";
|
|
5532
|
-
case
|
|
5399
|
+
case import_constants11.GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
|
|
5533
5400
|
return "Mismatched attachments";
|
|
5534
|
-
case
|
|
5401
|
+
case import_constants11.GL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
|
|
5535
5402
|
return "No attachments";
|
|
5536
|
-
case
|
|
5403
|
+
case import_constants11.GL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
|
|
5537
5404
|
return "Height/width mismatch";
|
|
5538
|
-
case
|
|
5405
|
+
case import_constants11.GL.FRAMEBUFFER_UNSUPPORTED:
|
|
5539
5406
|
return "Unsupported or split attachments";
|
|
5540
|
-
case
|
|
5407
|
+
case import_constants11.GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
|
|
5541
5408
|
return "Samples mismatch";
|
|
5542
5409
|
default:
|
|
5543
5410
|
return `${status}`;
|
|
@@ -5630,7 +5497,9 @@ ${htmlLog}
|
|
|
5630
5497
|
if (!initialized) {
|
|
5631
5498
|
initialized = true;
|
|
5632
5499
|
spector.spyCanvases();
|
|
5633
|
-
spector?.onCaptureStarted.add(
|
|
5500
|
+
spector?.onCaptureStarted.add(
|
|
5501
|
+
(capture) => log.info("Spector capture started:", capture)()
|
|
5502
|
+
);
|
|
5634
5503
|
spector?.onCapture.add((capture) => {
|
|
5635
5504
|
log.info("Spector capture complete:", capture)();
|
|
5636
5505
|
spector?.getResultUI();
|
|
@@ -5652,9 +5521,9 @@ ${htmlLog}
|
|
|
5652
5521
|
}
|
|
5653
5522
|
|
|
5654
5523
|
// src/context/debug/webgl-developer-tools.ts
|
|
5655
|
-
var
|
|
5524
|
+
var import_constants12 = __toESM(require_constants(), 1);
|
|
5656
5525
|
var WEBGL_DEBUG_CDN_URL = "https://unpkg.com/webgl-debug@2.0.1/index.js";
|
|
5657
|
-
function
|
|
5526
|
+
function getWebGLContextData(gl) {
|
|
5658
5527
|
gl.luma = gl.luma || {};
|
|
5659
5528
|
return gl.luma;
|
|
5660
5529
|
}
|
|
@@ -5672,7 +5541,7 @@ ${htmlLog}
|
|
|
5672
5541
|
return props.debug ? getDebugContext(gl, props) : getRealContext(gl);
|
|
5673
5542
|
}
|
|
5674
5543
|
function getRealContext(gl) {
|
|
5675
|
-
const data =
|
|
5544
|
+
const data = getWebGLContextData(gl);
|
|
5676
5545
|
return data.realContext ? data.realContext : gl;
|
|
5677
5546
|
}
|
|
5678
5547
|
function getDebugContext(gl, props) {
|
|
@@ -5680,19 +5549,19 @@ ${htmlLog}
|
|
|
5680
5549
|
log.warn("webgl-debug not loaded")();
|
|
5681
5550
|
return gl;
|
|
5682
5551
|
}
|
|
5683
|
-
const data =
|
|
5552
|
+
const data = getWebGLContextData(gl);
|
|
5684
5553
|
if (data.debugContext) {
|
|
5685
5554
|
return data.debugContext;
|
|
5686
5555
|
}
|
|
5687
|
-
globalThis.WebGLDebugUtils.init({ ...
|
|
5556
|
+
globalThis.WebGLDebugUtils.init({ ...import_constants12.GL, ...gl });
|
|
5688
5557
|
const glDebug = globalThis.WebGLDebugUtils.makeDebugContext(
|
|
5689
5558
|
gl,
|
|
5690
5559
|
onGLError.bind(null, props),
|
|
5691
5560
|
onValidateGLFunc.bind(null, props)
|
|
5692
5561
|
);
|
|
5693
|
-
for (const key in
|
|
5694
|
-
if (!(key in glDebug) && typeof
|
|
5695
|
-
glDebug[key] =
|
|
5562
|
+
for (const key in import_constants12.GL) {
|
|
5563
|
+
if (!(key in glDebug) && typeof import_constants12.GL[key] === "number") {
|
|
5564
|
+
glDebug[key] = import_constants12.GL[key];
|
|
5696
5565
|
}
|
|
5697
5566
|
}
|
|
5698
5567
|
class WebGLDebugContext {
|
|
@@ -5730,7 +5599,9 @@ ${htmlLog}
|
|
|
5730
5599
|
}
|
|
5731
5600
|
if (props.break && props.break.length > 0) {
|
|
5732
5601
|
functionString = functionString || getFunctionString(functionName, functionArgs);
|
|
5733
|
-
const isBreakpoint = props.break.every(
|
|
5602
|
+
const isBreakpoint = props.break.every(
|
|
5603
|
+
(breakOn) => functionString.indexOf(breakOn) !== -1
|
|
5604
|
+
);
|
|
5734
5605
|
if (isBreakpoint) {
|
|
5735
5606
|
debugger;
|
|
5736
5607
|
}
|
|
@@ -5749,7 +5620,7 @@ ${htmlLog}
|
|
|
5749
5620
|
}
|
|
5750
5621
|
|
|
5751
5622
|
// src/adapter/resources/webgl-shader.ts
|
|
5752
|
-
var
|
|
5623
|
+
var import_constants13 = __toESM(require_constants(), 1);
|
|
5753
5624
|
|
|
5754
5625
|
// src/adapter/helpers/parse-shader-compiler-log.ts
|
|
5755
5626
|
function parseShaderCompilerLog(errLog) {
|
|
@@ -5804,10 +5675,10 @@ ${htmlLog}
|
|
|
5804
5675
|
this.device = device;
|
|
5805
5676
|
switch (this.props.stage) {
|
|
5806
5677
|
case "vertex":
|
|
5807
|
-
this.handle = this.props.handle || this.device.gl.createShader(
|
|
5678
|
+
this.handle = this.props.handle || this.device.gl.createShader(import_constants13.GL.VERTEX_SHADER);
|
|
5808
5679
|
break;
|
|
5809
5680
|
case "fragment":
|
|
5810
|
-
this.handle = this.props.handle || this.device.gl.createShader(
|
|
5681
|
+
this.handle = this.props.handle || this.device.gl.createShader(import_constants13.GL.FRAGMENT_SHADER);
|
|
5811
5682
|
break;
|
|
5812
5683
|
default:
|
|
5813
5684
|
throw new Error(this.props.stage);
|
|
@@ -5829,6 +5700,11 @@ ${htmlLog}
|
|
|
5829
5700
|
const log2 = this.device.gl.getShaderInfoLog(this.handle);
|
|
5830
5701
|
return parseShaderCompilerLog(log2);
|
|
5831
5702
|
}
|
|
5703
|
+
getTranslatedSource() {
|
|
5704
|
+
const extensions = this.device.getExtension("WEBGL_debug_shaders");
|
|
5705
|
+
const ext = extensions.WEBGL_debug_shaders;
|
|
5706
|
+
return ext?.getTranslatedShaderSource(this.handle);
|
|
5707
|
+
}
|
|
5832
5708
|
// PRIVATE METHODS
|
|
5833
5709
|
/** Compile a shader and get compilation status */
|
|
5834
5710
|
async _compile(source) {
|
|
@@ -5842,7 +5718,7 @@ ${source2}`;
|
|
|
5842
5718
|
this.compilationStatus = "pending";
|
|
5843
5719
|
return;
|
|
5844
5720
|
}
|
|
5845
|
-
if (!this.device.features.has("
|
|
5721
|
+
if (!this.device.features.has("compilation-status-async-webgl")) {
|
|
5846
5722
|
this._getCompilationStatus();
|
|
5847
5723
|
if (this.compilationStatus === "error") {
|
|
5848
5724
|
throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);
|
|
@@ -5860,13 +5736,13 @@ ${source2}`;
|
|
|
5860
5736
|
async _waitForCompilationComplete() {
|
|
5861
5737
|
const waitMs = async (ms) => await new Promise((resolve) => setTimeout(resolve, ms));
|
|
5862
5738
|
const DELAY_MS = 10;
|
|
5863
|
-
if (!this.device.features.has("
|
|
5739
|
+
if (!this.device.features.has("compilation-status-async-webgl")) {
|
|
5864
5740
|
await waitMs(DELAY_MS);
|
|
5865
5741
|
return;
|
|
5866
5742
|
}
|
|
5867
5743
|
const { gl } = this.device;
|
|
5868
5744
|
for (; ; ) {
|
|
5869
|
-
const complete = gl.getShaderParameter(this.handle,
|
|
5745
|
+
const complete = gl.getShaderParameter(this.handle, import_constants13.GL.COMPLETION_STATUS_KHR);
|
|
5870
5746
|
if (complete) {
|
|
5871
5747
|
return;
|
|
5872
5748
|
}
|
|
@@ -5877,14 +5753,14 @@ ${source2}`;
|
|
|
5877
5753
|
* Get the shader compilation status
|
|
5878
5754
|
* TODO - Load log even when no error reported, to catch warnings?
|
|
5879
5755
|
* https://gamedev.stackexchange.com/questions/30429/how-to-detect-glsl-warnings
|
|
5880
|
-
|
|
5756
|
+
*/
|
|
5881
5757
|
_getCompilationStatus() {
|
|
5882
|
-
this.compilationStatus = this.device.gl.getShaderParameter(this.handle,
|
|
5758
|
+
this.compilationStatus = this.device.gl.getShaderParameter(this.handle, import_constants13.GL.COMPILE_STATUS) ? "success" : "error";
|
|
5883
5759
|
}
|
|
5884
5760
|
};
|
|
5885
5761
|
|
|
5886
5762
|
// src/adapter/resources/webgl-render-pass.ts
|
|
5887
|
-
var
|
|
5763
|
+
var import_constants14 = __toESM(require_constants(), 1);
|
|
5888
5764
|
var GL_DEPTH_BUFFER_BIT = 256;
|
|
5889
5765
|
var GL_STENCIL_BUFFER_BIT = 1024;
|
|
5890
5766
|
var GL_COLOR_BUFFER_BIT = 16384;
|
|
@@ -5903,7 +5779,7 @@ ${source2}`;
|
|
|
5903
5779
|
end() {
|
|
5904
5780
|
popContextState(this.device.gl);
|
|
5905
5781
|
if (this.props.framebuffer) {
|
|
5906
|
-
setGLParameters(this.device, { framebuffer: null });
|
|
5782
|
+
setGLParameters(this.device.gl, { framebuffer: null });
|
|
5907
5783
|
}
|
|
5908
5784
|
}
|
|
5909
5785
|
pushDebugGroup(groupLabel) {
|
|
@@ -5912,7 +5788,6 @@ ${source2}`;
|
|
|
5912
5788
|
}
|
|
5913
5789
|
insertDebugMarker(markerLabel) {
|
|
5914
5790
|
}
|
|
5915
|
-
// writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
|
|
5916
5791
|
// beginOcclusionQuery(queryIndex: number): void;
|
|
5917
5792
|
// endOcclusionQuery(): void;
|
|
5918
5793
|
// executeBundles(bundles: Iterable<GPURenderBundle>): void;
|
|
@@ -5928,7 +5803,7 @@ ${source2}`;
|
|
|
5928
5803
|
glParameters.depthMask = !this.props.depthReadOnly;
|
|
5929
5804
|
}
|
|
5930
5805
|
glParameters.stencilMask = this.props.stencilReadOnly ? 0 : 1;
|
|
5931
|
-
glParameters[
|
|
5806
|
+
glParameters[import_constants14.GL.RASTERIZER_DISCARD] = this.props.discard;
|
|
5932
5807
|
if (parameters.viewport) {
|
|
5933
5808
|
if (parameters.viewport.length >= 6) {
|
|
5934
5809
|
glParameters.viewport = parameters.viewport.slice(0, 4);
|
|
@@ -5946,12 +5821,20 @@ ${source2}`;
|
|
|
5946
5821
|
}
|
|
5947
5822
|
if (parameters.stencilReference) {
|
|
5948
5823
|
console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL");
|
|
5949
|
-
parameters[
|
|
5824
|
+
parameters[import_constants14.GL.STENCIL_REF] = parameters.stencilReference;
|
|
5950
5825
|
}
|
|
5951
5826
|
this.glParameters = glParameters;
|
|
5952
|
-
setGLParameters(this.device, glParameters);
|
|
5827
|
+
setGLParameters(this.device.gl, glParameters);
|
|
5953
5828
|
}
|
|
5954
|
-
|
|
5829
|
+
beginOcclusionQuery(queryIndex) {
|
|
5830
|
+
const webglQuerySet = this.props.occlusionQuerySet;
|
|
5831
|
+
webglQuerySet?.beginOcclusionQuery();
|
|
5832
|
+
}
|
|
5833
|
+
endOcclusionQuery() {
|
|
5834
|
+
const webglQuerySet = this.props.occlusionQuerySet;
|
|
5835
|
+
webglQuerySet?.endOcclusionQuery();
|
|
5836
|
+
}
|
|
5837
|
+
// PRIVATE
|
|
5955
5838
|
/**
|
|
5956
5839
|
* Optionally clears depth, color and stencil buffers based on parameters
|
|
5957
5840
|
*/
|
|
@@ -5971,13 +5854,13 @@ ${source2}`;
|
|
|
5971
5854
|
glParameters.clearStencil = this.props.clearStencil;
|
|
5972
5855
|
}
|
|
5973
5856
|
if (clearMask !== 0) {
|
|
5974
|
-
withGLParameters(this.device, glParameters, () => {
|
|
5857
|
+
withGLParameters(this.device.gl, glParameters, () => {
|
|
5975
5858
|
this.device.gl.clear(clearMask);
|
|
5976
5859
|
});
|
|
5977
5860
|
}
|
|
5978
5861
|
}
|
|
5979
|
-
/**
|
|
5980
|
-
* WebGL2 - clear a specific color buffer
|
|
5862
|
+
/**
|
|
5863
|
+
* WebGL2 - clear a specific color buffer
|
|
5981
5864
|
*/
|
|
5982
5865
|
clearColorBuffer(drawBuffer = 0, value = [0, 0, 0, 0]) {
|
|
5983
5866
|
withGLParameters(this.device.gl, { framebuffer: this.props.framebuffer }, () => {
|
|
@@ -6016,36 +5899,36 @@ ${source2}`;
|
|
|
6016
5899
|
};
|
|
6017
5900
|
|
|
6018
5901
|
// src/adapter/resources/webgl-render-pipeline.ts
|
|
6019
|
-
var
|
|
5902
|
+
var import_constants21 = __toESM(require_constants(), 1);
|
|
6020
5903
|
|
|
6021
5904
|
// src/adapter/helpers/get-shader-layout.ts
|
|
6022
|
-
var
|
|
5905
|
+
var import_constants18 = __toESM(require_constants(), 1);
|
|
6023
5906
|
|
|
6024
5907
|
// src/classic/accessor.ts
|
|
6025
|
-
var
|
|
5908
|
+
var import_constants16 = __toESM(require_constants(), 1);
|
|
6026
5909
|
|
|
6027
5910
|
// src/classic/typed-array-utils.ts
|
|
6028
|
-
var
|
|
5911
|
+
var import_constants15 = __toESM(require_constants(), 1);
|
|
6029
5912
|
var ERR_TYPE_DEDUCTION = "Failed to deduce GL constant from typed array";
|
|
6030
5913
|
function getGLTypeFromTypedArray(arrayOrType) {
|
|
6031
5914
|
const type = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;
|
|
6032
5915
|
switch (type) {
|
|
6033
5916
|
case Float32Array:
|
|
6034
|
-
return
|
|
5917
|
+
return import_constants15.GL.FLOAT;
|
|
6035
5918
|
case Uint16Array:
|
|
6036
|
-
return
|
|
5919
|
+
return import_constants15.GL.UNSIGNED_SHORT;
|
|
6037
5920
|
case Uint32Array:
|
|
6038
|
-
return
|
|
5921
|
+
return import_constants15.GL.UNSIGNED_INT;
|
|
6039
5922
|
case Uint8Array:
|
|
6040
|
-
return
|
|
5923
|
+
return import_constants15.GL.UNSIGNED_BYTE;
|
|
6041
5924
|
case Uint8ClampedArray:
|
|
6042
|
-
return
|
|
5925
|
+
return import_constants15.GL.UNSIGNED_BYTE;
|
|
6043
5926
|
case Int8Array:
|
|
6044
|
-
return
|
|
5927
|
+
return import_constants15.GL.BYTE;
|
|
6045
5928
|
case Int16Array:
|
|
6046
|
-
return
|
|
5929
|
+
return import_constants15.GL.SHORT;
|
|
6047
5930
|
case Int32Array:
|
|
6048
|
-
return
|
|
5931
|
+
return import_constants15.GL.INT;
|
|
6049
5932
|
default:
|
|
6050
5933
|
throw new Error(ERR_TYPE_DEDUCTION);
|
|
6051
5934
|
}
|
|
@@ -6053,22 +5936,22 @@ ${source2}`;
|
|
|
6053
5936
|
function getTypedArrayFromGLType(glType, options) {
|
|
6054
5937
|
const { clamped = true } = options || {};
|
|
6055
5938
|
switch (glType) {
|
|
6056
|
-
case
|
|
5939
|
+
case import_constants15.GL.FLOAT:
|
|
6057
5940
|
return Float32Array;
|
|
6058
|
-
case
|
|
6059
|
-
case
|
|
6060
|
-
case
|
|
6061
|
-
case
|
|
5941
|
+
case import_constants15.GL.UNSIGNED_SHORT:
|
|
5942
|
+
case import_constants15.GL.UNSIGNED_SHORT_5_6_5:
|
|
5943
|
+
case import_constants15.GL.UNSIGNED_SHORT_4_4_4_4:
|
|
5944
|
+
case import_constants15.GL.UNSIGNED_SHORT_5_5_5_1:
|
|
6062
5945
|
return Uint16Array;
|
|
6063
|
-
case
|
|
5946
|
+
case import_constants15.GL.UNSIGNED_INT:
|
|
6064
5947
|
return Uint32Array;
|
|
6065
|
-
case
|
|
5948
|
+
case import_constants15.GL.UNSIGNED_BYTE:
|
|
6066
5949
|
return clamped ? Uint8ClampedArray : Uint8Array;
|
|
6067
|
-
case
|
|
5950
|
+
case import_constants15.GL.BYTE:
|
|
6068
5951
|
return Int8Array;
|
|
6069
|
-
case
|
|
5952
|
+
case import_constants15.GL.SHORT:
|
|
6070
5953
|
return Int16Array;
|
|
6071
|
-
case
|
|
5954
|
+
case import_constants15.GL.INT:
|
|
6072
5955
|
return Int32Array;
|
|
6073
5956
|
default:
|
|
6074
5957
|
throw new Error("Failed to deduce typed array type from GL constant");
|
|
@@ -6079,7 +5962,7 @@ ${source2}`;
|
|
|
6079
5962
|
var DEFAULT_ACCESSOR_VALUES = {
|
|
6080
5963
|
offset: 0,
|
|
6081
5964
|
stride: 0,
|
|
6082
|
-
type:
|
|
5965
|
+
type: import_constants16.GL.FLOAT,
|
|
6083
5966
|
size: 1,
|
|
6084
5967
|
divisor: 0,
|
|
6085
5968
|
normalized: false,
|
|
@@ -6102,12 +5985,12 @@ ${source2}`;
|
|
|
6102
5985
|
buffer;
|
|
6103
5986
|
index;
|
|
6104
5987
|
static getBytesPerElement(accessor) {
|
|
6105
|
-
const ArrayType = getTypedArrayFromGLType(accessor.type ||
|
|
5988
|
+
const ArrayType = getTypedArrayFromGLType(accessor.type || import_constants16.GL.FLOAT);
|
|
6106
5989
|
return ArrayType.BYTES_PER_ELEMENT;
|
|
6107
5990
|
}
|
|
6108
5991
|
static getBytesPerVertex(accessor) {
|
|
6109
5992
|
assert2(accessor.size);
|
|
6110
|
-
const ArrayType = getTypedArrayFromGLType(accessor.type ||
|
|
5993
|
+
const ArrayType = getTypedArrayFromGLType(accessor.type || import_constants16.GL.FLOAT);
|
|
6111
5994
|
return ArrayType.BYTES_PER_ELEMENT * accessor.size;
|
|
6112
5995
|
}
|
|
6113
5996
|
// Combines (merges) a list of accessors. On top of default values
|
|
@@ -6138,7 +6021,7 @@ ${source2}`;
|
|
|
6138
6021
|
props = checkProps("Accessor", props, PROP_CHECKS);
|
|
6139
6022
|
if (props.type !== void 0) {
|
|
6140
6023
|
this.type = props.type;
|
|
6141
|
-
if (props.type ===
|
|
6024
|
+
if (props.type === import_constants16.GL.INT || props.type === import_constants16.GL.UNSIGNED_INT) {
|
|
6142
6025
|
this.integer = true;
|
|
6143
6026
|
}
|
|
6144
6027
|
}
|
|
@@ -6202,62 +6085,62 @@ ${source2}`;
|
|
|
6202
6085
|
};
|
|
6203
6086
|
|
|
6204
6087
|
// src/adapter/helpers/decode-webgl-types.ts
|
|
6205
|
-
var
|
|
6088
|
+
var import_constants17 = __toESM(require_constants(), 1);
|
|
6206
6089
|
function isSamplerUniform(type) {
|
|
6207
6090
|
return SAMPLER_TYPES.includes(type);
|
|
6208
6091
|
}
|
|
6209
6092
|
var SAMPLER_TYPES = [
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6093
|
+
import_constants17.GL.SAMPLER_2D,
|
|
6094
|
+
import_constants17.GL.SAMPLER_CUBE,
|
|
6095
|
+
import_constants17.GL.SAMPLER_3D,
|
|
6096
|
+
import_constants17.GL.SAMPLER_2D_SHADOW,
|
|
6097
|
+
import_constants17.GL.SAMPLER_2D_ARRAY,
|
|
6098
|
+
import_constants17.GL.SAMPLER_2D_ARRAY_SHADOW,
|
|
6099
|
+
import_constants17.GL.SAMPLER_CUBE_SHADOW,
|
|
6100
|
+
import_constants17.GL.INT_SAMPLER_2D,
|
|
6101
|
+
import_constants17.GL.INT_SAMPLER_3D,
|
|
6102
|
+
import_constants17.GL.INT_SAMPLER_CUBE,
|
|
6103
|
+
import_constants17.GL.INT_SAMPLER_2D_ARRAY,
|
|
6104
|
+
import_constants17.GL.UNSIGNED_INT_SAMPLER_2D,
|
|
6105
|
+
import_constants17.GL.UNSIGNED_INT_SAMPLER_3D,
|
|
6106
|
+
import_constants17.GL.UNSIGNED_INT_SAMPLER_CUBE,
|
|
6107
|
+
import_constants17.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY
|
|
6225
6108
|
];
|
|
6226
6109
|
var COMPOSITE_GL_TYPES = {
|
|
6227
|
-
[
|
|
6228
|
-
[
|
|
6229
|
-
[
|
|
6230
|
-
[
|
|
6231
|
-
[
|
|
6232
|
-
[
|
|
6233
|
-
[
|
|
6234
|
-
[
|
|
6235
|
-
[
|
|
6236
|
-
[
|
|
6237
|
-
[
|
|
6238
|
-
[
|
|
6239
|
-
[
|
|
6240
|
-
[
|
|
6241
|
-
[
|
|
6242
|
-
[
|
|
6110
|
+
[import_constants17.GL.FLOAT]: [import_constants17.GL.FLOAT, 1, "float", "f32", "float32"],
|
|
6111
|
+
[import_constants17.GL.FLOAT_VEC2]: [import_constants17.GL.FLOAT, 2, "vec2", "vec2<f32>", "float32x2"],
|
|
6112
|
+
[import_constants17.GL.FLOAT_VEC3]: [import_constants17.GL.FLOAT, 3, "vec3", "vec3<f32>", "float32x3"],
|
|
6113
|
+
[import_constants17.GL.FLOAT_VEC4]: [import_constants17.GL.FLOAT, 4, "vec4", "vec4<f32>", "float32x4"],
|
|
6114
|
+
[import_constants17.GL.INT]: [import_constants17.GL.INT, 1, "int", "i32", "sint32"],
|
|
6115
|
+
[import_constants17.GL.INT_VEC2]: [import_constants17.GL.INT, 2, "ivec2", "vec2<i32>", "sint32x2"],
|
|
6116
|
+
[import_constants17.GL.INT_VEC3]: [import_constants17.GL.INT, 3, "ivec3", "vec3<i32>", "sint32x3"],
|
|
6117
|
+
[import_constants17.GL.INT_VEC4]: [import_constants17.GL.INT, 4, "ivec4", "vec4<i32>", "sint32x4"],
|
|
6118
|
+
[import_constants17.GL.UNSIGNED_INT]: [import_constants17.GL.UNSIGNED_INT, 1, "uint", "u32", "uint32"],
|
|
6119
|
+
[import_constants17.GL.UNSIGNED_INT_VEC2]: [import_constants17.GL.UNSIGNED_INT, 2, "uvec2", "vec2<u32>", "uint32x2"],
|
|
6120
|
+
[import_constants17.GL.UNSIGNED_INT_VEC3]: [import_constants17.GL.UNSIGNED_INT, 3, "uvec3", "vec3<u32>", "uint32x3"],
|
|
6121
|
+
[import_constants17.GL.UNSIGNED_INT_VEC4]: [import_constants17.GL.UNSIGNED_INT, 4, "uvec4", "vec4<u32>", "uint32x4"],
|
|
6122
|
+
[import_constants17.GL.BOOL]: [import_constants17.GL.FLOAT, 1, "bool", "f32", "float32"],
|
|
6123
|
+
[import_constants17.GL.BOOL_VEC2]: [import_constants17.GL.FLOAT, 2, "bvec2", "vec2<f32>", "float32x2"],
|
|
6124
|
+
[import_constants17.GL.BOOL_VEC3]: [import_constants17.GL.FLOAT, 3, "bvec3", "vec3<f32>", "float32x3"],
|
|
6125
|
+
[import_constants17.GL.BOOL_VEC4]: [import_constants17.GL.FLOAT, 4, "bvec4", "vec4<f32>", "float32x4"],
|
|
6243
6126
|
// TODO - are sizes/components below correct?
|
|
6244
|
-
[
|
|
6127
|
+
[import_constants17.GL.FLOAT_MAT2]: [import_constants17.GL.FLOAT, 8, "mat2", "mat2x2<f32>"],
|
|
6245
6128
|
// 4
|
|
6246
|
-
[
|
|
6129
|
+
[import_constants17.GL.FLOAT_MAT2x3]: [import_constants17.GL.FLOAT, 8, "mat2x3", "mat2x3<f32>"],
|
|
6247
6130
|
// 6
|
|
6248
|
-
[
|
|
6131
|
+
[import_constants17.GL.FLOAT_MAT2x4]: [import_constants17.GL.FLOAT, 8, "mat2x4", "mat2x4<f32>"],
|
|
6249
6132
|
// 8
|
|
6250
|
-
[
|
|
6133
|
+
[import_constants17.GL.FLOAT_MAT3x2]: [import_constants17.GL.FLOAT, 12, "mat3x2", "mat3x2<f32>"],
|
|
6251
6134
|
// 6
|
|
6252
|
-
[
|
|
6135
|
+
[import_constants17.GL.FLOAT_MAT3]: [import_constants17.GL.FLOAT, 12, "mat3", "mat3x3<f32>"],
|
|
6253
6136
|
// 9
|
|
6254
|
-
[
|
|
6137
|
+
[import_constants17.GL.FLOAT_MAT3x4]: [import_constants17.GL.FLOAT, 12, "mat3x4", "mat3x4<f32>"],
|
|
6255
6138
|
// 12
|
|
6256
|
-
[
|
|
6139
|
+
[import_constants17.GL.FLOAT_MAT4x2]: [import_constants17.GL.FLOAT, 16, "mat4x2", "mat4x2<f32>"],
|
|
6257
6140
|
// 8
|
|
6258
|
-
[
|
|
6141
|
+
[import_constants17.GL.FLOAT_MAT4x3]: [import_constants17.GL.FLOAT, 16, "mat4x3", "mat4x3<f32>"],
|
|
6259
6142
|
// 12
|
|
6260
|
-
[
|
|
6143
|
+
[import_constants17.GL.FLOAT_MAT4]: [import_constants17.GL.FLOAT, 16, "mat4", "mat4x4<f32>"]
|
|
6261
6144
|
// 16
|
|
6262
6145
|
};
|
|
6263
6146
|
function decodeGLUniformType(glUniformType) {
|
|
@@ -6359,7 +6242,7 @@ ${source2}`;
|
|
|
6359
6242
|
}
|
|
6360
6243
|
function readVaryings(gl, program) {
|
|
6361
6244
|
const varyings = [];
|
|
6362
|
-
const count = gl.getProgramParameter(program,
|
|
6245
|
+
const count = gl.getProgramParameter(program, import_constants18.GL.TRANSFORM_FEEDBACK_VARYINGS);
|
|
6363
6246
|
for (let location = 0; location < count; location++) {
|
|
6364
6247
|
const activeInfo = gl.getTransformFeedbackVarying(program, location);
|
|
6365
6248
|
if (!activeInfo) {
|
|
@@ -6376,7 +6259,7 @@ ${source2}`;
|
|
|
6376
6259
|
}
|
|
6377
6260
|
function readUniformBindings(gl, program) {
|
|
6378
6261
|
const uniforms = [];
|
|
6379
|
-
const uniformCount = gl.getProgramParameter(program,
|
|
6262
|
+
const uniformCount = gl.getProgramParameter(program, import_constants18.GL.ACTIVE_UNIFORMS);
|
|
6380
6263
|
for (let i = 0; i < uniformCount; i++) {
|
|
6381
6264
|
const activeInfo = gl.getActiveUniform(program, i);
|
|
6382
6265
|
if (!activeInfo) {
|
|
@@ -6412,22 +6295,22 @@ ${source2}`;
|
|
|
6412
6295
|
function readUniformBlocks(gl, program) {
|
|
6413
6296
|
const getBlockParameter = (blockIndex, pname) => gl.getActiveUniformBlockParameter(program, blockIndex, pname);
|
|
6414
6297
|
const uniformBlocks = [];
|
|
6415
|
-
const blockCount = gl.getProgramParameter(program,
|
|
6298
|
+
const blockCount = gl.getProgramParameter(program, import_constants18.GL.ACTIVE_UNIFORM_BLOCKS);
|
|
6416
6299
|
for (let blockIndex = 0; blockIndex < blockCount; blockIndex++) {
|
|
6417
6300
|
const blockInfo = {
|
|
6418
6301
|
name: gl.getActiveUniformBlockName(program, blockIndex) || "",
|
|
6419
|
-
location: getBlockParameter(blockIndex,
|
|
6420
|
-
byteLength: getBlockParameter(blockIndex,
|
|
6421
|
-
vertex: getBlockParameter(blockIndex,
|
|
6422
|
-
fragment: getBlockParameter(blockIndex,
|
|
6423
|
-
uniformCount: getBlockParameter(blockIndex,
|
|
6302
|
+
location: getBlockParameter(blockIndex, import_constants18.GL.UNIFORM_BLOCK_BINDING),
|
|
6303
|
+
byteLength: getBlockParameter(blockIndex, import_constants18.GL.UNIFORM_BLOCK_DATA_SIZE),
|
|
6304
|
+
vertex: getBlockParameter(blockIndex, import_constants18.GL.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),
|
|
6305
|
+
fragment: getBlockParameter(blockIndex, import_constants18.GL.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),
|
|
6306
|
+
uniformCount: getBlockParameter(blockIndex, import_constants18.GL.UNIFORM_BLOCK_ACTIVE_UNIFORMS),
|
|
6424
6307
|
uniforms: []
|
|
6425
6308
|
};
|
|
6426
|
-
const uniformIndices = getBlockParameter(blockIndex,
|
|
6427
|
-
const uniformType = gl.getActiveUniforms(program, uniformIndices,
|
|
6428
|
-
const uniformArrayLength = gl.getActiveUniforms(program, uniformIndices,
|
|
6429
|
-
const uniformOffset = gl.getActiveUniforms(program, uniformIndices,
|
|
6430
|
-
const uniformStride = gl.getActiveUniforms(program, uniformIndices,
|
|
6309
|
+
const uniformIndices = getBlockParameter(blockIndex, import_constants18.GL.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES) || [];
|
|
6310
|
+
const uniformType = gl.getActiveUniforms(program, uniformIndices, import_constants18.GL.UNIFORM_TYPE);
|
|
6311
|
+
const uniformArrayLength = gl.getActiveUniforms(program, uniformIndices, import_constants18.GL.UNIFORM_SIZE);
|
|
6312
|
+
const uniformOffset = gl.getActiveUniforms(program, uniformIndices, import_constants18.GL.UNIFORM_OFFSET);
|
|
6313
|
+
const uniformStride = gl.getActiveUniforms(program, uniformIndices, import_constants18.GL.UNIFORM_ARRAY_STRIDE);
|
|
6431
6314
|
for (let i = 0; i < blockInfo.uniformCount; ++i) {
|
|
6432
6315
|
const activeInfo = gl.getActiveUniform(program, uniformIndices[i]);
|
|
6433
6316
|
if (!activeInfo) {
|
|
@@ -6450,21 +6333,21 @@ ${source2}`;
|
|
|
6450
6333
|
return uniformBlocks;
|
|
6451
6334
|
}
|
|
6452
6335
|
var SAMPLER_UNIFORMS_GL_TO_GPU = {
|
|
6453
|
-
[
|
|
6454
|
-
[
|
|
6455
|
-
[
|
|
6456
|
-
[
|
|
6457
|
-
[
|
|
6458
|
-
[
|
|
6459
|
-
[
|
|
6460
|
-
[
|
|
6461
|
-
[
|
|
6462
|
-
[
|
|
6463
|
-
[
|
|
6464
|
-
[
|
|
6465
|
-
[
|
|
6466
|
-
[
|
|
6467
|
-
[
|
|
6336
|
+
[import_constants18.GL.SAMPLER_2D]: ["2d", "float"],
|
|
6337
|
+
[import_constants18.GL.SAMPLER_CUBE]: ["cube", "float"],
|
|
6338
|
+
[import_constants18.GL.SAMPLER_3D]: ["3d", "float"],
|
|
6339
|
+
[import_constants18.GL.SAMPLER_2D_SHADOW]: ["3d", "depth"],
|
|
6340
|
+
[import_constants18.GL.SAMPLER_2D_ARRAY]: ["2d-array", "float"],
|
|
6341
|
+
[import_constants18.GL.SAMPLER_2D_ARRAY_SHADOW]: ["2d-array", "depth"],
|
|
6342
|
+
[import_constants18.GL.SAMPLER_CUBE_SHADOW]: ["cube", "float"],
|
|
6343
|
+
[import_constants18.GL.INT_SAMPLER_2D]: ["2d", "sint"],
|
|
6344
|
+
[import_constants18.GL.INT_SAMPLER_3D]: ["3d", "sint"],
|
|
6345
|
+
[import_constants18.GL.INT_SAMPLER_CUBE]: ["cube", "sint"],
|
|
6346
|
+
[import_constants18.GL.INT_SAMPLER_2D_ARRAY]: ["2d-array", "uint"],
|
|
6347
|
+
[import_constants18.GL.UNSIGNED_INT_SAMPLER_2D]: ["2d", "uint"],
|
|
6348
|
+
[import_constants18.GL.UNSIGNED_INT_SAMPLER_3D]: ["3d", "uint"],
|
|
6349
|
+
[import_constants18.GL.UNSIGNED_INT_SAMPLER_CUBE]: ["cube", "uint"],
|
|
6350
|
+
[import_constants18.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]: ["2d-array", "uint"]
|
|
6468
6351
|
};
|
|
6469
6352
|
function getSamplerInfo(type) {
|
|
6470
6353
|
const sampler = SAMPLER_UNIFORMS_GL_TO_GPU[type];
|
|
@@ -6495,7 +6378,7 @@ ${source2}`;
|
|
|
6495
6378
|
}
|
|
6496
6379
|
|
|
6497
6380
|
// src/adapter/helpers/set-uniform.ts
|
|
6498
|
-
var
|
|
6381
|
+
var import_constants19 = __toESM(require_constants(), 1);
|
|
6499
6382
|
function setUniform(gl, location, type, value) {
|
|
6500
6383
|
const gl2 = gl;
|
|
6501
6384
|
let uniformValue = value;
|
|
@@ -6507,97 +6390,97 @@ ${source2}`;
|
|
|
6507
6390
|
}
|
|
6508
6391
|
const arrayValue = typeof uniformValue === "number" ? [uniformValue] : uniformValue;
|
|
6509
6392
|
switch (type) {
|
|
6510
|
-
case
|
|
6511
|
-
case
|
|
6512
|
-
case
|
|
6513
|
-
case
|
|
6514
|
-
case
|
|
6515
|
-
case
|
|
6516
|
-
case
|
|
6517
|
-
case
|
|
6518
|
-
case
|
|
6519
|
-
case
|
|
6520
|
-
case
|
|
6521
|
-
case
|
|
6522
|
-
case
|
|
6523
|
-
case
|
|
6524
|
-
case
|
|
6393
|
+
case import_constants19.GL.SAMPLER_2D:
|
|
6394
|
+
case import_constants19.GL.SAMPLER_CUBE:
|
|
6395
|
+
case import_constants19.GL.SAMPLER_3D:
|
|
6396
|
+
case import_constants19.GL.SAMPLER_2D_SHADOW:
|
|
6397
|
+
case import_constants19.GL.SAMPLER_2D_ARRAY:
|
|
6398
|
+
case import_constants19.GL.SAMPLER_2D_ARRAY_SHADOW:
|
|
6399
|
+
case import_constants19.GL.SAMPLER_CUBE_SHADOW:
|
|
6400
|
+
case import_constants19.GL.INT_SAMPLER_2D:
|
|
6401
|
+
case import_constants19.GL.INT_SAMPLER_3D:
|
|
6402
|
+
case import_constants19.GL.INT_SAMPLER_CUBE:
|
|
6403
|
+
case import_constants19.GL.INT_SAMPLER_2D_ARRAY:
|
|
6404
|
+
case import_constants19.GL.UNSIGNED_INT_SAMPLER_2D:
|
|
6405
|
+
case import_constants19.GL.UNSIGNED_INT_SAMPLER_3D:
|
|
6406
|
+
case import_constants19.GL.UNSIGNED_INT_SAMPLER_CUBE:
|
|
6407
|
+
case import_constants19.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY:
|
|
6525
6408
|
if (typeof value !== "number") {
|
|
6526
6409
|
throw new Error("samplers must be set to integers");
|
|
6527
6410
|
}
|
|
6528
6411
|
return gl.uniform1i(location, value);
|
|
6529
|
-
case
|
|
6412
|
+
case import_constants19.GL.FLOAT:
|
|
6530
6413
|
return gl.uniform1fv(location, arrayValue);
|
|
6531
|
-
case
|
|
6414
|
+
case import_constants19.GL.FLOAT_VEC2:
|
|
6532
6415
|
return gl.uniform2fv(location, arrayValue);
|
|
6533
|
-
case
|
|
6416
|
+
case import_constants19.GL.FLOAT_VEC3:
|
|
6534
6417
|
return gl.uniform3fv(location, arrayValue);
|
|
6535
|
-
case
|
|
6418
|
+
case import_constants19.GL.FLOAT_VEC4:
|
|
6536
6419
|
return gl.uniform4fv(location, arrayValue);
|
|
6537
|
-
case
|
|
6420
|
+
case import_constants19.GL.INT:
|
|
6538
6421
|
return gl.uniform1iv(location, arrayValue);
|
|
6539
|
-
case
|
|
6422
|
+
case import_constants19.GL.INT_VEC2:
|
|
6540
6423
|
return gl.uniform2iv(location, arrayValue);
|
|
6541
|
-
case
|
|
6424
|
+
case import_constants19.GL.INT_VEC3:
|
|
6542
6425
|
return gl.uniform3iv(location, arrayValue);
|
|
6543
|
-
case
|
|
6426
|
+
case import_constants19.GL.INT_VEC4:
|
|
6544
6427
|
return gl.uniform4iv(location, arrayValue);
|
|
6545
|
-
case
|
|
6428
|
+
case import_constants19.GL.BOOL:
|
|
6546
6429
|
return gl.uniform1iv(location, arrayValue);
|
|
6547
|
-
case
|
|
6430
|
+
case import_constants19.GL.BOOL_VEC2:
|
|
6548
6431
|
return gl.uniform2iv(location, arrayValue);
|
|
6549
|
-
case
|
|
6432
|
+
case import_constants19.GL.BOOL_VEC3:
|
|
6550
6433
|
return gl.uniform3iv(location, arrayValue);
|
|
6551
|
-
case
|
|
6434
|
+
case import_constants19.GL.BOOL_VEC4:
|
|
6552
6435
|
return gl.uniform4iv(location, arrayValue);
|
|
6553
|
-
case
|
|
6436
|
+
case import_constants19.GL.UNSIGNED_INT:
|
|
6554
6437
|
return gl2.uniform1uiv(location, arrayValue, 1);
|
|
6555
|
-
case
|
|
6438
|
+
case import_constants19.GL.UNSIGNED_INT_VEC2:
|
|
6556
6439
|
return gl2.uniform2uiv(location, arrayValue, 2);
|
|
6557
|
-
case
|
|
6440
|
+
case import_constants19.GL.UNSIGNED_INT_VEC3:
|
|
6558
6441
|
return gl2.uniform3uiv(location, arrayValue, 3);
|
|
6559
|
-
case
|
|
6442
|
+
case import_constants19.GL.UNSIGNED_INT_VEC4:
|
|
6560
6443
|
return gl2.uniform4uiv(location, arrayValue, 4);
|
|
6561
|
-
case
|
|
6444
|
+
case import_constants19.GL.FLOAT_MAT2:
|
|
6562
6445
|
return gl.uniformMatrix2fv(location, false, arrayValue);
|
|
6563
|
-
case
|
|
6446
|
+
case import_constants19.GL.FLOAT_MAT3:
|
|
6564
6447
|
return gl.uniformMatrix3fv(location, false, arrayValue);
|
|
6565
|
-
case
|
|
6448
|
+
case import_constants19.GL.FLOAT_MAT4:
|
|
6566
6449
|
return gl.uniformMatrix4fv(location, false, arrayValue);
|
|
6567
|
-
case
|
|
6450
|
+
case import_constants19.GL.FLOAT_MAT2x3:
|
|
6568
6451
|
return gl2.uniformMatrix2x3fv(location, false, arrayValue);
|
|
6569
|
-
case
|
|
6452
|
+
case import_constants19.GL.FLOAT_MAT2x4:
|
|
6570
6453
|
return gl2.uniformMatrix2x4fv(location, false, arrayValue);
|
|
6571
|
-
case
|
|
6454
|
+
case import_constants19.GL.FLOAT_MAT3x2:
|
|
6572
6455
|
return gl2.uniformMatrix3x2fv(location, false, arrayValue);
|
|
6573
|
-
case
|
|
6456
|
+
case import_constants19.GL.FLOAT_MAT3x4:
|
|
6574
6457
|
return gl2.uniformMatrix3x4fv(location, false, arrayValue);
|
|
6575
|
-
case
|
|
6458
|
+
case import_constants19.GL.FLOAT_MAT4x2:
|
|
6576
6459
|
return gl2.uniformMatrix4x2fv(location, false, arrayValue);
|
|
6577
|
-
case
|
|
6460
|
+
case import_constants19.GL.FLOAT_MAT4x3:
|
|
6578
6461
|
return gl2.uniformMatrix4x3fv(location, false, arrayValue);
|
|
6579
6462
|
}
|
|
6580
6463
|
throw new Error("Illegal uniform");
|
|
6581
6464
|
}
|
|
6582
6465
|
|
|
6583
6466
|
// src/adapter/helpers/webgl-topology-utils.ts
|
|
6584
|
-
var
|
|
6467
|
+
var import_constants20 = __toESM(require_constants(), 1);
|
|
6585
6468
|
function getGLDrawMode(topology) {
|
|
6586
6469
|
switch (topology) {
|
|
6587
6470
|
case "point-list":
|
|
6588
|
-
return
|
|
6471
|
+
return import_constants20.GL.POINTS;
|
|
6589
6472
|
case "line-list":
|
|
6590
|
-
return
|
|
6473
|
+
return import_constants20.GL.LINES;
|
|
6591
6474
|
case "line-strip":
|
|
6592
|
-
return
|
|
6475
|
+
return import_constants20.GL.LINE_STRIP;
|
|
6593
6476
|
case "line-loop-webgl":
|
|
6594
|
-
return
|
|
6477
|
+
return import_constants20.GL.LINE_LOOP;
|
|
6595
6478
|
case "triangle-list":
|
|
6596
|
-
return
|
|
6479
|
+
return import_constants20.GL.TRIANGLES;
|
|
6597
6480
|
case "triangle-strip":
|
|
6598
|
-
return
|
|
6481
|
+
return import_constants20.GL.TRIANGLE_STRIP;
|
|
6599
6482
|
case "triangle-fan-webgl":
|
|
6600
|
-
return
|
|
6483
|
+
return import_constants20.GL.TRIANGLE_FAN;
|
|
6601
6484
|
default:
|
|
6602
6485
|
throw new Error(topology);
|
|
6603
6486
|
}
|
|
@@ -6605,19 +6488,19 @@ ${source2}`;
|
|
|
6605
6488
|
function getGLPrimitive(topology) {
|
|
6606
6489
|
switch (topology) {
|
|
6607
6490
|
case "point-list":
|
|
6608
|
-
return
|
|
6491
|
+
return import_constants20.GL.POINTS;
|
|
6609
6492
|
case "line-list":
|
|
6610
|
-
return
|
|
6493
|
+
return import_constants20.GL.LINES;
|
|
6611
6494
|
case "line-strip":
|
|
6612
|
-
return
|
|
6495
|
+
return import_constants20.GL.LINES;
|
|
6613
6496
|
case "line-loop-webgl":
|
|
6614
|
-
return
|
|
6497
|
+
return import_constants20.GL.LINES;
|
|
6615
6498
|
case "triangle-list":
|
|
6616
|
-
return
|
|
6499
|
+
return import_constants20.GL.TRIANGLES;
|
|
6617
6500
|
case "triangle-strip":
|
|
6618
|
-
return
|
|
6501
|
+
return import_constants20.GL.TRIANGLES;
|
|
6619
6502
|
case "triangle-fan-webgl":
|
|
6620
|
-
return
|
|
6503
|
+
return import_constants20.GL.TRIANGLES;
|
|
6621
6504
|
default:
|
|
6622
6505
|
throw new Error(topology);
|
|
6623
6506
|
}
|
|
@@ -6652,13 +6535,15 @@ ${source2}`;
|
|
|
6652
6535
|
this.device.setSpectorMetadata(this.handle, { id: this.props.id });
|
|
6653
6536
|
this.vs = cast(props.vs);
|
|
6654
6537
|
this.fs = cast(props.fs);
|
|
6655
|
-
const { varyings, bufferMode =
|
|
6538
|
+
const { varyings, bufferMode = import_constants21.GL.SEPARATE_ATTRIBS } = props;
|
|
6656
6539
|
if (varyings && varyings.length > 0) {
|
|
6657
6540
|
this.varyings = varyings;
|
|
6658
6541
|
this.device.gl.transformFeedbackVaryings(this.handle, varyings, bufferMode);
|
|
6659
6542
|
}
|
|
6660
6543
|
this._linkShaders();
|
|
6544
|
+
log.time(0, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
6661
6545
|
this.introspectedLayout = getShaderLayout(this.device.gl, this.handle);
|
|
6546
|
+
log.timeEnd(0, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
6662
6547
|
this.shaderLayout = mergeShaderLayout(this.introspectedLayout, props.shaderLayout);
|
|
6663
6548
|
switch (this.props.topology) {
|
|
6664
6549
|
case "triangle-fan-webgl":
|
|
@@ -6700,7 +6585,7 @@ ${source2}`;
|
|
|
6700
6585
|
}
|
|
6701
6586
|
break;
|
|
6702
6587
|
case "texture":
|
|
6703
|
-
if (!(value instanceof WEBGLTexture || value instanceof WEBGLFramebuffer)) {
|
|
6588
|
+
if (!(value instanceof WEBGLTextureView || value instanceof WEBGLTexture || value instanceof WEBGLFramebuffer)) {
|
|
6704
6589
|
throw new Error("texture value");
|
|
6705
6590
|
}
|
|
6706
6591
|
break;
|
|
@@ -6713,26 +6598,11 @@ ${source2}`;
|
|
|
6713
6598
|
this.bindings[name2] = value;
|
|
6714
6599
|
}
|
|
6715
6600
|
}
|
|
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
6601
|
/** @todo needed for portable model
|
|
6729
6602
|
* @note The WebGL API is offers many ways to draw things
|
|
6730
6603
|
* This function unifies those ways into a single call using common parameters with sane defaults
|
|
6731
6604
|
*/
|
|
6732
6605
|
draw(options) {
|
|
6733
|
-
if (this.linkStatus !== "success") {
|
|
6734
|
-
return false;
|
|
6735
|
-
}
|
|
6736
6606
|
const {
|
|
6737
6607
|
renderPass,
|
|
6738
6608
|
vertexArray,
|
|
@@ -6749,9 +6619,18 @@ ${source2}`;
|
|
|
6749
6619
|
const isIndexed = Boolean(vertexArray.indexBuffer);
|
|
6750
6620
|
const glIndexType = vertexArray.indexBuffer?.glIndexType;
|
|
6751
6621
|
const isInstanced = Number(instanceCount) > 0;
|
|
6622
|
+
if (this.linkStatus !== "success") {
|
|
6623
|
+
log.info(2, `RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)();
|
|
6624
|
+
return false;
|
|
6625
|
+
}
|
|
6752
6626
|
if (!this._areTexturesRenderable() || vertexCount === 0) {
|
|
6627
|
+
log.info(2, `RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)();
|
|
6753
6628
|
return false;
|
|
6754
6629
|
}
|
|
6630
|
+
if (vertexCount === 0) {
|
|
6631
|
+
log.info(2, `RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)();
|
|
6632
|
+
return true;
|
|
6633
|
+
}
|
|
6755
6634
|
this.device.gl.useProgram(this.handle);
|
|
6756
6635
|
vertexArray.bindBeforeRender(renderPass);
|
|
6757
6636
|
if (transformFeedback) {
|
|
@@ -6794,6 +6673,18 @@ ${source2}`;
|
|
|
6794
6673
|
vertexArray.unbindAfterRender(renderPass);
|
|
6795
6674
|
return true;
|
|
6796
6675
|
}
|
|
6676
|
+
// DEPRECATED METHODS
|
|
6677
|
+
setUniformsWebGL(uniforms) {
|
|
6678
|
+
const { bindings } = splitUniformsAndBindings(uniforms);
|
|
6679
|
+
Object.keys(bindings).forEach((name2) => {
|
|
6680
|
+
log.warn(
|
|
6681
|
+
`Unsupported value "${JSON.stringify(
|
|
6682
|
+
bindings[name2]
|
|
6683
|
+
)}" used in setUniforms() for key ${name2}. Use setBindings() instead?`
|
|
6684
|
+
)();
|
|
6685
|
+
});
|
|
6686
|
+
Object.assign(this.uniforms, uniforms);
|
|
6687
|
+
}
|
|
6797
6688
|
// PRIVATE METHODS
|
|
6798
6689
|
// setAttributes(attributes: Record<string, Buffer>): void {}
|
|
6799
6690
|
// setBindings(bindings: Record<string, Binding>): void {}
|
|
@@ -6806,7 +6697,7 @@ ${source2}`;
|
|
|
6806
6697
|
log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
|
|
6807
6698
|
if (log.level === 0) {
|
|
6808
6699
|
}
|
|
6809
|
-
if (!this.device.features.has("
|
|
6700
|
+
if (!this.device.features.has("compilation-status-async-webgl")) {
|
|
6810
6701
|
const status2 = this._getLinkStatus();
|
|
6811
6702
|
this._reportLinkStatus(status2);
|
|
6812
6703
|
return;
|
|
@@ -6859,13 +6750,13 @@ ${source2}`;
|
|
|
6859
6750
|
async _waitForLinkComplete() {
|
|
6860
6751
|
const waitMs = async (ms) => await new Promise((resolve) => setTimeout(resolve, ms));
|
|
6861
6752
|
const DELAY_MS = 10;
|
|
6862
|
-
if (!this.device.features.has("
|
|
6753
|
+
if (!this.device.features.has("compilation-status-async-webgl")) {
|
|
6863
6754
|
await waitMs(DELAY_MS);
|
|
6864
6755
|
return;
|
|
6865
6756
|
}
|
|
6866
6757
|
const { gl } = this.device;
|
|
6867
6758
|
for (; ; ) {
|
|
6868
|
-
const complete = gl.getProgramParameter(this.handle,
|
|
6759
|
+
const complete = gl.getProgramParameter(this.handle, import_constants21.GL.COMPLETION_STATUS_KHR);
|
|
6869
6760
|
if (complete) {
|
|
6870
6761
|
return;
|
|
6871
6762
|
}
|
|
@@ -6905,15 +6796,15 @@ ${source2}`;
|
|
|
6905
6796
|
case "uniform":
|
|
6906
6797
|
const { name: name2 } = binding;
|
|
6907
6798
|
const location = gl.getUniformBlockIndex(this.handle, name2);
|
|
6908
|
-
if (location ===
|
|
6799
|
+
if (location === import_constants21.GL.INVALID_INDEX) {
|
|
6909
6800
|
throw new Error(`Invalid uniform block name ${name2}`);
|
|
6910
6801
|
}
|
|
6911
6802
|
gl.uniformBlockBinding(this.handle, uniformBufferIndex, location);
|
|
6912
6803
|
if (value instanceof WEBGLBuffer) {
|
|
6913
|
-
gl.bindBufferBase(
|
|
6804
|
+
gl.bindBufferBase(import_constants21.GL.UNIFORM_BUFFER, uniformBufferIndex, value.handle);
|
|
6914
6805
|
} else {
|
|
6915
6806
|
gl.bindBufferRange(
|
|
6916
|
-
|
|
6807
|
+
import_constants21.GL.UNIFORM_BUFFER,
|
|
6917
6808
|
uniformBufferIndex,
|
|
6918
6809
|
// @ts-expect-error
|
|
6919
6810
|
value.buffer.handle,
|
|
@@ -6926,11 +6817,13 @@ ${source2}`;
|
|
|
6926
6817
|
uniformBufferIndex += 1;
|
|
6927
6818
|
break;
|
|
6928
6819
|
case "texture":
|
|
6929
|
-
if (!(value instanceof WEBGLTexture || value instanceof WEBGLFramebuffer)) {
|
|
6820
|
+
if (!(value instanceof WEBGLTextureView || value instanceof WEBGLTexture || value instanceof WEBGLFramebuffer)) {
|
|
6930
6821
|
throw new Error("texture");
|
|
6931
6822
|
}
|
|
6932
6823
|
let texture;
|
|
6933
|
-
if (value instanceof
|
|
6824
|
+
if (value instanceof WEBGLTextureView) {
|
|
6825
|
+
texture = value.texture;
|
|
6826
|
+
} else if (value instanceof WEBGLTexture) {
|
|
6934
6827
|
texture = value;
|
|
6935
6828
|
} else if (value instanceof WEBGLFramebuffer && value.colorAttachments[0] instanceof WEBGLTexture) {
|
|
6936
6829
|
log.warn(
|
|
@@ -6940,7 +6833,7 @@ ${source2}`;
|
|
|
6940
6833
|
} else {
|
|
6941
6834
|
throw new Error("No texture");
|
|
6942
6835
|
}
|
|
6943
|
-
gl.activeTexture(
|
|
6836
|
+
gl.activeTexture(import_constants21.GL.TEXTURE0 + textureUnit);
|
|
6944
6837
|
gl.bindTexture(texture.target, texture.handle);
|
|
6945
6838
|
textureUnit += 1;
|
|
6946
6839
|
break;
|
|
@@ -6968,7 +6861,7 @@ ${source2}`;
|
|
|
6968
6861
|
};
|
|
6969
6862
|
|
|
6970
6863
|
// src/adapter/resources/webgl-command-buffer.ts
|
|
6971
|
-
var
|
|
6864
|
+
var import_constants22 = __toESM(require_constants(), 1);
|
|
6972
6865
|
function cast2(value) {
|
|
6973
6866
|
return value;
|
|
6974
6867
|
}
|
|
@@ -7001,17 +6894,17 @@ ${source2}`;
|
|
|
7001
6894
|
function _copyBufferToBuffer(device, options) {
|
|
7002
6895
|
const source = cast2(options.source);
|
|
7003
6896
|
const destination = cast2(options.destination);
|
|
7004
|
-
device.gl.bindBuffer(
|
|
7005
|
-
device.gl.bindBuffer(
|
|
6897
|
+
device.gl.bindBuffer(import_constants22.GL.COPY_READ_BUFFER, source.handle);
|
|
6898
|
+
device.gl.bindBuffer(import_constants22.GL.COPY_WRITE_BUFFER, destination.handle);
|
|
7006
6899
|
device.gl.copyBufferSubData(
|
|
7007
|
-
|
|
7008
|
-
|
|
6900
|
+
import_constants22.GL.COPY_READ_BUFFER,
|
|
6901
|
+
import_constants22.GL.COPY_WRITE_BUFFER,
|
|
7009
6902
|
options.sourceOffset ?? 0,
|
|
7010
6903
|
options.destinationOffset ?? 0,
|
|
7011
6904
|
options.size
|
|
7012
6905
|
);
|
|
7013
|
-
device.gl.bindBuffer(
|
|
7014
|
-
device.gl.bindBuffer(
|
|
6906
|
+
device.gl.bindBuffer(import_constants22.GL.COPY_READ_BUFFER, null);
|
|
6907
|
+
device.gl.bindBuffer(import_constants22.GL.COPY_WRITE_BUFFER, null);
|
|
7015
6908
|
}
|
|
7016
6909
|
function _copyBufferToTexture(device, options) {
|
|
7017
6910
|
throw new Error("Not implemented");
|
|
@@ -7058,11 +6951,11 @@ ${source2}`;
|
|
|
7058
6951
|
const webglBuffer = destination;
|
|
7059
6952
|
const sourceWidth = width || framebuffer.width;
|
|
7060
6953
|
const sourceHeight = height || framebuffer.height;
|
|
7061
|
-
const sourceParams = getWebGLTextureParameters(framebuffer.texture.format);
|
|
6954
|
+
const sourceParams = getWebGLTextureParameters(framebuffer.texture.props.format);
|
|
7062
6955
|
const sourceFormat = sourceParams.dataFormat;
|
|
7063
6956
|
const sourceType = sourceParams.type;
|
|
7064
|
-
device.gl.bindBuffer(
|
|
7065
|
-
device.gl.bindFramebuffer(
|
|
6957
|
+
device.gl.bindBuffer(import_constants22.GL.PIXEL_PACK_BUFFER, webglBuffer.handle);
|
|
6958
|
+
device.gl.bindFramebuffer(import_constants22.GL.FRAMEBUFFER, framebuffer.handle);
|
|
7066
6959
|
device.gl.readPixels(
|
|
7067
6960
|
origin[0],
|
|
7068
6961
|
origin[1],
|
|
@@ -7073,8 +6966,8 @@ ${source2}`;
|
|
|
7073
6966
|
byteOffset
|
|
7074
6967
|
);
|
|
7075
6968
|
} finally {
|
|
7076
|
-
device.gl.bindBuffer(
|
|
7077
|
-
device.gl.bindFramebuffer(
|
|
6969
|
+
device.gl.bindBuffer(import_constants22.GL.PIXEL_PACK_BUFFER, null);
|
|
6970
|
+
device.gl.bindFramebuffer(import_constants22.GL.FRAMEBUFFER, null);
|
|
7078
6971
|
if (destroyFramebuffer) {
|
|
7079
6972
|
framebuffer.destroy();
|
|
7080
6973
|
}
|
|
@@ -7105,11 +6998,11 @@ ${source2}`;
|
|
|
7105
6998
|
// depthOrArrayLayers = 0
|
|
7106
6999
|
} = options;
|
|
7107
7000
|
const destinationMipmaplevel = 0;
|
|
7108
|
-
const destinationInternalFormat =
|
|
7001
|
+
const destinationInternalFormat = import_constants22.GL.RGBA;
|
|
7109
7002
|
const { framebuffer, destroyFramebuffer } = getFramebuffer(source);
|
|
7110
7003
|
const [sourceX, sourceY] = origin;
|
|
7111
7004
|
const isSubCopy = false;
|
|
7112
|
-
device.gl.bindFramebuffer(
|
|
7005
|
+
device.gl.bindFramebuffer(import_constants22.GL.FRAMEBUFFER, framebuffer.handle);
|
|
7113
7006
|
let texture = null;
|
|
7114
7007
|
let textureTarget;
|
|
7115
7008
|
if (destination instanceof WEBGLTexture) {
|
|
@@ -7192,18 +7085,12 @@ ${source2}`;
|
|
|
7192
7085
|
}
|
|
7193
7086
|
insertDebugMarker(markerLabel) {
|
|
7194
7087
|
}
|
|
7195
|
-
|
|
7196
|
-
|
|
7197
|
-
// querySet: GPUQuerySet,
|
|
7198
|
-
// firstQuery: number,
|
|
7199
|
-
// queryCount: number,
|
|
7200
|
-
// destination: Buffer,
|
|
7201
|
-
// destinationOffset?: number;
|
|
7202
|
-
// }): void;
|
|
7088
|
+
resolveQuerySet(querySet, destination, options) {
|
|
7089
|
+
}
|
|
7203
7090
|
};
|
|
7204
7091
|
|
|
7205
7092
|
// src/adapter/resources/webgl-vertex-array.ts
|
|
7206
|
-
var
|
|
7093
|
+
var import_constants23 = __toESM(require_constants(), 1);
|
|
7207
7094
|
var WEBGLVertexArray = class extends VertexArray {
|
|
7208
7095
|
get [Symbol.toStringTag]() {
|
|
7209
7096
|
return "VertexArray";
|
|
@@ -7241,22 +7128,22 @@ ${source2}`;
|
|
|
7241
7128
|
*/
|
|
7242
7129
|
setIndexBuffer(indexBuffer) {
|
|
7243
7130
|
const buffer = indexBuffer;
|
|
7244
|
-
if (buffer && buffer.glTarget !==
|
|
7131
|
+
if (buffer && buffer.glTarget !== import_constants23.GL.ELEMENT_ARRAY_BUFFER) {
|
|
7245
7132
|
throw new Error("Use .setBuffer()");
|
|
7246
7133
|
}
|
|
7247
7134
|
this.device.gl.bindVertexArray(this.handle);
|
|
7248
|
-
this.device.gl.bindBuffer(
|
|
7135
|
+
this.device.gl.bindBuffer(import_constants23.GL.ELEMENT_ARRAY_BUFFER, buffer ? buffer.handle : null);
|
|
7249
7136
|
this.indexBuffer = buffer;
|
|
7250
7137
|
}
|
|
7251
7138
|
/** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */
|
|
7252
7139
|
setBuffer(location, attributeBuffer) {
|
|
7253
7140
|
const buffer = attributeBuffer;
|
|
7254
|
-
if (buffer.glTarget ===
|
|
7141
|
+
if (buffer.glTarget === import_constants23.GL.ELEMENT_ARRAY_BUFFER) {
|
|
7255
7142
|
throw new Error("Use .setIndexBuffer()");
|
|
7256
7143
|
}
|
|
7257
7144
|
const { size, type, stride, offset, normalized, integer, divisor } = this._getAccessor(location);
|
|
7258
7145
|
this.device.gl.bindVertexArray(this.handle);
|
|
7259
|
-
this.device.gl.bindBuffer(
|
|
7146
|
+
this.device.gl.bindBuffer(import_constants23.GL.ARRAY_BUFFER, buffer.handle);
|
|
7260
7147
|
if (integer) {
|
|
7261
7148
|
this.device.gl.vertexAttribIPointer(location, size, type, stride, offset);
|
|
7262
7149
|
} else {
|
|
@@ -7267,7 +7154,7 @@ ${source2}`;
|
|
|
7267
7154
|
this.attributes[location] = buffer;
|
|
7268
7155
|
}
|
|
7269
7156
|
/** Set a location in vertex attributes array to a constant value, disables the location */
|
|
7270
|
-
|
|
7157
|
+
setConstantWebGL(location, value) {
|
|
7271
7158
|
this._enable(location, false);
|
|
7272
7159
|
this.attributes[location] = value;
|
|
7273
7160
|
}
|
|
@@ -7276,7 +7163,7 @@ ${source2}`;
|
|
|
7276
7163
|
this.device.gl.bindVertexArray(this.handle);
|
|
7277
7164
|
if (!this.init) {
|
|
7278
7165
|
const webglBuffer = this.indexBuffer;
|
|
7279
|
-
this.device.gl.bindBuffer(
|
|
7166
|
+
this.device.gl.bindBuffer(import_constants23.GL.ELEMENT_ARRAY_BUFFER, webglBuffer?.handle || null);
|
|
7280
7167
|
this.init = true;
|
|
7281
7168
|
}
|
|
7282
7169
|
this._applyConstantAttributes();
|
|
@@ -7295,7 +7182,7 @@ ${source2}`;
|
|
|
7295
7182
|
for (let location = 0; location < this.maxVertexAttributes; ++location) {
|
|
7296
7183
|
const constant = this.attributes[location];
|
|
7297
7184
|
if (ArrayBuffer.isView(constant)) {
|
|
7298
|
-
this.device.
|
|
7185
|
+
this.device.setConstantAttributeWebGL(location, constant);
|
|
7299
7186
|
}
|
|
7300
7187
|
}
|
|
7301
7188
|
}
|
|
@@ -7402,7 +7289,7 @@ ${source2}`;
|
|
|
7402
7289
|
}
|
|
7403
7290
|
|
|
7404
7291
|
// src/adapter/resources/webgl-transform-feedback.ts
|
|
7405
|
-
var
|
|
7292
|
+
var import_constants24 = __toESM(require_constants(), 1);
|
|
7406
7293
|
var WEBGLTransformFeedback = class extends TransformFeedback {
|
|
7407
7294
|
device;
|
|
7408
7295
|
gl;
|
|
@@ -7438,7 +7325,7 @@ ${source2}`;
|
|
|
7438
7325
|
super.destroy();
|
|
7439
7326
|
}
|
|
7440
7327
|
begin(topology = "point-list") {
|
|
7441
|
-
this.gl.bindTransformFeedback(
|
|
7328
|
+
this.gl.bindTransformFeedback(import_constants24.GL.TRANSFORM_FEEDBACK, this.handle);
|
|
7442
7329
|
if (this.bindOnUse) {
|
|
7443
7330
|
this._bindBuffers();
|
|
7444
7331
|
}
|
|
@@ -7449,7 +7336,7 @@ ${source2}`;
|
|
|
7449
7336
|
if (!this.bindOnUse) {
|
|
7450
7337
|
this._unbindBuffers();
|
|
7451
7338
|
}
|
|
7452
|
-
this.gl.bindTransformFeedback(
|
|
7339
|
+
this.gl.bindTransformFeedback(import_constants24.GL.TRANSFORM_FEEDBACK, null);
|
|
7453
7340
|
}
|
|
7454
7341
|
// SUBCLASS
|
|
7455
7342
|
setBuffers(buffers) {
|
|
@@ -7483,16 +7370,16 @@ ${source2}`;
|
|
|
7483
7370
|
}
|
|
7484
7371
|
bind(funcOrHandle = this.handle) {
|
|
7485
7372
|
if (typeof funcOrHandle !== "function") {
|
|
7486
|
-
this.gl.bindTransformFeedback(
|
|
7373
|
+
this.gl.bindTransformFeedback(import_constants24.GL.TRANSFORM_FEEDBACK, funcOrHandle);
|
|
7487
7374
|
return this;
|
|
7488
7375
|
}
|
|
7489
7376
|
let value;
|
|
7490
7377
|
if (!this._bound) {
|
|
7491
|
-
this.gl.bindTransformFeedback(
|
|
7378
|
+
this.gl.bindTransformFeedback(import_constants24.GL.TRANSFORM_FEEDBACK, this.handle);
|
|
7492
7379
|
this._bound = true;
|
|
7493
7380
|
value = funcOrHandle();
|
|
7494
7381
|
this._bound = false;
|
|
7495
|
-
this.gl.bindTransformFeedback(
|
|
7382
|
+
this.gl.bindTransformFeedback(import_constants24.GL.TRANSFORM_FEEDBACK, null);
|
|
7496
7383
|
} else {
|
|
7497
7384
|
value = funcOrHandle();
|
|
7498
7385
|
}
|
|
@@ -7533,15 +7420,15 @@ ${source2}`;
|
|
|
7533
7420
|
}
|
|
7534
7421
|
_unbindBuffers() {
|
|
7535
7422
|
for (const bufferIndex in this.buffers) {
|
|
7536
|
-
this.gl.bindBufferBase(
|
|
7423
|
+
this.gl.bindBufferBase(import_constants24.GL.TRANSFORM_FEEDBACK_BUFFER, Number(bufferIndex), null);
|
|
7537
7424
|
}
|
|
7538
7425
|
}
|
|
7539
7426
|
_bindBuffer(index, buffer, byteOffset = 0, byteLength) {
|
|
7540
7427
|
const handle = buffer && buffer.handle;
|
|
7541
7428
|
if (!handle || byteLength === void 0) {
|
|
7542
|
-
this.gl.bindBufferBase(
|
|
7429
|
+
this.gl.bindBufferBase(import_constants24.GL.TRANSFORM_FEEDBACK_BUFFER, index, handle);
|
|
7543
7430
|
} else {
|
|
7544
|
-
this.gl.bindBufferRange(
|
|
7431
|
+
this.gl.bindBufferRange(import_constants24.GL.TRANSFORM_FEEDBACK_BUFFER, index, handle, byteOffset, byteLength);
|
|
7545
7432
|
}
|
|
7546
7433
|
}
|
|
7547
7434
|
};
|
|
@@ -7552,6 +7439,140 @@ ${source2}`;
|
|
|
7552
7439
|
return /^\d+$/.test(value);
|
|
7553
7440
|
}
|
|
7554
7441
|
|
|
7442
|
+
// src/adapter/resources/webgl-query-set.ts
|
|
7443
|
+
var import_constants25 = __toESM(require_constants(), 1);
|
|
7444
|
+
var WEBGLQuerySet = class extends QuerySet {
|
|
7445
|
+
device;
|
|
7446
|
+
handle;
|
|
7447
|
+
target = null;
|
|
7448
|
+
_queryPending = false;
|
|
7449
|
+
_pollingPromise = null;
|
|
7450
|
+
get [Symbol.toStringTag]() {
|
|
7451
|
+
return "Query";
|
|
7452
|
+
}
|
|
7453
|
+
// Create a query class
|
|
7454
|
+
constructor(device, props) {
|
|
7455
|
+
super(device, props);
|
|
7456
|
+
this.device = device;
|
|
7457
|
+
if (props.count > 1) {
|
|
7458
|
+
throw new Error("WebGL QuerySet can only have one value");
|
|
7459
|
+
}
|
|
7460
|
+
this.handle = this.device.gl.createQuery();
|
|
7461
|
+
Object.seal(this);
|
|
7462
|
+
}
|
|
7463
|
+
destroy() {
|
|
7464
|
+
this.device.gl.deleteQuery(this.handle);
|
|
7465
|
+
}
|
|
7466
|
+
// FOR RENDER PASS AND COMMAND ENCODER
|
|
7467
|
+
/**
|
|
7468
|
+
* Shortcut for timer query (dependent on extension in both WebGL1 and 2)
|
|
7469
|
+
* Measures GPU time delta between this call and a matching `end` call in the
|
|
7470
|
+
* GPU instruction stream.
|
|
7471
|
+
*/
|
|
7472
|
+
beginTimestampQuery() {
|
|
7473
|
+
return this._begin(import_constants25.GL.TIME_ELAPSED_EXT);
|
|
7474
|
+
}
|
|
7475
|
+
endTimestampQuery() {
|
|
7476
|
+
this._end();
|
|
7477
|
+
}
|
|
7478
|
+
// Shortcut for occlusion queries
|
|
7479
|
+
beginOcclusionQuery(options) {
|
|
7480
|
+
return this._begin(
|
|
7481
|
+
options?.conservative ? import_constants25.GL.ANY_SAMPLES_PASSED_CONSERVATIVE : import_constants25.GL.ANY_SAMPLES_PASSED
|
|
7482
|
+
);
|
|
7483
|
+
}
|
|
7484
|
+
endOcclusionQuery() {
|
|
7485
|
+
this._end();
|
|
7486
|
+
}
|
|
7487
|
+
// Shortcut for transformFeedbackQuery
|
|
7488
|
+
beginTransformFeedbackQuery() {
|
|
7489
|
+
return this._begin(import_constants25.GL.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
|
|
7490
|
+
}
|
|
7491
|
+
endTransformFeedbackQuery() {
|
|
7492
|
+
this._end();
|
|
7493
|
+
}
|
|
7494
|
+
async resolveQuery() {
|
|
7495
|
+
const value = await this.pollQuery();
|
|
7496
|
+
return [value];
|
|
7497
|
+
}
|
|
7498
|
+
// PRIVATE METHODS
|
|
7499
|
+
/**
|
|
7500
|
+
* Due to OpenGL API limitations, after calling `begin()` on one Query
|
|
7501
|
+
* instance, `end()` must be called on that same instance before
|
|
7502
|
+
* calling `begin()` on another query. While there can be multiple
|
|
7503
|
+
* outstanding queries representing disjoint `begin()`/`end()` intervals.
|
|
7504
|
+
* It is not possible to interleave or overlap `begin` and `end` calls.
|
|
7505
|
+
*/
|
|
7506
|
+
_begin(target) {
|
|
7507
|
+
if (this._queryPending) {
|
|
7508
|
+
return;
|
|
7509
|
+
}
|
|
7510
|
+
this.target = target;
|
|
7511
|
+
this.device.gl.beginQuery(this.target, this.handle);
|
|
7512
|
+
return;
|
|
7513
|
+
}
|
|
7514
|
+
// ends the current query
|
|
7515
|
+
_end() {
|
|
7516
|
+
if (this._queryPending) {
|
|
7517
|
+
return;
|
|
7518
|
+
}
|
|
7519
|
+
if (this.target) {
|
|
7520
|
+
this.device.gl.endQuery(this.target);
|
|
7521
|
+
this.target = null;
|
|
7522
|
+
this._queryPending = true;
|
|
7523
|
+
}
|
|
7524
|
+
return;
|
|
7525
|
+
}
|
|
7526
|
+
// Returns true if the query result is available
|
|
7527
|
+
isResultAvailable() {
|
|
7528
|
+
if (!this._queryPending) {
|
|
7529
|
+
return false;
|
|
7530
|
+
}
|
|
7531
|
+
const resultAvailable = this.device.gl.getQueryParameter(
|
|
7532
|
+
this.handle,
|
|
7533
|
+
import_constants25.GL.QUERY_RESULT_AVAILABLE
|
|
7534
|
+
);
|
|
7535
|
+
if (resultAvailable) {
|
|
7536
|
+
this._queryPending = false;
|
|
7537
|
+
}
|
|
7538
|
+
return resultAvailable;
|
|
7539
|
+
}
|
|
7540
|
+
// Timing query is disjoint, i.e. results are invalid
|
|
7541
|
+
isTimerDisjoint() {
|
|
7542
|
+
return this.device.gl.getParameter(import_constants25.GL.GPU_DISJOINT_EXT);
|
|
7543
|
+
}
|
|
7544
|
+
// Returns query result.
|
|
7545
|
+
getResult() {
|
|
7546
|
+
return this.device.gl.getQueryParameter(this.handle, import_constants25.GL.QUERY_RESULT);
|
|
7547
|
+
}
|
|
7548
|
+
// Returns the query result, converted to milliseconds to match JavaScript conventions.
|
|
7549
|
+
getTimerMilliseconds() {
|
|
7550
|
+
return this.getResult() / 1e6;
|
|
7551
|
+
}
|
|
7552
|
+
// Polls the query
|
|
7553
|
+
pollQuery(limit = Number.POSITIVE_INFINITY) {
|
|
7554
|
+
if (this._pollingPromise) {
|
|
7555
|
+
return this._pollingPromise;
|
|
7556
|
+
}
|
|
7557
|
+
let counter = 0;
|
|
7558
|
+
this._pollingPromise = new Promise((resolve, reject) => {
|
|
7559
|
+
const poll = () => {
|
|
7560
|
+
if (this.isResultAvailable()) {
|
|
7561
|
+
resolve(this.getResult());
|
|
7562
|
+
this._pollingPromise = null;
|
|
7563
|
+
} else if (counter++ > limit) {
|
|
7564
|
+
reject("Timed out");
|
|
7565
|
+
this._pollingPromise = null;
|
|
7566
|
+
} else {
|
|
7567
|
+
requestAnimationFrame(poll);
|
|
7568
|
+
}
|
|
7569
|
+
};
|
|
7570
|
+
requestAnimationFrame(poll);
|
|
7571
|
+
});
|
|
7572
|
+
return this._pollingPromise;
|
|
7573
|
+
}
|
|
7574
|
+
};
|
|
7575
|
+
|
|
7555
7576
|
// src/classic/copy-and-blit.ts
|
|
7556
7577
|
var import_constants27 = __toESM(require_constants(), 1);
|
|
7557
7578
|
|
|
@@ -7615,7 +7636,7 @@ ${source2}`;
|
|
|
7615
7636
|
sourceWidth = sourceWidth || framebuffer.width;
|
|
7616
7637
|
sourceHeight = sourceHeight || framebuffer.height;
|
|
7617
7638
|
const attachment = sourceAttachment - import_constants27.GL.COLOR_ATTACHMENT0;
|
|
7618
|
-
sourceType = sourceType || framebuffer.colorAttachments[attachment]?.type || import_constants27.GL.UNSIGNED_BYTE;
|
|
7639
|
+
sourceType = sourceType || framebuffer.colorAttachments[attachment]?.texture?.type || import_constants27.GL.UNSIGNED_BYTE;
|
|
7619
7640
|
target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight);
|
|
7620
7641
|
sourceType = sourceType || getGLTypeFromTypedArray(target);
|
|
7621
7642
|
const prevHandle = gl.bindFramebuffer(import_constants27.GL.FRAMEBUFFER, handle);
|
|
@@ -7627,7 +7648,13 @@ ${source2}`;
|
|
|
7627
7648
|
return target;
|
|
7628
7649
|
}
|
|
7629
7650
|
function readPixelsToBuffer(source, options) {
|
|
7630
|
-
const {
|
|
7651
|
+
const {
|
|
7652
|
+
target,
|
|
7653
|
+
sourceX = 0,
|
|
7654
|
+
sourceY = 0,
|
|
7655
|
+
sourceFormat = import_constants27.GL.RGBA,
|
|
7656
|
+
targetByteOffset = 0
|
|
7657
|
+
} = options || {};
|
|
7631
7658
|
let { sourceWidth, sourceHeight, sourceType } = options || {};
|
|
7632
7659
|
const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
|
|
7633
7660
|
assert2(framebuffer);
|
|
@@ -7715,8 +7742,8 @@ ${source2}`;
|
|
|
7715
7742
|
}
|
|
7716
7743
|
}
|
|
7717
7744
|
assert2(clearFlags !== 0, ERR_ARGUMENTS);
|
|
7718
|
-
|
|
7719
|
-
|
|
7745
|
+
const gl = device.gl;
|
|
7746
|
+
withGLParameters(gl, parameters, () => {
|
|
7720
7747
|
gl.clear(clearFlags);
|
|
7721
7748
|
});
|
|
7722
7749
|
}
|
|
@@ -7724,27 +7751,23 @@ ${source2}`;
|
|
|
7724
7751
|
// src/adapter/webgl-device.ts
|
|
7725
7752
|
var LOG_LEVEL2 = 1;
|
|
7726
7753
|
var _WebGLDevice = class extends Device {
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7754
|
+
/** type of this device */
|
|
7755
|
+
type = "webgl";
|
|
7756
|
+
/** The underlying WebGL context */
|
|
7757
|
+
handle;
|
|
7758
|
+
features;
|
|
7759
|
+
limits;
|
|
7730
7760
|
info;
|
|
7731
7761
|
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
7762
|
lost;
|
|
7742
7763
|
_resolveContextLost;
|
|
7743
|
-
_features;
|
|
7744
|
-
_limits;
|
|
7745
7764
|
//
|
|
7746
7765
|
// Static methods, expected to be present by `luma.createDevice()`
|
|
7747
7766
|
//
|
|
7767
|
+
/** Check if WebGL 2 is available */
|
|
7768
|
+
static isSupported() {
|
|
7769
|
+
return typeof WebGL2RenderingContext !== "undefined";
|
|
7770
|
+
}
|
|
7748
7771
|
/**
|
|
7749
7772
|
* Get a device instance from a GL context
|
|
7750
7773
|
* Creates and instruments the device if not already created
|
|
@@ -7765,22 +7788,29 @@ ${source2}`;
|
|
|
7765
7788
|
}
|
|
7766
7789
|
static async create(props = {}) {
|
|
7767
7790
|
log.groupCollapsed(LOG_LEVEL2, "WebGLDevice created")();
|
|
7768
|
-
|
|
7769
|
-
|
|
7791
|
+
const promises = [];
|
|
7792
|
+
if (props.debug) {
|
|
7793
|
+
promises.push(loadWebGLDeveloperTools());
|
|
7770
7794
|
}
|
|
7771
|
-
if (
|
|
7772
|
-
|
|
7795
|
+
if (props.spector) {
|
|
7796
|
+
promises.push(loadSpectorJS());
|
|
7773
7797
|
}
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7798
|
+
if (typeof props.canvas === "string") {
|
|
7799
|
+
promises.push(CanvasContext.pageLoaded);
|
|
7800
|
+
}
|
|
7801
|
+
const results = await Promise.allSettled(promises);
|
|
7802
|
+
for (const result of results) {
|
|
7803
|
+
if (result.status === "rejected") {
|
|
7804
|
+
log.error(`Failed to initialize debug libraries ${result.reason}`)();
|
|
7805
|
+
}
|
|
7777
7806
|
}
|
|
7778
7807
|
log.probe(LOG_LEVEL2 + 1, "DOM is loaded")();
|
|
7779
|
-
if (props.gl
|
|
7808
|
+
if (props.gl?.device) {
|
|
7809
|
+
log.warn("reattaching existing device")();
|
|
7780
7810
|
return _WebGLDevice.attach(props.gl);
|
|
7781
7811
|
}
|
|
7782
7812
|
const device = new _WebGLDevice(props);
|
|
7783
|
-
const message2 = `Created ${device.
|
|
7813
|
+
const message2 = `Created ${device.type}${device.debug ? " debug" : ""} context: ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;
|
|
7784
7814
|
log.probe(LOG_LEVEL2, message2)();
|
|
7785
7815
|
log.table(LOG_LEVEL2, device.info)();
|
|
7786
7816
|
log.groupEnd(LOG_LEVEL2)();
|
|
@@ -7795,46 +7825,52 @@ ${source2}`;
|
|
|
7795
7825
|
if (device) {
|
|
7796
7826
|
throw new Error(`WebGL context already attached to device ${device.id}`);
|
|
7797
7827
|
}
|
|
7798
|
-
const canvas = props.canvas || props.
|
|
7828
|
+
const canvas = props.gl?.canvas || props.canvas;
|
|
7799
7829
|
this.canvasContext = new WebGLCanvasContext(this, { ...props, canvas });
|
|
7800
7830
|
this.lost = new Promise((resolve) => {
|
|
7801
7831
|
this._resolveContextLost = resolve;
|
|
7802
7832
|
});
|
|
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
7833
|
let gl = props.gl || null;
|
|
7808
|
-
gl
|
|
7834
|
+
gl ||= createBrowserContext(this.canvasContext.canvas, {
|
|
7835
|
+
...props,
|
|
7836
|
+
onContextLost: (event) => this._resolveContextLost?.({
|
|
7837
|
+
reason: "destroyed",
|
|
7838
|
+
message: "Entered sleep mode, or too many apps or browser tabs are using the GPU."
|
|
7839
|
+
})
|
|
7840
|
+
});
|
|
7809
7841
|
if (!gl) {
|
|
7810
7842
|
throw new Error("WebGL context creation failed");
|
|
7811
7843
|
}
|
|
7812
7844
|
this.handle = gl;
|
|
7813
|
-
this.gl =
|
|
7814
|
-
this.canvasContext.resize();
|
|
7815
|
-
this.info = getDeviceInfo(this.gl);
|
|
7845
|
+
this.gl = gl;
|
|
7816
7846
|
this.gl.device = this;
|
|
7817
|
-
this.gl._version =
|
|
7847
|
+
this.gl._version = 2;
|
|
7848
|
+
this.info = getDeviceInfo(this.gl, this._extensions);
|
|
7849
|
+
this.limits = new WebGLDeviceLimits(this.gl);
|
|
7850
|
+
this.features = new WebGLDeviceFeatures(this.gl, this._extensions, this.props.disabledFeatures);
|
|
7851
|
+
if (this.props.initalizeFeatures) {
|
|
7852
|
+
this.features.initializeFeatures();
|
|
7853
|
+
}
|
|
7854
|
+
this.canvasContext.resize();
|
|
7818
7855
|
const { enable: enable2 = true, copyState = false } = props;
|
|
7819
7856
|
trackContextState(this.gl, {
|
|
7820
7857
|
enable: enable2,
|
|
7821
7858
|
copyState,
|
|
7822
7859
|
log: (...args) => log.log(1, ...args)()
|
|
7823
7860
|
});
|
|
7824
|
-
if (
|
|
7861
|
+
if (props.debug) {
|
|
7825
7862
|
this.gl = makeDebugContext(this.gl, { ...props, throwOnError: true });
|
|
7826
7863
|
this.debug = true;
|
|
7827
7864
|
log.level = Math.max(log.level, 1);
|
|
7828
7865
|
log.warn("WebGL debug mode activated. Performance reduced.")();
|
|
7829
7866
|
}
|
|
7830
|
-
if (
|
|
7831
|
-
|
|
7832
|
-
this.spector = initializeSpectorJS({ ...this.props, canvas: canvas2 });
|
|
7867
|
+
if (props.spector) {
|
|
7868
|
+
this.spectorJS = initializeSpectorJS({ ...this.props, canvas: this.handle.canvas });
|
|
7833
7869
|
}
|
|
7834
7870
|
}
|
|
7835
7871
|
/**
|
|
7836
7872
|
* Destroys the context
|
|
7837
|
-
* @note Has no effect for browser contexts, there is no browser API for destroying contexts
|
|
7873
|
+
* @note Has no effect for WebGL browser contexts, there is no browser API for destroying contexts
|
|
7838
7874
|
*/
|
|
7839
7875
|
destroy() {
|
|
7840
7876
|
}
|
|
@@ -7845,13 +7881,13 @@ ${source2}`;
|
|
|
7845
7881
|
return [this.gl.drawingBufferWidth, this.gl.drawingBufferHeight];
|
|
7846
7882
|
}
|
|
7847
7883
|
isTextureFormatSupported(format) {
|
|
7848
|
-
return isTextureFormatSupported(this.gl, format);
|
|
7884
|
+
return isTextureFormatSupported(this.gl, format, this._extensions);
|
|
7849
7885
|
}
|
|
7850
7886
|
isTextureFormatFilterable(format) {
|
|
7851
|
-
return isTextureFormatFilterable(this.gl, format);
|
|
7887
|
+
return isTextureFormatFilterable(this.gl, format, this._extensions);
|
|
7852
7888
|
}
|
|
7853
7889
|
isTextureFormatRenderable(format) {
|
|
7854
|
-
return isTextureFormatRenderable(this.gl, format);
|
|
7890
|
+
return isTextureFormatRenderable(this.gl, format, this._extensions);
|
|
7855
7891
|
}
|
|
7856
7892
|
// IMPLEMENTATION OF ABSTRACT DEVICE
|
|
7857
7893
|
createCanvasContext(props) {
|
|
@@ -7876,12 +7912,18 @@ ${source2}`;
|
|
|
7876
7912
|
createFramebuffer(props) {
|
|
7877
7913
|
return new WEBGLFramebuffer(this, props);
|
|
7878
7914
|
}
|
|
7879
|
-
createRenderPipeline(props) {
|
|
7880
|
-
return new WEBGLRenderPipeline(this, props);
|
|
7881
|
-
}
|
|
7882
7915
|
createVertexArray(props) {
|
|
7883
7916
|
return new WEBGLVertexArray(this, props);
|
|
7884
7917
|
}
|
|
7918
|
+
createTransformFeedback(props) {
|
|
7919
|
+
return new WEBGLTransformFeedback(this, props);
|
|
7920
|
+
}
|
|
7921
|
+
createQuerySet(props) {
|
|
7922
|
+
return new WEBGLQuerySet(this, props);
|
|
7923
|
+
}
|
|
7924
|
+
createRenderPipeline(props) {
|
|
7925
|
+
return new WEBGLRenderPipeline(this, props);
|
|
7926
|
+
}
|
|
7885
7927
|
beginRenderPass(props) {
|
|
7886
7928
|
return new WEBGLRenderPass(this, props);
|
|
7887
7929
|
}
|
|
@@ -7891,16 +7933,7 @@ ${source2}`;
|
|
|
7891
7933
|
beginComputePass(props) {
|
|
7892
7934
|
throw new Error("ComputePass not supported in WebGL");
|
|
7893
7935
|
}
|
|
7894
|
-
createTransformFeedback(props) {
|
|
7895
|
-
return new WEBGLTransformFeedback(this, props);
|
|
7896
|
-
}
|
|
7897
7936
|
renderPass = null;
|
|
7898
|
-
getDefaultRenderPass() {
|
|
7899
|
-
this.renderPass = this.renderPass || this.beginRenderPass({
|
|
7900
|
-
framebuffer: this.canvasContext.getCurrentFramebuffer()
|
|
7901
|
-
});
|
|
7902
|
-
return this.renderPass;
|
|
7903
|
-
}
|
|
7904
7937
|
createCommandEncoder(props) {
|
|
7905
7938
|
return new WEBGLCommandEncoder(this, props);
|
|
7906
7939
|
}
|
|
@@ -7915,7 +7948,7 @@ ${source2}`;
|
|
|
7915
7948
|
}
|
|
7916
7949
|
//
|
|
7917
7950
|
// TEMPORARY HACKS - will be removed in v9.1
|
|
7918
|
-
//
|
|
7951
|
+
//
|
|
7919
7952
|
/** @deprecated - should use command encoder */
|
|
7920
7953
|
readPixelsToArrayWebGL(source, options) {
|
|
7921
7954
|
return readPixelsToArray(source, options);
|
|
@@ -7925,13 +7958,13 @@ ${source2}`;
|
|
|
7925
7958
|
return readPixelsToBuffer(source, options);
|
|
7926
7959
|
}
|
|
7927
7960
|
setParametersWebGL(parameters) {
|
|
7928
|
-
setGLParameters(this, parameters);
|
|
7961
|
+
setGLParameters(this.gl, parameters);
|
|
7929
7962
|
}
|
|
7930
7963
|
getParametersWebGL(parameters) {
|
|
7931
|
-
return getGLParameters(this, parameters);
|
|
7964
|
+
return getGLParameters(this.gl, parameters);
|
|
7932
7965
|
}
|
|
7933
7966
|
withParametersWebGL(parameters, func) {
|
|
7934
|
-
withGLParameters(this, parameters, func);
|
|
7967
|
+
withGLParameters(this.gl, parameters, func);
|
|
7935
7968
|
}
|
|
7936
7969
|
clearWebGL(options) {
|
|
7937
7970
|
clear(this, options);
|
|
@@ -7948,20 +7981,15 @@ ${source2}`;
|
|
|
7948
7981
|
_extensions = {};
|
|
7949
7982
|
_polyfilled = false;
|
|
7950
7983
|
/** 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
|
-
}
|
|
7984
|
+
spectorJS;
|
|
7958
7985
|
/**
|
|
7959
7986
|
* Triggers device (or WebGL context) loss.
|
|
7960
7987
|
* @note primarily intended for testing how application reacts to device loss
|
|
7961
7988
|
*/
|
|
7962
7989
|
loseDevice() {
|
|
7963
7990
|
let deviceLossTriggered = false;
|
|
7964
|
-
const
|
|
7991
|
+
const extensions = this.getExtension("WEBGL_lose_context");
|
|
7992
|
+
const ext = extensions.WEBGL_lose_context;
|
|
7965
7993
|
if (ext) {
|
|
7966
7994
|
deviceLossTriggered = true;
|
|
7967
7995
|
ext.loseContext();
|
|
@@ -8010,11 +8038,15 @@ ${source2}`;
|
|
|
8010
8038
|
* so they need to be updated before every render
|
|
8011
8039
|
* @todo - remember/cache values to avoid setting them unnecessarily?
|
|
8012
8040
|
*/
|
|
8013
|
-
|
|
8014
|
-
|
|
8041
|
+
setConstantAttributeWebGL(location, constant) {
|
|
8042
|
+
const maxVertexAttributes = this.limits.maxVertexAttributes;
|
|
8043
|
+
this._constants = this._constants || new Array(maxVertexAttributes).fill(null);
|
|
8015
8044
|
const currentConstant = this._constants[location];
|
|
8016
8045
|
if (currentConstant && compareConstantArrayValues2(currentConstant, constant)) {
|
|
8017
|
-
log.info(
|
|
8046
|
+
log.info(
|
|
8047
|
+
1,
|
|
8048
|
+
`setConstantAttributeWebGL(${location}) could have been skipped, value unchanged`
|
|
8049
|
+
)();
|
|
8018
8050
|
}
|
|
8019
8051
|
this._constants[location] = constant;
|
|
8020
8052
|
switch (constant.constructor) {
|
|
@@ -8031,11 +8063,17 @@ ${source2}`;
|
|
|
8031
8063
|
assert2(false);
|
|
8032
8064
|
}
|
|
8033
8065
|
}
|
|
8066
|
+
/** Ensure extensions are only requested once */
|
|
8067
|
+
getExtension(name2) {
|
|
8068
|
+
getWebGLExtension(this.gl, name2, this._extensions);
|
|
8069
|
+
return this._extensions;
|
|
8070
|
+
}
|
|
8034
8071
|
};
|
|
8035
8072
|
var WebGLDevice = _WebGLDevice;
|
|
8036
8073
|
//
|
|
8037
8074
|
// Public `Device` API
|
|
8038
8075
|
//
|
|
8076
|
+
/** type of this device */
|
|
8039
8077
|
__publicField(WebGLDevice, "type", "webgl");
|
|
8040
8078
|
function isWebGL(gl) {
|
|
8041
8079
|
if (typeof WebGL2RenderingContext !== "undefined" && gl instanceof WebGL2RenderingContext) {
|
|
@@ -8078,6 +8116,216 @@ ${source2}`;
|
|
|
8078
8116
|
}
|
|
8079
8117
|
return true;
|
|
8080
8118
|
}
|
|
8119
|
+
|
|
8120
|
+
// src/adapter/objects/webgl-resource.ts
|
|
8121
|
+
var ERR_RESOURCE_METHOD_UNDEFINED = "Resource subclass must define virtual methods";
|
|
8122
|
+
var WebGLResource = class extends Resource {
|
|
8123
|
+
device;
|
|
8124
|
+
gl;
|
|
8125
|
+
gl2;
|
|
8126
|
+
_handle;
|
|
8127
|
+
_bound = false;
|
|
8128
|
+
// Only meaningful for resources that allocate GPU memory
|
|
8129
|
+
byteLength = 0;
|
|
8130
|
+
constructor(device, props, defaultProps) {
|
|
8131
|
+
super(device, props, defaultProps);
|
|
8132
|
+
this.device = device;
|
|
8133
|
+
const gl = this.device.gl;
|
|
8134
|
+
const { id } = props || {};
|
|
8135
|
+
this.gl = gl;
|
|
8136
|
+
this.gl2 = gl;
|
|
8137
|
+
this.id = id || uid(this.constructor.name);
|
|
8138
|
+
this._handle = props?.handle;
|
|
8139
|
+
if (this._handle === void 0) {
|
|
8140
|
+
this._handle = this._createHandle();
|
|
8141
|
+
}
|
|
8142
|
+
this.byteLength = 0;
|
|
8143
|
+
}
|
|
8144
|
+
toString() {
|
|
8145
|
+
return `${this.constructor.name}(${this.id})`;
|
|
8146
|
+
}
|
|
8147
|
+
get handle() {
|
|
8148
|
+
return this._handle;
|
|
8149
|
+
}
|
|
8150
|
+
delete({ deleteChildren = false } = {}) {
|
|
8151
|
+
const children = this._handle && this._deleteHandle(this._handle);
|
|
8152
|
+
if (this._handle) {
|
|
8153
|
+
this.removeStats();
|
|
8154
|
+
}
|
|
8155
|
+
this._handle = null;
|
|
8156
|
+
if (children && deleteChildren) {
|
|
8157
|
+
children.filter(Boolean).forEach((child) => child.destroy());
|
|
8158
|
+
}
|
|
8159
|
+
return this;
|
|
8160
|
+
}
|
|
8161
|
+
bind(funcOrHandle = this.handle) {
|
|
8162
|
+
if (typeof funcOrHandle !== "function") {
|
|
8163
|
+
this._bindHandle(funcOrHandle);
|
|
8164
|
+
return this;
|
|
8165
|
+
}
|
|
8166
|
+
let value;
|
|
8167
|
+
if (!this._bound) {
|
|
8168
|
+
this._bindHandle(this.handle);
|
|
8169
|
+
this._bound = true;
|
|
8170
|
+
value = funcOrHandle();
|
|
8171
|
+
this._bound = false;
|
|
8172
|
+
this._bindHandle(null);
|
|
8173
|
+
} else {
|
|
8174
|
+
value = funcOrHandle();
|
|
8175
|
+
}
|
|
8176
|
+
return value;
|
|
8177
|
+
}
|
|
8178
|
+
unbind() {
|
|
8179
|
+
this.bind(null);
|
|
8180
|
+
}
|
|
8181
|
+
// Install stubs for removed methods
|
|
8182
|
+
stubRemovedMethods(className, version, methodNames) {
|
|
8183
|
+
return stubRemovedMethods(this, className, version, methodNames);
|
|
8184
|
+
}
|
|
8185
|
+
// PUBLIC VIRTUAL METHODS
|
|
8186
|
+
initialize(props) {
|
|
8187
|
+
}
|
|
8188
|
+
// PROTECTED METHODS - These must be overridden by subclass
|
|
8189
|
+
_createHandle() {
|
|
8190
|
+
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
8191
|
+
}
|
|
8192
|
+
_deleteHandle() {
|
|
8193
|
+
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
8194
|
+
}
|
|
8195
|
+
_bindHandle(handle) {
|
|
8196
|
+
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
8197
|
+
}
|
|
8198
|
+
_getOptsFromHandle() {
|
|
8199
|
+
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
8200
|
+
}
|
|
8201
|
+
_getParameter(pname, props) {
|
|
8202
|
+
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
8203
|
+
}
|
|
8204
|
+
_setParameter(pname, value) {
|
|
8205
|
+
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
8206
|
+
}
|
|
8207
|
+
// PRIVATE METHODS
|
|
8208
|
+
/*
|
|
8209
|
+
_addStats() {
|
|
8210
|
+
const name = this.constructor.name;
|
|
8211
|
+
const stats = lumaStats.get('Resource Counts');
|
|
8212
|
+
|
|
8213
|
+
stats.get('Resources Created').incrementCount();
|
|
8214
|
+
stats.get(`${name}s Created`).incrementCount();
|
|
8215
|
+
stats.get(`${name}s Active`).incrementCount();
|
|
8216
|
+
}
|
|
8217
|
+
|
|
8218
|
+
_removeStats() {
|
|
8219
|
+
const name = this.constructor.name;
|
|
8220
|
+
const stats = lumaStats.get('Resource Counts');
|
|
8221
|
+
|
|
8222
|
+
stats.get(`${name}s Active`).decrementCount();
|
|
8223
|
+
}
|
|
8224
|
+
|
|
8225
|
+
trackAllocatedMemory(bytes, name = this.constructor.name) {
|
|
8226
|
+
const stats = lumaStats.get('Memory Usage');
|
|
8227
|
+
|
|
8228
|
+
stats.get('GPU Memory').addCount(bytes);
|
|
8229
|
+
stats.get(`${name} Memory`).addCount(bytes);
|
|
8230
|
+
this.byteLength = bytes;
|
|
8231
|
+
}
|
|
8232
|
+
|
|
8233
|
+
trackDeallocatedMemory(name = this.constructor.name) {
|
|
8234
|
+
const stats = lumaStats.get('Memory Usage');
|
|
8235
|
+
|
|
8236
|
+
stats.get('GPU Memory').subtractCount(this.byteLength);
|
|
8237
|
+
stats.get(`${name} Memory`).subtractCount(this.byteLength);
|
|
8238
|
+
this.byteLength = 0;
|
|
8239
|
+
}
|
|
8240
|
+
*/
|
|
8241
|
+
};
|
|
8242
|
+
|
|
8243
|
+
// src/adapter/objects/webgl-renderbuffer.ts
|
|
8244
|
+
var import_constants28 = __toESM(require_constants(), 1);
|
|
8245
|
+
var _WEBGLRenderbuffer = class extends WebGLResource {
|
|
8246
|
+
get [Symbol.toStringTag]() {
|
|
8247
|
+
return "Renderbuffer";
|
|
8248
|
+
}
|
|
8249
|
+
get width() {
|
|
8250
|
+
return this.props.width;
|
|
8251
|
+
}
|
|
8252
|
+
get height() {
|
|
8253
|
+
return this.props.height;
|
|
8254
|
+
}
|
|
8255
|
+
get format() {
|
|
8256
|
+
return this.props.format;
|
|
8257
|
+
}
|
|
8258
|
+
get samples() {
|
|
8259
|
+
return this.props.samples;
|
|
8260
|
+
}
|
|
8261
|
+
get attachment() {
|
|
8262
|
+
return;
|
|
8263
|
+
}
|
|
8264
|
+
/** WebGL format constant */
|
|
8265
|
+
glFormat;
|
|
8266
|
+
static isTextureFormatSupported(device, format) {
|
|
8267
|
+
return isRenderbufferFormatSupported(device.gl, format, device._extensions);
|
|
8268
|
+
}
|
|
8269
|
+
constructor(device, props) {
|
|
8270
|
+
if (typeof props.format === "number") {
|
|
8271
|
+
throw new Error("Renderbuffer");
|
|
8272
|
+
}
|
|
8273
|
+
super(device, props, _WEBGLRenderbuffer.defaultProps);
|
|
8274
|
+
this.glFormat = convertTextureFormatToGL(this.props.format);
|
|
8275
|
+
this._initialize(this.props);
|
|
8276
|
+
}
|
|
8277
|
+
resize(size) {
|
|
8278
|
+
if (size.width !== this.width || size.height !== this.height) {
|
|
8279
|
+
Object.assign(this.props, { ...size, format: this.format, samples: this.samples });
|
|
8280
|
+
this._initialize(this.props);
|
|
8281
|
+
}
|
|
8282
|
+
}
|
|
8283
|
+
// PRIVATE METHODS
|
|
8284
|
+
/** Creates and initializes a renderbuffer object's data store */
|
|
8285
|
+
_initialize(props) {
|
|
8286
|
+
const { format, width, height, samples } = props;
|
|
8287
|
+
assert2(format, "Needs format");
|
|
8288
|
+
this.trackDeallocatedMemory();
|
|
8289
|
+
this.gl.bindRenderbuffer(import_constants28.GL.RENDERBUFFER, this.handle);
|
|
8290
|
+
if (samples !== 0) {
|
|
8291
|
+
this.gl.renderbufferStorageMultisample(
|
|
8292
|
+
import_constants28.GL.RENDERBUFFER,
|
|
8293
|
+
samples,
|
|
8294
|
+
this.glFormat,
|
|
8295
|
+
width,
|
|
8296
|
+
height
|
|
8297
|
+
);
|
|
8298
|
+
} else {
|
|
8299
|
+
this.gl.renderbufferStorage(import_constants28.GL.RENDERBUFFER, this.glFormat, width, height);
|
|
8300
|
+
}
|
|
8301
|
+
this.gl.bindRenderbuffer(import_constants28.GL.RENDERBUFFER, null);
|
|
8302
|
+
this.trackAllocatedMemory(
|
|
8303
|
+
width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.format)
|
|
8304
|
+
);
|
|
8305
|
+
}
|
|
8306
|
+
// RESOURCE IMPLEMENTATION
|
|
8307
|
+
_createHandle() {
|
|
8308
|
+
return this.gl.createRenderbuffer();
|
|
8309
|
+
}
|
|
8310
|
+
_deleteHandle() {
|
|
8311
|
+
this.gl.deleteRenderbuffer(this.handle);
|
|
8312
|
+
this.trackDeallocatedMemory();
|
|
8313
|
+
}
|
|
8314
|
+
_bindHandle(handle) {
|
|
8315
|
+
this.gl.bindRenderbuffer(import_constants28.GL.RENDERBUFFER, handle);
|
|
8316
|
+
}
|
|
8317
|
+
};
|
|
8318
|
+
var WEBGLRenderbuffer = _WEBGLRenderbuffer;
|
|
8319
|
+
__publicField(WEBGLRenderbuffer, "defaultProps", {
|
|
8320
|
+
id: void 0,
|
|
8321
|
+
handle: void 0,
|
|
8322
|
+
userData: void 0,
|
|
8323
|
+
format: void 0,
|
|
8324
|
+
// 'depth16unorm'
|
|
8325
|
+
width: 1,
|
|
8326
|
+
height: 1,
|
|
8327
|
+
samples: 0
|
|
8328
|
+
});
|
|
8081
8329
|
return __toCommonJS(src_exports);
|
|
8082
8330
|
})();
|
|
8083
8331
|
return __exports__;
|