@luma.gl/webgl 9.0.0-beta.6 → 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 +81 -84
- package/dist/adapter/converters/sampler-parameters.js +17 -17
- package/dist/adapter/converters/shader-formats.js +12 -12
- package/dist/adapter/converters/texture-formats.d.ts +10 -8
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +175 -168
- package/dist/adapter/converters/vertex-formats.js +20 -20
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +2 -1
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +14 -2
- package/dist/adapter/device-helpers/webgl-device-info.js +5 -5
- package/dist/adapter/device-helpers/webgl-device-limits.js +10 -10
- package/dist/adapter/helpers/decode-webgl-types.js +45 -45
- package/dist/adapter/helpers/get-shader-layout.js +29 -29
- package/dist/adapter/helpers/set-uniform.js +40 -40
- package/dist/adapter/helpers/webgl-topology-utils.js +38 -38
- package/dist/adapter/objects/webgl-renderbuffer.js +6 -6
- package/dist/adapter/objects/webgl-resource.js +1 -2
- package/dist/adapter/resources/webgl-buffer.js +14 -14
- package/dist/adapter/resources/webgl-command-buffer.js +25 -25
- package/dist/adapter/resources/webgl-external-texture.js +3 -3
- package/dist/adapter/resources/webgl-framebuffer.d.ts +2 -4
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +41 -36
- package/dist/adapter/resources/webgl-query-set.js +6 -6
- package/dist/adapter/resources/webgl-render-pass.js +5 -5
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +19 -13
- package/dist/adapter/resources/webgl-sampler.js +2 -2
- package/dist/adapter/resources/webgl-shader.js +4 -4
- package/dist/adapter/resources/webgl-texture.d.ts +2 -1
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +29 -27
- package/dist/adapter/resources/webgl-transform-feedback.js +8 -8
- package/dist/adapter/resources/webgl-vertex-array.d.ts +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +5 -5
- package/dist/adapter/webgl-device.d.ts +6 -3
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +22 -17
- package/dist/classic/accessor.js +4 -4
- package/dist/classic/clear.js +2 -2
- package/dist/classic/copy-and-blit.js +15 -16
- package/dist/classic/format-utils.d.ts +2 -2
- package/dist/classic/format-utils.js +14 -14
- package/dist/classic/typed-array-utils.js +18 -18
- 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 +4 -9
- package/dist/context/parameters/webgl-parameter-tables.d.ts +2 -13
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +292 -298
- package/dist/context/state-tracker/with-parameters.d.ts +1 -2
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +2 -5
- package/dist/dist.dev.js +877 -840
- package/dist/index.cjs +1253 -1188
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist.min.js +6 -6
- package/package.json +4 -4
- package/src/adapter/converters/device-parameters.ts +9 -11
- package/src/adapter/converters/texture-formats.ts +64 -61
- package/src/adapter/device-helpers/webgl-device-features.ts +22 -2
- package/src/adapter/objects/webgl-renderbuffer.ts +1 -1
- package/src/adapter/objects/webgl-resource.ts +1 -1
- package/src/adapter/resources/webgl-external-texture.ts +3 -3
- package/src/adapter/resources/webgl-framebuffer.ts +29 -26
- package/src/adapter/resources/webgl-render-pass.ts +3 -3
- package/src/adapter/resources/webgl-render-pipeline.ts +13 -6
- package/src/adapter/resources/webgl-texture.ts +7 -3
- package/src/adapter/webgl-device.ts +24 -19
- package/src/classic/clear.ts +2 -2
- package/src/context/parameters/unified-parameter-api.ts +4 -16
- package/src/context/state-tracker/with-parameters.ts +2 -7
- package/src/index.ts +4 -4
- 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 +0 -14
- package/dist/context/context/context-data.d.ts.map +0 -1
- package/dist/context/context/context-data.js +0 -33
- package/dist/context/context/create-browser-context.d.ts +0 -35
- package/dist/context/context/create-browser-context.d.ts.map +0 -1
- package/dist/context/context/create-browser-context.js +0 -66
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) {
|
|
@@ -1043,6 +1001,8 @@ var __exports__ = (() => {
|
|
|
1043
1001
|
usage;
|
|
1044
1002
|
/** For index buffers, whether indices are 16 or 32 bit */
|
|
1045
1003
|
indexType;
|
|
1004
|
+
/** "Time" of last update */
|
|
1005
|
+
updateTimestamp;
|
|
1046
1006
|
constructor(device, props) {
|
|
1047
1007
|
const deducedProps = { ...props };
|
|
1048
1008
|
if ((props.usage || 0) & _Buffer.INDEX && !props.indexType) {
|
|
@@ -1055,6 +1015,7 @@ var __exports__ = (() => {
|
|
|
1055
1015
|
super(device, deducedProps, _Buffer.defaultProps);
|
|
1056
1016
|
this.usage = props.usage || 0;
|
|
1057
1017
|
this.indexType = deducedProps.indexType;
|
|
1018
|
+
this.updateTimestamp = device.incrementTimestamp();
|
|
1058
1019
|
}
|
|
1059
1020
|
/** Read data synchronously. @note WebGL2 only */
|
|
1060
1021
|
readSyncWebGL(byteOffset, byteLength) {
|
|
@@ -1232,14 +1193,16 @@ var __exports__ = (() => {
|
|
|
1232
1193
|
};
|
|
1233
1194
|
var DeviceFeatures = class {
|
|
1234
1195
|
features;
|
|
1235
|
-
|
|
1196
|
+
disabledFeatures;
|
|
1197
|
+
constructor(features = [], disabledFeatures) {
|
|
1236
1198
|
this.features = new Set(features);
|
|
1199
|
+
this.disabledFeatures = disabledFeatures || {};
|
|
1237
1200
|
}
|
|
1238
1201
|
*[Symbol.iterator]() {
|
|
1239
1202
|
yield* this.features;
|
|
1240
1203
|
}
|
|
1241
1204
|
has(feature) {
|
|
1242
|
-
return this.features.has(feature);
|
|
1205
|
+
return !this.disabledFeatures[feature] && this.features.has(feature);
|
|
1243
1206
|
}
|
|
1244
1207
|
};
|
|
1245
1208
|
var _Device = class {
|
|
@@ -1252,12 +1215,12 @@ var __exports__ = (() => {
|
|
|
1252
1215
|
}
|
|
1253
1216
|
/** id of this device, primarily for debugging */
|
|
1254
1217
|
id;
|
|
1255
|
-
/** stats */
|
|
1256
|
-
statsManager = lumaStats;
|
|
1257
1218
|
/** A copy of the device props */
|
|
1258
1219
|
props;
|
|
1259
1220
|
/** Available for the application to store data on the device */
|
|
1260
1221
|
userData = {};
|
|
1222
|
+
/** stats */
|
|
1223
|
+
statsManager = lumaStats;
|
|
1261
1224
|
/** Used by other luma.gl modules to store data on the device */
|
|
1262
1225
|
_lumaData = {};
|
|
1263
1226
|
/** Check if a specific texture format is GPU compressed */
|
|
@@ -1314,12 +1277,17 @@ var __exports__ = (() => {
|
|
|
1314
1277
|
clearWebGL(options) {
|
|
1315
1278
|
throw new Error("not implemented");
|
|
1316
1279
|
}
|
|
1317
|
-
|
|
1280
|
+
timestamp = 0;
|
|
1281
|
+
/** A monotonic counter for tracking buffer and texture updates */
|
|
1282
|
+
incrementTimestamp() {
|
|
1283
|
+
return this.timestamp++;
|
|
1284
|
+
}
|
|
1318
1285
|
// Error Handling
|
|
1319
1286
|
/** Report unhandled device errors */
|
|
1320
1287
|
onError(error) {
|
|
1321
1288
|
this.props.onError(error);
|
|
1322
1289
|
}
|
|
1290
|
+
// IMPLEMENTATION
|
|
1323
1291
|
_getBufferProps(props) {
|
|
1324
1292
|
if (props instanceof ArrayBuffer || ArrayBuffer.isView(props)) {
|
|
1325
1293
|
props = { data: props };
|
|
@@ -1340,19 +1308,23 @@ var __exports__ = (() => {
|
|
|
1340
1308
|
var Device = _Device;
|
|
1341
1309
|
__publicField(Device, "defaultProps", {
|
|
1342
1310
|
id: null,
|
|
1343
|
-
type: "best-available",
|
|
1344
1311
|
canvas: null,
|
|
1345
1312
|
container: null,
|
|
1346
1313
|
manageState: true,
|
|
1347
1314
|
width: 800,
|
|
1348
1315
|
// width are height are only used by headless gl
|
|
1349
1316
|
height: 600,
|
|
1350
|
-
|
|
1317
|
+
requestMaxLimits: true,
|
|
1351
1318
|
debug: Boolean(log.get("debug")),
|
|
1352
1319
|
// Instrument context (at the expense of performance)
|
|
1353
1320
|
spector: Boolean(log.get("spector")),
|
|
1354
1321
|
// Initialize the SpectorJS WebGL debugger
|
|
1355
1322
|
break: [],
|
|
1323
|
+
// TODO - Change these after confirming things work as expected
|
|
1324
|
+
initalizeFeatures: true,
|
|
1325
|
+
disabledFeatures: {
|
|
1326
|
+
"compilation-status-async-webgl": true
|
|
1327
|
+
},
|
|
1356
1328
|
// alpha: undefined,
|
|
1357
1329
|
// depth: undefined,
|
|
1358
1330
|
// stencil: undefined,
|
|
@@ -1663,6 +1635,9 @@ var __exports__ = (() => {
|
|
|
1663
1635
|
height;
|
|
1664
1636
|
/** depth of this texture */
|
|
1665
1637
|
depth;
|
|
1638
|
+
/** "Time" of last update. Monotonically increasing timestamp */
|
|
1639
|
+
updateTimestamp;
|
|
1640
|
+
/** Do not use directly. Create with device.createTexture() */
|
|
1666
1641
|
constructor(device, props, defaultProps = _Texture.defaultProps) {
|
|
1667
1642
|
super(device, props, defaultProps);
|
|
1668
1643
|
this.dimension = this.props.dimension;
|
|
@@ -1670,6 +1645,7 @@ var __exports__ = (() => {
|
|
|
1670
1645
|
this.width = this.props.width;
|
|
1671
1646
|
this.height = this.props.height;
|
|
1672
1647
|
this.depth = this.props.depth;
|
|
1648
|
+
this.updateTimestamp = device.incrementTimestamp();
|
|
1673
1649
|
}
|
|
1674
1650
|
};
|
|
1675
1651
|
var Texture = _Texture;
|
|
@@ -1898,7 +1874,7 @@ ${htmlLog}
|
|
|
1898
1874
|
__publicField(Shader, "defaultProps", {
|
|
1899
1875
|
...Resource.defaultProps,
|
|
1900
1876
|
language: "auto",
|
|
1901
|
-
stage:
|
|
1877
|
+
stage: void 0,
|
|
1902
1878
|
source: "",
|
|
1903
1879
|
sourceMap: null,
|
|
1904
1880
|
entryPoint: "main",
|
|
@@ -1967,6 +1943,9 @@ ${htmlLog}
|
|
|
1967
1943
|
}
|
|
1968
1944
|
/** Auto creates any textures */
|
|
1969
1945
|
autoCreateAttachmentTextures() {
|
|
1946
|
+
if (this.props.colorAttachments.length === 0 && !this.props.depthStencilAttachment) {
|
|
1947
|
+
throw new Error("Framebuffer has noattachments");
|
|
1948
|
+
}
|
|
1970
1949
|
this.colorAttachments = this.props.colorAttachments.map((attachment2) => {
|
|
1971
1950
|
if (typeof attachment2 === "string") {
|
|
1972
1951
|
const texture = this.createColorTexture(attachment2);
|
|
@@ -2047,7 +2026,7 @@ ${htmlLog}
|
|
|
2047
2026
|
width: 1,
|
|
2048
2027
|
height: 1,
|
|
2049
2028
|
colorAttachments: [],
|
|
2050
|
-
// ['rgba8unorm
|
|
2029
|
+
// ['rgba8unorm'],
|
|
2051
2030
|
depthStencilAttachment: null
|
|
2052
2031
|
// 'depth24plus-stencil8'
|
|
2053
2032
|
});
|
|
@@ -2085,12 +2064,10 @@ ${htmlLog}
|
|
|
2085
2064
|
__publicField(RenderPipeline, "defaultProps", {
|
|
2086
2065
|
...Resource.defaultProps,
|
|
2087
2066
|
vs: null,
|
|
2088
|
-
|
|
2089
|
-
// main
|
|
2067
|
+
vertexEntryPoint: "vertexMain",
|
|
2090
2068
|
vsConstants: {},
|
|
2091
2069
|
fs: null,
|
|
2092
|
-
|
|
2093
|
-
// main
|
|
2070
|
+
fragmentEntryPoint: "fragmentMain",
|
|
2094
2071
|
fsConstants: {},
|
|
2095
2072
|
shaderLayout: null,
|
|
2096
2073
|
bufferLayout: [],
|
|
@@ -3098,9 +3075,7 @@ ${htmlLog}
|
|
|
3098
3075
|
]);
|
|
3099
3076
|
|
|
3100
3077
|
// src/context/parameters/unified-parameter-api.ts
|
|
3101
|
-
function setGLParameters(
|
|
3102
|
-
const webglDevice = WebGLDevice.attach(device);
|
|
3103
|
-
const gl = webglDevice.gl;
|
|
3078
|
+
function setGLParameters(gl, parameters) {
|
|
3104
3079
|
if (isObjectEmpty2(parameters)) {
|
|
3105
3080
|
return;
|
|
3106
3081
|
}
|
|
@@ -3124,9 +3099,7 @@ ${htmlLog}
|
|
|
3124
3099
|
}
|
|
3125
3100
|
}
|
|
3126
3101
|
}
|
|
3127
|
-
function getGLParameters(
|
|
3128
|
-
const webglDevice = WebGLDevice.attach(device);
|
|
3129
|
-
const gl = webglDevice.gl;
|
|
3102
|
+
function getGLParameters(gl, parameters = GL_PARAMETER_DEFAULTS) {
|
|
3130
3103
|
if (typeof parameters === "number") {
|
|
3131
3104
|
const key = parameters;
|
|
3132
3105
|
const getter = GL_PARAMETER_GETTERS[key];
|
|
@@ -3140,8 +3113,8 @@ ${htmlLog}
|
|
|
3140
3113
|
}
|
|
3141
3114
|
return state;
|
|
3142
3115
|
}
|
|
3143
|
-
function resetGLParameters(
|
|
3144
|
-
setGLParameters(
|
|
3116
|
+
function resetGLParameters(gl) {
|
|
3117
|
+
setGLParameters(gl, GL_PARAMETER_DEFAULTS);
|
|
3145
3118
|
}
|
|
3146
3119
|
function isObjectEmpty2(object) {
|
|
3147
3120
|
for (const key in object) {
|
|
@@ -3519,9 +3492,7 @@ ${htmlLog}
|
|
|
3519
3492
|
return textureExtensions.every((extension) => getWebGLExtension(gl, extension, extensions));
|
|
3520
3493
|
}
|
|
3521
3494
|
var TEXTURE_FORMATS = {
|
|
3522
|
-
// Unsized formats that leave the precision up to the driver.
|
|
3523
|
-
// TODO - Fix bpp constants
|
|
3524
|
-
// '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
|
|
3525
3496
|
"rgb8unorm-unsized": {
|
|
3526
3497
|
gl: import_constants4.GL.RGB,
|
|
3527
3498
|
b: 4,
|
|
@@ -3538,27 +3509,28 @@ ${htmlLog}
|
|
|
3538
3509
|
dataFormat: import_constants4.GL.RGBA,
|
|
3539
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]
|
|
3540
3511
|
},
|
|
3512
|
+
// 'r8unorm-unsized': {gl: GL.LUMINANCE, b: 4, c: 2, bpp: 4},
|
|
3541
3513
|
// 'rgb8unorm-srgb-unsized': {gl: GL.SRGB_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
|
|
3542
3514
|
// 'rgba8unorm-srgb-unsized': {gl: GL.SRGB_ALPHA_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
|
|
3543
3515
|
// 8-bit formats
|
|
3544
|
-
"r8unorm": { gl: import_constants4.GL.R8, b: 1, c: 1,
|
|
3516
|
+
"r8unorm": { gl: import_constants4.GL.R8, b: 1, c: 1, rb: true },
|
|
3545
3517
|
"r8snorm": { gl: import_constants4.GL.R8_SNORM, b: 1, c: 1, render: snorm8_renderable },
|
|
3546
|
-
"r8uint": { gl: import_constants4.GL.R8UI, b: 1, c: 1,
|
|
3547
|
-
"r8sint": { gl: import_constants4.GL.R8I, b: 1, c: 1,
|
|
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 },
|
|
3548
3520
|
// 16-bit formats
|
|
3549
|
-
"rg8unorm": { gl: import_constants4.GL.RG8, b: 2, c: 2,
|
|
3521
|
+
"rg8unorm": { gl: import_constants4.GL.RG8, b: 2, c: 2, rb: true },
|
|
3550
3522
|
"rg8snorm": { gl: import_constants4.GL.RG8_SNORM, b: 2, c: 2, render: snorm8_renderable },
|
|
3551
|
-
"rg8uint": { gl: import_constants4.GL.RG8UI, b: 2, c: 2,
|
|
3552
|
-
"rg8sint": { gl: import_constants4.GL.RG8I, b: 2, c: 2,
|
|
3553
|
-
"r16uint": { gl: import_constants4.GL.R16UI, b: 2, c: 1,
|
|
3554
|
-
"r16sint": { gl: import_constants4.GL.R16I, b: 2, c: 1,
|
|
3555
|
-
"r16float": { gl: import_constants4.GL.R16F, b: 2, c: 1, render: float16_renderable, filter: "float16-filterable-webgl",
|
|
3556
|
-
"r16unorm-webgl": { gl: import_constants4.GL.R16_EXT, b: 2, c: 1, f: norm16_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 },
|
|
3557
3529
|
"r16snorm-webgl": { gl: import_constants4.GL.R16_SNORM_EXT, b: 2, c: 1, f: snorm16_renderable },
|
|
3558
3530
|
// Packed 16-bit formats
|
|
3559
|
-
"rgba4unorm-webgl": { gl: import_constants4.GL.RGBA4, b: 2, c: 4, wgpu: false,
|
|
3560
|
-
"rgb565unorm-webgl": { gl: import_constants4.GL.RGB565, b: 2, c: 4, wgpu: false,
|
|
3561
|
-
"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 },
|
|
3562
3534
|
// 24-bit formats
|
|
3563
3535
|
"rgb8unorm-webgl": { gl: import_constants4.GL.RGB8, b: 3, c: 3, wgpu: false },
|
|
3564
3536
|
"rgb8snorm-webgl": { gl: import_constants4.GL.RGB8_SNORM, b: 3, c: 3, wgpu: false },
|
|
@@ -3574,31 +3546,31 @@ ${htmlLog}
|
|
|
3574
3546
|
"rg16uint": { gl: import_constants4.GL.RG16UI, b: 4, c: 1, bpp: 4 },
|
|
3575
3547
|
"rg16sint": { gl: import_constants4.GL.RG16I, b: 4, c: 2, bpp: 4 },
|
|
3576
3548
|
// When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
|
|
3577
|
-
"rg16float": { gl: import_constants4.GL.RG16F, bpp: 4, b: 4, c: 2, render: float16_renderable, filter: float16_filterable,
|
|
3549
|
+
"rg16float": { gl: import_constants4.GL.RG16F, bpp: 4, b: 4, c: 2, render: float16_renderable, filter: float16_filterable, rb: true },
|
|
3578
3550
|
"rg16unorm-webgl": { gl: import_constants4.GL.RG16_EXT, b: 2, c: 2, render: norm16_renderable },
|
|
3579
3551
|
"rg16snorm-webgl": { gl: import_constants4.GL.RG16_SNORM_EXT, b: 2, c: 2, render: snorm16_renderable },
|
|
3580
|
-
"r32uint": { gl: import_constants4.GL.R32UI, b: 4, c: 1, bpp: 4,
|
|
3581
|
-
"r32sint": { gl: import_constants4.GL.R32I, b: 4, c: 1, bpp: 4,
|
|
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 },
|
|
3582
3554
|
"r32float": { gl: import_constants4.GL.R32F, bpp: 4, b: 4, c: 1, render: float32_renderable, filter: float32_filterable },
|
|
3583
3555
|
// Packed 32-bit formats
|
|
3584
3556
|
"rgb9e5ufloat": { gl: import_constants4.GL.RGB9_E5, b: 4, c: 3, p: 1, render: rgb9e5ufloat_renderable },
|
|
3585
3557
|
// , filter: true},
|
|
3586
|
-
"rg11b10ufloat": { gl: import_constants4.GL.R11F_G11F_B10F, b: 4, c: 3, p: 1, render: float32_renderable,
|
|
3587
|
-
"rgb10a2unorm": { gl: import_constants4.GL.RGB10_A2, b: 4, c: 4, p: 1,
|
|
3588
|
-
"rgb10a2uint-webgl": { b: 4, c: 4, gl: import_constants4.GL.RGB10_A2UI, p: 1, wgpu: false, bpp: 4,
|
|
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 },
|
|
3589
3561
|
// 48-bit formats
|
|
3590
3562
|
"rgb16unorm-webgl": { gl: import_constants4.GL.RGB16_EXT, b: 2, c: 3, f: norm16_renderable },
|
|
3591
3563
|
// rgb not renderable
|
|
3592
3564
|
"rgb16snorm-webgl": { gl: import_constants4.GL.RGB16_SNORM_EXT, b: 2, c: 3, f: norm16_renderable },
|
|
3593
3565
|
// rgb not renderable
|
|
3594
3566
|
// 64-bit formats
|
|
3595
|
-
"rg32uint": { gl: import_constants4.GL.RG32UI, b: 8, c: 2,
|
|
3596
|
-
"rg32sint": { gl: import_constants4.GL.RG32I, b: 8, c: 2,
|
|
3597
|
-
"rg32float": { gl: import_constants4.GL.RG32F, b: 8, c: 2, render: float32_renderable, filter: float32_filterable,
|
|
3598
|
-
"rgba16uint": { gl: import_constants4.GL.RGBA16UI, b: 8, c: 4,
|
|
3599
|
-
"rgba16sint": { gl: import_constants4.GL.RGBA16I, b: 8, 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 },
|
|
3600
3572
|
"rgba16float": { gl: import_constants4.GL.RGBA16F, b: 8, c: 4, render: float16_renderable, filter: float16_filterable },
|
|
3601
|
-
"rgba16unorm-webgl": { gl: import_constants4.GL.RGBA16_EXT, b: 2, c: 4, render: norm16_renderable,
|
|
3573
|
+
"rgba16unorm-webgl": { gl: import_constants4.GL.RGBA16_EXT, b: 2, c: 4, render: norm16_renderable, rb: true },
|
|
3602
3574
|
"rgba16snorm-webgl": { gl: import_constants4.GL.RGBA16_SNORM_EXT, b: 2, c: 4, render: snorm16_renderable },
|
|
3603
3575
|
// 96-bit formats (deprecated!)
|
|
3604
3576
|
"rgb32float-webgl": {
|
|
@@ -3610,22 +3582,73 @@ ${htmlLog}
|
|
|
3610
3582
|
types: [import_constants4.GL.FLOAT]
|
|
3611
3583
|
},
|
|
3612
3584
|
// 128-bit formats
|
|
3613
|
-
"rgba32uint": { gl: import_constants4.GL.RGBA32UI, b: 16, c: 4,
|
|
3614
|
-
"rgba32sint": { gl: import_constants4.GL.RGBA32I, b: 16, c: 4,
|
|
3615
|
-
"rgba32float": { gl: import_constants4.GL.RGBA32F, b: 16, c: 4, render: float32_renderable, filter: float32_filterable,
|
|
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 },
|
|
3616
3588
|
// Depth and stencil formats
|
|
3617
|
-
"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 },
|
|
3618
3590
|
// 8 stencil bits
|
|
3619
|
-
"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
|
+
},
|
|
3620
3600
|
// 16 depth bits
|
|
3621
|
-
"depth24plus": {
|
|
3622
|
-
|
|
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
|
+
},
|
|
3623
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.
|
|
3624
|
-
"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
|
+
},
|
|
3625
3630
|
// "depth24unorm-stencil8" feature
|
|
3626
|
-
"depth24unorm-stencil8": {
|
|
3627
|
-
|
|
3628
|
-
|
|
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
|
+
},
|
|
3629
3652
|
// BC compressed formats: check device.features.has("texture-compression-bc");
|
|
3630
3653
|
"bc1-rgb-unorm-webgl": { gl: import_constants4.GL.COMPRESSED_RGB_S3TC_DXT1_EXT, x: X_S3TC, f: texture_compression_bc },
|
|
3631
3654
|
"bc1-rgb-unorm-srgb-webgl": { gl: import_constants4.GL.COMPRESSED_SRGB_S3TC_DXT1_EXT, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
@@ -3721,8 +3744,7 @@ ${htmlLog}
|
|
|
3721
3744
|
[import_constants4.GL.BYTE]: 1,
|
|
3722
3745
|
[import_constants4.GL.UNSIGNED_BYTE]: 1
|
|
3723
3746
|
};
|
|
3724
|
-
function isTextureFormatSupported(gl,
|
|
3725
|
-
const format = convertGLToTextureFormat(formatOrGL);
|
|
3747
|
+
function isTextureFormatSupported(gl, format, extensions) {
|
|
3726
3748
|
const info = TEXTURE_FORMATS[format];
|
|
3727
3749
|
if (!info) {
|
|
3728
3750
|
return false;
|
|
@@ -3737,7 +3759,7 @@ ${htmlLog}
|
|
|
3737
3759
|
return true;
|
|
3738
3760
|
}
|
|
3739
3761
|
function isRenderbufferFormatSupported(gl, format, extensions) {
|
|
3740
|
-
return isTextureFormatSupported(gl, format, extensions) && TEXTURE_FORMATS[format]?.
|
|
3762
|
+
return isTextureFormatSupported(gl, format, extensions) && TEXTURE_FORMATS[format]?.rb;
|
|
3741
3763
|
}
|
|
3742
3764
|
function convertGLToTextureFormat(format) {
|
|
3743
3765
|
if (typeof format === "string") {
|
|
@@ -3757,11 +3779,13 @@ ${htmlLog}
|
|
|
3757
3779
|
}
|
|
3758
3780
|
return webglFormat;
|
|
3759
3781
|
}
|
|
3760
|
-
function isTextureFormatFilterable(gl,
|
|
3761
|
-
const format = convertGLToTextureFormat(formatOrGL);
|
|
3782
|
+
function isTextureFormatFilterable(gl, format, extensions) {
|
|
3762
3783
|
if (!isTextureFormatSupported(gl, format, extensions)) {
|
|
3763
3784
|
return false;
|
|
3764
3785
|
}
|
|
3786
|
+
if (format.startsWith("depth") || format.startsWith("stencil")) {
|
|
3787
|
+
return false;
|
|
3788
|
+
}
|
|
3765
3789
|
try {
|
|
3766
3790
|
const decoded = decodeTextureFormat(format);
|
|
3767
3791
|
if (decoded.signed) {
|
|
@@ -3778,8 +3802,7 @@ ${htmlLog}
|
|
|
3778
3802
|
}
|
|
3779
3803
|
return true;
|
|
3780
3804
|
}
|
|
3781
|
-
function isTextureFormatRenderable(gl,
|
|
3782
|
-
const format = convertGLToTextureFormat(formatOrGL);
|
|
3805
|
+
function isTextureFormatRenderable(gl, format, extensions) {
|
|
3783
3806
|
if (!isTextureFormatSupported(gl, format, extensions)) {
|
|
3784
3807
|
return false;
|
|
3785
3808
|
}
|
|
@@ -3788,20 +3811,15 @@ ${htmlLog}
|
|
|
3788
3811
|
}
|
|
3789
3812
|
return true;
|
|
3790
3813
|
}
|
|
3791
|
-
function getWebGLTextureParameters(
|
|
3792
|
-
const
|
|
3814
|
+
function getWebGLTextureParameters(format) {
|
|
3815
|
+
const formatData = TEXTURE_FORMATS[format];
|
|
3793
3816
|
const webglFormat = convertTextureFormatToGL(format);
|
|
3794
3817
|
const decoded = decodeTextureFormat(format);
|
|
3795
3818
|
return {
|
|
3796
3819
|
format: webglFormat,
|
|
3797
|
-
dataFormat: getWebGLPixelDataFormat(
|
|
3798
|
-
decoded.format,
|
|
3799
|
-
decoded.integer,
|
|
3800
|
-
decoded.normalized,
|
|
3801
|
-
webglFormat
|
|
3802
|
-
),
|
|
3820
|
+
dataFormat: formatData?.dataFormat || getWebGLPixelDataFormat(decoded.format, decoded.integer, decoded.normalized, webglFormat),
|
|
3803
3821
|
// depth formats don't have a type
|
|
3804
|
-
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,
|
|
3805
3823
|
// @ts-expect-error
|
|
3806
3824
|
compressed: decoded.compressed
|
|
3807
3825
|
};
|
|
@@ -3813,8 +3831,7 @@ ${htmlLog}
|
|
|
3813
3831
|
}
|
|
3814
3832
|
return info.attachment;
|
|
3815
3833
|
}
|
|
3816
|
-
function getTextureFormatBytesPerPixel(
|
|
3817
|
-
const format = convertGLToTextureFormat(formatOrGL);
|
|
3834
|
+
function getTextureFormatBytesPerPixel(format) {
|
|
3818
3835
|
const params = getWebGLTextureParameters(format);
|
|
3819
3836
|
const channels = DATA_FORMAT_CHANNELS[params.dataFormat] || 4;
|
|
3820
3837
|
const channelSize = TYPE_SIZES3[params.type] || 1;
|
|
@@ -3862,8 +3879,8 @@ ${htmlLog}
|
|
|
3862
3879
|
gl;
|
|
3863
3880
|
extensions;
|
|
3864
3881
|
testedFeatures = /* @__PURE__ */ new Set();
|
|
3865
|
-
constructor(gl, extensions) {
|
|
3866
|
-
super();
|
|
3882
|
+
constructor(gl, extensions, disabledFeatures) {
|
|
3883
|
+
super([], disabledFeatures);
|
|
3867
3884
|
this.gl = gl;
|
|
3868
3885
|
this.extensions = extensions;
|
|
3869
3886
|
getWebGLExtension(gl, "EXT_color_buffer_float", extensions);
|
|
@@ -3882,6 +3899,9 @@ ${htmlLog}
|
|
|
3882
3899
|
return [];
|
|
3883
3900
|
}
|
|
3884
3901
|
has(feature) {
|
|
3902
|
+
if (this.disabledFeatures[feature]) {
|
|
3903
|
+
return false;
|
|
3904
|
+
}
|
|
3885
3905
|
if (!this.testedFeatures.has(feature)) {
|
|
3886
3906
|
this.testedFeatures.add(feature);
|
|
3887
3907
|
if (isTextureFeature(feature) && checkTextureFeature(this.gl, feature, this.extensions)) {
|
|
@@ -3893,6 +3913,12 @@ ${htmlLog}
|
|
|
3893
3913
|
}
|
|
3894
3914
|
return this.features.has(feature);
|
|
3895
3915
|
}
|
|
3916
|
+
// FOR DEVICE
|
|
3917
|
+
initializeFeatures() {
|
|
3918
|
+
for (const feature of this) {
|
|
3919
|
+
}
|
|
3920
|
+
}
|
|
3921
|
+
// IMPLEMENTATION
|
|
3896
3922
|
/** Extract all WebGL features */
|
|
3897
3923
|
getWebGLFeature(feature) {
|
|
3898
3924
|
const featureInfo = WEBGL_FEATURES[feature];
|
|
@@ -4012,17 +4038,15 @@ ${htmlLog}
|
|
|
4012
4038
|
};
|
|
4013
4039
|
|
|
4014
4040
|
// src/adapter/resources/webgl-framebuffer.ts
|
|
4015
|
-
var
|
|
4041
|
+
var import_constants11 = __toESM(require_constants(), 1);
|
|
4016
4042
|
|
|
4017
4043
|
// src/adapter/resources/webgl-texture.ts
|
|
4018
4044
|
var import_constants10 = __toESM(require_constants(), 1);
|
|
4019
4045
|
|
|
4020
4046
|
// src/context/state-tracker/with-parameters.ts
|
|
4021
|
-
function withGLParameters(
|
|
4022
|
-
const webglDevice = WebGLDevice.attach(device);
|
|
4023
|
-
const gl = webglDevice.gl;
|
|
4047
|
+
function withGLParameters(gl, parameters, func) {
|
|
4024
4048
|
if (isObjectEmpty3(parameters)) {
|
|
4025
|
-
return func(
|
|
4049
|
+
return func(gl);
|
|
4026
4050
|
}
|
|
4027
4051
|
const { nocatch = true } = parameters;
|
|
4028
4052
|
pushContextState(gl);
|
|
@@ -4056,13 +4080,14 @@ ${htmlLog}
|
|
|
4056
4080
|
if (isObjectEmpty(parameters)) {
|
|
4057
4081
|
return func(device);
|
|
4058
4082
|
}
|
|
4059
|
-
|
|
4083
|
+
const webglDevice = device;
|
|
4084
|
+
pushContextState(webglDevice.gl);
|
|
4060
4085
|
try {
|
|
4061
4086
|
setDeviceParameters(device, parameters);
|
|
4062
|
-
setGLParameters(
|
|
4087
|
+
setGLParameters(webglDevice.gl, glParameters);
|
|
4063
4088
|
return func(device);
|
|
4064
4089
|
} finally {
|
|
4065
|
-
popContextState(
|
|
4090
|
+
popContextState(webglDevice.gl);
|
|
4066
4091
|
}
|
|
4067
4092
|
}
|
|
4068
4093
|
function withDeviceParameters(device, parameters, func) {
|
|
@@ -4078,7 +4103,7 @@ ${htmlLog}
|
|
|
4078
4103
|
}
|
|
4079
4104
|
}
|
|
4080
4105
|
function setDeviceParameters(device, parameters) {
|
|
4081
|
-
const webglDevice =
|
|
4106
|
+
const webglDevice = device;
|
|
4082
4107
|
const { gl } = webglDevice;
|
|
4083
4108
|
if (parameters.cullMode) {
|
|
4084
4109
|
switch (parameters.cullMode) {
|
|
@@ -4600,6 +4625,9 @@ ${htmlLog}
|
|
|
4600
4625
|
toString() {
|
|
4601
4626
|
return `Texture(${this.id},${this.width}x${this.height})`;
|
|
4602
4627
|
}
|
|
4628
|
+
createView(props) {
|
|
4629
|
+
return new WEBGLTextureView(this.device, { ...props, texture: this });
|
|
4630
|
+
}
|
|
4603
4631
|
// eslint-disable-next-line max-statements
|
|
4604
4632
|
initialize(props = {}) {
|
|
4605
4633
|
if (this.props.dimension === "cube") {
|
|
@@ -4665,8 +4693,8 @@ ${htmlLog}
|
|
|
4665
4693
|
});
|
|
4666
4694
|
this.setSampler(props.sampler);
|
|
4667
4695
|
this._setSamplerParameters(parameters);
|
|
4668
|
-
this.view =
|
|
4669
|
-
if (mipmaps) {
|
|
4696
|
+
this.view = this.createView({ ...this.props, mipLevelCount: 1, arrayLayerCount: 1 });
|
|
4697
|
+
if (mipmaps && this.device.isTextureFormatFilterable(props.format)) {
|
|
4670
4698
|
this.generateMipmap();
|
|
4671
4699
|
}
|
|
4672
4700
|
if (isVideo) {
|
|
@@ -5221,398 +5249,184 @@ ${htmlLog}
|
|
|
5221
5249
|
log.log(1, "texture sampler parameters", parameters)();
|
|
5222
5250
|
}
|
|
5223
5251
|
|
|
5224
|
-
// src/adapter/
|
|
5225
|
-
var
|
|
5226
|
-
|
|
5227
|
-
// src/adapter/objects/webgl-resource.ts
|
|
5228
|
-
var ERR_RESOURCE_METHOD_UNDEFINED = "Resource subclass must define virtual methods";
|
|
5229
|
-
var WebGLResource = class extends Resource {
|
|
5252
|
+
// src/adapter/resources/webgl-framebuffer.ts
|
|
5253
|
+
var WEBGLFramebuffer = class extends Framebuffer {
|
|
5230
5254
|
device;
|
|
5231
5255
|
gl;
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
this.device =
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5256
|
+
handle;
|
|
5257
|
+
get texture() {
|
|
5258
|
+
return this.colorAttachments[0];
|
|
5259
|
+
}
|
|
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);
|
|
5248
5290
|
}
|
|
5249
|
-
this.byteLength = 0;
|
|
5250
5291
|
}
|
|
5251
|
-
|
|
5252
|
-
|
|
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
|
+
}
|
|
5253
5298
|
}
|
|
5254
|
-
|
|
5255
|
-
|
|
5299
|
+
// PRIVATE
|
|
5300
|
+
/** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */
|
|
5301
|
+
createDepthStencilTexture(format) {
|
|
5302
|
+
return new WEBGLTexture(this.device, {
|
|
5303
|
+
id: `${this.id}-depth-stencil`,
|
|
5304
|
+
format,
|
|
5305
|
+
width: this.width,
|
|
5306
|
+
height: this.height,
|
|
5307
|
+
mipmaps: false
|
|
5308
|
+
});
|
|
5256
5309
|
}
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5310
|
+
/**
|
|
5311
|
+
* Attachment resize is expected to be a noop if size is same
|
|
5312
|
+
*/
|
|
5313
|
+
resizeAttachments(width, height) {
|
|
5314
|
+
if (this.handle === null) {
|
|
5315
|
+
this.width = this.gl.drawingBufferWidth;
|
|
5316
|
+
this.height = this.gl.drawingBufferHeight;
|
|
5317
|
+
return this;
|
|
5261
5318
|
}
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5319
|
+
if (width === void 0) {
|
|
5320
|
+
width = this.gl.drawingBufferWidth;
|
|
5321
|
+
}
|
|
5322
|
+
if (height === void 0) {
|
|
5323
|
+
height = this.gl.drawingBufferHeight;
|
|
5324
|
+
}
|
|
5325
|
+
for (const colorAttachment of this.colorAttachments) {
|
|
5326
|
+
colorAttachment.texture.resize({ width, height });
|
|
5327
|
+
}
|
|
5328
|
+
if (this.depthStencilAttachment) {
|
|
5329
|
+
this.depthStencilAttachment.texture.resize({ width, height });
|
|
5265
5330
|
}
|
|
5266
5331
|
return this;
|
|
5267
5332
|
}
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5333
|
+
/** Attach one attachment */
|
|
5334
|
+
_attachOne(attachmentPoint, attachment) {
|
|
5335
|
+
if (Array.isArray(attachment)) {
|
|
5336
|
+
const [texture, layer = 0, level = 0] = attachment;
|
|
5337
|
+
this._attachTexture(attachmentPoint, texture, layer, level);
|
|
5338
|
+
return texture;
|
|
5272
5339
|
}
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
this._bound = true;
|
|
5277
|
-
value = funcOrHandle();
|
|
5278
|
-
this._bound = false;
|
|
5279
|
-
this._bindHandle(null);
|
|
5280
|
-
} else {
|
|
5281
|
-
value = funcOrHandle();
|
|
5340
|
+
if (attachment instanceof WEBGLTexture) {
|
|
5341
|
+
this._attachTexture(attachmentPoint, attachment, 0, 0);
|
|
5342
|
+
return attachment;
|
|
5282
5343
|
}
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
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
|
+
}
|
|
5354
|
+
throw new Error("attach");
|
|
5291
5355
|
}
|
|
5292
|
-
//
|
|
5293
|
-
|
|
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
|
+
// }
|
|
5365
|
+
/**
|
|
5366
|
+
* @param attachment
|
|
5367
|
+
* @param texture
|
|
5368
|
+
* @param layer = 0 - index into WEBGLTextureArray and Texture3D or face for `TextureCubeMap`
|
|
5369
|
+
* @param level = 0 - mipmapLevel
|
|
5370
|
+
*/
|
|
5371
|
+
_attachTexture(attachment, texture, layer, level) {
|
|
5372
|
+
const { gl } = this.device;
|
|
5373
|
+
gl.bindTexture(texture.target, texture.handle);
|
|
5374
|
+
switch (texture.target) {
|
|
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);
|
|
5378
|
+
break;
|
|
5379
|
+
case import_constants11.GL.TEXTURE_CUBE_MAP:
|
|
5380
|
+
const face = mapIndexToCubeMapFace(layer);
|
|
5381
|
+
gl.framebufferTexture2D(import_constants11.GL.FRAMEBUFFER, attachment, face, texture.handle, level);
|
|
5382
|
+
break;
|
|
5383
|
+
case import_constants11.GL.TEXTURE_2D:
|
|
5384
|
+
gl.framebufferTexture2D(import_constants11.GL.FRAMEBUFFER, attachment, import_constants11.GL.TEXTURE_2D, texture.handle, level);
|
|
5385
|
+
break;
|
|
5386
|
+
default:
|
|
5387
|
+
assert2(false, "Illegal texture type");
|
|
5388
|
+
}
|
|
5389
|
+
gl.bindTexture(texture.target, null);
|
|
5294
5390
|
}
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5391
|
+
};
|
|
5392
|
+
function mapIndexToCubeMapFace(layer) {
|
|
5393
|
+
return layer < import_constants11.GL.TEXTURE_CUBE_MAP_POSITIVE_X ? layer + import_constants11.GL.TEXTURE_CUBE_MAP_POSITIVE_X : layer;
|
|
5394
|
+
}
|
|
5395
|
+
function _getFrameBufferStatus(status) {
|
|
5396
|
+
switch (status) {
|
|
5397
|
+
case import_constants11.GL.FRAMEBUFFER_COMPLETE:
|
|
5398
|
+
return "success";
|
|
5399
|
+
case import_constants11.GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
|
|
5400
|
+
return "Mismatched attachments";
|
|
5401
|
+
case import_constants11.GL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
|
|
5402
|
+
return "No attachments";
|
|
5403
|
+
case import_constants11.GL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
|
|
5404
|
+
return "Height/width mismatch";
|
|
5405
|
+
case import_constants11.GL.FRAMEBUFFER_UNSUPPORTED:
|
|
5406
|
+
return "Unsupported or split attachments";
|
|
5407
|
+
case import_constants11.GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
|
|
5408
|
+
return "Samples mismatch";
|
|
5409
|
+
default:
|
|
5410
|
+
return `${status}`;
|
|
5298
5411
|
}
|
|
5299
|
-
|
|
5300
|
-
|
|
5412
|
+
}
|
|
5413
|
+
|
|
5414
|
+
// src/adapter/webgl-canvas-context.ts
|
|
5415
|
+
var WebGLCanvasContext = class extends CanvasContext {
|
|
5416
|
+
device;
|
|
5417
|
+
presentationSize;
|
|
5418
|
+
_framebuffer = null;
|
|
5419
|
+
constructor(device, props) {
|
|
5420
|
+
super(props);
|
|
5421
|
+
this.device = device;
|
|
5422
|
+
this.presentationSize = [-1, -1];
|
|
5423
|
+
this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);
|
|
5424
|
+
this.update();
|
|
5301
5425
|
}
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
5307
|
-
}
|
|
5308
|
-
_getParameter(pname, props) {
|
|
5309
|
-
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
5310
|
-
}
|
|
5311
|
-
_setParameter(pname, value) {
|
|
5312
|
-
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
5313
|
-
}
|
|
5314
|
-
// PRIVATE METHODS
|
|
5315
|
-
/*
|
|
5316
|
-
_addStats() {
|
|
5317
|
-
const name = this.constructor.name;
|
|
5318
|
-
const stats = lumaStats.get('Resource Counts');
|
|
5319
|
-
|
|
5320
|
-
stats.get('Resources Created').incrementCount();
|
|
5321
|
-
stats.get(`${name}s Created`).incrementCount();
|
|
5322
|
-
stats.get(`${name}s Active`).incrementCount();
|
|
5323
|
-
}
|
|
5324
|
-
|
|
5325
|
-
_removeStats() {
|
|
5326
|
-
const name = this.constructor.name;
|
|
5327
|
-
const stats = lumaStats.get('Resource Counts');
|
|
5328
|
-
|
|
5329
|
-
stats.get(`${name}s Active`).decrementCount();
|
|
5330
|
-
}
|
|
5331
|
-
|
|
5332
|
-
trackAllocatedMemory(bytes, name = this.constructor.name) {
|
|
5333
|
-
const stats = lumaStats.get('Memory Usage');
|
|
5334
|
-
|
|
5335
|
-
stats.get('GPU Memory').addCount(bytes);
|
|
5336
|
-
stats.get(`${name} Memory`).addCount(bytes);
|
|
5337
|
-
this.byteLength = bytes;
|
|
5338
|
-
}
|
|
5339
|
-
|
|
5340
|
-
trackDeallocatedMemory(name = this.constructor.name) {
|
|
5341
|
-
const stats = lumaStats.get('Memory Usage');
|
|
5342
|
-
|
|
5343
|
-
stats.get('GPU Memory').subtractCount(this.byteLength);
|
|
5344
|
-
stats.get(`${name} Memory`).subtractCount(this.byteLength);
|
|
5345
|
-
this.byteLength = 0;
|
|
5346
|
-
}
|
|
5347
|
-
*/
|
|
5348
|
-
};
|
|
5349
|
-
|
|
5350
|
-
// src/adapter/objects/webgl-renderbuffer.ts
|
|
5351
|
-
var _WEBGLRenderbuffer = class extends WebGLResource {
|
|
5352
|
-
get [Symbol.toStringTag]() {
|
|
5353
|
-
return "Renderbuffer";
|
|
5354
|
-
}
|
|
5355
|
-
get width() {
|
|
5356
|
-
return this.props.width;
|
|
5357
|
-
}
|
|
5358
|
-
get height() {
|
|
5359
|
-
return this.props.height;
|
|
5360
|
-
}
|
|
5361
|
-
get format() {
|
|
5362
|
-
return this.props.format;
|
|
5363
|
-
}
|
|
5364
|
-
get samples() {
|
|
5365
|
-
return this.props.samples;
|
|
5366
|
-
}
|
|
5367
|
-
get attachment() {
|
|
5368
|
-
return;
|
|
5369
|
-
}
|
|
5370
|
-
/** WebGL format constant */
|
|
5371
|
-
glFormat;
|
|
5372
|
-
static isTextureFormatSupported(device, format) {
|
|
5373
|
-
return isRenderbufferFormatSupported(device.gl, format, device._extensions);
|
|
5374
|
-
}
|
|
5375
|
-
constructor(device, props) {
|
|
5376
|
-
if (typeof props.format === "number") {
|
|
5377
|
-
throw new Error("Renderbuffer");
|
|
5378
|
-
}
|
|
5379
|
-
super(device, props, _WEBGLRenderbuffer.defaultProps);
|
|
5380
|
-
this.glFormat = convertTextureFormatToGL(this.props.format);
|
|
5381
|
-
this._initialize(this.props);
|
|
5382
|
-
}
|
|
5383
|
-
resize(size) {
|
|
5384
|
-
if (size.width !== this.width || size.height !== this.height) {
|
|
5385
|
-
Object.assign(this.props, { ...size, format: this.format, samples: this.samples });
|
|
5386
|
-
this._initialize(this.props);
|
|
5387
|
-
}
|
|
5388
|
-
}
|
|
5389
|
-
// PRIVATE METHODS
|
|
5390
|
-
/** Creates and initializes a renderbuffer object's data store */
|
|
5391
|
-
_initialize(props) {
|
|
5392
|
-
const { format, width, height, samples } = props;
|
|
5393
|
-
assert2(format, "Needs format");
|
|
5394
|
-
this.trackDeallocatedMemory();
|
|
5395
|
-
this.gl.bindRenderbuffer(import_constants11.GL.RENDERBUFFER, this.handle);
|
|
5396
|
-
if (samples !== 0) {
|
|
5397
|
-
this.gl.renderbufferStorageMultisample(
|
|
5398
|
-
import_constants11.GL.RENDERBUFFER,
|
|
5399
|
-
samples,
|
|
5400
|
-
this.glFormat,
|
|
5401
|
-
width,
|
|
5402
|
-
height
|
|
5403
|
-
);
|
|
5404
|
-
} else {
|
|
5405
|
-
this.gl.renderbufferStorage(import_constants11.GL.RENDERBUFFER, this.glFormat, width, height);
|
|
5406
|
-
}
|
|
5407
|
-
this.gl.bindRenderbuffer(import_constants11.GL.RENDERBUFFER, null);
|
|
5408
|
-
this.trackAllocatedMemory(
|
|
5409
|
-
width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat)
|
|
5410
|
-
);
|
|
5411
|
-
}
|
|
5412
|
-
// RESOURCE IMPLEMENTATION
|
|
5413
|
-
_createHandle() {
|
|
5414
|
-
return this.gl.createRenderbuffer();
|
|
5415
|
-
}
|
|
5416
|
-
_deleteHandle() {
|
|
5417
|
-
this.gl.deleteRenderbuffer(this.handle);
|
|
5418
|
-
this.trackDeallocatedMemory();
|
|
5419
|
-
}
|
|
5420
|
-
_bindHandle(handle) {
|
|
5421
|
-
this.gl.bindRenderbuffer(import_constants11.GL.RENDERBUFFER, handle);
|
|
5422
|
-
}
|
|
5423
|
-
};
|
|
5424
|
-
var WEBGLRenderbuffer = _WEBGLRenderbuffer;
|
|
5425
|
-
__publicField(WEBGLRenderbuffer, "defaultProps", {
|
|
5426
|
-
id: void 0,
|
|
5427
|
-
handle: void 0,
|
|
5428
|
-
userData: void 0,
|
|
5429
|
-
format: void 0,
|
|
5430
|
-
// 'depth16unorm'
|
|
5431
|
-
width: 1,
|
|
5432
|
-
height: 1,
|
|
5433
|
-
samples: 0
|
|
5434
|
-
});
|
|
5435
|
-
|
|
5436
|
-
// src/adapter/resources/webgl-framebuffer.ts
|
|
5437
|
-
var WEBGLFramebuffer = class extends Framebuffer {
|
|
5438
|
-
device;
|
|
5439
|
-
gl;
|
|
5440
|
-
handle;
|
|
5441
|
-
get texture() {
|
|
5442
|
-
return this.colorAttachments[0];
|
|
5443
|
-
}
|
|
5444
|
-
constructor(device, props) {
|
|
5445
|
-
super(device, props);
|
|
5446
|
-
const isDefaultFramebuffer = props.handle === null;
|
|
5447
|
-
this.device = device;
|
|
5448
|
-
this.gl = device.gl;
|
|
5449
|
-
this.handle = this.props.handle || isDefaultFramebuffer ? this.props.handle : this.gl.createFramebuffer();
|
|
5450
|
-
if (!isDefaultFramebuffer) {
|
|
5451
|
-
device.setSpectorMetadata(this.handle, { id: this.props.id, props: this.props });
|
|
5452
|
-
this.autoCreateAttachmentTextures();
|
|
5453
|
-
this.gl.bindFramebuffer(import_constants12.GL.FRAMEBUFFER, this.handle);
|
|
5454
|
-
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
5455
|
-
const attachment = this.colorAttachments[i];
|
|
5456
|
-
const attachmentPoint = import_constants12.GL.COLOR_ATTACHMENT0 + i;
|
|
5457
|
-
if (attachment) {
|
|
5458
|
-
this._attachOne(attachmentPoint, attachment);
|
|
5459
|
-
}
|
|
5460
|
-
}
|
|
5461
|
-
if (this.depthStencilAttachment) {
|
|
5462
|
-
this._attachOne(
|
|
5463
|
-
getDepthStencilAttachmentWebGL(this.depthStencilAttachment.props.format),
|
|
5464
|
-
this.depthStencilAttachment
|
|
5465
|
-
);
|
|
5466
|
-
}
|
|
5467
|
-
if (props.check !== false) {
|
|
5468
|
-
const status = this.gl.checkFramebufferStatus(import_constants12.GL.FRAMEBUFFER);
|
|
5469
|
-
if (status !== import_constants12.GL.FRAMEBUFFER_COMPLETE) {
|
|
5470
|
-
throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
|
|
5471
|
-
}
|
|
5472
|
-
}
|
|
5473
|
-
this.gl.bindFramebuffer(import_constants12.GL.FRAMEBUFFER, null);
|
|
5474
|
-
}
|
|
5475
|
-
}
|
|
5476
|
-
/** destroys any auto created resources etc. */
|
|
5477
|
-
destroy() {
|
|
5478
|
-
super.destroy();
|
|
5479
|
-
if (!this.destroyed && this.handle !== null) {
|
|
5480
|
-
this.gl.deleteFramebuffer(this.handle);
|
|
5481
|
-
}
|
|
5482
|
-
}
|
|
5483
|
-
// PRIVATE
|
|
5484
|
-
/** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */
|
|
5485
|
-
createDepthStencilTexture(format) {
|
|
5486
|
-
return new WEBGLRenderbuffer(this.device, {
|
|
5487
|
-
id: `${this.id}-depth-stencil`,
|
|
5488
|
-
// TODO misleading if not depth and stencil?
|
|
5489
|
-
format,
|
|
5490
|
-
// dataFormat: GL.DEPTH_STENCIL,
|
|
5491
|
-
// type: GL.UNSIGNED_INT_24_8,
|
|
5492
|
-
width: this.width,
|
|
5493
|
-
height: this.height
|
|
5494
|
-
});
|
|
5495
|
-
}
|
|
5496
|
-
/**
|
|
5497
|
-
* Attachment resize is expected to be a noop if size is same
|
|
5498
|
-
*/
|
|
5499
|
-
resizeAttachments(width, height) {
|
|
5500
|
-
if (this.handle === null) {
|
|
5501
|
-
this.width = this.gl.drawingBufferWidth;
|
|
5502
|
-
this.height = this.gl.drawingBufferHeight;
|
|
5503
|
-
return this;
|
|
5504
|
-
}
|
|
5505
|
-
if (width === void 0) {
|
|
5506
|
-
width = this.gl.drawingBufferWidth;
|
|
5507
|
-
}
|
|
5508
|
-
if (height === void 0) {
|
|
5509
|
-
height = this.gl.drawingBufferHeight;
|
|
5510
|
-
}
|
|
5511
|
-
for (const colorAttachment of this.colorAttachments) {
|
|
5512
|
-
colorAttachment.texture.resize({ width, height });
|
|
5513
|
-
}
|
|
5514
|
-
if (this.depthStencilAttachment) {
|
|
5515
|
-
this.depthStencilAttachment.texture.resize({ width, height });
|
|
5516
|
-
}
|
|
5517
|
-
return this;
|
|
5518
|
-
}
|
|
5519
|
-
/** Attach one attachment */
|
|
5520
|
-
_attachOne(attachmentPoint, attachment) {
|
|
5521
|
-
if (attachment instanceof WEBGLRenderbuffer) {
|
|
5522
|
-
this._attachWEBGLRenderbuffer(attachmentPoint, attachment);
|
|
5523
|
-
return attachment;
|
|
5524
|
-
} else if (Array.isArray(attachment)) {
|
|
5525
|
-
const [texture, layer = 0, level = 0] = attachment;
|
|
5526
|
-
this._attachTexture(attachmentPoint, texture, layer, level);
|
|
5527
|
-
return texture;
|
|
5528
|
-
} else if (attachment instanceof WEBGLTexture) {
|
|
5529
|
-
this._attachTexture(attachmentPoint, attachment, 0, 0);
|
|
5530
|
-
return attachment;
|
|
5531
|
-
} else if (attachment instanceof WEBGLTextureView) {
|
|
5532
|
-
const textureView = attachment;
|
|
5533
|
-
this._attachTexture(
|
|
5534
|
-
attachmentPoint,
|
|
5535
|
-
textureView.texture,
|
|
5536
|
-
textureView.props.baseMipLevel,
|
|
5537
|
-
textureView.props.baseArrayLayer
|
|
5538
|
-
);
|
|
5539
|
-
return attachment.texture;
|
|
5540
|
-
}
|
|
5541
|
-
throw new Error("attach");
|
|
5542
|
-
}
|
|
5543
|
-
_attachWEBGLRenderbuffer(attachment, renderbuffer) {
|
|
5544
|
-
this.gl.framebufferRenderbuffer(
|
|
5545
|
-
import_constants12.GL.FRAMEBUFFER,
|
|
5546
|
-
attachment,
|
|
5547
|
-
import_constants12.GL.RENDERBUFFER,
|
|
5548
|
-
renderbuffer.handle
|
|
5549
|
-
);
|
|
5550
|
-
}
|
|
5551
|
-
/**
|
|
5552
|
-
* @param attachment
|
|
5553
|
-
* @param texture
|
|
5554
|
-
* @param layer = 0 - index into WEBGLTextureArray and Texture3D or face for `TextureCubeMap`
|
|
5555
|
-
* @param level = 0 - mipmapLevel
|
|
5556
|
-
*/
|
|
5557
|
-
_attachTexture(attachment, texture, layer, level) {
|
|
5558
|
-
const { gl } = this.device;
|
|
5559
|
-
gl.bindTexture(texture.target, texture.handle);
|
|
5560
|
-
switch (texture.target) {
|
|
5561
|
-
case import_constants12.GL.TEXTURE_2D_ARRAY:
|
|
5562
|
-
case import_constants12.GL.TEXTURE_3D:
|
|
5563
|
-
gl.framebufferTextureLayer(import_constants12.GL.FRAMEBUFFER, attachment, texture.target, level, layer);
|
|
5564
|
-
break;
|
|
5565
|
-
case import_constants12.GL.TEXTURE_CUBE_MAP:
|
|
5566
|
-
const face = mapIndexToCubeMapFace(layer);
|
|
5567
|
-
gl.framebufferTexture2D(import_constants12.GL.FRAMEBUFFER, attachment, face, texture.handle, level);
|
|
5568
|
-
break;
|
|
5569
|
-
case import_constants12.GL.TEXTURE_2D:
|
|
5570
|
-
gl.framebufferTexture2D(import_constants12.GL.FRAMEBUFFER, attachment, import_constants12.GL.TEXTURE_2D, texture.handle, level);
|
|
5571
|
-
break;
|
|
5572
|
-
default:
|
|
5573
|
-
assert2(false, "Illegal texture type");
|
|
5574
|
-
}
|
|
5575
|
-
gl.bindTexture(texture.target, null);
|
|
5576
|
-
}
|
|
5577
|
-
};
|
|
5578
|
-
function mapIndexToCubeMapFace(layer) {
|
|
5579
|
-
return layer < import_constants12.GL.TEXTURE_CUBE_MAP_POSITIVE_X ? layer + import_constants12.GL.TEXTURE_CUBE_MAP_POSITIVE_X : layer;
|
|
5580
|
-
}
|
|
5581
|
-
function _getFrameBufferStatus(status) {
|
|
5582
|
-
switch (status) {
|
|
5583
|
-
case import_constants12.GL.FRAMEBUFFER_COMPLETE:
|
|
5584
|
-
return "success";
|
|
5585
|
-
case import_constants12.GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
|
|
5586
|
-
return "Mismatched attachments";
|
|
5587
|
-
case import_constants12.GL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
|
|
5588
|
-
return "No attachments";
|
|
5589
|
-
case import_constants12.GL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
|
|
5590
|
-
return "Height/width mismatch";
|
|
5591
|
-
case import_constants12.GL.FRAMEBUFFER_UNSUPPORTED:
|
|
5592
|
-
return "Unsupported or split attachments";
|
|
5593
|
-
case import_constants12.GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
|
|
5594
|
-
return "Samples mismatch";
|
|
5595
|
-
default:
|
|
5596
|
-
return `${status}`;
|
|
5597
|
-
}
|
|
5598
|
-
}
|
|
5599
|
-
|
|
5600
|
-
// src/adapter/webgl-canvas-context.ts
|
|
5601
|
-
var WebGLCanvasContext = class extends CanvasContext {
|
|
5602
|
-
device;
|
|
5603
|
-
presentationSize;
|
|
5604
|
-
_framebuffer = null;
|
|
5605
|
-
constructor(device, props) {
|
|
5606
|
-
super(props);
|
|
5607
|
-
this.device = device;
|
|
5608
|
-
this.presentationSize = [-1, -1];
|
|
5609
|
-
this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);
|
|
5610
|
-
this.update();
|
|
5611
|
-
}
|
|
5612
|
-
getCurrentFramebuffer() {
|
|
5613
|
-
this.update();
|
|
5614
|
-
this._framebuffer = this._framebuffer || new WEBGLFramebuffer(this.device, { handle: null });
|
|
5615
|
-
return this._framebuffer;
|
|
5426
|
+
getCurrentFramebuffer() {
|
|
5427
|
+
this.update();
|
|
5428
|
+
this._framebuffer = this._framebuffer || new WEBGLFramebuffer(this.device, { handle: null });
|
|
5429
|
+
return this._framebuffer;
|
|
5616
5430
|
}
|
|
5617
5431
|
/** Resizes and updates render targets if necessary */
|
|
5618
5432
|
update() {
|
|
@@ -5707,7 +5521,7 @@ ${htmlLog}
|
|
|
5707
5521
|
}
|
|
5708
5522
|
|
|
5709
5523
|
// src/context/debug/webgl-developer-tools.ts
|
|
5710
|
-
var
|
|
5524
|
+
var import_constants12 = __toESM(require_constants(), 1);
|
|
5711
5525
|
var WEBGL_DEBUG_CDN_URL = "https://unpkg.com/webgl-debug@2.0.1/index.js";
|
|
5712
5526
|
function getWebGLContextData(gl) {
|
|
5713
5527
|
gl.luma = gl.luma || {};
|
|
@@ -5739,15 +5553,15 @@ ${htmlLog}
|
|
|
5739
5553
|
if (data.debugContext) {
|
|
5740
5554
|
return data.debugContext;
|
|
5741
5555
|
}
|
|
5742
|
-
globalThis.WebGLDebugUtils.init({ ...
|
|
5556
|
+
globalThis.WebGLDebugUtils.init({ ...import_constants12.GL, ...gl });
|
|
5743
5557
|
const glDebug = globalThis.WebGLDebugUtils.makeDebugContext(
|
|
5744
5558
|
gl,
|
|
5745
5559
|
onGLError.bind(null, props),
|
|
5746
5560
|
onValidateGLFunc.bind(null, props)
|
|
5747
5561
|
);
|
|
5748
|
-
for (const key in
|
|
5749
|
-
if (!(key in glDebug) && typeof
|
|
5750
|
-
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];
|
|
5751
5565
|
}
|
|
5752
5566
|
}
|
|
5753
5567
|
class WebGLDebugContext {
|
|
@@ -5806,7 +5620,7 @@ ${htmlLog}
|
|
|
5806
5620
|
}
|
|
5807
5621
|
|
|
5808
5622
|
// src/adapter/resources/webgl-shader.ts
|
|
5809
|
-
var
|
|
5623
|
+
var import_constants13 = __toESM(require_constants(), 1);
|
|
5810
5624
|
|
|
5811
5625
|
// src/adapter/helpers/parse-shader-compiler-log.ts
|
|
5812
5626
|
function parseShaderCompilerLog(errLog) {
|
|
@@ -5861,10 +5675,10 @@ ${htmlLog}
|
|
|
5861
5675
|
this.device = device;
|
|
5862
5676
|
switch (this.props.stage) {
|
|
5863
5677
|
case "vertex":
|
|
5864
|
-
this.handle = this.props.handle || this.device.gl.createShader(
|
|
5678
|
+
this.handle = this.props.handle || this.device.gl.createShader(import_constants13.GL.VERTEX_SHADER);
|
|
5865
5679
|
break;
|
|
5866
5680
|
case "fragment":
|
|
5867
|
-
this.handle = this.props.handle || this.device.gl.createShader(
|
|
5681
|
+
this.handle = this.props.handle || this.device.gl.createShader(import_constants13.GL.FRAGMENT_SHADER);
|
|
5868
5682
|
break;
|
|
5869
5683
|
default:
|
|
5870
5684
|
throw new Error(this.props.stage);
|
|
@@ -5928,7 +5742,7 @@ ${source2}`;
|
|
|
5928
5742
|
}
|
|
5929
5743
|
const { gl } = this.device;
|
|
5930
5744
|
for (; ; ) {
|
|
5931
|
-
const complete = gl.getShaderParameter(this.handle,
|
|
5745
|
+
const complete = gl.getShaderParameter(this.handle, import_constants13.GL.COMPLETION_STATUS_KHR);
|
|
5932
5746
|
if (complete) {
|
|
5933
5747
|
return;
|
|
5934
5748
|
}
|
|
@@ -5941,12 +5755,12 @@ ${source2}`;
|
|
|
5941
5755
|
* https://gamedev.stackexchange.com/questions/30429/how-to-detect-glsl-warnings
|
|
5942
5756
|
*/
|
|
5943
5757
|
_getCompilationStatus() {
|
|
5944
|
-
this.compilationStatus = this.device.gl.getShaderParameter(this.handle,
|
|
5758
|
+
this.compilationStatus = this.device.gl.getShaderParameter(this.handle, import_constants13.GL.COMPILE_STATUS) ? "success" : "error";
|
|
5945
5759
|
}
|
|
5946
5760
|
};
|
|
5947
5761
|
|
|
5948
5762
|
// src/adapter/resources/webgl-render-pass.ts
|
|
5949
|
-
var
|
|
5763
|
+
var import_constants14 = __toESM(require_constants(), 1);
|
|
5950
5764
|
var GL_DEPTH_BUFFER_BIT = 256;
|
|
5951
5765
|
var GL_STENCIL_BUFFER_BIT = 1024;
|
|
5952
5766
|
var GL_COLOR_BUFFER_BIT = 16384;
|
|
@@ -5965,7 +5779,7 @@ ${source2}`;
|
|
|
5965
5779
|
end() {
|
|
5966
5780
|
popContextState(this.device.gl);
|
|
5967
5781
|
if (this.props.framebuffer) {
|
|
5968
|
-
setGLParameters(this.device, { framebuffer: null });
|
|
5782
|
+
setGLParameters(this.device.gl, { framebuffer: null });
|
|
5969
5783
|
}
|
|
5970
5784
|
}
|
|
5971
5785
|
pushDebugGroup(groupLabel) {
|
|
@@ -5989,7 +5803,7 @@ ${source2}`;
|
|
|
5989
5803
|
glParameters.depthMask = !this.props.depthReadOnly;
|
|
5990
5804
|
}
|
|
5991
5805
|
glParameters.stencilMask = this.props.stencilReadOnly ? 0 : 1;
|
|
5992
|
-
glParameters[
|
|
5806
|
+
glParameters[import_constants14.GL.RASTERIZER_DISCARD] = this.props.discard;
|
|
5993
5807
|
if (parameters.viewport) {
|
|
5994
5808
|
if (parameters.viewport.length >= 6) {
|
|
5995
5809
|
glParameters.viewport = parameters.viewport.slice(0, 4);
|
|
@@ -6007,10 +5821,10 @@ ${source2}`;
|
|
|
6007
5821
|
}
|
|
6008
5822
|
if (parameters.stencilReference) {
|
|
6009
5823
|
console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL");
|
|
6010
|
-
parameters[
|
|
5824
|
+
parameters[import_constants14.GL.STENCIL_REF] = parameters.stencilReference;
|
|
6011
5825
|
}
|
|
6012
5826
|
this.glParameters = glParameters;
|
|
6013
|
-
setGLParameters(this.device, glParameters);
|
|
5827
|
+
setGLParameters(this.device.gl, glParameters);
|
|
6014
5828
|
}
|
|
6015
5829
|
beginOcclusionQuery(queryIndex) {
|
|
6016
5830
|
const webglQuerySet = this.props.occlusionQuerySet;
|
|
@@ -6040,7 +5854,7 @@ ${source2}`;
|
|
|
6040
5854
|
glParameters.clearStencil = this.props.clearStencil;
|
|
6041
5855
|
}
|
|
6042
5856
|
if (clearMask !== 0) {
|
|
6043
|
-
withGLParameters(this.device, glParameters, () => {
|
|
5857
|
+
withGLParameters(this.device.gl, glParameters, () => {
|
|
6044
5858
|
this.device.gl.clear(clearMask);
|
|
6045
5859
|
});
|
|
6046
5860
|
}
|
|
@@ -6085,36 +5899,36 @@ ${source2}`;
|
|
|
6085
5899
|
};
|
|
6086
5900
|
|
|
6087
5901
|
// src/adapter/resources/webgl-render-pipeline.ts
|
|
6088
|
-
var
|
|
5902
|
+
var import_constants21 = __toESM(require_constants(), 1);
|
|
6089
5903
|
|
|
6090
5904
|
// src/adapter/helpers/get-shader-layout.ts
|
|
6091
|
-
var
|
|
5905
|
+
var import_constants18 = __toESM(require_constants(), 1);
|
|
6092
5906
|
|
|
6093
5907
|
// src/classic/accessor.ts
|
|
6094
|
-
var
|
|
5908
|
+
var import_constants16 = __toESM(require_constants(), 1);
|
|
6095
5909
|
|
|
6096
5910
|
// src/classic/typed-array-utils.ts
|
|
6097
|
-
var
|
|
5911
|
+
var import_constants15 = __toESM(require_constants(), 1);
|
|
6098
5912
|
var ERR_TYPE_DEDUCTION = "Failed to deduce GL constant from typed array";
|
|
6099
5913
|
function getGLTypeFromTypedArray(arrayOrType) {
|
|
6100
5914
|
const type = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;
|
|
6101
5915
|
switch (type) {
|
|
6102
5916
|
case Float32Array:
|
|
6103
|
-
return
|
|
5917
|
+
return import_constants15.GL.FLOAT;
|
|
6104
5918
|
case Uint16Array:
|
|
6105
|
-
return
|
|
5919
|
+
return import_constants15.GL.UNSIGNED_SHORT;
|
|
6106
5920
|
case Uint32Array:
|
|
6107
|
-
return
|
|
5921
|
+
return import_constants15.GL.UNSIGNED_INT;
|
|
6108
5922
|
case Uint8Array:
|
|
6109
|
-
return
|
|
5923
|
+
return import_constants15.GL.UNSIGNED_BYTE;
|
|
6110
5924
|
case Uint8ClampedArray:
|
|
6111
|
-
return
|
|
5925
|
+
return import_constants15.GL.UNSIGNED_BYTE;
|
|
6112
5926
|
case Int8Array:
|
|
6113
|
-
return
|
|
5927
|
+
return import_constants15.GL.BYTE;
|
|
6114
5928
|
case Int16Array:
|
|
6115
|
-
return
|
|
5929
|
+
return import_constants15.GL.SHORT;
|
|
6116
5930
|
case Int32Array:
|
|
6117
|
-
return
|
|
5931
|
+
return import_constants15.GL.INT;
|
|
6118
5932
|
default:
|
|
6119
5933
|
throw new Error(ERR_TYPE_DEDUCTION);
|
|
6120
5934
|
}
|
|
@@ -6122,22 +5936,22 @@ ${source2}`;
|
|
|
6122
5936
|
function getTypedArrayFromGLType(glType, options) {
|
|
6123
5937
|
const { clamped = true } = options || {};
|
|
6124
5938
|
switch (glType) {
|
|
6125
|
-
case
|
|
5939
|
+
case import_constants15.GL.FLOAT:
|
|
6126
5940
|
return Float32Array;
|
|
6127
|
-
case
|
|
6128
|
-
case
|
|
6129
|
-
case
|
|
6130
|
-
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:
|
|
6131
5945
|
return Uint16Array;
|
|
6132
|
-
case
|
|
5946
|
+
case import_constants15.GL.UNSIGNED_INT:
|
|
6133
5947
|
return Uint32Array;
|
|
6134
|
-
case
|
|
5948
|
+
case import_constants15.GL.UNSIGNED_BYTE:
|
|
6135
5949
|
return clamped ? Uint8ClampedArray : Uint8Array;
|
|
6136
|
-
case
|
|
5950
|
+
case import_constants15.GL.BYTE:
|
|
6137
5951
|
return Int8Array;
|
|
6138
|
-
case
|
|
5952
|
+
case import_constants15.GL.SHORT:
|
|
6139
5953
|
return Int16Array;
|
|
6140
|
-
case
|
|
5954
|
+
case import_constants15.GL.INT:
|
|
6141
5955
|
return Int32Array;
|
|
6142
5956
|
default:
|
|
6143
5957
|
throw new Error("Failed to deduce typed array type from GL constant");
|
|
@@ -6148,7 +5962,7 @@ ${source2}`;
|
|
|
6148
5962
|
var DEFAULT_ACCESSOR_VALUES = {
|
|
6149
5963
|
offset: 0,
|
|
6150
5964
|
stride: 0,
|
|
6151
|
-
type:
|
|
5965
|
+
type: import_constants16.GL.FLOAT,
|
|
6152
5966
|
size: 1,
|
|
6153
5967
|
divisor: 0,
|
|
6154
5968
|
normalized: false,
|
|
@@ -6171,12 +5985,12 @@ ${source2}`;
|
|
|
6171
5985
|
buffer;
|
|
6172
5986
|
index;
|
|
6173
5987
|
static getBytesPerElement(accessor) {
|
|
6174
|
-
const ArrayType = getTypedArrayFromGLType(accessor.type ||
|
|
5988
|
+
const ArrayType = getTypedArrayFromGLType(accessor.type || import_constants16.GL.FLOAT);
|
|
6175
5989
|
return ArrayType.BYTES_PER_ELEMENT;
|
|
6176
5990
|
}
|
|
6177
5991
|
static getBytesPerVertex(accessor) {
|
|
6178
5992
|
assert2(accessor.size);
|
|
6179
|
-
const ArrayType = getTypedArrayFromGLType(accessor.type ||
|
|
5993
|
+
const ArrayType = getTypedArrayFromGLType(accessor.type || import_constants16.GL.FLOAT);
|
|
6180
5994
|
return ArrayType.BYTES_PER_ELEMENT * accessor.size;
|
|
6181
5995
|
}
|
|
6182
5996
|
// Combines (merges) a list of accessors. On top of default values
|
|
@@ -6207,7 +6021,7 @@ ${source2}`;
|
|
|
6207
6021
|
props = checkProps("Accessor", props, PROP_CHECKS);
|
|
6208
6022
|
if (props.type !== void 0) {
|
|
6209
6023
|
this.type = props.type;
|
|
6210
|
-
if (props.type ===
|
|
6024
|
+
if (props.type === import_constants16.GL.INT || props.type === import_constants16.GL.UNSIGNED_INT) {
|
|
6211
6025
|
this.integer = true;
|
|
6212
6026
|
}
|
|
6213
6027
|
}
|
|
@@ -6271,62 +6085,62 @@ ${source2}`;
|
|
|
6271
6085
|
};
|
|
6272
6086
|
|
|
6273
6087
|
// src/adapter/helpers/decode-webgl-types.ts
|
|
6274
|
-
var
|
|
6088
|
+
var import_constants17 = __toESM(require_constants(), 1);
|
|
6275
6089
|
function isSamplerUniform(type) {
|
|
6276
6090
|
return SAMPLER_TYPES.includes(type);
|
|
6277
6091
|
}
|
|
6278
6092
|
var SAMPLER_TYPES = [
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
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
|
|
6294
6108
|
];
|
|
6295
6109
|
var COMPOSITE_GL_TYPES = {
|
|
6296
|
-
[
|
|
6297
|
-
[
|
|
6298
|
-
[
|
|
6299
|
-
[
|
|
6300
|
-
[
|
|
6301
|
-
[
|
|
6302
|
-
[
|
|
6303
|
-
[
|
|
6304
|
-
[
|
|
6305
|
-
[
|
|
6306
|
-
[
|
|
6307
|
-
[
|
|
6308
|
-
[
|
|
6309
|
-
[
|
|
6310
|
-
[
|
|
6311
|
-
[
|
|
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"],
|
|
6312
6126
|
// TODO - are sizes/components below correct?
|
|
6313
|
-
[
|
|
6127
|
+
[import_constants17.GL.FLOAT_MAT2]: [import_constants17.GL.FLOAT, 8, "mat2", "mat2x2<f32>"],
|
|
6314
6128
|
// 4
|
|
6315
|
-
[
|
|
6129
|
+
[import_constants17.GL.FLOAT_MAT2x3]: [import_constants17.GL.FLOAT, 8, "mat2x3", "mat2x3<f32>"],
|
|
6316
6130
|
// 6
|
|
6317
|
-
[
|
|
6131
|
+
[import_constants17.GL.FLOAT_MAT2x4]: [import_constants17.GL.FLOAT, 8, "mat2x4", "mat2x4<f32>"],
|
|
6318
6132
|
// 8
|
|
6319
|
-
[
|
|
6133
|
+
[import_constants17.GL.FLOAT_MAT3x2]: [import_constants17.GL.FLOAT, 12, "mat3x2", "mat3x2<f32>"],
|
|
6320
6134
|
// 6
|
|
6321
|
-
[
|
|
6135
|
+
[import_constants17.GL.FLOAT_MAT3]: [import_constants17.GL.FLOAT, 12, "mat3", "mat3x3<f32>"],
|
|
6322
6136
|
// 9
|
|
6323
|
-
[
|
|
6137
|
+
[import_constants17.GL.FLOAT_MAT3x4]: [import_constants17.GL.FLOAT, 12, "mat3x4", "mat3x4<f32>"],
|
|
6324
6138
|
// 12
|
|
6325
|
-
[
|
|
6139
|
+
[import_constants17.GL.FLOAT_MAT4x2]: [import_constants17.GL.FLOAT, 16, "mat4x2", "mat4x2<f32>"],
|
|
6326
6140
|
// 8
|
|
6327
|
-
[
|
|
6141
|
+
[import_constants17.GL.FLOAT_MAT4x3]: [import_constants17.GL.FLOAT, 16, "mat4x3", "mat4x3<f32>"],
|
|
6328
6142
|
// 12
|
|
6329
|
-
[
|
|
6143
|
+
[import_constants17.GL.FLOAT_MAT4]: [import_constants17.GL.FLOAT, 16, "mat4", "mat4x4<f32>"]
|
|
6330
6144
|
// 16
|
|
6331
6145
|
};
|
|
6332
6146
|
function decodeGLUniformType(glUniformType) {
|
|
@@ -6428,7 +6242,7 @@ ${source2}`;
|
|
|
6428
6242
|
}
|
|
6429
6243
|
function readVaryings(gl, program) {
|
|
6430
6244
|
const varyings = [];
|
|
6431
|
-
const count = gl.getProgramParameter(program,
|
|
6245
|
+
const count = gl.getProgramParameter(program, import_constants18.GL.TRANSFORM_FEEDBACK_VARYINGS);
|
|
6432
6246
|
for (let location = 0; location < count; location++) {
|
|
6433
6247
|
const activeInfo = gl.getTransformFeedbackVarying(program, location);
|
|
6434
6248
|
if (!activeInfo) {
|
|
@@ -6445,7 +6259,7 @@ ${source2}`;
|
|
|
6445
6259
|
}
|
|
6446
6260
|
function readUniformBindings(gl, program) {
|
|
6447
6261
|
const uniforms = [];
|
|
6448
|
-
const uniformCount = gl.getProgramParameter(program,
|
|
6262
|
+
const uniformCount = gl.getProgramParameter(program, import_constants18.GL.ACTIVE_UNIFORMS);
|
|
6449
6263
|
for (let i = 0; i < uniformCount; i++) {
|
|
6450
6264
|
const activeInfo = gl.getActiveUniform(program, i);
|
|
6451
6265
|
if (!activeInfo) {
|
|
@@ -6481,22 +6295,22 @@ ${source2}`;
|
|
|
6481
6295
|
function readUniformBlocks(gl, program) {
|
|
6482
6296
|
const getBlockParameter = (blockIndex, pname) => gl.getActiveUniformBlockParameter(program, blockIndex, pname);
|
|
6483
6297
|
const uniformBlocks = [];
|
|
6484
|
-
const blockCount = gl.getProgramParameter(program,
|
|
6298
|
+
const blockCount = gl.getProgramParameter(program, import_constants18.GL.ACTIVE_UNIFORM_BLOCKS);
|
|
6485
6299
|
for (let blockIndex = 0; blockIndex < blockCount; blockIndex++) {
|
|
6486
6300
|
const blockInfo = {
|
|
6487
6301
|
name: gl.getActiveUniformBlockName(program, blockIndex) || "",
|
|
6488
|
-
location: getBlockParameter(blockIndex,
|
|
6489
|
-
byteLength: getBlockParameter(blockIndex,
|
|
6490
|
-
vertex: getBlockParameter(blockIndex,
|
|
6491
|
-
fragment: getBlockParameter(blockIndex,
|
|
6492
|
-
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),
|
|
6493
6307
|
uniforms: []
|
|
6494
6308
|
};
|
|
6495
|
-
const uniformIndices = getBlockParameter(blockIndex,
|
|
6496
|
-
const uniformType = gl.getActiveUniforms(program, uniformIndices,
|
|
6497
|
-
const uniformArrayLength = gl.getActiveUniforms(program, uniformIndices,
|
|
6498
|
-
const uniformOffset = gl.getActiveUniforms(program, uniformIndices,
|
|
6499
|
-
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);
|
|
6500
6314
|
for (let i = 0; i < blockInfo.uniformCount; ++i) {
|
|
6501
6315
|
const activeInfo = gl.getActiveUniform(program, uniformIndices[i]);
|
|
6502
6316
|
if (!activeInfo) {
|
|
@@ -6519,21 +6333,21 @@ ${source2}`;
|
|
|
6519
6333
|
return uniformBlocks;
|
|
6520
6334
|
}
|
|
6521
6335
|
var SAMPLER_UNIFORMS_GL_TO_GPU = {
|
|
6522
|
-
[
|
|
6523
|
-
[
|
|
6524
|
-
[
|
|
6525
|
-
[
|
|
6526
|
-
[
|
|
6527
|
-
[
|
|
6528
|
-
[
|
|
6529
|
-
[
|
|
6530
|
-
[
|
|
6531
|
-
[
|
|
6532
|
-
[
|
|
6533
|
-
[
|
|
6534
|
-
[
|
|
6535
|
-
[
|
|
6536
|
-
[
|
|
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"]
|
|
6537
6351
|
};
|
|
6538
6352
|
function getSamplerInfo(type) {
|
|
6539
6353
|
const sampler = SAMPLER_UNIFORMS_GL_TO_GPU[type];
|
|
@@ -6564,7 +6378,7 @@ ${source2}`;
|
|
|
6564
6378
|
}
|
|
6565
6379
|
|
|
6566
6380
|
// src/adapter/helpers/set-uniform.ts
|
|
6567
|
-
var
|
|
6381
|
+
var import_constants19 = __toESM(require_constants(), 1);
|
|
6568
6382
|
function setUniform(gl, location, type, value) {
|
|
6569
6383
|
const gl2 = gl;
|
|
6570
6384
|
let uniformValue = value;
|
|
@@ -6576,97 +6390,97 @@ ${source2}`;
|
|
|
6576
6390
|
}
|
|
6577
6391
|
const arrayValue = typeof uniformValue === "number" ? [uniformValue] : uniformValue;
|
|
6578
6392
|
switch (type) {
|
|
6579
|
-
case
|
|
6580
|
-
case
|
|
6581
|
-
case
|
|
6582
|
-
case
|
|
6583
|
-
case
|
|
6584
|
-
case
|
|
6585
|
-
case
|
|
6586
|
-
case
|
|
6587
|
-
case
|
|
6588
|
-
case
|
|
6589
|
-
case
|
|
6590
|
-
case
|
|
6591
|
-
case
|
|
6592
|
-
case
|
|
6593
|
-
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:
|
|
6594
6408
|
if (typeof value !== "number") {
|
|
6595
6409
|
throw new Error("samplers must be set to integers");
|
|
6596
6410
|
}
|
|
6597
6411
|
return gl.uniform1i(location, value);
|
|
6598
|
-
case
|
|
6412
|
+
case import_constants19.GL.FLOAT:
|
|
6599
6413
|
return gl.uniform1fv(location, arrayValue);
|
|
6600
|
-
case
|
|
6414
|
+
case import_constants19.GL.FLOAT_VEC2:
|
|
6601
6415
|
return gl.uniform2fv(location, arrayValue);
|
|
6602
|
-
case
|
|
6416
|
+
case import_constants19.GL.FLOAT_VEC3:
|
|
6603
6417
|
return gl.uniform3fv(location, arrayValue);
|
|
6604
|
-
case
|
|
6418
|
+
case import_constants19.GL.FLOAT_VEC4:
|
|
6605
6419
|
return gl.uniform4fv(location, arrayValue);
|
|
6606
|
-
case
|
|
6420
|
+
case import_constants19.GL.INT:
|
|
6607
6421
|
return gl.uniform1iv(location, arrayValue);
|
|
6608
|
-
case
|
|
6422
|
+
case import_constants19.GL.INT_VEC2:
|
|
6609
6423
|
return gl.uniform2iv(location, arrayValue);
|
|
6610
|
-
case
|
|
6424
|
+
case import_constants19.GL.INT_VEC3:
|
|
6611
6425
|
return gl.uniform3iv(location, arrayValue);
|
|
6612
|
-
case
|
|
6426
|
+
case import_constants19.GL.INT_VEC4:
|
|
6613
6427
|
return gl.uniform4iv(location, arrayValue);
|
|
6614
|
-
case
|
|
6428
|
+
case import_constants19.GL.BOOL:
|
|
6615
6429
|
return gl.uniform1iv(location, arrayValue);
|
|
6616
|
-
case
|
|
6430
|
+
case import_constants19.GL.BOOL_VEC2:
|
|
6617
6431
|
return gl.uniform2iv(location, arrayValue);
|
|
6618
|
-
case
|
|
6432
|
+
case import_constants19.GL.BOOL_VEC3:
|
|
6619
6433
|
return gl.uniform3iv(location, arrayValue);
|
|
6620
|
-
case
|
|
6434
|
+
case import_constants19.GL.BOOL_VEC4:
|
|
6621
6435
|
return gl.uniform4iv(location, arrayValue);
|
|
6622
|
-
case
|
|
6436
|
+
case import_constants19.GL.UNSIGNED_INT:
|
|
6623
6437
|
return gl2.uniform1uiv(location, arrayValue, 1);
|
|
6624
|
-
case
|
|
6438
|
+
case import_constants19.GL.UNSIGNED_INT_VEC2:
|
|
6625
6439
|
return gl2.uniform2uiv(location, arrayValue, 2);
|
|
6626
|
-
case
|
|
6440
|
+
case import_constants19.GL.UNSIGNED_INT_VEC3:
|
|
6627
6441
|
return gl2.uniform3uiv(location, arrayValue, 3);
|
|
6628
|
-
case
|
|
6442
|
+
case import_constants19.GL.UNSIGNED_INT_VEC4:
|
|
6629
6443
|
return gl2.uniform4uiv(location, arrayValue, 4);
|
|
6630
|
-
case
|
|
6444
|
+
case import_constants19.GL.FLOAT_MAT2:
|
|
6631
6445
|
return gl.uniformMatrix2fv(location, false, arrayValue);
|
|
6632
|
-
case
|
|
6446
|
+
case import_constants19.GL.FLOAT_MAT3:
|
|
6633
6447
|
return gl.uniformMatrix3fv(location, false, arrayValue);
|
|
6634
|
-
case
|
|
6448
|
+
case import_constants19.GL.FLOAT_MAT4:
|
|
6635
6449
|
return gl.uniformMatrix4fv(location, false, arrayValue);
|
|
6636
|
-
case
|
|
6450
|
+
case import_constants19.GL.FLOAT_MAT2x3:
|
|
6637
6451
|
return gl2.uniformMatrix2x3fv(location, false, arrayValue);
|
|
6638
|
-
case
|
|
6452
|
+
case import_constants19.GL.FLOAT_MAT2x4:
|
|
6639
6453
|
return gl2.uniformMatrix2x4fv(location, false, arrayValue);
|
|
6640
|
-
case
|
|
6454
|
+
case import_constants19.GL.FLOAT_MAT3x2:
|
|
6641
6455
|
return gl2.uniformMatrix3x2fv(location, false, arrayValue);
|
|
6642
|
-
case
|
|
6456
|
+
case import_constants19.GL.FLOAT_MAT3x4:
|
|
6643
6457
|
return gl2.uniformMatrix3x4fv(location, false, arrayValue);
|
|
6644
|
-
case
|
|
6458
|
+
case import_constants19.GL.FLOAT_MAT4x2:
|
|
6645
6459
|
return gl2.uniformMatrix4x2fv(location, false, arrayValue);
|
|
6646
|
-
case
|
|
6460
|
+
case import_constants19.GL.FLOAT_MAT4x3:
|
|
6647
6461
|
return gl2.uniformMatrix4x3fv(location, false, arrayValue);
|
|
6648
6462
|
}
|
|
6649
6463
|
throw new Error("Illegal uniform");
|
|
6650
6464
|
}
|
|
6651
6465
|
|
|
6652
6466
|
// src/adapter/helpers/webgl-topology-utils.ts
|
|
6653
|
-
var
|
|
6467
|
+
var import_constants20 = __toESM(require_constants(), 1);
|
|
6654
6468
|
function getGLDrawMode(topology) {
|
|
6655
6469
|
switch (topology) {
|
|
6656
6470
|
case "point-list":
|
|
6657
|
-
return
|
|
6471
|
+
return import_constants20.GL.POINTS;
|
|
6658
6472
|
case "line-list":
|
|
6659
|
-
return
|
|
6473
|
+
return import_constants20.GL.LINES;
|
|
6660
6474
|
case "line-strip":
|
|
6661
|
-
return
|
|
6475
|
+
return import_constants20.GL.LINE_STRIP;
|
|
6662
6476
|
case "line-loop-webgl":
|
|
6663
|
-
return
|
|
6477
|
+
return import_constants20.GL.LINE_LOOP;
|
|
6664
6478
|
case "triangle-list":
|
|
6665
|
-
return
|
|
6479
|
+
return import_constants20.GL.TRIANGLES;
|
|
6666
6480
|
case "triangle-strip":
|
|
6667
|
-
return
|
|
6481
|
+
return import_constants20.GL.TRIANGLE_STRIP;
|
|
6668
6482
|
case "triangle-fan-webgl":
|
|
6669
|
-
return
|
|
6483
|
+
return import_constants20.GL.TRIANGLE_FAN;
|
|
6670
6484
|
default:
|
|
6671
6485
|
throw new Error(topology);
|
|
6672
6486
|
}
|
|
@@ -6674,19 +6488,19 @@ ${source2}`;
|
|
|
6674
6488
|
function getGLPrimitive(topology) {
|
|
6675
6489
|
switch (topology) {
|
|
6676
6490
|
case "point-list":
|
|
6677
|
-
return
|
|
6491
|
+
return import_constants20.GL.POINTS;
|
|
6678
6492
|
case "line-list":
|
|
6679
|
-
return
|
|
6493
|
+
return import_constants20.GL.LINES;
|
|
6680
6494
|
case "line-strip":
|
|
6681
|
-
return
|
|
6495
|
+
return import_constants20.GL.LINES;
|
|
6682
6496
|
case "line-loop-webgl":
|
|
6683
|
-
return
|
|
6497
|
+
return import_constants20.GL.LINES;
|
|
6684
6498
|
case "triangle-list":
|
|
6685
|
-
return
|
|
6499
|
+
return import_constants20.GL.TRIANGLES;
|
|
6686
6500
|
case "triangle-strip":
|
|
6687
|
-
return
|
|
6501
|
+
return import_constants20.GL.TRIANGLES;
|
|
6688
6502
|
case "triangle-fan-webgl":
|
|
6689
|
-
return
|
|
6503
|
+
return import_constants20.GL.TRIANGLES;
|
|
6690
6504
|
default:
|
|
6691
6505
|
throw new Error(topology);
|
|
6692
6506
|
}
|
|
@@ -6721,7 +6535,7 @@ ${source2}`;
|
|
|
6721
6535
|
this.device.setSpectorMetadata(this.handle, { id: this.props.id });
|
|
6722
6536
|
this.vs = cast(props.vs);
|
|
6723
6537
|
this.fs = cast(props.fs);
|
|
6724
|
-
const { varyings, bufferMode =
|
|
6538
|
+
const { varyings, bufferMode = import_constants21.GL.SEPARATE_ATTRIBS } = props;
|
|
6725
6539
|
if (varyings && varyings.length > 0) {
|
|
6726
6540
|
this.varyings = varyings;
|
|
6727
6541
|
this.device.gl.transformFeedbackVaryings(this.handle, varyings, bufferMode);
|
|
@@ -6789,9 +6603,6 @@ ${source2}`;
|
|
|
6789
6603
|
* This function unifies those ways into a single call using common parameters with sane defaults
|
|
6790
6604
|
*/
|
|
6791
6605
|
draw(options) {
|
|
6792
|
-
if (this.linkStatus !== "success") {
|
|
6793
|
-
return false;
|
|
6794
|
-
}
|
|
6795
6606
|
const {
|
|
6796
6607
|
renderPass,
|
|
6797
6608
|
vertexArray,
|
|
@@ -6808,9 +6619,18 @@ ${source2}`;
|
|
|
6808
6619
|
const isIndexed = Boolean(vertexArray.indexBuffer);
|
|
6809
6620
|
const glIndexType = vertexArray.indexBuffer?.glIndexType;
|
|
6810
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
|
+
}
|
|
6811
6626
|
if (!this._areTexturesRenderable() || vertexCount === 0) {
|
|
6627
|
+
log.info(2, `RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)();
|
|
6812
6628
|
return false;
|
|
6813
6629
|
}
|
|
6630
|
+
if (vertexCount === 0) {
|
|
6631
|
+
log.info(2, `RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)();
|
|
6632
|
+
return true;
|
|
6633
|
+
}
|
|
6814
6634
|
this.device.gl.useProgram(this.handle);
|
|
6815
6635
|
vertexArray.bindBeforeRender(renderPass);
|
|
6816
6636
|
if (transformFeedback) {
|
|
@@ -6936,7 +6756,7 @@ ${source2}`;
|
|
|
6936
6756
|
}
|
|
6937
6757
|
const { gl } = this.device;
|
|
6938
6758
|
for (; ; ) {
|
|
6939
|
-
const complete = gl.getProgramParameter(this.handle,
|
|
6759
|
+
const complete = gl.getProgramParameter(this.handle, import_constants21.GL.COMPLETION_STATUS_KHR);
|
|
6940
6760
|
if (complete) {
|
|
6941
6761
|
return;
|
|
6942
6762
|
}
|
|
@@ -6976,15 +6796,15 @@ ${source2}`;
|
|
|
6976
6796
|
case "uniform":
|
|
6977
6797
|
const { name: name2 } = binding;
|
|
6978
6798
|
const location = gl.getUniformBlockIndex(this.handle, name2);
|
|
6979
|
-
if (location ===
|
|
6799
|
+
if (location === import_constants21.GL.INVALID_INDEX) {
|
|
6980
6800
|
throw new Error(`Invalid uniform block name ${name2}`);
|
|
6981
6801
|
}
|
|
6982
6802
|
gl.uniformBlockBinding(this.handle, uniformBufferIndex, location);
|
|
6983
6803
|
if (value instanceof WEBGLBuffer) {
|
|
6984
|
-
gl.bindBufferBase(
|
|
6804
|
+
gl.bindBufferBase(import_constants21.GL.UNIFORM_BUFFER, uniformBufferIndex, value.handle);
|
|
6985
6805
|
} else {
|
|
6986
6806
|
gl.bindBufferRange(
|
|
6987
|
-
|
|
6807
|
+
import_constants21.GL.UNIFORM_BUFFER,
|
|
6988
6808
|
uniformBufferIndex,
|
|
6989
6809
|
// @ts-expect-error
|
|
6990
6810
|
value.buffer.handle,
|
|
@@ -7013,7 +6833,7 @@ ${source2}`;
|
|
|
7013
6833
|
} else {
|
|
7014
6834
|
throw new Error("No texture");
|
|
7015
6835
|
}
|
|
7016
|
-
gl.activeTexture(
|
|
6836
|
+
gl.activeTexture(import_constants21.GL.TEXTURE0 + textureUnit);
|
|
7017
6837
|
gl.bindTexture(texture.target, texture.handle);
|
|
7018
6838
|
textureUnit += 1;
|
|
7019
6839
|
break;
|
|
@@ -7041,7 +6861,7 @@ ${source2}`;
|
|
|
7041
6861
|
};
|
|
7042
6862
|
|
|
7043
6863
|
// src/adapter/resources/webgl-command-buffer.ts
|
|
7044
|
-
var
|
|
6864
|
+
var import_constants22 = __toESM(require_constants(), 1);
|
|
7045
6865
|
function cast2(value) {
|
|
7046
6866
|
return value;
|
|
7047
6867
|
}
|
|
@@ -7074,17 +6894,17 @@ ${source2}`;
|
|
|
7074
6894
|
function _copyBufferToBuffer(device, options) {
|
|
7075
6895
|
const source = cast2(options.source);
|
|
7076
6896
|
const destination = cast2(options.destination);
|
|
7077
|
-
device.gl.bindBuffer(
|
|
7078
|
-
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);
|
|
7079
6899
|
device.gl.copyBufferSubData(
|
|
7080
|
-
|
|
7081
|
-
|
|
6900
|
+
import_constants22.GL.COPY_READ_BUFFER,
|
|
6901
|
+
import_constants22.GL.COPY_WRITE_BUFFER,
|
|
7082
6902
|
options.sourceOffset ?? 0,
|
|
7083
6903
|
options.destinationOffset ?? 0,
|
|
7084
6904
|
options.size
|
|
7085
6905
|
);
|
|
7086
|
-
device.gl.bindBuffer(
|
|
7087
|
-
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);
|
|
7088
6908
|
}
|
|
7089
6909
|
function _copyBufferToTexture(device, options) {
|
|
7090
6910
|
throw new Error("Not implemented");
|
|
@@ -7134,8 +6954,8 @@ ${source2}`;
|
|
|
7134
6954
|
const sourceParams = getWebGLTextureParameters(framebuffer.texture.props.format);
|
|
7135
6955
|
const sourceFormat = sourceParams.dataFormat;
|
|
7136
6956
|
const sourceType = sourceParams.type;
|
|
7137
|
-
device.gl.bindBuffer(
|
|
7138
|
-
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);
|
|
7139
6959
|
device.gl.readPixels(
|
|
7140
6960
|
origin[0],
|
|
7141
6961
|
origin[1],
|
|
@@ -7146,8 +6966,8 @@ ${source2}`;
|
|
|
7146
6966
|
byteOffset
|
|
7147
6967
|
);
|
|
7148
6968
|
} finally {
|
|
7149
|
-
device.gl.bindBuffer(
|
|
7150
|
-
device.gl.bindFramebuffer(
|
|
6969
|
+
device.gl.bindBuffer(import_constants22.GL.PIXEL_PACK_BUFFER, null);
|
|
6970
|
+
device.gl.bindFramebuffer(import_constants22.GL.FRAMEBUFFER, null);
|
|
7151
6971
|
if (destroyFramebuffer) {
|
|
7152
6972
|
framebuffer.destroy();
|
|
7153
6973
|
}
|
|
@@ -7178,11 +6998,11 @@ ${source2}`;
|
|
|
7178
6998
|
// depthOrArrayLayers = 0
|
|
7179
6999
|
} = options;
|
|
7180
7000
|
const destinationMipmaplevel = 0;
|
|
7181
|
-
const destinationInternalFormat =
|
|
7001
|
+
const destinationInternalFormat = import_constants22.GL.RGBA;
|
|
7182
7002
|
const { framebuffer, destroyFramebuffer } = getFramebuffer(source);
|
|
7183
7003
|
const [sourceX, sourceY] = origin;
|
|
7184
7004
|
const isSubCopy = false;
|
|
7185
|
-
device.gl.bindFramebuffer(
|
|
7005
|
+
device.gl.bindFramebuffer(import_constants22.GL.FRAMEBUFFER, framebuffer.handle);
|
|
7186
7006
|
let texture = null;
|
|
7187
7007
|
let textureTarget;
|
|
7188
7008
|
if (destination instanceof WEBGLTexture) {
|
|
@@ -7270,7 +7090,7 @@ ${source2}`;
|
|
|
7270
7090
|
};
|
|
7271
7091
|
|
|
7272
7092
|
// src/adapter/resources/webgl-vertex-array.ts
|
|
7273
|
-
var
|
|
7093
|
+
var import_constants23 = __toESM(require_constants(), 1);
|
|
7274
7094
|
var WEBGLVertexArray = class extends VertexArray {
|
|
7275
7095
|
get [Symbol.toStringTag]() {
|
|
7276
7096
|
return "VertexArray";
|
|
@@ -7308,22 +7128,22 @@ ${source2}`;
|
|
|
7308
7128
|
*/
|
|
7309
7129
|
setIndexBuffer(indexBuffer) {
|
|
7310
7130
|
const buffer = indexBuffer;
|
|
7311
|
-
if (buffer && buffer.glTarget !==
|
|
7131
|
+
if (buffer && buffer.glTarget !== import_constants23.GL.ELEMENT_ARRAY_BUFFER) {
|
|
7312
7132
|
throw new Error("Use .setBuffer()");
|
|
7313
7133
|
}
|
|
7314
7134
|
this.device.gl.bindVertexArray(this.handle);
|
|
7315
|
-
this.device.gl.bindBuffer(
|
|
7135
|
+
this.device.gl.bindBuffer(import_constants23.GL.ELEMENT_ARRAY_BUFFER, buffer ? buffer.handle : null);
|
|
7316
7136
|
this.indexBuffer = buffer;
|
|
7317
7137
|
}
|
|
7318
7138
|
/** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */
|
|
7319
7139
|
setBuffer(location, attributeBuffer) {
|
|
7320
7140
|
const buffer = attributeBuffer;
|
|
7321
|
-
if (buffer.glTarget ===
|
|
7141
|
+
if (buffer.glTarget === import_constants23.GL.ELEMENT_ARRAY_BUFFER) {
|
|
7322
7142
|
throw new Error("Use .setIndexBuffer()");
|
|
7323
7143
|
}
|
|
7324
7144
|
const { size, type, stride, offset, normalized, integer, divisor } = this._getAccessor(location);
|
|
7325
7145
|
this.device.gl.bindVertexArray(this.handle);
|
|
7326
|
-
this.device.gl.bindBuffer(
|
|
7146
|
+
this.device.gl.bindBuffer(import_constants23.GL.ARRAY_BUFFER, buffer.handle);
|
|
7327
7147
|
if (integer) {
|
|
7328
7148
|
this.device.gl.vertexAttribIPointer(location, size, type, stride, offset);
|
|
7329
7149
|
} else {
|
|
@@ -7343,7 +7163,7 @@ ${source2}`;
|
|
|
7343
7163
|
this.device.gl.bindVertexArray(this.handle);
|
|
7344
7164
|
if (!this.init) {
|
|
7345
7165
|
const webglBuffer = this.indexBuffer;
|
|
7346
|
-
this.device.gl.bindBuffer(
|
|
7166
|
+
this.device.gl.bindBuffer(import_constants23.GL.ELEMENT_ARRAY_BUFFER, webglBuffer?.handle || null);
|
|
7347
7167
|
this.init = true;
|
|
7348
7168
|
}
|
|
7349
7169
|
this._applyConstantAttributes();
|
|
@@ -7469,7 +7289,7 @@ ${source2}`;
|
|
|
7469
7289
|
}
|
|
7470
7290
|
|
|
7471
7291
|
// src/adapter/resources/webgl-transform-feedback.ts
|
|
7472
|
-
var
|
|
7292
|
+
var import_constants24 = __toESM(require_constants(), 1);
|
|
7473
7293
|
var WEBGLTransformFeedback = class extends TransformFeedback {
|
|
7474
7294
|
device;
|
|
7475
7295
|
gl;
|
|
@@ -7505,7 +7325,7 @@ ${source2}`;
|
|
|
7505
7325
|
super.destroy();
|
|
7506
7326
|
}
|
|
7507
7327
|
begin(topology = "point-list") {
|
|
7508
|
-
this.gl.bindTransformFeedback(
|
|
7328
|
+
this.gl.bindTransformFeedback(import_constants24.GL.TRANSFORM_FEEDBACK, this.handle);
|
|
7509
7329
|
if (this.bindOnUse) {
|
|
7510
7330
|
this._bindBuffers();
|
|
7511
7331
|
}
|
|
@@ -7516,7 +7336,7 @@ ${source2}`;
|
|
|
7516
7336
|
if (!this.bindOnUse) {
|
|
7517
7337
|
this._unbindBuffers();
|
|
7518
7338
|
}
|
|
7519
|
-
this.gl.bindTransformFeedback(
|
|
7339
|
+
this.gl.bindTransformFeedback(import_constants24.GL.TRANSFORM_FEEDBACK, null);
|
|
7520
7340
|
}
|
|
7521
7341
|
// SUBCLASS
|
|
7522
7342
|
setBuffers(buffers) {
|
|
@@ -7550,16 +7370,16 @@ ${source2}`;
|
|
|
7550
7370
|
}
|
|
7551
7371
|
bind(funcOrHandle = this.handle) {
|
|
7552
7372
|
if (typeof funcOrHandle !== "function") {
|
|
7553
|
-
this.gl.bindTransformFeedback(
|
|
7373
|
+
this.gl.bindTransformFeedback(import_constants24.GL.TRANSFORM_FEEDBACK, funcOrHandle);
|
|
7554
7374
|
return this;
|
|
7555
7375
|
}
|
|
7556
7376
|
let value;
|
|
7557
7377
|
if (!this._bound) {
|
|
7558
|
-
this.gl.bindTransformFeedback(
|
|
7378
|
+
this.gl.bindTransformFeedback(import_constants24.GL.TRANSFORM_FEEDBACK, this.handle);
|
|
7559
7379
|
this._bound = true;
|
|
7560
7380
|
value = funcOrHandle();
|
|
7561
7381
|
this._bound = false;
|
|
7562
|
-
this.gl.bindTransformFeedback(
|
|
7382
|
+
this.gl.bindTransformFeedback(import_constants24.GL.TRANSFORM_FEEDBACK, null);
|
|
7563
7383
|
} else {
|
|
7564
7384
|
value = funcOrHandle();
|
|
7565
7385
|
}
|
|
@@ -7600,15 +7420,15 @@ ${source2}`;
|
|
|
7600
7420
|
}
|
|
7601
7421
|
_unbindBuffers() {
|
|
7602
7422
|
for (const bufferIndex in this.buffers) {
|
|
7603
|
-
this.gl.bindBufferBase(
|
|
7423
|
+
this.gl.bindBufferBase(import_constants24.GL.TRANSFORM_FEEDBACK_BUFFER, Number(bufferIndex), null);
|
|
7604
7424
|
}
|
|
7605
7425
|
}
|
|
7606
7426
|
_bindBuffer(index, buffer, byteOffset = 0, byteLength) {
|
|
7607
7427
|
const handle = buffer && buffer.handle;
|
|
7608
7428
|
if (!handle || byteLength === void 0) {
|
|
7609
|
-
this.gl.bindBufferBase(
|
|
7429
|
+
this.gl.bindBufferBase(import_constants24.GL.TRANSFORM_FEEDBACK_BUFFER, index, handle);
|
|
7610
7430
|
} else {
|
|
7611
|
-
this.gl.bindBufferRange(
|
|
7431
|
+
this.gl.bindBufferRange(import_constants24.GL.TRANSFORM_FEEDBACK_BUFFER, index, handle, byteOffset, byteLength);
|
|
7612
7432
|
}
|
|
7613
7433
|
}
|
|
7614
7434
|
};
|
|
@@ -7620,7 +7440,7 @@ ${source2}`;
|
|
|
7620
7440
|
}
|
|
7621
7441
|
|
|
7622
7442
|
// src/adapter/resources/webgl-query-set.ts
|
|
7623
|
-
var
|
|
7443
|
+
var import_constants25 = __toESM(require_constants(), 1);
|
|
7624
7444
|
var WEBGLQuerySet = class extends QuerySet {
|
|
7625
7445
|
device;
|
|
7626
7446
|
handle;
|
|
@@ -7650,7 +7470,7 @@ ${source2}`;
|
|
|
7650
7470
|
* GPU instruction stream.
|
|
7651
7471
|
*/
|
|
7652
7472
|
beginTimestampQuery() {
|
|
7653
|
-
return this._begin(
|
|
7473
|
+
return this._begin(import_constants25.GL.TIME_ELAPSED_EXT);
|
|
7654
7474
|
}
|
|
7655
7475
|
endTimestampQuery() {
|
|
7656
7476
|
this._end();
|
|
@@ -7658,7 +7478,7 @@ ${source2}`;
|
|
|
7658
7478
|
// Shortcut for occlusion queries
|
|
7659
7479
|
beginOcclusionQuery(options) {
|
|
7660
7480
|
return this._begin(
|
|
7661
|
-
options?.conservative ?
|
|
7481
|
+
options?.conservative ? import_constants25.GL.ANY_SAMPLES_PASSED_CONSERVATIVE : import_constants25.GL.ANY_SAMPLES_PASSED
|
|
7662
7482
|
);
|
|
7663
7483
|
}
|
|
7664
7484
|
endOcclusionQuery() {
|
|
@@ -7666,7 +7486,7 @@ ${source2}`;
|
|
|
7666
7486
|
}
|
|
7667
7487
|
// Shortcut for transformFeedbackQuery
|
|
7668
7488
|
beginTransformFeedbackQuery() {
|
|
7669
|
-
return this._begin(
|
|
7489
|
+
return this._begin(import_constants25.GL.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
|
|
7670
7490
|
}
|
|
7671
7491
|
endTransformFeedbackQuery() {
|
|
7672
7492
|
this._end();
|
|
@@ -7710,7 +7530,7 @@ ${source2}`;
|
|
|
7710
7530
|
}
|
|
7711
7531
|
const resultAvailable = this.device.gl.getQueryParameter(
|
|
7712
7532
|
this.handle,
|
|
7713
|
-
|
|
7533
|
+
import_constants25.GL.QUERY_RESULT_AVAILABLE
|
|
7714
7534
|
);
|
|
7715
7535
|
if (resultAvailable) {
|
|
7716
7536
|
this._queryPending = false;
|
|
@@ -7719,11 +7539,11 @@ ${source2}`;
|
|
|
7719
7539
|
}
|
|
7720
7540
|
// Timing query is disjoint, i.e. results are invalid
|
|
7721
7541
|
isTimerDisjoint() {
|
|
7722
|
-
return this.device.gl.getParameter(
|
|
7542
|
+
return this.device.gl.getParameter(import_constants25.GL.GPU_DISJOINT_EXT);
|
|
7723
7543
|
}
|
|
7724
7544
|
// Returns query result.
|
|
7725
7545
|
getResult() {
|
|
7726
|
-
return this.device.gl.getQueryParameter(this.handle,
|
|
7546
|
+
return this.device.gl.getQueryParameter(this.handle, import_constants25.GL.QUERY_RESULT);
|
|
7727
7547
|
}
|
|
7728
7548
|
// Returns the query result, converted to milliseconds to match JavaScript conventions.
|
|
7729
7549
|
getTimerMilliseconds() {
|
|
@@ -7754,24 +7574,24 @@ ${source2}`;
|
|
|
7754
7574
|
};
|
|
7755
7575
|
|
|
7756
7576
|
// src/classic/copy-and-blit.ts
|
|
7757
|
-
var
|
|
7577
|
+
var import_constants27 = __toESM(require_constants(), 1);
|
|
7758
7578
|
|
|
7759
7579
|
// src/classic/format-utils.ts
|
|
7760
|
-
var
|
|
7580
|
+
var import_constants26 = __toESM(require_constants(), 1);
|
|
7761
7581
|
function glFormatToComponents(format) {
|
|
7762
7582
|
switch (format) {
|
|
7763
|
-
case
|
|
7764
|
-
case
|
|
7765
|
-
case
|
|
7583
|
+
case import_constants26.GL.ALPHA:
|
|
7584
|
+
case import_constants26.GL.R32F:
|
|
7585
|
+
case import_constants26.GL.RED:
|
|
7766
7586
|
return 1;
|
|
7767
|
-
case
|
|
7768
|
-
case
|
|
7587
|
+
case import_constants26.GL.RG32F:
|
|
7588
|
+
case import_constants26.GL.RG:
|
|
7769
7589
|
return 2;
|
|
7770
|
-
case
|
|
7771
|
-
case
|
|
7590
|
+
case import_constants26.GL.RGB:
|
|
7591
|
+
case import_constants26.GL.RGB32F:
|
|
7772
7592
|
return 3;
|
|
7773
|
-
case
|
|
7774
|
-
case
|
|
7593
|
+
case import_constants26.GL.RGBA:
|
|
7594
|
+
case import_constants26.GL.RGBA32F:
|
|
7775
7595
|
return 4;
|
|
7776
7596
|
default:
|
|
7777
7597
|
assert2(false);
|
|
@@ -7780,13 +7600,13 @@ ${source2}`;
|
|
|
7780
7600
|
}
|
|
7781
7601
|
function glTypeToBytes(type) {
|
|
7782
7602
|
switch (type) {
|
|
7783
|
-
case
|
|
7603
|
+
case import_constants26.GL.UNSIGNED_BYTE:
|
|
7784
7604
|
return 1;
|
|
7785
|
-
case
|
|
7786
|
-
case
|
|
7787
|
-
case
|
|
7605
|
+
case import_constants26.GL.UNSIGNED_SHORT_5_6_5:
|
|
7606
|
+
case import_constants26.GL.UNSIGNED_SHORT_4_4_4_4:
|
|
7607
|
+
case import_constants26.GL.UNSIGNED_SHORT_5_5_5_1:
|
|
7788
7608
|
return 2;
|
|
7789
|
-
case
|
|
7609
|
+
case import_constants26.GL.FLOAT:
|
|
7790
7610
|
return 4;
|
|
7791
7611
|
default:
|
|
7792
7612
|
assert2(false);
|
|
@@ -7799,8 +7619,8 @@ ${source2}`;
|
|
|
7799
7619
|
const {
|
|
7800
7620
|
sourceX = 0,
|
|
7801
7621
|
sourceY = 0,
|
|
7802
|
-
sourceFormat =
|
|
7803
|
-
sourceAttachment =
|
|
7622
|
+
sourceFormat = import_constants27.GL.RGBA,
|
|
7623
|
+
sourceAttachment = import_constants27.GL.COLOR_ATTACHMENT0
|
|
7804
7624
|
// TODO - support gl.readBuffer
|
|
7805
7625
|
} = options || {};
|
|
7806
7626
|
let {
|
|
@@ -7815,13 +7635,13 @@ ${source2}`;
|
|
|
7815
7635
|
const { gl, handle } = framebuffer;
|
|
7816
7636
|
sourceWidth = sourceWidth || framebuffer.width;
|
|
7817
7637
|
sourceHeight = sourceHeight || framebuffer.height;
|
|
7818
|
-
const attachment = sourceAttachment -
|
|
7819
|
-
sourceType = sourceType || framebuffer.colorAttachments[attachment]?.texture?.type ||
|
|
7638
|
+
const attachment = sourceAttachment - import_constants27.GL.COLOR_ATTACHMENT0;
|
|
7639
|
+
sourceType = sourceType || framebuffer.colorAttachments[attachment]?.texture?.type || import_constants27.GL.UNSIGNED_BYTE;
|
|
7820
7640
|
target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight);
|
|
7821
7641
|
sourceType = sourceType || getGLTypeFromTypedArray(target);
|
|
7822
|
-
const prevHandle = gl.bindFramebuffer(
|
|
7642
|
+
const prevHandle = gl.bindFramebuffer(import_constants27.GL.FRAMEBUFFER, handle);
|
|
7823
7643
|
gl.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);
|
|
7824
|
-
gl.bindFramebuffer(
|
|
7644
|
+
gl.bindFramebuffer(import_constants27.GL.FRAMEBUFFER, prevHandle || null);
|
|
7825
7645
|
if (deleteFramebuffer) {
|
|
7826
7646
|
framebuffer.destroy();
|
|
7827
7647
|
}
|
|
@@ -7832,7 +7652,7 @@ ${source2}`;
|
|
|
7832
7652
|
target,
|
|
7833
7653
|
sourceX = 0,
|
|
7834
7654
|
sourceY = 0,
|
|
7835
|
-
sourceFormat =
|
|
7655
|
+
sourceFormat = import_constants27.GL.RGBA,
|
|
7836
7656
|
targetByteOffset = 0
|
|
7837
7657
|
} = options || {};
|
|
7838
7658
|
let { sourceWidth, sourceHeight, sourceType } = options || {};
|
|
@@ -7841,7 +7661,7 @@ ${source2}`;
|
|
|
7841
7661
|
sourceWidth = sourceWidth || framebuffer.width;
|
|
7842
7662
|
sourceHeight = sourceHeight || framebuffer.height;
|
|
7843
7663
|
const webglFramebuffer = framebuffer;
|
|
7844
|
-
sourceType = sourceType ||
|
|
7664
|
+
sourceType = sourceType || import_constants27.GL.UNSIGNED_BYTE;
|
|
7845
7665
|
let webglBufferTarget = target;
|
|
7846
7666
|
if (!webglBufferTarget) {
|
|
7847
7667
|
const components = glFormatToComponents(sourceFormat);
|
|
@@ -7885,7 +7705,7 @@ ${source2}`;
|
|
|
7885
7705
|
if (pixelArray) {
|
|
7886
7706
|
return pixelArray;
|
|
7887
7707
|
}
|
|
7888
|
-
type = type ||
|
|
7708
|
+
type = type || import_constants27.GL.UNSIGNED_BYTE;
|
|
7889
7709
|
const ArrayType = getTypedArrayFromGLType(type, { clamped: false });
|
|
7890
7710
|
const components = glFormatToComponents(format);
|
|
7891
7711
|
return new ArrayType(width * height * components);
|
|
@@ -7922,8 +7742,8 @@ ${source2}`;
|
|
|
7922
7742
|
}
|
|
7923
7743
|
}
|
|
7924
7744
|
assert2(clearFlags !== 0, ERR_ARGUMENTS);
|
|
7925
|
-
|
|
7926
|
-
|
|
7745
|
+
const gl = device.gl;
|
|
7746
|
+
withGLParameters(gl, parameters, () => {
|
|
7927
7747
|
gl.clear(clearFlags);
|
|
7928
7748
|
});
|
|
7929
7749
|
}
|
|
@@ -7931,9 +7751,8 @@ ${source2}`;
|
|
|
7931
7751
|
// src/adapter/webgl-device.ts
|
|
7932
7752
|
var LOG_LEVEL2 = 1;
|
|
7933
7753
|
var _WebGLDevice = class extends Device {
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
}
|
|
7754
|
+
/** type of this device */
|
|
7755
|
+
type = "webgl";
|
|
7937
7756
|
/** The underlying WebGL context */
|
|
7938
7757
|
handle;
|
|
7939
7758
|
features;
|
|
@@ -7945,6 +7764,10 @@ ${source2}`;
|
|
|
7945
7764
|
//
|
|
7946
7765
|
// Static methods, expected to be present by `luma.createDevice()`
|
|
7947
7766
|
//
|
|
7767
|
+
/** Check if WebGL 2 is available */
|
|
7768
|
+
static isSupported() {
|
|
7769
|
+
return typeof WebGL2RenderingContext !== "undefined";
|
|
7770
|
+
}
|
|
7948
7771
|
/**
|
|
7949
7772
|
* Get a device instance from a GL context
|
|
7950
7773
|
* Creates and instruments the device if not already created
|
|
@@ -7975,13 +7798,19 @@ ${source2}`;
|
|
|
7975
7798
|
if (typeof props.canvas === "string") {
|
|
7976
7799
|
promises.push(CanvasContext.pageLoaded);
|
|
7977
7800
|
}
|
|
7978
|
-
await Promise.
|
|
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
|
+
}
|
|
7806
|
+
}
|
|
7979
7807
|
log.probe(LOG_LEVEL2 + 1, "DOM is loaded")();
|
|
7980
7808
|
if (props.gl?.device) {
|
|
7809
|
+
log.warn("reattaching existing device")();
|
|
7981
7810
|
return _WebGLDevice.attach(props.gl);
|
|
7982
7811
|
}
|
|
7983
7812
|
const device = new _WebGLDevice(props);
|
|
7984
|
-
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}`;
|
|
7985
7814
|
log.probe(LOG_LEVEL2, message2)();
|
|
7986
7815
|
log.table(LOG_LEVEL2, device.info)();
|
|
7987
7816
|
log.groupEnd(LOG_LEVEL2)();
|
|
@@ -8017,8 +7846,11 @@ ${source2}`;
|
|
|
8017
7846
|
this.gl.device = this;
|
|
8018
7847
|
this.gl._version = 2;
|
|
8019
7848
|
this.info = getDeviceInfo(this.gl, this._extensions);
|
|
8020
|
-
this.features = new WebGLDeviceFeatures(this.gl, this._extensions);
|
|
8021
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
|
+
}
|
|
8022
7854
|
this.canvasContext.resize();
|
|
8023
7855
|
const { enable: enable2 = true, copyState = false } = props;
|
|
8024
7856
|
trackContextState(this.gl, {
|
|
@@ -8102,12 +7934,6 @@ ${source2}`;
|
|
|
8102
7934
|
throw new Error("ComputePass not supported in WebGL");
|
|
8103
7935
|
}
|
|
8104
7936
|
renderPass = null;
|
|
8105
|
-
getDefaultRenderPass() {
|
|
8106
|
-
this.renderPass = this.renderPass || this.beginRenderPass({
|
|
8107
|
-
framebuffer: this.canvasContext.getCurrentFramebuffer()
|
|
8108
|
-
});
|
|
8109
|
-
return this.renderPass;
|
|
8110
|
-
}
|
|
8111
7937
|
createCommandEncoder(props) {
|
|
8112
7938
|
return new WEBGLCommandEncoder(this, props);
|
|
8113
7939
|
}
|
|
@@ -8132,13 +7958,13 @@ ${source2}`;
|
|
|
8132
7958
|
return readPixelsToBuffer(source, options);
|
|
8133
7959
|
}
|
|
8134
7960
|
setParametersWebGL(parameters) {
|
|
8135
|
-
setGLParameters(this, parameters);
|
|
7961
|
+
setGLParameters(this.gl, parameters);
|
|
8136
7962
|
}
|
|
8137
7963
|
getParametersWebGL(parameters) {
|
|
8138
|
-
return getGLParameters(this, parameters);
|
|
7964
|
+
return getGLParameters(this.gl, parameters);
|
|
8139
7965
|
}
|
|
8140
7966
|
withParametersWebGL(parameters, func) {
|
|
8141
|
-
withGLParameters(this, parameters, func);
|
|
7967
|
+
withGLParameters(this.gl, parameters, func);
|
|
8142
7968
|
}
|
|
8143
7969
|
clearWebGL(options) {
|
|
8144
7970
|
clear(this, options);
|
|
@@ -8247,6 +8073,7 @@ ${source2}`;
|
|
|
8247
8073
|
//
|
|
8248
8074
|
// Public `Device` API
|
|
8249
8075
|
//
|
|
8076
|
+
/** type of this device */
|
|
8250
8077
|
__publicField(WebGLDevice, "type", "webgl");
|
|
8251
8078
|
function isWebGL(gl) {
|
|
8252
8079
|
if (typeof WebGL2RenderingContext !== "undefined" && gl instanceof WebGL2RenderingContext) {
|
|
@@ -8289,6 +8116,216 @@ ${source2}`;
|
|
|
8289
8116
|
}
|
|
8290
8117
|
return true;
|
|
8291
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
|
+
});
|
|
8292
8329
|
return __toCommonJS(src_exports);
|
|
8293
8330
|
})();
|
|
8294
8331
|
return __exports__;
|