@luma.gl/webgl 9.0.0-alpha.27 → 9.0.0-alpha.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/helpers/get-shader-layout.d.ts +8 -5
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +59 -16
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts +12 -0
- package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts.map +1 -0
- package/dist/adapter/helpers/get-vertex-buffer-layout.js +84 -0
- package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +1 -0
- package/dist/adapter/objects/webgl-vertex-array-object.js +2 -2
- package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts +13 -4
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +23 -21
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-external-texture.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +27 -4
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +25 -7
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +5 -2
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/buffer-with-accessor.d.ts +5 -15
- package/dist/classic/buffer-with-accessor.d.ts.map +1 -1
- package/dist/classic/buffer-with-accessor.js +25 -30
- package/dist/classic/buffer-with-accessor.js.map +1 -1
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +2 -2
- package/dist/classic/copy-and-blit.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +2 -1
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +2 -2
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/dist.dev.js +164 -83
- package/dist/index.cjs +207 -146
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist.min.js +22 -22
- package/package.json +5 -5
- package/src/adapter/helpers/get-shader-layout.ts +93 -33
- package/src/adapter/helpers/get-vertex-buffer-layout.ts +123 -0
- package/src/adapter/objects/webgl-vertex-array-object.ts +2 -2
- package/src/adapter/resources/webgl-buffer.ts +40 -41
- package/src/adapter/resources/webgl-external-texture.ts +1 -1
- package/src/adapter/resources/webgl-render-pipeline.ts +51 -35
- package/src/adapter/webgl-device.ts +4 -2
- package/src/classic/buffer-with-accessor.ts +42 -43
- package/src/classic/copy-and-blit.ts +2 -3
- package/src/context/debug/webgl-developer-tools.ts +8 -2
- package/src/context/parameters/webgl-parameter-tables.ts +2 -2
- package/src/index.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -80,11 +80,11 @@ __export(src_exports, {
|
|
|
80
80
|
convertGLToTextureFormat: () => convertGLToTextureFormat,
|
|
81
81
|
copyToTexture: () => copyToTexture,
|
|
82
82
|
getParameters: () => getParameters,
|
|
83
|
-
getProgramBindings: () => getProgramBindings,
|
|
84
83
|
getShaderLayout: () => getShaderLayout,
|
|
85
84
|
getWebGL2Context: () => getWebGL2Context,
|
|
86
85
|
isWebGL: () => isWebGL,
|
|
87
86
|
isWebGL2: () => isWebGL2,
|
|
87
|
+
mergeShaderLayout: () => mergeShaderLayout,
|
|
88
88
|
polyfillContext: () => polyfillContext,
|
|
89
89
|
popContextState: () => popContextState,
|
|
90
90
|
pushContextState: () => pushContextState,
|
|
@@ -133,8 +133,8 @@ function createHeadlessContext(options) {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
// src/adapter/webgl-device.ts
|
|
136
|
-
var
|
|
137
|
-
var
|
|
136
|
+
var import_api27 = require("@luma.gl/api");
|
|
137
|
+
var import_env3 = require("@probe.gl/env");
|
|
138
138
|
|
|
139
139
|
// src/context/polyfill/polyfill-context.ts
|
|
140
140
|
var import_api3 = require("@luma.gl/api");
|
|
@@ -880,8 +880,8 @@ var bindBuffer = (gl2, value, key) => {
|
|
|
880
880
|
[import_constants3.GL.PIXEL_PACK_BUFFER_BINDING]: import_constants3.GL.PIXEL_PACK_BUFFER,
|
|
881
881
|
[import_constants3.GL.PIXEL_UNPACK_BUFFER_BINDING]: import_constants3.GL.PIXEL_UNPACK_BUFFER
|
|
882
882
|
};
|
|
883
|
-
const
|
|
884
|
-
gl2.bindBuffer(
|
|
883
|
+
const glTarget = bindingMap[key];
|
|
884
|
+
gl2.bindBuffer(glTarget, value);
|
|
885
885
|
};
|
|
886
886
|
function isArray(array) {
|
|
887
887
|
return Array.isArray(array) || ArrayBuffer.isView(array) && !(array instanceof DataView);
|
|
@@ -1358,7 +1358,7 @@ var GLState = class {
|
|
|
1358
1358
|
constructor(gl2, {
|
|
1359
1359
|
copyState = false,
|
|
1360
1360
|
// Copy cache from params (slow) or initialize from WebGL defaults (fast)
|
|
1361
|
-
log:
|
|
1361
|
+
log: log10 = () => {
|
|
1362
1362
|
}
|
|
1363
1363
|
// Logging function, called when gl parameter change calls are actually issued
|
|
1364
1364
|
} = {}) {
|
|
@@ -1367,7 +1367,7 @@ var GLState = class {
|
|
|
1367
1367
|
this.enable = true;
|
|
1368
1368
|
this.gl = gl2;
|
|
1369
1369
|
this.cache = copyState ? getParameters(gl2) : Object.assign({}, GL_PARAMETER_DEFAULTS);
|
|
1370
|
-
this.log =
|
|
1370
|
+
this.log = log10;
|
|
1371
1371
|
this._updateCache = this._updateCache.bind(this);
|
|
1372
1372
|
Object.seal(this);
|
|
1373
1373
|
}
|
|
@@ -2521,9 +2521,11 @@ var import_api7 = require("@luma.gl/api");
|
|
|
2521
2521
|
var import_constants9 = require("@luma.gl/constants");
|
|
2522
2522
|
var DEBUG_DATA_LENGTH = 10;
|
|
2523
2523
|
var WEBGLBuffer = class extends import_api7.Buffer {
|
|
2524
|
-
// accessor: {};
|
|
2525
2524
|
constructor(device, props = {}) {
|
|
2526
2525
|
super(device, props);
|
|
2526
|
+
/** Index type is needed when issuing draw calls, so we pre-compute it */
|
|
2527
|
+
this.glIndexType = import_constants9.GL.UNSIGNED_SHORT;
|
|
2528
|
+
/** A partial CPU-side copy of the data in this buffer, for debugging purposes */
|
|
2527
2529
|
this.debugData = null;
|
|
2528
2530
|
this.device = device;
|
|
2529
2531
|
this.gl = this.device.gl;
|
|
@@ -2531,8 +2533,9 @@ var WEBGLBuffer = class extends import_api7.Buffer {
|
|
|
2531
2533
|
const handle = typeof props === "object" ? props.handle : void 0;
|
|
2532
2534
|
this.handle = handle || this.gl.createBuffer();
|
|
2533
2535
|
device.setSpectorMetadata(this.handle, __spreadProps(__spreadValues({}, this.props), { data: typeof this.props.data }));
|
|
2534
|
-
this.
|
|
2535
|
-
this.
|
|
2536
|
+
this.glTarget = getWebGLTarget(this.props.usage);
|
|
2537
|
+
this.glUsage = getWebGLUsage(this.props.usage);
|
|
2538
|
+
this.glIndexType = this.props.indexType === "uint32" ? import_constants9.GL.UNSIGNED_INT : import_constants9.GL.UNSIGNED_SHORT;
|
|
2536
2539
|
this.debugData = null;
|
|
2537
2540
|
if (props.data) {
|
|
2538
2541
|
this._initWithData(props.data, props.byteOffset, props.byteLength);
|
|
@@ -2541,14 +2544,14 @@ var WEBGLBuffer = class extends import_api7.Buffer {
|
|
|
2541
2544
|
}
|
|
2542
2545
|
}
|
|
2543
2546
|
// PRIVATE METHODS
|
|
2544
|
-
|
|
2547
|
+
/** Allocate a new buffer and initialize to contents of typed array */
|
|
2545
2548
|
_initWithData(data, byteOffset = 0, byteLength = data.byteLength + byteOffset) {
|
|
2546
2549
|
(0, import_api7.assert)(ArrayBuffer.isView(data));
|
|
2547
|
-
const
|
|
2548
|
-
this.gl.bindBuffer(
|
|
2549
|
-
this.gl.bufferData(
|
|
2550
|
-
this.gl.bufferSubData(
|
|
2551
|
-
this.gl.bindBuffer(
|
|
2550
|
+
const glTarget = this._getWriteTarget();
|
|
2551
|
+
this.gl.bindBuffer(glTarget, this.handle);
|
|
2552
|
+
this.gl.bufferData(glTarget, byteLength, this.glUsage);
|
|
2553
|
+
this.gl.bufferSubData(glTarget, byteOffset, data);
|
|
2554
|
+
this.gl.bindBuffer(glTarget, null);
|
|
2552
2555
|
this.debugData = data.slice(0, DEBUG_DATA_LENGTH);
|
|
2553
2556
|
this.bytesUsed = byteLength;
|
|
2554
2557
|
this.byteLength = byteLength;
|
|
@@ -2562,10 +2565,10 @@ var WEBGLBuffer = class extends import_api7.Buffer {
|
|
|
2562
2565
|
if (byteLength === 0) {
|
|
2563
2566
|
data = new Float32Array(0);
|
|
2564
2567
|
}
|
|
2565
|
-
const
|
|
2566
|
-
this.gl.bindBuffer(
|
|
2567
|
-
this.gl.bufferData(
|
|
2568
|
-
this.gl.bindBuffer(
|
|
2568
|
+
const glTarget = this._getWriteTarget();
|
|
2569
|
+
this.gl.bindBuffer(glTarget, this.handle);
|
|
2570
|
+
this.gl.bufferData(glTarget, data, this.glUsage);
|
|
2571
|
+
this.gl.bindBuffer(glTarget, null);
|
|
2569
2572
|
this.debugData = null;
|
|
2570
2573
|
this.bytesUsed = byteLength;
|
|
2571
2574
|
this.byteLength = byteLength;
|
|
@@ -2583,15 +2586,15 @@ var WEBGLBuffer = class extends import_api7.Buffer {
|
|
|
2583
2586
|
write(data, byteOffset = 0) {
|
|
2584
2587
|
const srcOffset = 0;
|
|
2585
2588
|
const byteLength = void 0;
|
|
2586
|
-
const
|
|
2587
|
-
this.gl.bindBuffer(
|
|
2589
|
+
const glTarget = this.device.isWebGL2 ? import_constants9.GL.COPY_WRITE_BUFFER : this.glTarget;
|
|
2590
|
+
this.gl.bindBuffer(glTarget, this.handle);
|
|
2588
2591
|
if (srcOffset !== 0 || byteLength !== void 0) {
|
|
2589
2592
|
this.device.assertWebGL2();
|
|
2590
|
-
this.gl2.bufferSubData(
|
|
2593
|
+
this.gl2.bufferSubData(glTarget, byteOffset, data, srcOffset, byteLength);
|
|
2591
2594
|
} else {
|
|
2592
|
-
this.gl.bufferSubData(
|
|
2595
|
+
this.gl.bufferSubData(glTarget, byteOffset, data);
|
|
2593
2596
|
}
|
|
2594
|
-
this.gl.bindBuffer(
|
|
2597
|
+
this.gl.bindBuffer(glTarget, null);
|
|
2595
2598
|
}
|
|
2596
2599
|
/** Read data from the buffer */
|
|
2597
2600
|
readAsync(byteOffset = 0, byteLength) {
|
|
@@ -2610,10 +2613,10 @@ var WEBGLBuffer = class extends import_api7.Buffer {
|
|
|
2610
2613
|
this.debugData = null;
|
|
2611
2614
|
}
|
|
2612
2615
|
_getWriteTarget() {
|
|
2613
|
-
return this.
|
|
2616
|
+
return this.glTarget;
|
|
2614
2617
|
}
|
|
2615
2618
|
_getReadTarget() {
|
|
2616
|
-
return this.
|
|
2619
|
+
return this.glTarget;
|
|
2617
2620
|
}
|
|
2618
2621
|
};
|
|
2619
2622
|
function getWebGLTarget(usage) {
|
|
@@ -2638,7 +2641,7 @@ function getWebGLUsage(usage) {
|
|
|
2638
2641
|
if (usage & import_api7.Buffer.UNIFORM) {
|
|
2639
2642
|
return import_constants9.GL.DYNAMIC_DRAW;
|
|
2640
2643
|
}
|
|
2641
|
-
return import_constants9.GL.
|
|
2644
|
+
return import_constants9.GL.STATIC_DRAW;
|
|
2642
2645
|
}
|
|
2643
2646
|
|
|
2644
2647
|
// src/adapter/resources/webgl-sampler.ts
|
|
@@ -3973,6 +3976,7 @@ function initializeSpectorJS(props) {
|
|
|
3973
3976
|
// src/context/debug/webgl-developer-tools.ts
|
|
3974
3977
|
var import_api17 = require("@luma.gl/api");
|
|
3975
3978
|
var import_constants14 = require("@luma.gl/constants");
|
|
3979
|
+
var import_env = require("@probe.gl/env");
|
|
3976
3980
|
var WEBGL_DEBUG_CDN_URL = "https://unpkg.com/webgl-debug@2.0.1/index.js";
|
|
3977
3981
|
function getContextData2(gl2) {
|
|
3978
3982
|
gl2.luma = gl2.luma || {};
|
|
@@ -3980,7 +3984,7 @@ function getContextData2(gl2) {
|
|
|
3980
3984
|
}
|
|
3981
3985
|
function loadWebGLDeveloperTools() {
|
|
3982
3986
|
return __async(this, null, function* () {
|
|
3983
|
-
if (!globalThis.WebGLDebugUtils) {
|
|
3987
|
+
if ((0, import_env.isBrowser)() && !globalThis.WebGLDebugUtils) {
|
|
3984
3988
|
globalThis.global = globalThis.global || globalThis;
|
|
3985
3989
|
globalThis.global.module = {};
|
|
3986
3990
|
yield (0, import_api17.loadScript)(WEBGL_DEBUG_CDN_URL);
|
|
@@ -4280,9 +4284,6 @@ function getWEBGLBufferProps(props) {
|
|
|
4280
4284
|
}
|
|
4281
4285
|
props = (0, import_api19.checkProps)("Buffer", props, PROP_CHECKS_INITIALIZE);
|
|
4282
4286
|
const bufferProps = __spreadValues({}, props);
|
|
4283
|
-
if (bufferProps.offset) {
|
|
4284
|
-
bufferProps.byteOffset = bufferProps.offset;
|
|
4285
|
-
}
|
|
4286
4287
|
return bufferProps;
|
|
4287
4288
|
}
|
|
4288
4289
|
var BufferWithAccessor = class extends WEBGLBuffer {
|
|
@@ -4319,11 +4320,11 @@ var BufferWithAccessor = class extends WEBGLBuffer {
|
|
|
4319
4320
|
props = { byteLength: props };
|
|
4320
4321
|
}
|
|
4321
4322
|
props = (0, import_api19.checkProps)("Buffer", props, PROP_CHECKS_INITIALIZE);
|
|
4322
|
-
this.
|
|
4323
|
+
this.glUsage = props.glUsage || import_constants17.GL.STATIC_DRAW;
|
|
4323
4324
|
this.debugData = null;
|
|
4324
4325
|
this.setAccessor(Object.assign({}, props, props.accessor));
|
|
4325
4326
|
if (props.data) {
|
|
4326
|
-
this._setData(props.data, props.
|
|
4327
|
+
this._setData(props.data, props.byteOffset, props.byteLength);
|
|
4327
4328
|
} else {
|
|
4328
4329
|
this._setByteLength(props.byteLength || 0);
|
|
4329
4330
|
}
|
|
@@ -4373,15 +4374,15 @@ var BufferWithAccessor = class extends WEBGLBuffer {
|
|
|
4373
4374
|
const { data, offset = 0, srcOffset = 0 } = options;
|
|
4374
4375
|
const byteLength = options.byteLength || options.length;
|
|
4375
4376
|
(0, import_api19.assert)(data);
|
|
4376
|
-
const
|
|
4377
|
-
this.gl.bindBuffer(
|
|
4377
|
+
const glTarget = this.gl.webgl2 ? import_constants17.GL.COPY_WRITE_BUFFER : this.glTarget;
|
|
4378
|
+
this.gl.bindBuffer(glTarget, this.handle);
|
|
4378
4379
|
if (srcOffset !== 0 || byteLength !== void 0) {
|
|
4379
4380
|
assertWebGL2Context(this.gl);
|
|
4380
|
-
this.gl.bufferSubData(this.
|
|
4381
|
+
this.gl.bufferSubData(this.glTarget, offset, data, srcOffset, byteLength);
|
|
4381
4382
|
} else {
|
|
4382
|
-
this.gl.bufferSubData(
|
|
4383
|
+
this.gl.bufferSubData(glTarget, offset, data);
|
|
4383
4384
|
}
|
|
4384
|
-
this.gl.bindBuffer(
|
|
4385
|
+
this.gl.bindBuffer(glTarget, null);
|
|
4385
4386
|
this.debugData = null;
|
|
4386
4387
|
this._inferType(data);
|
|
4387
4388
|
return this;
|
|
@@ -4445,33 +4446,33 @@ var BufferWithAccessor = class extends WEBGLBuffer {
|
|
|
4445
4446
|
bind(options) {
|
|
4446
4447
|
var _a, _b;
|
|
4447
4448
|
const {
|
|
4448
|
-
|
|
4449
|
+
glTarget = this.glTarget,
|
|
4449
4450
|
// target for the bind operation
|
|
4450
4451
|
index = this.accessor && this.accessor.index,
|
|
4451
4452
|
// index = index of target (indexed bind point)
|
|
4452
4453
|
offset = 0,
|
|
4453
4454
|
size
|
|
4454
4455
|
} = options || {};
|
|
4455
|
-
if (
|
|
4456
|
+
if (glTarget === import_constants17.GL.UNIFORM_BUFFER || glTarget === import_constants17.GL.TRANSFORM_FEEDBACK_BUFFER) {
|
|
4456
4457
|
if (size !== void 0) {
|
|
4457
|
-
(_a = this.gl2) == null ? void 0 : _a.bindBufferRange(
|
|
4458
|
+
(_a = this.gl2) == null ? void 0 : _a.bindBufferRange(glTarget, index, this.handle, offset, size);
|
|
4458
4459
|
} else {
|
|
4459
4460
|
(0, import_api19.assert)(offset === 0);
|
|
4460
|
-
(_b = this.gl2) == null ? void 0 : _b.bindBufferBase(
|
|
4461
|
+
(_b = this.gl2) == null ? void 0 : _b.bindBufferBase(glTarget, index, this.handle);
|
|
4461
4462
|
}
|
|
4462
4463
|
} else {
|
|
4463
|
-
this.gl.bindBuffer(
|
|
4464
|
+
this.gl.bindBuffer(glTarget, this.handle);
|
|
4464
4465
|
}
|
|
4465
4466
|
return this;
|
|
4466
4467
|
}
|
|
4467
4468
|
unbind(options) {
|
|
4468
4469
|
var _a;
|
|
4469
|
-
const {
|
|
4470
|
-
const isIndexedBuffer =
|
|
4470
|
+
const { glTarget = this.glTarget, index = this.accessor && this.accessor.index } = options || {};
|
|
4471
|
+
const isIndexedBuffer = glTarget === import_constants17.GL.UNIFORM_BUFFER || glTarget === import_constants17.GL.TRANSFORM_FEEDBACK_BUFFER;
|
|
4471
4472
|
if (isIndexedBuffer) {
|
|
4472
|
-
(_a = this.gl2) == null ? void 0 : _a.bindBufferBase(
|
|
4473
|
+
(_a = this.gl2) == null ? void 0 : _a.bindBufferBase(glTarget, index, null);
|
|
4473
4474
|
} else {
|
|
4474
|
-
this.gl.bindBuffer(
|
|
4475
|
+
this.gl.bindBuffer(glTarget, null);
|
|
4475
4476
|
}
|
|
4476
4477
|
return this;
|
|
4477
4478
|
}
|
|
@@ -4494,7 +4495,7 @@ var BufferWithAccessor = class extends WEBGLBuffer {
|
|
|
4494
4495
|
this.trackDeallocatedMemory();
|
|
4495
4496
|
const target = this._getTarget();
|
|
4496
4497
|
this.gl.bindBuffer(target, this.handle);
|
|
4497
|
-
this.gl.bufferData(target, byteLength, this.
|
|
4498
|
+
this.gl.bufferData(target, byteLength, this.glUsage);
|
|
4498
4499
|
this.gl.bufferSubData(target, offset, data);
|
|
4499
4500
|
this.gl.bindBuffer(target, null);
|
|
4500
4501
|
this.debugData = data.slice(0, DEBUG_DATA_LENGTH2);
|
|
@@ -4507,18 +4508,17 @@ var BufferWithAccessor = class extends WEBGLBuffer {
|
|
|
4507
4508
|
return this;
|
|
4508
4509
|
}
|
|
4509
4510
|
// Allocate a GPU buffer of specified size.
|
|
4510
|
-
_setByteLength(byteLength
|
|
4511
|
+
_setByteLength(byteLength) {
|
|
4511
4512
|
(0, import_api19.assert)(byteLength >= 0);
|
|
4512
4513
|
this.trackDeallocatedMemory();
|
|
4513
4514
|
let data = byteLength;
|
|
4514
4515
|
if (byteLength === 0) {
|
|
4515
4516
|
data = new Float32Array(0);
|
|
4516
4517
|
}
|
|
4517
|
-
const
|
|
4518
|
-
this.gl.bindBuffer(
|
|
4519
|
-
this.gl.bufferData(
|
|
4520
|
-
this.gl.bindBuffer(
|
|
4521
|
-
this.webglUsage = webglUsage;
|
|
4518
|
+
const glTarget = this._getTarget();
|
|
4519
|
+
this.gl.bindBuffer(glTarget, this.handle);
|
|
4520
|
+
this.gl.bufferData(glTarget, data, this.glUsage);
|
|
4521
|
+
this.gl.bindBuffer(glTarget, null);
|
|
4522
4522
|
this.debugData = null;
|
|
4523
4523
|
this.bytesUsed = byteLength;
|
|
4524
4524
|
this.byteLength = byteLength;
|
|
@@ -4528,7 +4528,7 @@ var BufferWithAccessor = class extends WEBGLBuffer {
|
|
|
4528
4528
|
// Binding a buffer for the first time locks the type
|
|
4529
4529
|
// In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type
|
|
4530
4530
|
_getTarget() {
|
|
4531
|
-
return this.gl.webgl2 ? import_constants17.GL.COPY_WRITE_BUFFER : this.
|
|
4531
|
+
return this.gl.webgl2 ? import_constants17.GL.COPY_WRITE_BUFFER : this.glTarget;
|
|
4532
4532
|
}
|
|
4533
4533
|
_getAvailableElementCount(srcByteOffset) {
|
|
4534
4534
|
const ArrayType = getTypedArrayFromGLType(this.accessor.type || import_constants17.GL.FLOAT, { clamped: false });
|
|
@@ -4544,9 +4544,9 @@ var BufferWithAccessor = class extends WEBGLBuffer {
|
|
|
4544
4544
|
}
|
|
4545
4545
|
// RESOURCE METHODS
|
|
4546
4546
|
getParameter(pname) {
|
|
4547
|
-
this.gl.bindBuffer(this.
|
|
4548
|
-
const value = this.gl.getBufferParameter(this.
|
|
4549
|
-
this.gl.bindBuffer(this.
|
|
4547
|
+
this.gl.bindBuffer(this.glTarget, this.handle);
|
|
4548
|
+
const value = this.gl.getBufferParameter(this.glTarget, pname);
|
|
4549
|
+
this.gl.bindBuffer(this.glTarget, null);
|
|
4550
4550
|
return value;
|
|
4551
4551
|
}
|
|
4552
4552
|
// DEPRECATIONS - v7.0
|
|
@@ -4643,8 +4643,8 @@ var WEBGLShader = class extends import_api20.Shader {
|
|
|
4643
4643
|
}
|
|
4644
4644
|
compilationInfo() {
|
|
4645
4645
|
return __async(this, null, function* () {
|
|
4646
|
-
const
|
|
4647
|
-
return
|
|
4646
|
+
const log10 = this.device.gl.getShaderInfoLog(this.handle);
|
|
4647
|
+
return log10 ? parseShaderCompilerLog(log10) : [];
|
|
4648
4648
|
});
|
|
4649
4649
|
}
|
|
4650
4650
|
// PRIVATE METHODS
|
|
@@ -4794,10 +4794,11 @@ var WEBGLRenderPass = class extends import_api21.RenderPass {
|
|
|
4794
4794
|
};
|
|
4795
4795
|
|
|
4796
4796
|
// src/adapter/resources/webgl-render-pipeline.ts
|
|
4797
|
-
var
|
|
4797
|
+
var import_api24 = require("@luma.gl/api");
|
|
4798
4798
|
var import_constants25 = require("@luma.gl/constants");
|
|
4799
4799
|
|
|
4800
4800
|
// src/adapter/helpers/get-shader-layout.ts
|
|
4801
|
+
var import_api22 = require("@luma.gl/api");
|
|
4801
4802
|
var import_constants22 = require("@luma.gl/constants");
|
|
4802
4803
|
|
|
4803
4804
|
// src/adapter/helpers/uniforms.ts
|
|
@@ -4907,13 +4908,12 @@ function getDataFormat(type) {
|
|
|
4907
4908
|
|
|
4908
4909
|
// src/adapter/helpers/get-shader-layout.ts
|
|
4909
4910
|
function getShaderLayout(gl2, program) {
|
|
4910
|
-
var _a, _b;
|
|
4911
|
-
const programBindings = getProgramBindings(gl2, program);
|
|
4912
4911
|
const shaderLayout = {
|
|
4913
4912
|
attributes: [],
|
|
4914
4913
|
bindings: []
|
|
4915
4914
|
};
|
|
4916
|
-
|
|
4915
|
+
const attributes = readAttributeBindings(gl2, program);
|
|
4916
|
+
for (const attribute of attributes) {
|
|
4917
4917
|
const size = Math.min(attribute.accessor.size, 4);
|
|
4918
4918
|
const format = (
|
|
4919
4919
|
// attribute.accessor.format ||
|
|
@@ -4926,7 +4926,8 @@ function getShaderLayout(gl2, program) {
|
|
|
4926
4926
|
stepMode: attribute.accessor.divisor === 1 ? "instance" : "vertex"
|
|
4927
4927
|
});
|
|
4928
4928
|
}
|
|
4929
|
-
|
|
4929
|
+
const uniformBlocks = readUniformBlocks(gl2, program);
|
|
4930
|
+
for (const uniformBlock of uniformBlocks) {
|
|
4930
4931
|
const uniforms2 = uniformBlock.uniforms.map((uniform) => ({
|
|
4931
4932
|
name: uniform.name,
|
|
4932
4933
|
format: uniform.format,
|
|
@@ -4943,8 +4944,9 @@ function getShaderLayout(gl2, program) {
|
|
|
4943
4944
|
uniforms: uniforms2
|
|
4944
4945
|
});
|
|
4945
4946
|
}
|
|
4947
|
+
const uniforms = readUniformBindings(gl2, program);
|
|
4946
4948
|
let textureUnit = 0;
|
|
4947
|
-
for (const uniform of
|
|
4949
|
+
for (const uniform of uniforms) {
|
|
4948
4950
|
if (isSamplerUniform(uniform.type)) {
|
|
4949
4951
|
const { viewDimension, sampleType } = getSamplerInfo(uniform.type);
|
|
4950
4952
|
shaderLayout.bindings.push({
|
|
@@ -4958,24 +4960,59 @@ function getShaderLayout(gl2, program) {
|
|
|
4958
4960
|
textureUnit += 1;
|
|
4959
4961
|
}
|
|
4960
4962
|
}
|
|
4961
|
-
const uniforms = ((_a = programBindings.uniforms) == null ? void 0 : _a.filter((uniform) => uniform.location !== null)) || [];
|
|
4962
4963
|
if (uniforms.length) {
|
|
4963
4964
|
shaderLayout.uniforms = uniforms;
|
|
4964
4965
|
}
|
|
4965
|
-
|
|
4966
|
-
|
|
4966
|
+
const varyings = readVaryings(gl2, program);
|
|
4967
|
+
if (varyings == null ? void 0 : varyings.length) {
|
|
4968
|
+
shaderLayout.varyings = varyings;
|
|
4967
4969
|
}
|
|
4968
4970
|
return shaderLayout;
|
|
4969
4971
|
}
|
|
4970
|
-
function
|
|
4971
|
-
const
|
|
4972
|
-
attributes:
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4972
|
+
function mergeShaderLayout(baseLayout, overrideLayout) {
|
|
4973
|
+
const mergedLayout = __spreadProps(__spreadValues({}, baseLayout), {
|
|
4974
|
+
attributes: baseLayout.attributes.map((attribute) => __spreadValues({}, attribute))
|
|
4975
|
+
});
|
|
4976
|
+
for (const attribute of (overrideLayout == null ? void 0 : overrideLayout.attributes) || []) {
|
|
4977
|
+
const baseAttribute = mergedLayout.attributes.find((attr) => attr.name === attribute.name);
|
|
4978
|
+
if (!baseAttribute) {
|
|
4979
|
+
import_api22.log.warn(`shader layout attribute ${attribute.name} not present in shader`);
|
|
4980
|
+
} else {
|
|
4981
|
+
baseAttribute.format = attribute.format || baseAttribute.format;
|
|
4982
|
+
baseAttribute.stepMode = attribute.stepMode || baseAttribute.stepMode;
|
|
4983
|
+
}
|
|
4984
|
+
}
|
|
4985
|
+
return mergedLayout;
|
|
4986
|
+
}
|
|
4987
|
+
function mergeBufferMap(baseLayout, bufferMap) {
|
|
4988
|
+
const mergedLayout = __spreadProps(__spreadValues({}, baseLayout), {
|
|
4989
|
+
attributes: baseLayout.attributes.map((attribute) => __spreadValues({}, attribute))
|
|
4990
|
+
});
|
|
4991
|
+
for (const bufferMapping of bufferMap) {
|
|
4992
|
+
switch (bufferMapping.type) {
|
|
4993
|
+
case "interleave":
|
|
4994
|
+
for (const attributeOverride of bufferMapping.attributes) {
|
|
4995
|
+
overrideShaderLayoutAttribute(mergedLayout, attributeOverride);
|
|
4996
|
+
}
|
|
4997
|
+
break;
|
|
4998
|
+
default:
|
|
4999
|
+
overrideShaderLayoutAttribute(mergedLayout, bufferMapping);
|
|
5000
|
+
}
|
|
5001
|
+
}
|
|
5002
|
+
return mergedLayout;
|
|
5003
|
+
}
|
|
5004
|
+
function overrideShaderLayoutAttribute(layout, attributeOverride) {
|
|
5005
|
+
const attribute = getAttributeFromLayout(layout, attributeOverride.name);
|
|
5006
|
+
if (attribute && attributeOverride.format) {
|
|
5007
|
+
attribute.format = attributeOverride.format;
|
|
5008
|
+
}
|
|
5009
|
+
}
|
|
5010
|
+
function getAttributeFromLayout(shaderLayout, name) {
|
|
5011
|
+
const attribute = shaderLayout.attributes.find((attr) => attr.name === name);
|
|
5012
|
+
if (!attribute) {
|
|
5013
|
+
import_api22.log.warn(`shader layout attribute "${name}" not present in shader`);
|
|
5014
|
+
}
|
|
5015
|
+
return attribute || null;
|
|
4979
5016
|
}
|
|
4980
5017
|
function readAttributeBindings(gl2, program) {
|
|
4981
5018
|
const attributes = [];
|
|
@@ -5231,14 +5268,14 @@ function setUniform(gl2, location, type, value) {
|
|
|
5231
5268
|
}
|
|
5232
5269
|
|
|
5233
5270
|
// src/adapter/objects/webgl-vertex-array-object.ts
|
|
5234
|
-
var
|
|
5271
|
+
var import_api23 = require("@luma.gl/api");
|
|
5235
5272
|
var import_constants24 = require("@luma.gl/constants");
|
|
5236
|
-
var
|
|
5273
|
+
var import_env2 = require("@probe.gl/env");
|
|
5237
5274
|
var ERR_ELEMENTS = "elements must be GL.ELEMENT_ARRAY_BUFFER";
|
|
5238
5275
|
var WEBGLVertexArrayObject = class extends WebGLResource {
|
|
5239
5276
|
// Create a VertexArray
|
|
5240
5277
|
constructor(device, props) {
|
|
5241
|
-
super(device, props, __spreadProps(__spreadValues({},
|
|
5278
|
+
super(device, props, __spreadProps(__spreadValues({}, import_api23.Resource.defaultProps), { constantAttributeZero: false }));
|
|
5242
5279
|
/** Buffer constant */
|
|
5243
5280
|
this.buffer = null;
|
|
5244
5281
|
this.bufferValue = null;
|
|
@@ -5248,7 +5285,7 @@ var WEBGLVertexArrayObject = class extends WebGLResource {
|
|
|
5248
5285
|
return "BaseVertexArrayObject";
|
|
5249
5286
|
}
|
|
5250
5287
|
static isConstantAttributeZeroSupported(device) {
|
|
5251
|
-
return device.info.type === "webgl2" || (0,
|
|
5288
|
+
return device.info.type === "webgl2" || (0, import_env2.getBrowser)() === "Chrome";
|
|
5252
5289
|
}
|
|
5253
5290
|
destroy() {
|
|
5254
5291
|
var _a;
|
|
@@ -5274,7 +5311,7 @@ var WEBGLVertexArrayObject = class extends WebGLResource {
|
|
|
5274
5311
|
* TODO - convert classic arrays based on known type?
|
|
5275
5312
|
*/
|
|
5276
5313
|
enable(location, enable2 = true) {
|
|
5277
|
-
const canDisableAttributeZero = this.device.isWebGL2 || (0,
|
|
5314
|
+
const canDisableAttributeZero = this.device.isWebGL2 || (0, import_env2.getBrowser)() === "Chrome";
|
|
5278
5315
|
const canDisableAttribute = canDisableAttributeZero || location !== 0;
|
|
5279
5316
|
if (enable2 || canDisableAttribute) {
|
|
5280
5317
|
location = Number(location);
|
|
@@ -5286,14 +5323,14 @@ var WEBGLVertexArrayObject = class extends WebGLResource {
|
|
|
5286
5323
|
// Set (bind) an elements buffer, for indexed rendering.
|
|
5287
5324
|
// Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER. Constants not supported
|
|
5288
5325
|
setElementBuffer(elementBuffer = null, opts = {}) {
|
|
5289
|
-
(0,
|
|
5326
|
+
(0, import_api23.assert)(!elementBuffer || elementBuffer.glTarget === import_constants24.GL.ELEMENT_ARRAY_BUFFER, ERR_ELEMENTS);
|
|
5290
5327
|
this.bind(() => {
|
|
5291
5328
|
this.gl.bindBuffer(import_constants24.GL.ELEMENT_ARRAY_BUFFER, elementBuffer ? elementBuffer.handle : null);
|
|
5292
5329
|
});
|
|
5293
5330
|
}
|
|
5294
5331
|
/** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */
|
|
5295
5332
|
setBuffer(location, buffer, accessor) {
|
|
5296
|
-
if (buffer.
|
|
5333
|
+
if (buffer.glTarget === import_constants24.GL.ELEMENT_ARRAY_BUFFER) {
|
|
5297
5334
|
this.setElementBuffer(buffer, accessor);
|
|
5298
5335
|
return;
|
|
5299
5336
|
}
|
|
@@ -5335,7 +5372,7 @@ var WEBGLVertexArrayObject = class extends WebGLResource {
|
|
|
5335
5372
|
setConstantUintArray(this.device, location, array);
|
|
5336
5373
|
break;
|
|
5337
5374
|
default:
|
|
5338
|
-
(0,
|
|
5375
|
+
(0, import_api23.assert)(false);
|
|
5339
5376
|
}
|
|
5340
5377
|
}
|
|
5341
5378
|
/**
|
|
@@ -5353,8 +5390,8 @@ var WEBGLVertexArrayObject = class extends WebGLResource {
|
|
|
5353
5390
|
updateNeeded = updateNeeded || this.buffer.reallocate(byteLength);
|
|
5354
5391
|
updateNeeded = updateNeeded || !compareConstantArrayValues(constantValue, this.bufferValue);
|
|
5355
5392
|
if (updateNeeded) {
|
|
5356
|
-
const typedArray = (0,
|
|
5357
|
-
(0,
|
|
5393
|
+
const typedArray = (0, import_api23.getScratchArray)(value.constructor, length);
|
|
5394
|
+
(0, import_api23.fillArray)({ target: typedArray, source: constantValue, start: 0, count: length });
|
|
5358
5395
|
this.buffer.subData(typedArray);
|
|
5359
5396
|
this.bufferValue = value;
|
|
5360
5397
|
}
|
|
@@ -5376,7 +5413,7 @@ function setConstantFloatArray(device, location, array) {
|
|
|
5376
5413
|
device.gl.vertexAttrib4fv(location, array);
|
|
5377
5414
|
break;
|
|
5378
5415
|
default:
|
|
5379
|
-
(0,
|
|
5416
|
+
(0, import_api23.assert)(false);
|
|
5380
5417
|
}
|
|
5381
5418
|
}
|
|
5382
5419
|
function setConstantIntArray(device, location, array) {
|
|
@@ -5409,16 +5446,19 @@ function compareConstantArrayValues(v1, v2) {
|
|
|
5409
5446
|
|
|
5410
5447
|
// src/adapter/resources/webgl-render-pipeline.ts
|
|
5411
5448
|
var LOG_PROGRAM_PERF_PRIORITY = 4;
|
|
5412
|
-
var WEBGLRenderPipeline = class extends
|
|
5449
|
+
var WEBGLRenderPipeline = class extends import_api24.RenderPipeline {
|
|
5413
5450
|
// TODO are these used?
|
|
5414
5451
|
constructor(device, props) {
|
|
5415
5452
|
var _a;
|
|
5416
5453
|
super(device, props);
|
|
5417
|
-
|
|
5418
|
-
// Experimental flag to avoid deleting Program object while it is cached
|
|
5419
|
-
this.varyings = null;
|
|
5454
|
+
/** Uniforms set on this model */
|
|
5420
5455
|
this.uniforms = {};
|
|
5456
|
+
/** Bindings set on this model */
|
|
5421
5457
|
this.bindings = {};
|
|
5458
|
+
/** Any constant attributes */
|
|
5459
|
+
this.constantAttributes = {};
|
|
5460
|
+
/** WebGL varyings */
|
|
5461
|
+
this.varyings = null;
|
|
5422
5462
|
this._textureUniforms = {};
|
|
5423
5463
|
this._textureIndexCounter = 0;
|
|
5424
5464
|
this._uniformCount = 0;
|
|
@@ -5426,8 +5466,8 @@ var WEBGLRenderPipeline = class extends import_api23.RenderPipeline {
|
|
|
5426
5466
|
this.device = device;
|
|
5427
5467
|
this.handle = this.props.handle || this.device.gl.createProgram();
|
|
5428
5468
|
this.device.setSpectorMetadata(this.handle, { id: this.props.id });
|
|
5429
|
-
this.vs = (0,
|
|
5430
|
-
this.fs = (0,
|
|
5469
|
+
this.vs = (0, import_api24.cast)(props.vs);
|
|
5470
|
+
this.fs = (0, import_api24.cast)(props.fs);
|
|
5431
5471
|
const { varyings, bufferMode = import_constants25.GL.SEPARATE_ATTRIBS } = props;
|
|
5432
5472
|
if (varyings && varyings.length > 0) {
|
|
5433
5473
|
this.device.assertWebGL2();
|
|
@@ -5435,7 +5475,10 @@ var WEBGLRenderPipeline = class extends import_api23.RenderPipeline {
|
|
|
5435
5475
|
(_a = this.device.gl2) == null ? void 0 : _a.transformFeedbackVaryings(this.handle, varyings, bufferMode);
|
|
5436
5476
|
}
|
|
5437
5477
|
this._compileAndLink();
|
|
5438
|
-
this.
|
|
5478
|
+
this.introspectedLayout = getShaderLayout(this.device.gl, this.handle);
|
|
5479
|
+
this.layout = mergeShaderLayout(this.introspectedLayout, props.layout);
|
|
5480
|
+
this.bufferMap = props.bufferMap || [];
|
|
5481
|
+
this.layout = mergeBufferMap(this.layout, this.bufferMap);
|
|
5439
5482
|
this.vertexArrayObject = new WEBGLVertexArrayObject(this.device);
|
|
5440
5483
|
}
|
|
5441
5484
|
destroy() {
|
|
@@ -5445,20 +5488,20 @@ var WEBGLRenderPipeline = class extends import_api23.RenderPipeline {
|
|
|
5445
5488
|
}
|
|
5446
5489
|
}
|
|
5447
5490
|
setIndexBuffer(indexBuffer) {
|
|
5448
|
-
const webglBuffer = (0,
|
|
5491
|
+
const webglBuffer = (0, import_api24.cast)(indexBuffer);
|
|
5449
5492
|
this.vertexArrayObject.setElementBuffer(webglBuffer);
|
|
5450
|
-
this._indexBuffer =
|
|
5493
|
+
this._indexBuffer = webglBuffer;
|
|
5451
5494
|
}
|
|
5452
5495
|
/** @todo needed for portable model */
|
|
5453
5496
|
setAttributes(attributes) {
|
|
5454
5497
|
for (const [name, buffer] of Object.entries(attributes)) {
|
|
5455
|
-
const webglBuffer = (0,
|
|
5498
|
+
const webglBuffer = (0, import_api24.cast)(buffer);
|
|
5456
5499
|
const attribute = getAttributeLayout(this.layout, name);
|
|
5457
5500
|
if (!attribute) {
|
|
5458
|
-
|
|
5501
|
+
import_api24.log.warn(`Ignoring buffer supplied for unknown attribute "${name}" in pipeline "${this.id}" (buffer "${buffer.id}")`)();
|
|
5459
5502
|
continue;
|
|
5460
5503
|
}
|
|
5461
|
-
const decoded = (0,
|
|
5504
|
+
const decoded = (0, import_api24.decodeVertexFormat)(attribute.format);
|
|
5462
5505
|
const { type: typeString, components: size, byteLength: stride, normalized, integer } = decoded;
|
|
5463
5506
|
const divisor = attribute.stepMode === "instance" ? 1 : 0;
|
|
5464
5507
|
const type = getWebGLDataType(typeString);
|
|
@@ -5483,11 +5526,12 @@ var WEBGLRenderPipeline = class extends import_api23.RenderPipeline {
|
|
|
5483
5526
|
for (const [name, value] of Object.entries(attributes)) {
|
|
5484
5527
|
const attribute = getAttributeLayout(this.layout, name);
|
|
5485
5528
|
if (!attribute) {
|
|
5486
|
-
|
|
5529
|
+
import_api24.log.warn(`Ignoring constant value supplied for unknown attribute "${name}" in pipeline "${this.id}"`)();
|
|
5487
5530
|
continue;
|
|
5488
5531
|
}
|
|
5489
5532
|
this.vertexArrayObject.setConstant(attribute.location, value);
|
|
5490
5533
|
}
|
|
5534
|
+
Object.assign(this.constantAttributes, attributes);
|
|
5491
5535
|
}
|
|
5492
5536
|
/**
|
|
5493
5537
|
* Bindings include: textures, samplers and uniform buffers
|
|
@@ -5497,11 +5541,11 @@ var WEBGLRenderPipeline = class extends import_api23.RenderPipeline {
|
|
|
5497
5541
|
for (const [name, value] of Object.entries(bindings)) {
|
|
5498
5542
|
const binding = this.layout.bindings.find((binding2) => binding2.name === name);
|
|
5499
5543
|
if (!binding) {
|
|
5500
|
-
|
|
5544
|
+
import_api24.log.warn(`Unknown binding ${name} in render pipeline ${this.id}`)();
|
|
5501
5545
|
continue;
|
|
5502
5546
|
}
|
|
5503
5547
|
if (!value) {
|
|
5504
|
-
|
|
5548
|
+
import_api24.log.warn(`Unsetting binding ${name} in render pipeline ${this.id}`)();
|
|
5505
5549
|
}
|
|
5506
5550
|
switch (binding.type) {
|
|
5507
5551
|
case "uniform":
|
|
@@ -5515,7 +5559,7 @@ var WEBGLRenderPipeline = class extends import_api23.RenderPipeline {
|
|
|
5515
5559
|
}
|
|
5516
5560
|
break;
|
|
5517
5561
|
case "sampler":
|
|
5518
|
-
|
|
5562
|
+
import_api24.log.warn(`Ignoring sampler ${name}`)();
|
|
5519
5563
|
break;
|
|
5520
5564
|
default:
|
|
5521
5565
|
throw new Error(binding.type);
|
|
@@ -5544,7 +5588,7 @@ var WEBGLRenderPipeline = class extends import_api23.RenderPipeline {
|
|
|
5544
5588
|
} = options;
|
|
5545
5589
|
const drawMode = getDrawMode(this.props.topology);
|
|
5546
5590
|
const isIndexed = Boolean(this._indexBuffer);
|
|
5547
|
-
const indexType = (
|
|
5591
|
+
const indexType = (_a = this._indexBuffer) == null ? void 0 : _a.glIndexType;
|
|
5548
5592
|
const isInstanced = Number(options.instanceCount) > 0;
|
|
5549
5593
|
if (!this._areTexturesRenderable() || options.vertexCount === 0) {
|
|
5550
5594
|
return false;
|
|
@@ -5558,6 +5602,7 @@ var WEBGLRenderPipeline = class extends import_api23.RenderPipeline {
|
|
|
5558
5602
|
}
|
|
5559
5603
|
this._applyBindings();
|
|
5560
5604
|
this._applyUniforms();
|
|
5605
|
+
this._applyConstantAttributes();
|
|
5561
5606
|
const webglRenderPass = renderPass;
|
|
5562
5607
|
withDeviceParameters(this.device, this.props.parameters, () => {
|
|
5563
5608
|
withGLParameters(this.device, webglRenderPass.glParameters, () => {
|
|
@@ -5592,10 +5637,10 @@ var WEBGLRenderPipeline = class extends import_api23.RenderPipeline {
|
|
|
5592
5637
|
const { gl: gl2 } = this.device;
|
|
5593
5638
|
gl2.attachShader(this.handle, this.vs.handle);
|
|
5594
5639
|
gl2.attachShader(this.handle, this.fs.handle);
|
|
5595
|
-
|
|
5640
|
+
import_api24.log.time(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
|
|
5596
5641
|
gl2.linkProgram(this.handle);
|
|
5597
|
-
|
|
5598
|
-
if (gl2.debug ||
|
|
5642
|
+
import_api24.log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
|
|
5643
|
+
if (gl2.debug || import_api24.log.level > 0) {
|
|
5599
5644
|
const linked = gl2.getProgramParameter(this.handle, gl2.LINK_STATUS);
|
|
5600
5645
|
if (!linked) {
|
|
5601
5646
|
throw new Error(`Error linking: ${gl2.getProgramInfoLog(this.handle)}`);
|
|
@@ -5688,6 +5733,21 @@ var WEBGLRenderPipeline = class extends import_api23.RenderPipeline {
|
|
|
5688
5733
|
}
|
|
5689
5734
|
}
|
|
5690
5735
|
}
|
|
5736
|
+
/**
|
|
5737
|
+
* Constant attributes are only supported in WebGL, not in WebGPU
|
|
5738
|
+
* Any attribute that is disabled in the current vertex array object
|
|
5739
|
+
* is read from the context's global constant value for that attribute location.
|
|
5740
|
+
*/
|
|
5741
|
+
_applyConstantAttributes() {
|
|
5742
|
+
for (const [name, value] of Object.entries(this.constantAttributes)) {
|
|
5743
|
+
const attribute = getAttributeLayout(this.layout, name);
|
|
5744
|
+
if (!attribute) {
|
|
5745
|
+
import_api24.log.warn(`Ignoring constant value supplied for unknown attribute "${name}" in pipeline "${this.id}"`)();
|
|
5746
|
+
continue;
|
|
5747
|
+
}
|
|
5748
|
+
this.vertexArrayObject.setConstant(attribute.location, value);
|
|
5749
|
+
}
|
|
5750
|
+
}
|
|
5691
5751
|
};
|
|
5692
5752
|
function getDrawMode(topology) {
|
|
5693
5753
|
switch (topology) {
|
|
@@ -5734,15 +5794,15 @@ function getAttributeLayout(layout, name) {
|
|
|
5734
5794
|
}
|
|
5735
5795
|
|
|
5736
5796
|
// src/adapter/resources/webgl-command-encoder.ts
|
|
5737
|
-
var
|
|
5797
|
+
var import_api26 = require("@luma.gl/api");
|
|
5738
5798
|
|
|
5739
5799
|
// src/adapter/resources/webgl-command-buffer.ts
|
|
5740
|
-
var
|
|
5800
|
+
var import_api25 = require("@luma.gl/api");
|
|
5741
5801
|
var import_constants26 = require("@luma.gl/constants");
|
|
5742
5802
|
function cast3(value) {
|
|
5743
5803
|
return value;
|
|
5744
5804
|
}
|
|
5745
|
-
var WEBGLCommandBuffer = class extends
|
|
5805
|
+
var WEBGLCommandBuffer = class extends import_api25.CommandBuffer {
|
|
5746
5806
|
constructor(device) {
|
|
5747
5807
|
super({});
|
|
5748
5808
|
this.commands = [];
|
|
@@ -5920,7 +5980,7 @@ function _copyTextureToTexture(device, options) {
|
|
|
5920
5980
|
return texture;
|
|
5921
5981
|
}
|
|
5922
5982
|
function getFramebuffer(source) {
|
|
5923
|
-
if (source instanceof
|
|
5983
|
+
if (source instanceof import_api25.Texture) {
|
|
5924
5984
|
const { width, height, id } = source;
|
|
5925
5985
|
const framebuffer = source.device.createFramebuffer({
|
|
5926
5986
|
id: `framebuffer-for-${id}`,
|
|
@@ -5934,7 +5994,7 @@ function getFramebuffer(source) {
|
|
|
5934
5994
|
}
|
|
5935
5995
|
|
|
5936
5996
|
// src/adapter/resources/webgl-command-encoder.ts
|
|
5937
|
-
var WEBGLCommandEncoder = class extends
|
|
5997
|
+
var WEBGLCommandEncoder = class extends import_api26.CommandEncoder {
|
|
5938
5998
|
constructor(device, props) {
|
|
5939
5999
|
super(props);
|
|
5940
6000
|
this.device = device;
|
|
@@ -5978,13 +6038,13 @@ var WEBGLCommandEncoder = class extends import_api25.CommandEncoder {
|
|
|
5978
6038
|
|
|
5979
6039
|
// src/adapter/webgl-device.ts
|
|
5980
6040
|
var LOG_LEVEL2 = 1;
|
|
5981
|
-
var _WebGLDevice = class extends
|
|
6041
|
+
var _WebGLDevice = class extends import_api27.Device {
|
|
5982
6042
|
//
|
|
5983
6043
|
// Public API
|
|
5984
6044
|
//
|
|
5985
6045
|
constructor(props) {
|
|
5986
6046
|
var _a;
|
|
5987
|
-
super(__spreadProps(__spreadValues({}, props), { id: props.id || (0,
|
|
6047
|
+
super(__spreadProps(__spreadValues({}, props), { id: props.id || (0, import_api27.uid)("webgl-device") }));
|
|
5988
6048
|
this.renderPass = null;
|
|
5989
6049
|
/** WebGL2 typed context. Need to check isWebGL2 or isWebGL1 before using. */
|
|
5990
6050
|
this.gl2 = null;
|
|
@@ -6010,8 +6070,8 @@ var _WebGLDevice = class extends import_api26.Device {
|
|
|
6010
6070
|
});
|
|
6011
6071
|
};
|
|
6012
6072
|
let gl2 = props.gl || null;
|
|
6013
|
-
gl2 = gl2 || ((0,
|
|
6014
|
-
gl2 = gl2 || (!(0,
|
|
6073
|
+
gl2 = gl2 || ((0, import_env3.isBrowser)() ? createBrowserContext(this.canvasContext.canvas, __spreadProps(__spreadValues({}, props), { onContextLost })) : null);
|
|
6074
|
+
gl2 = gl2 || (!(0, import_env3.isBrowser)() ? createHeadlessContext(__spreadProps(__spreadValues({}, props), { onContextLost })) : null);
|
|
6015
6075
|
if (!gl2) {
|
|
6016
6076
|
throw new Error("WebGL context creation failed");
|
|
6017
6077
|
}
|
|
@@ -6028,22 +6088,22 @@ var _WebGLDevice = class extends import_api26.Device {
|
|
|
6028
6088
|
trackContextState(this.gl, {
|
|
6029
6089
|
enable: enable2,
|
|
6030
6090
|
copyState,
|
|
6031
|
-
log: (...args) =>
|
|
6091
|
+
log: (...args) => import_api27.log.log(1, ...args)()
|
|
6032
6092
|
});
|
|
6033
|
-
if ((0,
|
|
6093
|
+
if ((0, import_env3.isBrowser)() && props.debug) {
|
|
6034
6094
|
this.gl = makeDebugContext(this.gl, __spreadProps(__spreadValues({}, props), { webgl2: this.isWebGL2, throwOnError: true }));
|
|
6035
6095
|
this.gl2 = this.gl;
|
|
6036
6096
|
this.debug = true;
|
|
6037
|
-
|
|
6038
|
-
|
|
6097
|
+
import_api27.log.level = Math.max(import_api27.log.level, 1);
|
|
6098
|
+
import_api27.log.warn("WebGL debug mode activated. Performance reduced.")();
|
|
6039
6099
|
}
|
|
6040
|
-
if ((0,
|
|
6100
|
+
if ((0, import_env3.isBrowser)() && props.spector) {
|
|
6041
6101
|
const canvas = this.handle.canvas || props.canvas;
|
|
6042
6102
|
this.spector = initializeSpectorJS(__spreadProps(__spreadValues({}, this.props), { canvas }));
|
|
6043
6103
|
}
|
|
6044
6104
|
const message2 = `Created ${this.info.type}${this.debug ? " debug" : ""} context: ${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;
|
|
6045
|
-
|
|
6046
|
-
|
|
6105
|
+
import_api27.log.probe(LOG_LEVEL2, message2)();
|
|
6106
|
+
import_api27.log.groupEnd(LOG_LEVEL2)();
|
|
6047
6107
|
}
|
|
6048
6108
|
static isSupported() {
|
|
6049
6109
|
return typeof WebGLRenderingContext !== "undefined" || isHeadlessGLRegistered();
|
|
@@ -6069,7 +6129,7 @@ var _WebGLDevice = class extends import_api26.Device {
|
|
|
6069
6129
|
if (gl2 instanceof _WebGLDevice) {
|
|
6070
6130
|
return gl2;
|
|
6071
6131
|
}
|
|
6072
|
-
if ((gl2 == null ? void 0 : gl2.device) instanceof
|
|
6132
|
+
if ((gl2 == null ? void 0 : gl2.device) instanceof import_api27.Device) {
|
|
6073
6133
|
return gl2.device;
|
|
6074
6134
|
}
|
|
6075
6135
|
if (!isWebGL3(gl2)) {
|
|
@@ -6079,17 +6139,18 @@ var _WebGLDevice = class extends import_api26.Device {
|
|
|
6079
6139
|
}
|
|
6080
6140
|
static create() {
|
|
6081
6141
|
return __async(this, arguments, function* (props = {}) {
|
|
6082
|
-
|
|
6142
|
+
import_api27.log.groupCollapsed(LOG_LEVEL2, "WebGLDevice created");
|
|
6083
6143
|
if (typeof props.canvas === "string") {
|
|
6084
|
-
yield
|
|
6144
|
+
yield import_api27.CanvasContext.pageLoaded;
|
|
6085
6145
|
}
|
|
6086
|
-
if (props.debug) {
|
|
6146
|
+
if (import_api27.log.get("debug") || props.debug) {
|
|
6087
6147
|
yield loadWebGLDeveloperTools();
|
|
6088
6148
|
}
|
|
6089
|
-
|
|
6149
|
+
const { spector: spector2 } = props;
|
|
6150
|
+
if (import_api27.log.get("spector") || spector2) {
|
|
6090
6151
|
yield loadSpectorJS();
|
|
6091
6152
|
}
|
|
6092
|
-
|
|
6153
|
+
import_api27.log.probe(LOG_LEVEL2 + 1, "DOM is loaded")();
|
|
6093
6154
|
if (props.gl && props.gl.device) {
|
|
6094
6155
|
return _WebGLDevice.attach(props.gl);
|
|
6095
6156
|
}
|
|
@@ -6259,7 +6320,7 @@ function isWebGL22(gl2) {
|
|
|
6259
6320
|
}
|
|
6260
6321
|
|
|
6261
6322
|
// src/classic/clear.ts
|
|
6262
|
-
var
|
|
6323
|
+
var import_api28 = require("@luma.gl/api");
|
|
6263
6324
|
var GL_DEPTH_BUFFER_BIT2 = 256;
|
|
6264
6325
|
var GL_STENCIL_BUFFER_BIT2 = 1024;
|
|
6265
6326
|
var GL_COLOR_BUFFER_BIT2 = 16384;
|
|
@@ -6290,18 +6351,18 @@ function clear(gl2, options) {
|
|
|
6290
6351
|
parameters.clearStencil = depth;
|
|
6291
6352
|
}
|
|
6292
6353
|
}
|
|
6293
|
-
(0,
|
|
6354
|
+
(0, import_api28.assert)(clearFlags !== 0, ERR_ARGUMENTS);
|
|
6294
6355
|
withParameters(device.gl, parameters, () => {
|
|
6295
6356
|
device.gl.clear(clearFlags);
|
|
6296
6357
|
});
|
|
6297
6358
|
}
|
|
6298
6359
|
|
|
6299
6360
|
// src/classic/copy-and-blit.ts
|
|
6300
|
-
var
|
|
6361
|
+
var import_api30 = require("@luma.gl/api");
|
|
6301
6362
|
var import_constants28 = require("@luma.gl/constants");
|
|
6302
6363
|
|
|
6303
6364
|
// src/classic/format-utils.ts
|
|
6304
|
-
var
|
|
6365
|
+
var import_api29 = require("@luma.gl/api");
|
|
6305
6366
|
var import_constants27 = require("@luma.gl/constants");
|
|
6306
6367
|
function glFormatToComponents(format) {
|
|
6307
6368
|
switch (format) {
|
|
@@ -6319,7 +6380,7 @@ function glFormatToComponents(format) {
|
|
|
6319
6380
|
case import_constants27.GL.RGBA32F:
|
|
6320
6381
|
return 4;
|
|
6321
6382
|
default:
|
|
6322
|
-
(0,
|
|
6383
|
+
(0, import_api29.assert)(false);
|
|
6323
6384
|
return 0;
|
|
6324
6385
|
}
|
|
6325
6386
|
}
|
|
@@ -6334,7 +6395,7 @@ function glTypeToBytes(type) {
|
|
|
6334
6395
|
case import_constants27.GL.FLOAT:
|
|
6335
6396
|
return 4;
|
|
6336
6397
|
default:
|
|
6337
|
-
(0,
|
|
6398
|
+
(0, import_api29.assert)(false);
|
|
6338
6399
|
return 0;
|
|
6339
6400
|
}
|
|
6340
6401
|
}
|
|
@@ -6352,7 +6413,7 @@ function readPixelsToArray(source, options) {
|
|
|
6352
6413
|
sourceType
|
|
6353
6414
|
} = options || {};
|
|
6354
6415
|
const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
|
|
6355
|
-
(0,
|
|
6416
|
+
(0, import_api30.assert)(framebuffer);
|
|
6356
6417
|
const { gl: gl2, handle } = framebuffer;
|
|
6357
6418
|
sourceWidth = sourceWidth || framebuffer.width;
|
|
6358
6419
|
sourceHeight = sourceHeight || framebuffer.height;
|
|
@@ -6375,7 +6436,7 @@ function readPixelsToBuffer(source, options) {
|
|
|
6375
6436
|
const { sourceX = 0, sourceY = 0, sourceFormat = import_constants28.GL.RGBA, targetByteOffset = 0 } = options || {};
|
|
6376
6437
|
let { target, sourceWidth, sourceHeight, sourceType } = options || {};
|
|
6377
6438
|
const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
|
|
6378
|
-
(0,
|
|
6439
|
+
(0, import_api30.assert)(framebuffer);
|
|
6379
6440
|
sourceWidth = sourceWidth || framebuffer.width;
|
|
6380
6441
|
sourceHeight = sourceHeight || framebuffer.height;
|
|
6381
6442
|
const webglFramebuffer = framebuffer;
|
|
@@ -6387,7 +6448,7 @@ function readPixelsToBuffer(source, options) {
|
|
|
6387
6448
|
const byteLength = targetByteOffset + sourceWidth * sourceHeight * components * byteCount;
|
|
6388
6449
|
target = new BufferWithAccessor(gl2, { byteLength, accessor: { type: sourceType, size: components } });
|
|
6389
6450
|
}
|
|
6390
|
-
target.bind({
|
|
6451
|
+
target.bind({ glTarget: import_constants28.GL.PIXEL_PACK_BUFFER });
|
|
6391
6452
|
withParameters(gl2, { framebuffer }, () => {
|
|
6392
6453
|
gl2.readPixels(
|
|
6393
6454
|
sourceX,
|
|
@@ -6399,7 +6460,7 @@ function readPixelsToBuffer(source, options) {
|
|
|
6399
6460
|
targetByteOffset
|
|
6400
6461
|
);
|
|
6401
6462
|
});
|
|
6402
|
-
target.unbind({
|
|
6463
|
+
target.unbind({ glTarget: import_constants28.GL.PIXEL_PACK_BUFFER });
|
|
6403
6464
|
if (deleteFramebuffer) {
|
|
6404
6465
|
framebuffer.destroy();
|
|
6405
6466
|
}
|
|
@@ -6423,7 +6484,7 @@ function copyToTexture(source, target, options) {
|
|
|
6423
6484
|
// defaults to target height
|
|
6424
6485
|
} = options || {};
|
|
6425
6486
|
const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
|
|
6426
|
-
(0,
|
|
6487
|
+
(0, import_api30.assert)(framebuffer);
|
|
6427
6488
|
const webglFramebuffer = framebuffer;
|
|
6428
6489
|
const { device, handle } = webglFramebuffer;
|
|
6429
6490
|
const isSubCopy = typeof targetX !== "undefined" || typeof targetY !== "undefined" || typeof targetZ !== "undefined";
|
|
@@ -6431,10 +6492,10 @@ function copyToTexture(source, target, options) {
|
|
|
6431
6492
|
targetY = targetY || 0;
|
|
6432
6493
|
targetZ = targetZ || 0;
|
|
6433
6494
|
const prevHandle2 = device.gl.bindFramebuffer(import_constants28.GL.FRAMEBUFFER, handle);
|
|
6434
|
-
(0,
|
|
6495
|
+
(0, import_api30.assert)(target);
|
|
6435
6496
|
let texture = null;
|
|
6436
6497
|
let textureTarget;
|
|
6437
|
-
if (target instanceof
|
|
6498
|
+
if (target instanceof import_api30.Texture) {
|
|
6438
6499
|
texture = target;
|
|
6439
6500
|
width = Number.isFinite(width) ? width : texture.width;
|
|
6440
6501
|
height = Number.isFinite(height) ? height : texture.height;
|
|
@@ -6498,7 +6559,7 @@ function copyToTexture(source, target, options) {
|
|
|
6498
6559
|
return texture;
|
|
6499
6560
|
}
|
|
6500
6561
|
function getFramebuffer2(source) {
|
|
6501
|
-
if (!(source instanceof
|
|
6562
|
+
if (!(source instanceof import_api30.Framebuffer)) {
|
|
6502
6563
|
return { framebuffer: toFramebuffer(source), deleteFramebuffer: true };
|
|
6503
6564
|
}
|
|
6504
6565
|
return { framebuffer: source, deleteFramebuffer: false };
|