@luma.gl/webgl 9.0.0-alpha.52 → 9.0.0-alpha.54
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/sampler-parameters.d.ts +2 -8
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +12 -107
- package/dist/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.js +21 -3
- package/dist/adapter/device-helpers/get-device-info.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts +4 -7
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +13 -19
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +2 -3
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +9 -7
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/context/polyfill/polyfill-context.js +5 -2
- package/dist/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/dist.dev.js +87 -65
- package/dist/index.cjs +161 -148
- package/dist.min.js +38 -38
- package/package.json +5 -5
- package/src/adapter/converters/sampler-parameters.ts +26 -151
- package/src/adapter/device-helpers/get-device-info.ts +24 -5
- package/src/adapter/resources/webgl-buffer.ts +46 -56
- package/src/adapter/resources/webgl-texture.ts +3 -4
- package/src/adapter/webgl-device.ts +13 -10
- package/src/context/polyfill/polyfill-context.ts +6 -2
package/dist/index.cjs
CHANGED
|
@@ -100,7 +100,7 @@ function createHeadlessContext(options) {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
// src/adapter/webgl-device.ts
|
|
103
|
-
var
|
|
103
|
+
var import_core26 = require("@luma.gl/core");
|
|
104
104
|
var import_env3 = require("@probe.gl/env");
|
|
105
105
|
|
|
106
106
|
// src/context/polyfill/polyfill-context.ts
|
|
@@ -692,9 +692,12 @@ function polyfillContext(gl) {
|
|
|
692
692
|
function initializeExtensions(gl) {
|
|
693
693
|
const contextState = getContextData(gl);
|
|
694
694
|
const EXTENSIONS = gl.getSupportedExtensions() || [];
|
|
695
|
+
const IGNORE_EXTENSIONS = ["WEBGL_polygon_mode"];
|
|
695
696
|
for (const extensionName of EXTENSIONS) {
|
|
696
|
-
|
|
697
|
-
|
|
697
|
+
if (!IGNORE_EXTENSIONS.includes(extensionName)) {
|
|
698
|
+
const extension = gl.getExtension(extensionName);
|
|
699
|
+
contextState._extensions[extensionName] = extension;
|
|
700
|
+
}
|
|
698
701
|
}
|
|
699
702
|
}
|
|
700
703
|
function installPolyfills(gl, polyfills) {
|
|
@@ -1526,11 +1529,13 @@ function getDeviceInfo(gl) {
|
|
|
1526
1529
|
const version = gl.getParameter(import_constants4.GL.VERSION);
|
|
1527
1530
|
const gpu = identifyGPUVendor(vendor, renderer);
|
|
1528
1531
|
const gpuBackend = identifyGPUBackend(vendor, renderer);
|
|
1532
|
+
const gpuType = identifyGPUType(vendor, renderer);
|
|
1529
1533
|
const shadingLanguage = "glsl";
|
|
1530
1534
|
const shadingLanguageVersion = isWebGL2(gl) ? 300 : 100;
|
|
1531
1535
|
return {
|
|
1532
1536
|
type: isWebGL2(gl) ? "webgl2" : "webgl",
|
|
1533
1537
|
gpu,
|
|
1538
|
+
gpuType,
|
|
1534
1539
|
gpuBackend,
|
|
1535
1540
|
vendor,
|
|
1536
1541
|
renderer,
|
|
@@ -1558,14 +1563,30 @@ function identifyGPUVendor(vendor, renderer) {
|
|
|
1558
1563
|
return "unknown";
|
|
1559
1564
|
}
|
|
1560
1565
|
function identifyGPUBackend(vendor, renderer) {
|
|
1561
|
-
if (/ANGLE/i.exec(vendor) || /ANGLE/i.exec(renderer)) {
|
|
1562
|
-
return "angle";
|
|
1563
|
-
}
|
|
1564
1566
|
if (/Metal/i.exec(vendor) || /Metal/i.exec(renderer)) {
|
|
1565
1567
|
return "metal";
|
|
1566
1568
|
}
|
|
1569
|
+
if (/ANGLE/i.exec(vendor) || /ANGLE/i.exec(renderer)) {
|
|
1570
|
+
return "opengl";
|
|
1571
|
+
}
|
|
1567
1572
|
return "unknown";
|
|
1568
1573
|
}
|
|
1574
|
+
function identifyGPUType(vendor, renderer) {
|
|
1575
|
+
if (/SwiftShader/i.exec(vendor) || /SwiftShader/i.exec(renderer)) {
|
|
1576
|
+
return "cpu";
|
|
1577
|
+
}
|
|
1578
|
+
const gpuVendor = identifyGPUVendor(vendor, renderer);
|
|
1579
|
+
switch (gpuVendor) {
|
|
1580
|
+
case "intel":
|
|
1581
|
+
return "integrated";
|
|
1582
|
+
case "software":
|
|
1583
|
+
return "cpu";
|
|
1584
|
+
case "unknown":
|
|
1585
|
+
return "unknown";
|
|
1586
|
+
default:
|
|
1587
|
+
return "discrete";
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1569
1590
|
|
|
1570
1591
|
// src/adapter/device-helpers/is-old-ie.ts
|
|
1571
1592
|
function isOldIE(opts = {}) {
|
|
@@ -2268,15 +2289,14 @@ function getWebGLLimits(gl) {
|
|
|
2268
2289
|
}
|
|
2269
2290
|
|
|
2270
2291
|
// src/adapter/webgl-canvas-context.ts
|
|
2271
|
-
var
|
|
2292
|
+
var import_core14 = require("@luma.gl/core");
|
|
2272
2293
|
|
|
2273
2294
|
// src/adapter/resources/webgl-framebuffer.ts
|
|
2274
|
-
var
|
|
2295
|
+
var import_core13 = require("@luma.gl/core");
|
|
2275
2296
|
var import_constants14 = require("@luma.gl/constants");
|
|
2276
2297
|
|
|
2277
2298
|
// src/adapter/resources/webgl-texture.ts
|
|
2278
2299
|
var import_core9 = require("@luma.gl/core");
|
|
2279
|
-
var import_core10 = require("@luma.gl/core");
|
|
2280
2300
|
var import_constants12 = require("@luma.gl/constants");
|
|
2281
2301
|
|
|
2282
2302
|
// src/context/state-tracker/with-parameters.ts
|
|
@@ -2512,6 +2532,15 @@ function convertSamplerParametersToWebGL(props) {
|
|
|
2512
2532
|
}
|
|
2513
2533
|
return params;
|
|
2514
2534
|
}
|
|
2535
|
+
function updateSamplerParametersForNPOT(parameters) {
|
|
2536
|
+
const newParameters = { ...parameters };
|
|
2537
|
+
if (parameters[import_constants9.GL.TEXTURE_MIN_FILTER] !== import_constants9.GL.NEAREST) {
|
|
2538
|
+
newParameters[import_constants9.GL.TEXTURE_MIN_FILTER] = import_constants9.GL.LINEAR;
|
|
2539
|
+
}
|
|
2540
|
+
newParameters[import_constants9.GL.TEXTURE_WRAP_S] = import_constants9.GL.CLAMP_TO_EDGE;
|
|
2541
|
+
newParameters[import_constants9.GL.TEXTURE_WRAP_T] = import_constants9.GL.CLAMP_TO_EDGE;
|
|
2542
|
+
return newParameters;
|
|
2543
|
+
}
|
|
2515
2544
|
function convertAddressMode(addressMode) {
|
|
2516
2545
|
switch (addressMode) {
|
|
2517
2546
|
case "clamp-to-edge":
|
|
@@ -2541,20 +2570,10 @@ function convertMinFilterMode(minFilter, mipmapFilter) {
|
|
|
2541
2570
|
return mipmapFilter === "nearest" ? import_constants9.GL.LINEAR_MIPMAP_NEAREST : import_constants9.GL.LINEAR_MIPMAP_LINEAR;
|
|
2542
2571
|
}
|
|
2543
2572
|
}
|
|
2544
|
-
function updateSamplerParametersForNPOT(parameters) {
|
|
2545
|
-
const newParameters = { ...parameters };
|
|
2546
|
-
if (parameters[import_constants9.GL.TEXTURE_MIN_FILTER] !== import_constants9.GL.NEAREST) {
|
|
2547
|
-
newParameters[import_constants9.GL.TEXTURE_MIN_FILTER] = import_constants9.GL.LINEAR;
|
|
2548
|
-
}
|
|
2549
|
-
newParameters[import_constants9.GL.TEXTURE_WRAP_S] = import_constants9.GL.CLAMP_TO_EDGE;
|
|
2550
|
-
newParameters[import_constants9.GL.TEXTURE_WRAP_T] = import_constants9.GL.CLAMP_TO_EDGE;
|
|
2551
|
-
return newParameters;
|
|
2552
|
-
}
|
|
2553
2573
|
|
|
2554
2574
|
// src/adapter/resources/webgl-buffer.ts
|
|
2555
2575
|
var import_core7 = require("@luma.gl/core");
|
|
2556
2576
|
var import_constants10 = require("@luma.gl/constants");
|
|
2557
|
-
var DEBUG_DATA_LENGTH = 10;
|
|
2558
2577
|
var WEBGLBuffer = class extends import_core7.Buffer {
|
|
2559
2578
|
device;
|
|
2560
2579
|
gl;
|
|
@@ -2570,8 +2589,6 @@ var WEBGLBuffer = class extends import_core7.Buffer {
|
|
|
2570
2589
|
byteLength;
|
|
2571
2590
|
/** Number of bytes used */
|
|
2572
2591
|
bytesUsed;
|
|
2573
|
-
/** A partial CPU-side copy of the data in this buffer, for debugging purposes */
|
|
2574
|
-
debugData = null;
|
|
2575
2592
|
constructor(device, props = {}) {
|
|
2576
2593
|
super(device, props);
|
|
2577
2594
|
this.device = device;
|
|
@@ -2583,7 +2600,6 @@ var WEBGLBuffer = class extends import_core7.Buffer {
|
|
|
2583
2600
|
this.glTarget = getWebGLTarget(this.props.usage);
|
|
2584
2601
|
this.glUsage = getWebGLUsage(this.props.usage);
|
|
2585
2602
|
this.glIndexType = this.props.indexType === "uint32" ? import_constants10.GL.UNSIGNED_INT : import_constants10.GL.UNSIGNED_SHORT;
|
|
2586
|
-
this.debugData = null;
|
|
2587
2603
|
if (props.data) {
|
|
2588
2604
|
this._initWithData(props.data, props.byteOffset, props.byteLength);
|
|
2589
2605
|
} else {
|
|
@@ -2593,17 +2609,15 @@ var WEBGLBuffer = class extends import_core7.Buffer {
|
|
|
2593
2609
|
// PRIVATE METHODS
|
|
2594
2610
|
/** Allocate a new buffer and initialize to contents of typed array */
|
|
2595
2611
|
_initWithData(data, byteOffset = 0, byteLength = data.byteLength + byteOffset) {
|
|
2596
|
-
|
|
2597
|
-
const glTarget = this._getWriteTarget();
|
|
2612
|
+
const glTarget = this.glTarget;
|
|
2598
2613
|
this.gl.bindBuffer(glTarget, this.handle);
|
|
2599
2614
|
this.gl.bufferData(glTarget, byteLength, this.glUsage);
|
|
2600
2615
|
this.gl.bufferSubData(glTarget, byteOffset, data);
|
|
2601
2616
|
this.gl.bindBuffer(glTarget, null);
|
|
2602
|
-
this.debugData = data.slice(0, DEBUG_DATA_LENGTH);
|
|
2603
2617
|
this.bytesUsed = byteLength;
|
|
2604
2618
|
this.byteLength = byteLength;
|
|
2619
|
+
this._setDebugData(data, byteOffset, byteLength);
|
|
2605
2620
|
this.trackAllocatedMemory(byteLength);
|
|
2606
|
-
return this;
|
|
2607
2621
|
}
|
|
2608
2622
|
// Allocate a GPU buffer of specified size.
|
|
2609
2623
|
_initWithByteLength(byteLength) {
|
|
@@ -2612,13 +2626,14 @@ var WEBGLBuffer = class extends import_core7.Buffer {
|
|
|
2612
2626
|
if (byteLength === 0) {
|
|
2613
2627
|
data = new Float32Array(0);
|
|
2614
2628
|
}
|
|
2615
|
-
const glTarget = this.
|
|
2629
|
+
const glTarget = this.glTarget;
|
|
2616
2630
|
this.gl.bindBuffer(glTarget, this.handle);
|
|
2617
2631
|
this.gl.bufferData(glTarget, data, this.glUsage);
|
|
2618
2632
|
this.gl.bindBuffer(glTarget, null);
|
|
2619
|
-
this.debugData = null;
|
|
2620
2633
|
this.bytesUsed = byteLength;
|
|
2621
2634
|
this.byteLength = byteLength;
|
|
2635
|
+
this._setDebugData(null, 0, byteLength);
|
|
2636
|
+
this.trackAllocatedMemory(byteLength);
|
|
2622
2637
|
return this;
|
|
2623
2638
|
}
|
|
2624
2639
|
destroy() {
|
|
@@ -2642,28 +2657,24 @@ var WEBGLBuffer = class extends import_core7.Buffer {
|
|
|
2642
2657
|
this.gl.bufferSubData(glTarget, byteOffset, data);
|
|
2643
2658
|
}
|
|
2644
2659
|
this.gl.bindBuffer(glTarget, null);
|
|
2660
|
+
this._setDebugData(data, byteOffset, data.byteLength);
|
|
2645
2661
|
}
|
|
2646
|
-
/**
|
|
2662
|
+
/** Asynchronously read data from the buffer */
|
|
2647
2663
|
async readAsync(byteOffset = 0, byteLength) {
|
|
2664
|
+
return this.readSyncWebGL2(byteOffset, byteLength);
|
|
2665
|
+
}
|
|
2666
|
+
/** Synchronously read data from the buffer. WebGL only. */
|
|
2667
|
+
readSyncWebGL2(byteOffset = 0, byteLength) {
|
|
2648
2668
|
this.device.assertWebGL2();
|
|
2649
|
-
byteLength = byteLength ?? this.byteLength;
|
|
2669
|
+
byteLength = byteLength ?? this.byteLength - byteOffset;
|
|
2650
2670
|
const data = new Uint8Array(byteLength);
|
|
2651
2671
|
const dstOffset = 0;
|
|
2652
2672
|
this.gl.bindBuffer(import_constants10.GL.COPY_READ_BUFFER, this.handle);
|
|
2653
2673
|
this.gl2.getBufferSubData(import_constants10.GL.COPY_READ_BUFFER, byteOffset, data, dstOffset, byteLength);
|
|
2654
2674
|
this.gl.bindBuffer(import_constants10.GL.COPY_READ_BUFFER, null);
|
|
2675
|
+
this._setDebugData(data, byteOffset, byteLength);
|
|
2655
2676
|
return data;
|
|
2656
2677
|
}
|
|
2657
|
-
// PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)
|
|
2658
|
-
_invalidateDebugData() {
|
|
2659
|
-
this.debugData = null;
|
|
2660
|
-
}
|
|
2661
|
-
_getWriteTarget() {
|
|
2662
|
-
return this.glTarget;
|
|
2663
|
-
}
|
|
2664
|
-
_getReadTarget() {
|
|
2665
|
-
return this.glTarget;
|
|
2666
|
-
}
|
|
2667
2678
|
};
|
|
2668
2679
|
function getWebGLTarget(usage) {
|
|
2669
2680
|
if (usage & import_core7.Buffer.INDEX) {
|
|
@@ -2743,7 +2754,7 @@ var DEFAULT_WEBGL_TEXTURE_PROPS = {
|
|
|
2743
2754
|
textureUnit: void 0,
|
|
2744
2755
|
target: void 0
|
|
2745
2756
|
};
|
|
2746
|
-
var _WEBGLTexture = class extends
|
|
2757
|
+
var _WEBGLTexture = class extends import_core9.Texture {
|
|
2747
2758
|
MAX_ATTRIBUTES;
|
|
2748
2759
|
device;
|
|
2749
2760
|
gl;
|
|
@@ -2777,7 +2788,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
2777
2788
|
constructor(device, props) {
|
|
2778
2789
|
var _a;
|
|
2779
2790
|
super(device, { ...DEFAULT_WEBGL_TEXTURE_PROPS, format: "rgba8unorm", ...props });
|
|
2780
|
-
this.device =
|
|
2791
|
+
this.device = device;
|
|
2781
2792
|
this.gl = this.device.gl;
|
|
2782
2793
|
this.gl2 = this.device.gl2;
|
|
2783
2794
|
this.handle = this.props.handle || this.gl.createTexture();
|
|
@@ -2786,7 +2797,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
2786
2797
|
this.target = getWebGLTextureTarget(this.props);
|
|
2787
2798
|
this.loaded = false;
|
|
2788
2799
|
if (typeof ((_a = this.props) == null ? void 0 : _a.data) === "string") {
|
|
2789
|
-
Object.assign(this.props, { data: (0,
|
|
2800
|
+
Object.assign(this.props, { data: (0, import_core9.loadImage)(this.props.data) });
|
|
2790
2801
|
}
|
|
2791
2802
|
this.initialize(this.props);
|
|
2792
2803
|
Object.seal(this);
|
|
@@ -2853,7 +2864,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
2853
2864
|
this.gl.bindTexture(this.target, this.handle);
|
|
2854
2865
|
}
|
|
2855
2866
|
if (mipmaps && this.device.isWebGL1 && isNPOT(this.width, this.height)) {
|
|
2856
|
-
|
|
2867
|
+
import_core9.log.warn(`texture: ${this} is Non-Power-Of-Two, disabling mipmaps`)();
|
|
2857
2868
|
mipmaps = false;
|
|
2858
2869
|
}
|
|
2859
2870
|
this.mipmaps = mipmaps;
|
|
@@ -2947,7 +2958,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
2947
2958
|
// Call to regenerate mipmaps after modifying texture(s)
|
|
2948
2959
|
generateMipmap(params = {}) {
|
|
2949
2960
|
if (this.device.isWebGL1 && isNPOT(this.width, this.height)) {
|
|
2950
|
-
|
|
2961
|
+
import_core9.log.warn(`texture: ${this} is Non-Power-Of-Two, disabling mipmaping`)();
|
|
2951
2962
|
return this;
|
|
2952
2963
|
}
|
|
2953
2964
|
this.mipmaps = true;
|
|
@@ -3095,7 +3106,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
3095
3106
|
}
|
|
3096
3107
|
break;
|
|
3097
3108
|
default:
|
|
3098
|
-
(0,
|
|
3109
|
+
(0, import_core9.assert)(false, "Unknown image data type");
|
|
3099
3110
|
}
|
|
3100
3111
|
});
|
|
3101
3112
|
if (data && data.byteLength) {
|
|
@@ -3137,7 +3148,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
3137
3148
|
width,
|
|
3138
3149
|
height
|
|
3139
3150
|
}));
|
|
3140
|
-
(0,
|
|
3151
|
+
(0, import_core9.assert)(this.depth === 1, "texSubImage not supported for 3D textures");
|
|
3141
3152
|
if (!data) {
|
|
3142
3153
|
data = pixels;
|
|
3143
3154
|
}
|
|
@@ -3181,7 +3192,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
3181
3192
|
* rendering can be faster.
|
|
3182
3193
|
*/
|
|
3183
3194
|
copyFramebuffer(opts = {}) {
|
|
3184
|
-
|
|
3195
|
+
import_core9.log.error(
|
|
3185
3196
|
"Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})"
|
|
3186
3197
|
)();
|
|
3187
3198
|
return null;
|
|
@@ -3255,12 +3266,12 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
3255
3266
|
} else {
|
|
3256
3267
|
size = { width, height };
|
|
3257
3268
|
}
|
|
3258
|
-
(0,
|
|
3259
|
-
(0,
|
|
3269
|
+
(0, import_core9.assert)(size, "Could not deduced texture size");
|
|
3270
|
+
(0, import_core9.assert)(
|
|
3260
3271
|
width === void 0 || size.width === width,
|
|
3261
3272
|
"Deduced texture width does not match supplied width"
|
|
3262
3273
|
);
|
|
3263
|
-
(0,
|
|
3274
|
+
(0, import_core9.assert)(
|
|
3264
3275
|
height === void 0 || size.height === height,
|
|
3265
3276
|
"Deduced texture height does not match supplied height"
|
|
3266
3277
|
);
|
|
@@ -3281,7 +3292,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
3281
3292
|
this.bind();
|
|
3282
3293
|
_WEBGLTexture.FACES.forEach((face, index) => {
|
|
3283
3294
|
if (resolvedFaces[index].length > 1 && this.props.mipmaps !== false) {
|
|
3284
|
-
|
|
3295
|
+
import_core9.log.warn(`${this.id} has mipmap and multiple LODs.`)();
|
|
3285
3296
|
}
|
|
3286
3297
|
resolvedFaces[index].forEach((image, lodLevel) => {
|
|
3287
3298
|
if (width && height) {
|
|
@@ -3464,21 +3475,21 @@ function isNPOT(width, height) {
|
|
|
3464
3475
|
if (!width || !height) {
|
|
3465
3476
|
return false;
|
|
3466
3477
|
}
|
|
3467
|
-
return !(0,
|
|
3478
|
+
return !(0, import_core9.isPowerOfTwo)(width) || !(0, import_core9.isPowerOfTwo)(height);
|
|
3468
3479
|
}
|
|
3469
3480
|
function logParameters(parameters) {
|
|
3470
|
-
|
|
3481
|
+
import_core9.log.log(1, "texture sampler parameters", parameters)();
|
|
3471
3482
|
}
|
|
3472
3483
|
|
|
3473
3484
|
// src/adapter/objects/webgl-renderbuffer.ts
|
|
3474
|
-
var
|
|
3485
|
+
var import_core12 = require("@luma.gl/core");
|
|
3475
3486
|
var import_constants13 = require("@luma.gl/constants");
|
|
3476
3487
|
|
|
3477
3488
|
// src/adapter/objects/webgl-resource.ts
|
|
3478
|
-
var
|
|
3489
|
+
var import_core11 = require("@luma.gl/core");
|
|
3479
3490
|
|
|
3480
3491
|
// src/adapter/objects/constants-to-keys.ts
|
|
3481
|
-
var
|
|
3492
|
+
var import_core10 = require("@luma.gl/core");
|
|
3482
3493
|
function getKeyValue(gl, name) {
|
|
3483
3494
|
if (typeof name !== "string") {
|
|
3484
3495
|
return name;
|
|
@@ -3489,13 +3500,13 @@ function getKeyValue(gl, name) {
|
|
|
3489
3500
|
}
|
|
3490
3501
|
name = name.replace(/^.*\./, "");
|
|
3491
3502
|
const value = gl[name];
|
|
3492
|
-
(0,
|
|
3503
|
+
(0, import_core10.assert)(value !== void 0, `Accessing undefined constant GL.${name}`);
|
|
3493
3504
|
return value;
|
|
3494
3505
|
}
|
|
3495
3506
|
|
|
3496
3507
|
// src/adapter/objects/webgl-resource.ts
|
|
3497
3508
|
var ERR_RESOURCE_METHOD_UNDEFINED = "Resource subclass must define virtual methods";
|
|
3498
|
-
var WebGLResource = class extends
|
|
3509
|
+
var WebGLResource = class extends import_core11.Resource {
|
|
3499
3510
|
device;
|
|
3500
3511
|
gl;
|
|
3501
3512
|
gl2;
|
|
@@ -3511,7 +3522,7 @@ var WebGLResource = class extends import_core12.Resource {
|
|
|
3511
3522
|
const { id } = props || {};
|
|
3512
3523
|
this.gl = gl;
|
|
3513
3524
|
this.gl2 = gl;
|
|
3514
|
-
this.id = id || (0,
|
|
3525
|
+
this.id = id || (0, import_core11.uid)(this.constructor.name);
|
|
3515
3526
|
this._handle = props == null ? void 0 : props.handle;
|
|
3516
3527
|
if (this._handle === void 0) {
|
|
3517
3528
|
this._handle = this._createHandle();
|
|
@@ -3563,7 +3574,7 @@ var WebGLResource = class extends import_core12.Resource {
|
|
|
3563
3574
|
*/
|
|
3564
3575
|
getParameter(pname, props = {}) {
|
|
3565
3576
|
pname = getKeyValue(this.gl, pname);
|
|
3566
|
-
(0,
|
|
3577
|
+
(0, import_core11.assert)(pname);
|
|
3567
3578
|
const parameters = this.constructor.PARAMETERS || {};
|
|
3568
3579
|
const parameter = parameters[pname];
|
|
3569
3580
|
if (parameter) {
|
|
@@ -3611,7 +3622,7 @@ var WebGLResource = class extends import_core12.Resource {
|
|
|
3611
3622
|
*/
|
|
3612
3623
|
setParameter(pname, value) {
|
|
3613
3624
|
pname = getKeyValue(this.gl, pname);
|
|
3614
|
-
(0,
|
|
3625
|
+
(0, import_core11.assert)(pname);
|
|
3615
3626
|
const parameters = this.constructor.PARAMETERS || {};
|
|
3616
3627
|
const parameter = parameters[pname];
|
|
3617
3628
|
if (parameter) {
|
|
@@ -3639,7 +3650,7 @@ var WebGLResource = class extends import_core12.Resource {
|
|
|
3639
3650
|
}
|
|
3640
3651
|
// Install stubs for removed methods
|
|
3641
3652
|
stubRemovedMethods(className, version, methodNames) {
|
|
3642
|
-
return (0,
|
|
3653
|
+
return (0, import_core11.stubRemovedMethods)(this, className, version, methodNames);
|
|
3643
3654
|
}
|
|
3644
3655
|
// PUBLIC VIRTUAL METHODS
|
|
3645
3656
|
initialize(props) {
|
|
@@ -3742,7 +3753,7 @@ var _WEBGLRenderbuffer = class extends WebGLResource {
|
|
|
3742
3753
|
/** Creates and initializes a renderbuffer object's data store */
|
|
3743
3754
|
_initialize(props) {
|
|
3744
3755
|
const { format, width, height, samples } = props;
|
|
3745
|
-
(0,
|
|
3756
|
+
(0, import_core12.assert)(format, "Needs format");
|
|
3746
3757
|
this.trackDeallocatedMemory();
|
|
3747
3758
|
this.gl.bindRenderbuffer(import_constants13.GL.RENDERBUFFER, this.handle);
|
|
3748
3759
|
if (samples !== 0 && this.device.isWebGL2) {
|
|
@@ -3780,7 +3791,7 @@ __publicField(WEBGLRenderbuffer, "defaultProps", {
|
|
|
3780
3791
|
});
|
|
3781
3792
|
|
|
3782
3793
|
// src/adapter/resources/webgl-framebuffer.ts
|
|
3783
|
-
var WEBGLFramebuffer = class extends
|
|
3794
|
+
var WEBGLFramebuffer = class extends import_core13.Framebuffer {
|
|
3784
3795
|
device;
|
|
3785
3796
|
gl;
|
|
3786
3797
|
handle;
|
|
@@ -3915,7 +3926,7 @@ var WEBGLFramebuffer = class extends import_core14.Framebuffer {
|
|
|
3915
3926
|
gl.framebufferTexture2D(import_constants14.GL.FRAMEBUFFER, attachment, import_constants14.GL.TEXTURE_2D, texture.handle, level);
|
|
3916
3927
|
break;
|
|
3917
3928
|
default:
|
|
3918
|
-
(0,
|
|
3929
|
+
(0, import_core13.assert)(false, "Illegal texture type");
|
|
3919
3930
|
}
|
|
3920
3931
|
gl.bindTexture(texture.target, null);
|
|
3921
3932
|
}
|
|
@@ -3943,7 +3954,7 @@ function _getFrameBufferStatus(status) {
|
|
|
3943
3954
|
}
|
|
3944
3955
|
|
|
3945
3956
|
// src/adapter/webgl-canvas-context.ts
|
|
3946
|
-
var WebGLCanvasContext = class extends
|
|
3957
|
+
var WebGLCanvasContext = class extends import_core14.CanvasContext {
|
|
3947
3958
|
device;
|
|
3948
3959
|
presentationSize;
|
|
3949
3960
|
_framebuffer = null;
|
|
@@ -3995,9 +4006,9 @@ var WebGLCanvasContext = class extends import_core15.CanvasContext {
|
|
|
3995
4006
|
};
|
|
3996
4007
|
|
|
3997
4008
|
// src/context/debug/spector.ts
|
|
3998
|
-
var
|
|
4009
|
+
var import_core15 = require("@luma.gl/core");
|
|
3999
4010
|
var DEFAULT_SPECTOR_PROPS = {
|
|
4000
|
-
spector:
|
|
4011
|
+
spector: import_core15.log.get("spector") || import_core15.log.get("inspect")
|
|
4001
4012
|
};
|
|
4002
4013
|
var SPECTOR_CDN_URL = "https://spectorcdn.babylonjs.com/spector.bundle.js";
|
|
4003
4014
|
var LOG_LEVEL = 1;
|
|
@@ -4006,9 +4017,9 @@ var initialized = false;
|
|
|
4006
4017
|
async function loadSpectorJS(props) {
|
|
4007
4018
|
if (!globalThis.SPECTOR) {
|
|
4008
4019
|
try {
|
|
4009
|
-
await (0,
|
|
4020
|
+
await (0, import_core15.loadScript)(SPECTOR_CDN_URL);
|
|
4010
4021
|
} catch (error2) {
|
|
4011
|
-
|
|
4022
|
+
import_core15.log.warn(String(error2));
|
|
4012
4023
|
}
|
|
4013
4024
|
}
|
|
4014
4025
|
}
|
|
@@ -4018,7 +4029,7 @@ function initializeSpectorJS(props) {
|
|
|
4018
4029
|
return null;
|
|
4019
4030
|
}
|
|
4020
4031
|
if (!spector && globalThis.SPECTOR) {
|
|
4021
|
-
|
|
4032
|
+
import_core15.log.probe(LOG_LEVEL, "SPECTOR found and initialized")();
|
|
4022
4033
|
spector = new globalThis.SPECTOR.Spector();
|
|
4023
4034
|
if (globalThis.luma) {
|
|
4024
4035
|
globalThis.luma.spector = spector;
|
|
@@ -4030,9 +4041,9 @@ function initializeSpectorJS(props) {
|
|
|
4030
4041
|
if (!initialized) {
|
|
4031
4042
|
initialized = true;
|
|
4032
4043
|
spector.spyCanvases();
|
|
4033
|
-
spector == null ? void 0 : spector.onCaptureStarted.add((capture) =>
|
|
4044
|
+
spector == null ? void 0 : spector.onCaptureStarted.add((capture) => import_core15.log.info("Spector capture started:", capture)());
|
|
4034
4045
|
spector == null ? void 0 : spector.onCapture.add((capture) => {
|
|
4035
|
-
|
|
4046
|
+
import_core15.log.info("Spector capture complete:", capture)();
|
|
4036
4047
|
spector == null ? void 0 : spector.getResultUI();
|
|
4037
4048
|
spector == null ? void 0 : spector.resultView.display();
|
|
4038
4049
|
spector == null ? void 0 : spector.resultView.addCapture(capture);
|
|
@@ -4044,7 +4055,7 @@ function initializeSpectorJS(props) {
|
|
|
4044
4055
|
}
|
|
4045
4056
|
spector == null ? void 0 : spector.startCapture(props == null ? void 0 : props.canvas, 500);
|
|
4046
4057
|
new Promise((resolve) => setTimeout(resolve, 2e3)).then((_) => {
|
|
4047
|
-
|
|
4058
|
+
import_core15.log.info("Spector capture stopped after 2 seconds")();
|
|
4048
4059
|
spector == null ? void 0 : spector.stopCapture();
|
|
4049
4060
|
});
|
|
4050
4061
|
}
|
|
@@ -4052,7 +4063,7 @@ function initializeSpectorJS(props) {
|
|
|
4052
4063
|
}
|
|
4053
4064
|
|
|
4054
4065
|
// src/context/debug/webgl-developer-tools.ts
|
|
4055
|
-
var
|
|
4066
|
+
var import_core16 = require("@luma.gl/core");
|
|
4056
4067
|
var import_constants15 = require("@luma.gl/constants");
|
|
4057
4068
|
var import_env = require("@probe.gl/env");
|
|
4058
4069
|
var WEBGL_DEBUG_CDN_URL = "https://unpkg.com/webgl-debug@2.0.1/index.js";
|
|
@@ -4064,7 +4075,7 @@ async function loadWebGLDeveloperTools() {
|
|
|
4064
4075
|
if ((0, import_env.isBrowser)() && !globalThis.WebGLDebugUtils) {
|
|
4065
4076
|
globalThis.global = globalThis.global || globalThis;
|
|
4066
4077
|
globalThis.global.module = {};
|
|
4067
|
-
await (0,
|
|
4078
|
+
await (0, import_core16.loadScript)(WEBGL_DEBUG_CDN_URL);
|
|
4068
4079
|
}
|
|
4069
4080
|
}
|
|
4070
4081
|
function makeDebugContext(gl, props = {}) {
|
|
@@ -4079,7 +4090,7 @@ function getRealContext(gl) {
|
|
|
4079
4090
|
}
|
|
4080
4091
|
function getDebugContext(gl, props) {
|
|
4081
4092
|
if (!globalThis.WebGLDebugUtils) {
|
|
4082
|
-
|
|
4093
|
+
import_core16.log.warn("webgl-debug not loaded")();
|
|
4083
4094
|
return gl;
|
|
4084
4095
|
}
|
|
4085
4096
|
const data = getContextData2(gl);
|
|
@@ -4119,7 +4130,7 @@ function onGLError(props, err, functionName, args) {
|
|
|
4119
4130
|
const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);
|
|
4120
4131
|
const glName = props.webgl2 ? "gl2" : "gl1";
|
|
4121
4132
|
const message2 = `${errorMessage} in ${glName}.${functionName}(${functionArgs})`;
|
|
4122
|
-
|
|
4133
|
+
import_core16.log.error(message2)();
|
|
4123
4134
|
debugger;
|
|
4124
4135
|
if (props.throwOnError) {
|
|
4125
4136
|
throw new Error(message2);
|
|
@@ -4127,9 +4138,9 @@ function onGLError(props, err, functionName, args) {
|
|
|
4127
4138
|
}
|
|
4128
4139
|
function onValidateGLFunc(props, functionName, functionArgs) {
|
|
4129
4140
|
let functionString = "";
|
|
4130
|
-
if (
|
|
4141
|
+
if (import_core16.log.level >= 1) {
|
|
4131
4142
|
functionString = getFunctionString(functionName, functionArgs);
|
|
4132
|
-
|
|
4143
|
+
import_core16.log.log(1, functionString)();
|
|
4133
4144
|
}
|
|
4134
4145
|
if (props.break && props.break.length > 0) {
|
|
4135
4146
|
functionString = functionString || getFunctionString(functionName, functionArgs);
|
|
@@ -4144,7 +4155,7 @@ function onValidateGLFunc(props, functionName, functionArgs) {
|
|
|
4144
4155
|
if (props.throwOnError) {
|
|
4145
4156
|
throw new Error(`Undefined argument: ${functionString}`);
|
|
4146
4157
|
} else {
|
|
4147
|
-
|
|
4158
|
+
import_core16.log.error(`Undefined argument: ${functionString}`)();
|
|
4148
4159
|
debugger;
|
|
4149
4160
|
}
|
|
4150
4161
|
}
|
|
@@ -4152,7 +4163,7 @@ function onValidateGLFunc(props, functionName, functionArgs) {
|
|
|
4152
4163
|
}
|
|
4153
4164
|
|
|
4154
4165
|
// src/adapter/resources/webgl-shader.ts
|
|
4155
|
-
var
|
|
4166
|
+
var import_core17 = require("@luma.gl/core");
|
|
4156
4167
|
var import_constants16 = require("@luma.gl/constants");
|
|
4157
4168
|
|
|
4158
4169
|
// src/adapter/helpers/parse-shader-compiler-log.ts
|
|
@@ -4200,7 +4211,7 @@ function getMessageType(messageType) {
|
|
|
4200
4211
|
}
|
|
4201
4212
|
|
|
4202
4213
|
// src/adapter/resources/webgl-shader.ts
|
|
4203
|
-
var WEBGLShader = class extends
|
|
4214
|
+
var WEBGLShader = class extends import_core17.Shader {
|
|
4204
4215
|
device;
|
|
4205
4216
|
handle;
|
|
4206
4217
|
constructor(device, props) {
|
|
@@ -4249,13 +4260,13 @@ ${source2}`;
|
|
|
4249
4260
|
};
|
|
4250
4261
|
|
|
4251
4262
|
// src/adapter/resources/webgl-render-pass.ts
|
|
4252
|
-
var
|
|
4263
|
+
var import_core18 = require("@luma.gl/core");
|
|
4253
4264
|
var import_constants17 = require("@luma.gl/constants");
|
|
4254
4265
|
var GL_DEPTH_BUFFER_BIT = 256;
|
|
4255
4266
|
var GL_STENCIL_BUFFER_BIT = 1024;
|
|
4256
4267
|
var GL_COLOR_BUFFER_BIT = 16384;
|
|
4257
4268
|
var GL_COLOR = 6144;
|
|
4258
|
-
var WEBGLRenderPass = class extends
|
|
4269
|
+
var WEBGLRenderPass = class extends import_core18.RenderPass {
|
|
4259
4270
|
device;
|
|
4260
4271
|
/** Parameters that should be applied before each draw call */
|
|
4261
4272
|
glParameters;
|
|
@@ -4382,15 +4393,15 @@ var WEBGLRenderPass = class extends import_core19.RenderPass {
|
|
|
4382
4393
|
};
|
|
4383
4394
|
|
|
4384
4395
|
// src/adapter/resources/webgl-render-pipeline.ts
|
|
4396
|
+
var import_core20 = require("@luma.gl/core");
|
|
4385
4397
|
var import_core21 = require("@luma.gl/core");
|
|
4386
|
-
var import_core22 = require("@luma.gl/core");
|
|
4387
4398
|
var import_constants24 = require("@luma.gl/constants");
|
|
4388
4399
|
|
|
4389
4400
|
// src/adapter/helpers/get-shader-layout.ts
|
|
4390
4401
|
var import_constants21 = require("@luma.gl/constants");
|
|
4391
4402
|
|
|
4392
4403
|
// src/classic/accessor.ts
|
|
4393
|
-
var
|
|
4404
|
+
var import_core19 = require("@luma.gl/core");
|
|
4394
4405
|
var import_constants19 = require("@luma.gl/constants");
|
|
4395
4406
|
|
|
4396
4407
|
// src/classic/typed-array-utils.ts
|
|
@@ -4475,7 +4486,7 @@ var Accessor = class {
|
|
|
4475
4486
|
return ArrayType.BYTES_PER_ELEMENT;
|
|
4476
4487
|
}
|
|
4477
4488
|
static getBytesPerVertex(accessor) {
|
|
4478
|
-
(0,
|
|
4489
|
+
(0, import_core19.assert)(accessor.size);
|
|
4479
4490
|
const ArrayType = getTypedArrayFromGLType(accessor.type || import_constants19.GL.FLOAT);
|
|
4480
4491
|
return ArrayType.BYTES_PER_ELEMENT * accessor.size;
|
|
4481
4492
|
}
|
|
@@ -4504,7 +4515,7 @@ var Accessor = class {
|
|
|
4504
4515
|
// PRIVATE
|
|
4505
4516
|
// eslint-disable-next-line complexity, max-statements
|
|
4506
4517
|
_assign(props = {}) {
|
|
4507
|
-
props = (0,
|
|
4518
|
+
props = (0, import_core19.checkProps)("Accessor", props, PROP_CHECKS);
|
|
4508
4519
|
if (props.type !== void 0) {
|
|
4509
4520
|
this.type = props.type;
|
|
4510
4521
|
if (props.type === import_constants19.GL.INT || props.type === import_constants19.GL.UNSIGNED_INT) {
|
|
@@ -5002,7 +5013,7 @@ function getGLPrimitive(topology) {
|
|
|
5002
5013
|
|
|
5003
5014
|
// src/adapter/resources/webgl-render-pipeline.ts
|
|
5004
5015
|
var LOG_PROGRAM_PERF_PRIORITY = 4;
|
|
5005
|
-
var WEBGLRenderPipeline = class extends
|
|
5016
|
+
var WEBGLRenderPipeline = class extends import_core20.RenderPipeline {
|
|
5006
5017
|
/** The WebGL device that created this render pipeline */
|
|
5007
5018
|
device;
|
|
5008
5019
|
/** Handle to underlying WebGL program */
|
|
@@ -5028,8 +5039,8 @@ var WEBGLRenderPipeline = class extends import_core21.RenderPipeline {
|
|
|
5028
5039
|
this.device = device;
|
|
5029
5040
|
this.handle = this.props.handle || this.device.gl.createProgram();
|
|
5030
5041
|
this.device.setSpectorMetadata(this.handle, { id: this.props.id });
|
|
5031
|
-
this.vs = (0,
|
|
5032
|
-
this.fs = (0,
|
|
5042
|
+
this.vs = (0, import_core20.cast)(props.vs);
|
|
5043
|
+
this.fs = (0, import_core20.cast)(props.fs);
|
|
5033
5044
|
const { varyings, bufferMode = import_constants24.GL.SEPARATE_ATTRIBS } = props;
|
|
5034
5045
|
if (varyings && varyings.length > 0) {
|
|
5035
5046
|
this.device.assertWebGL2();
|
|
@@ -5038,7 +5049,7 @@ var WEBGLRenderPipeline = class extends import_core21.RenderPipeline {
|
|
|
5038
5049
|
}
|
|
5039
5050
|
this._compileAndLink();
|
|
5040
5051
|
this.introspectedLayout = getShaderLayout(this.device.gl, this.handle);
|
|
5041
|
-
this.shaderLayout = (0,
|
|
5052
|
+
this.shaderLayout = (0, import_core21.mergeShaderLayout)(this.introspectedLayout, props.shaderLayout);
|
|
5042
5053
|
}
|
|
5043
5054
|
destroy() {
|
|
5044
5055
|
if (this.handle) {
|
|
@@ -5086,13 +5097,13 @@ var WEBGLRenderPipeline = class extends import_core21.RenderPipeline {
|
|
|
5086
5097
|
const binding = this.shaderLayout.bindings.find((binding2) => binding2.name === name) || this.shaderLayout.bindings.find((binding2) => binding2.name === `${name}Uniforms`);
|
|
5087
5098
|
if (!binding) {
|
|
5088
5099
|
const validBindings = this.shaderLayout.bindings.map((binding2) => `"${binding2.name}"`).join(", ");
|
|
5089
|
-
|
|
5100
|
+
import_core20.log.warn(
|
|
5090
5101
|
`Unknown binding "${name}" in render pipeline "${this.id}", expected one of ${validBindings}`
|
|
5091
5102
|
)();
|
|
5092
5103
|
continue;
|
|
5093
5104
|
}
|
|
5094
5105
|
if (!value) {
|
|
5095
|
-
|
|
5106
|
+
import_core20.log.warn(`Unsetting binding "${name}" in render pipeline "${this.id}"`)();
|
|
5096
5107
|
}
|
|
5097
5108
|
switch (binding.type) {
|
|
5098
5109
|
case "uniform":
|
|
@@ -5106,7 +5117,7 @@ var WEBGLRenderPipeline = class extends import_core21.RenderPipeline {
|
|
|
5106
5117
|
}
|
|
5107
5118
|
break;
|
|
5108
5119
|
case "sampler":
|
|
5109
|
-
|
|
5120
|
+
import_core20.log.warn(`Ignoring sampler ${name}`)();
|
|
5110
5121
|
break;
|
|
5111
5122
|
default:
|
|
5112
5123
|
throw new Error(binding.type);
|
|
@@ -5115,9 +5126,9 @@ var WEBGLRenderPipeline = class extends import_core21.RenderPipeline {
|
|
|
5115
5126
|
}
|
|
5116
5127
|
}
|
|
5117
5128
|
setUniforms(uniforms) {
|
|
5118
|
-
const { bindings } = (0,
|
|
5129
|
+
const { bindings } = (0, import_core20.splitUniformsAndBindings)(uniforms);
|
|
5119
5130
|
Object.keys(bindings).forEach((name) => {
|
|
5120
|
-
|
|
5131
|
+
import_core20.log.warn(
|
|
5121
5132
|
`Unsupported value "${JSON.stringify(bindings[name])}" used in setUniforms() for key ${name}. Use setBindings() instead?`
|
|
5122
5133
|
)();
|
|
5123
5134
|
});
|
|
@@ -5197,10 +5208,10 @@ var WEBGLRenderPipeline = class extends import_core21.RenderPipeline {
|
|
|
5197
5208
|
const { gl } = this.device;
|
|
5198
5209
|
gl.attachShader(this.handle, this.vs.handle);
|
|
5199
5210
|
gl.attachShader(this.handle, this.fs.handle);
|
|
5200
|
-
|
|
5211
|
+
import_core20.log.time(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
|
|
5201
5212
|
gl.linkProgram(this.handle);
|
|
5202
|
-
|
|
5203
|
-
if (!gl.debug &&
|
|
5213
|
+
import_core20.log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
|
|
5214
|
+
if (!gl.debug && import_core20.log.level === 0) {
|
|
5204
5215
|
}
|
|
5205
5216
|
const linked = gl.getProgramParameter(this.handle, gl.LINK_STATUS);
|
|
5206
5217
|
if (!linked) {
|
|
@@ -5295,7 +5306,7 @@ var WEBGLRenderPipeline = class extends import_core21.RenderPipeline {
|
|
|
5295
5306
|
if (value instanceof WEBGLTexture) {
|
|
5296
5307
|
texture = value;
|
|
5297
5308
|
} else if (value instanceof WEBGLFramebuffer && value.colorAttachments[0] instanceof WEBGLTexture) {
|
|
5298
|
-
|
|
5309
|
+
import_core20.log.warn(
|
|
5299
5310
|
"Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead"
|
|
5300
5311
|
)();
|
|
5301
5312
|
texture = value.colorAttachments[0];
|
|
@@ -5330,15 +5341,15 @@ var WEBGLRenderPipeline = class extends import_core21.RenderPipeline {
|
|
|
5330
5341
|
};
|
|
5331
5342
|
|
|
5332
5343
|
// src/adapter/resources/webgl-command-encoder.ts
|
|
5333
|
-
var
|
|
5344
|
+
var import_core23 = require("@luma.gl/core");
|
|
5334
5345
|
|
|
5335
5346
|
// src/adapter/resources/webgl-command-buffer.ts
|
|
5336
|
-
var
|
|
5347
|
+
var import_core22 = require("@luma.gl/core");
|
|
5337
5348
|
var import_constants25 = require("@luma.gl/constants");
|
|
5338
|
-
function
|
|
5349
|
+
function cast2(value) {
|
|
5339
5350
|
return value;
|
|
5340
5351
|
}
|
|
5341
|
-
var WEBGLCommandBuffer = class extends
|
|
5352
|
+
var WEBGLCommandBuffer = class extends import_core22.CommandBuffer {
|
|
5342
5353
|
device;
|
|
5343
5354
|
commands = [];
|
|
5344
5355
|
constructor(device) {
|
|
@@ -5365,8 +5376,8 @@ var WEBGLCommandBuffer = class extends import_core23.CommandBuffer {
|
|
|
5365
5376
|
}
|
|
5366
5377
|
};
|
|
5367
5378
|
function _copyBufferToBuffer(device, options) {
|
|
5368
|
-
const source =
|
|
5369
|
-
const destination =
|
|
5379
|
+
const source = cast2(options.source);
|
|
5380
|
+
const destination = cast2(options.destination);
|
|
5370
5381
|
const gl2 = device.assertWebGL2();
|
|
5371
5382
|
if (gl2) {
|
|
5372
5383
|
gl2.bindBuffer(import_constants25.GL.COPY_READ_BUFFER, source.handle);
|
|
@@ -5516,7 +5527,7 @@ function _copyTextureToTexture(device, options) {
|
|
|
5516
5527
|
return texture;
|
|
5517
5528
|
}
|
|
5518
5529
|
function getFramebuffer(source) {
|
|
5519
|
-
if (source instanceof
|
|
5530
|
+
if (source instanceof import_core22.Texture) {
|
|
5520
5531
|
const { width, height, id } = source;
|
|
5521
5532
|
const framebuffer = source.device.createFramebuffer({
|
|
5522
5533
|
id: `framebuffer-for-${id}`,
|
|
@@ -5530,7 +5541,7 @@ function getFramebuffer(source) {
|
|
|
5530
5541
|
}
|
|
5531
5542
|
|
|
5532
5543
|
// src/adapter/resources/webgl-command-encoder.ts
|
|
5533
|
-
var WEBGLCommandEncoder = class extends
|
|
5544
|
+
var WEBGLCommandEncoder = class extends import_core23.CommandEncoder {
|
|
5534
5545
|
device;
|
|
5535
5546
|
commandBuffer;
|
|
5536
5547
|
constructor(device, props) {
|
|
@@ -5575,10 +5586,10 @@ var WEBGLCommandEncoder = class extends import_core24.CommandEncoder {
|
|
|
5575
5586
|
};
|
|
5576
5587
|
|
|
5577
5588
|
// src/adapter/resources/webgl-vertex-array.ts
|
|
5578
|
-
var
|
|
5589
|
+
var import_core24 = require("@luma.gl/core");
|
|
5579
5590
|
var import_constants26 = require("@luma.gl/constants");
|
|
5580
5591
|
var import_env2 = require("@probe.gl/env");
|
|
5581
|
-
var WEBGLVertexArray = class extends
|
|
5592
|
+
var WEBGLVertexArray = class extends import_core24.VertexArray {
|
|
5582
5593
|
get [Symbol.toStringTag]() {
|
|
5583
5594
|
return "VertexArray";
|
|
5584
5595
|
}
|
|
@@ -5752,8 +5763,8 @@ var WEBGLVertexArray = class extends import_core25.VertexArray {
|
|
|
5752
5763
|
this.buffer = this.buffer || this.device.createBuffer({ byteLength });
|
|
5753
5764
|
updateNeeded = updateNeeded || !compareConstantArrayValues(constantValue, this.bufferValue);
|
|
5754
5765
|
if (updateNeeded) {
|
|
5755
|
-
const typedArray = (0,
|
|
5756
|
-
(0,
|
|
5766
|
+
const typedArray = (0, import_core24.getScratchArray)(value.constructor, length);
|
|
5767
|
+
(0, import_core24.fillArray)({ target: typedArray, source: constantValue, start: 0, count: length });
|
|
5757
5768
|
this.buffer.write(typedArray);
|
|
5758
5769
|
this.bufferValue = value;
|
|
5759
5770
|
}
|
|
@@ -5779,9 +5790,9 @@ function compareConstantArrayValues(v1, v2) {
|
|
|
5779
5790
|
}
|
|
5780
5791
|
|
|
5781
5792
|
// src/adapter/resources/webgl-transform-feedback.ts
|
|
5782
|
-
var
|
|
5793
|
+
var import_core25 = require("@luma.gl/core");
|
|
5783
5794
|
var import_constants27 = require("@luma.gl/constants");
|
|
5784
|
-
var WEBGLTransformFeedback = class extends
|
|
5795
|
+
var WEBGLTransformFeedback = class extends import_core25.TransformFeedback {
|
|
5785
5796
|
device;
|
|
5786
5797
|
gl2;
|
|
5787
5798
|
handle;
|
|
@@ -5845,7 +5856,7 @@ var WEBGLTransformFeedback = class extends import_core26.TransformFeedback {
|
|
|
5845
5856
|
const { buffer, byteLength, byteOffset } = this._getBufferRange(bufferOrRange);
|
|
5846
5857
|
if (location < 0) {
|
|
5847
5858
|
this.unusedBuffers[locationOrName] = buffer;
|
|
5848
|
-
|
|
5859
|
+
import_core25.log.warn(`${this.id} unusedBuffers varying buffer ${locationOrName}`)();
|
|
5849
5860
|
return;
|
|
5850
5861
|
}
|
|
5851
5862
|
this.buffers[location] = { buffer, byteLength, byteOffset };
|
|
@@ -5933,7 +5944,7 @@ function isIndex(value) {
|
|
|
5933
5944
|
|
|
5934
5945
|
// src/adapter/webgl-device.ts
|
|
5935
5946
|
var LOG_LEVEL2 = 1;
|
|
5936
|
-
var _WebGLDevice = class extends
|
|
5947
|
+
var _WebGLDevice = class extends import_core26.Device {
|
|
5937
5948
|
static isSupported() {
|
|
5938
5949
|
return typeof WebGLRenderingContext !== "undefined" || isHeadlessGLRegistered();
|
|
5939
5950
|
}
|
|
@@ -5965,7 +5976,7 @@ var _WebGLDevice = class extends import_core27.Device {
|
|
|
5965
5976
|
if (gl instanceof _WebGLDevice) {
|
|
5966
5977
|
return gl;
|
|
5967
5978
|
}
|
|
5968
|
-
if ((gl == null ? void 0 : gl.device) instanceof
|
|
5979
|
+
if ((gl == null ? void 0 : gl.device) instanceof import_core26.Device) {
|
|
5969
5980
|
return gl.device;
|
|
5970
5981
|
}
|
|
5971
5982
|
if (!isWebGL3(gl)) {
|
|
@@ -5974,29 +5985,34 @@ var _WebGLDevice = class extends import_core27.Device {
|
|
|
5974
5985
|
return new _WebGLDevice({ gl });
|
|
5975
5986
|
}
|
|
5976
5987
|
static async create(props = {}) {
|
|
5977
|
-
|
|
5988
|
+
import_core26.log.groupCollapsed(LOG_LEVEL2, "WebGLDevice created")();
|
|
5978
5989
|
if (typeof props.canvas === "string") {
|
|
5979
|
-
await
|
|
5990
|
+
await import_core26.CanvasContext.pageLoaded;
|
|
5980
5991
|
}
|
|
5981
|
-
if (
|
|
5992
|
+
if (import_core26.log.get("debug") || props.debug) {
|
|
5982
5993
|
await loadWebGLDeveloperTools();
|
|
5983
5994
|
}
|
|
5984
5995
|
const { spector: spector2 } = props;
|
|
5985
|
-
if (
|
|
5996
|
+
if (import_core26.log.get("spector") || spector2) {
|
|
5986
5997
|
await loadSpectorJS();
|
|
5987
5998
|
}
|
|
5988
|
-
|
|
5999
|
+
import_core26.log.probe(LOG_LEVEL2 + 1, "DOM is loaded")();
|
|
5989
6000
|
if (props.gl && props.gl.device) {
|
|
5990
6001
|
return _WebGLDevice.attach(props.gl);
|
|
5991
6002
|
}
|
|
5992
|
-
|
|
6003
|
+
const device = new _WebGLDevice(props);
|
|
6004
|
+
const message2 = `Created ${device.info.type}${device.debug ? " debug" : ""} context: ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;
|
|
6005
|
+
import_core26.log.probe(LOG_LEVEL2, message2)();
|
|
6006
|
+
import_core26.log.table(LOG_LEVEL2, device.info)();
|
|
6007
|
+
import_core26.log.groupEnd(LOG_LEVEL2)();
|
|
6008
|
+
return device;
|
|
5993
6009
|
}
|
|
5994
6010
|
//
|
|
5995
6011
|
// Public API
|
|
5996
6012
|
//
|
|
5997
6013
|
constructor(props) {
|
|
5998
6014
|
var _a;
|
|
5999
|
-
super({ ...props, id: props.id || (0,
|
|
6015
|
+
super({ ...props, id: props.id || (0, import_core26.uid)("webgl-device") });
|
|
6000
6016
|
const device = (_a = props.gl) == null ? void 0 : _a.device;
|
|
6001
6017
|
if (device) {
|
|
6002
6018
|
throw new Error(`WebGL context already attached to device ${device.id}`);
|
|
@@ -6031,22 +6047,19 @@ var _WebGLDevice = class extends import_core27.Device {
|
|
|
6031
6047
|
trackContextState(this.gl, {
|
|
6032
6048
|
enable: enable2,
|
|
6033
6049
|
copyState,
|
|
6034
|
-
log: (...args) =>
|
|
6050
|
+
log: (...args) => import_core26.log.log(1, ...args)()
|
|
6035
6051
|
});
|
|
6036
6052
|
if ((0, import_env3.isBrowser)() && props.debug) {
|
|
6037
6053
|
this.gl = makeDebugContext(this.gl, { ...props, webgl2: this.isWebGL2, throwOnError: true });
|
|
6038
6054
|
this.gl2 = this.gl;
|
|
6039
6055
|
this.debug = true;
|
|
6040
|
-
|
|
6041
|
-
|
|
6056
|
+
import_core26.log.level = Math.max(import_core26.log.level, 1);
|
|
6057
|
+
import_core26.log.warn("WebGL debug mode activated. Performance reduced.")();
|
|
6042
6058
|
}
|
|
6043
6059
|
if ((0, import_env3.isBrowser)() && props.spector) {
|
|
6044
6060
|
const canvas = this.handle.canvas || props.canvas;
|
|
6045
6061
|
this.spector = initializeSpectorJS({ ...this.props, canvas });
|
|
6046
6062
|
}
|
|
6047
|
-
const message2 = `Created ${this.info.type}${this.debug ? " debug" : ""} context: ${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;
|
|
6048
|
-
import_core27.log.probe(LOG_LEVEL2, message2)();
|
|
6049
|
-
import_core27.log.groupEnd(LOG_LEVEL2)();
|
|
6050
6063
|
}
|
|
6051
6064
|
/**
|
|
6052
6065
|
* Destroys the context
|
|
@@ -6227,7 +6240,7 @@ var _WebGLDevice = class extends import_core27.Device {
|
|
|
6227
6240
|
this._constants = this._constants || new Array(this.limits.maxVertexAttributes).fill(null);
|
|
6228
6241
|
const currentConstant = this._constants[location];
|
|
6229
6242
|
if (currentConstant && compareConstantArrayValues2(currentConstant, constant)) {
|
|
6230
|
-
|
|
6243
|
+
import_core26.log.info(1, `setConstantAttribute(${location}) could have been skipped, value unchanged`)();
|
|
6231
6244
|
}
|
|
6232
6245
|
this._constants[location] = constant;
|
|
6233
6246
|
switch (constant.constructor) {
|
|
@@ -6241,7 +6254,7 @@ var _WebGLDevice = class extends import_core27.Device {
|
|
|
6241
6254
|
setConstantUintArray(this, location, constant);
|
|
6242
6255
|
break;
|
|
6243
6256
|
default:
|
|
6244
|
-
(0,
|
|
6257
|
+
(0, import_core26.assert)(false);
|
|
6245
6258
|
}
|
|
6246
6259
|
}
|
|
6247
6260
|
};
|
|
@@ -6280,7 +6293,7 @@ function setConstantFloatArray(device, location, array) {
|
|
|
6280
6293
|
device.gl.vertexAttrib4fv(location, array);
|
|
6281
6294
|
break;
|
|
6282
6295
|
default:
|
|
6283
|
-
(0,
|
|
6296
|
+
(0, import_core26.assert)(false);
|
|
6284
6297
|
}
|
|
6285
6298
|
}
|
|
6286
6299
|
function setConstantIntArray(device, location, array) {
|
|
@@ -6306,7 +6319,7 @@ function compareConstantArrayValues2(v1, v2) {
|
|
|
6306
6319
|
}
|
|
6307
6320
|
|
|
6308
6321
|
// src/classic/clear.ts
|
|
6309
|
-
var
|
|
6322
|
+
var import_core27 = require("@luma.gl/core");
|
|
6310
6323
|
var GL_DEPTH_BUFFER_BIT2 = 256;
|
|
6311
6324
|
var GL_STENCIL_BUFFER_BIT2 = 1024;
|
|
6312
6325
|
var GL_COLOR_BUFFER_BIT2 = 16384;
|
|
@@ -6337,18 +6350,18 @@ function clear(gl, options) {
|
|
|
6337
6350
|
parameters.clearStencil = depth;
|
|
6338
6351
|
}
|
|
6339
6352
|
}
|
|
6340
|
-
(0,
|
|
6353
|
+
(0, import_core27.assert)(clearFlags !== 0, ERR_ARGUMENTS);
|
|
6341
6354
|
withGLParameters(device.gl, parameters, () => {
|
|
6342
6355
|
device.gl.clear(clearFlags);
|
|
6343
6356
|
});
|
|
6344
6357
|
}
|
|
6345
6358
|
|
|
6346
6359
|
// src/classic/copy-and-blit.ts
|
|
6347
|
-
var
|
|
6360
|
+
var import_core29 = require("@luma.gl/core");
|
|
6348
6361
|
var import_constants29 = require("@luma.gl/constants");
|
|
6349
6362
|
|
|
6350
6363
|
// src/classic/format-utils.ts
|
|
6351
|
-
var
|
|
6364
|
+
var import_core28 = require("@luma.gl/core");
|
|
6352
6365
|
var import_constants28 = require("@luma.gl/constants");
|
|
6353
6366
|
function glFormatToComponents(format) {
|
|
6354
6367
|
switch (format) {
|
|
@@ -6366,7 +6379,7 @@ function glFormatToComponents(format) {
|
|
|
6366
6379
|
case import_constants28.GL.RGBA32F:
|
|
6367
6380
|
return 4;
|
|
6368
6381
|
default:
|
|
6369
|
-
(0,
|
|
6382
|
+
(0, import_core28.assert)(false);
|
|
6370
6383
|
return 0;
|
|
6371
6384
|
}
|
|
6372
6385
|
}
|
|
@@ -6381,7 +6394,7 @@ function glTypeToBytes(type) {
|
|
|
6381
6394
|
case import_constants28.GL.FLOAT:
|
|
6382
6395
|
return 4;
|
|
6383
6396
|
default:
|
|
6384
|
-
(0,
|
|
6397
|
+
(0, import_core28.assert)(false);
|
|
6385
6398
|
return 0;
|
|
6386
6399
|
}
|
|
6387
6400
|
}
|
|
@@ -6404,7 +6417,7 @@ function readPixelsToArray(source, options) {
|
|
|
6404
6417
|
sourceType
|
|
6405
6418
|
} = options || {};
|
|
6406
6419
|
const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
|
|
6407
|
-
(0,
|
|
6420
|
+
(0, import_core29.assert)(framebuffer);
|
|
6408
6421
|
const { gl, handle } = framebuffer;
|
|
6409
6422
|
sourceWidth = sourceWidth || framebuffer.width;
|
|
6410
6423
|
sourceHeight = sourceHeight || framebuffer.height;
|
|
@@ -6424,7 +6437,7 @@ function readPixelsToBuffer(source, options) {
|
|
|
6424
6437
|
const { sourceX = 0, sourceY = 0, sourceFormat = import_constants29.GL.RGBA, targetByteOffset = 0 } = options || {};
|
|
6425
6438
|
let { target, sourceWidth, sourceHeight, sourceType } = options || {};
|
|
6426
6439
|
const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
|
|
6427
|
-
(0,
|
|
6440
|
+
(0, import_core29.assert)(framebuffer);
|
|
6428
6441
|
sourceWidth = sourceWidth || framebuffer.width;
|
|
6429
6442
|
sourceHeight = sourceHeight || framebuffer.height;
|
|
6430
6443
|
const webglFramebuffer = framebuffer;
|
|
@@ -6468,7 +6481,7 @@ function copyToTexture(source, target, options) {
|
|
|
6468
6481
|
// defaults to target height
|
|
6469
6482
|
} = options || {};
|
|
6470
6483
|
const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
|
|
6471
|
-
(0,
|
|
6484
|
+
(0, import_core29.assert)(framebuffer);
|
|
6472
6485
|
const webglFramebuffer = framebuffer;
|
|
6473
6486
|
const { device, handle } = webglFramebuffer;
|
|
6474
6487
|
const isSubCopy = typeof targetX !== "undefined" || typeof targetY !== "undefined" || typeof targetZ !== "undefined";
|
|
@@ -6476,10 +6489,10 @@ function copyToTexture(source, target, options) {
|
|
|
6476
6489
|
targetY = targetY || 0;
|
|
6477
6490
|
targetZ = targetZ || 0;
|
|
6478
6491
|
const prevHandle = device.gl.bindFramebuffer(import_constants29.GL.FRAMEBUFFER, handle);
|
|
6479
|
-
(0,
|
|
6492
|
+
(0, import_core29.assert)(target);
|
|
6480
6493
|
let texture = null;
|
|
6481
6494
|
let textureTarget;
|
|
6482
|
-
if (target instanceof
|
|
6495
|
+
if (target instanceof import_core29.Texture) {
|
|
6483
6496
|
texture = target;
|
|
6484
6497
|
width = Number.isFinite(width) ? width : texture.width;
|
|
6485
6498
|
height = Number.isFinite(height) ? height : texture.height;
|
|
@@ -6543,7 +6556,7 @@ function copyToTexture(source, target, options) {
|
|
|
6543
6556
|
return texture;
|
|
6544
6557
|
}
|
|
6545
6558
|
function getFramebuffer2(source) {
|
|
6546
|
-
if (!(source instanceof
|
|
6559
|
+
if (!(source instanceof import_core29.Framebuffer)) {
|
|
6547
6560
|
return { framebuffer: toFramebuffer(source), deleteFramebuffer: true };
|
|
6548
6561
|
}
|
|
6549
6562
|
return { framebuffer: source, deleteFramebuffer: false };
|