@luma.gl/webgl 9.0.0-alpha.51 → 9.0.0-alpha.53
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-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/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +5 -4
- package/dist/context/debug/webgl-developer-tools.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 +739 -46
- package/dist/index.cjs +148 -126
- 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-texture.ts +3 -4
- package/src/adapter/webgl-device.ts +13 -10
- package/src/context/debug/webgl-developer-tools.ts +7 -6
- package/src/context/polyfill/polyfill-context.ts +6 -2
- package/src/adapter/resources/.webgl-render-pipeline.ts.swp +0 -0
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,15 +2570,6 @@ 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");
|
|
@@ -2743,7 +2763,7 @@ var DEFAULT_WEBGL_TEXTURE_PROPS = {
|
|
|
2743
2763
|
textureUnit: void 0,
|
|
2744
2764
|
target: void 0
|
|
2745
2765
|
};
|
|
2746
|
-
var _WEBGLTexture = class extends
|
|
2766
|
+
var _WEBGLTexture = class extends import_core9.Texture {
|
|
2747
2767
|
MAX_ATTRIBUTES;
|
|
2748
2768
|
device;
|
|
2749
2769
|
gl;
|
|
@@ -2777,7 +2797,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
2777
2797
|
constructor(device, props) {
|
|
2778
2798
|
var _a;
|
|
2779
2799
|
super(device, { ...DEFAULT_WEBGL_TEXTURE_PROPS, format: "rgba8unorm", ...props });
|
|
2780
|
-
this.device =
|
|
2800
|
+
this.device = device;
|
|
2781
2801
|
this.gl = this.device.gl;
|
|
2782
2802
|
this.gl2 = this.device.gl2;
|
|
2783
2803
|
this.handle = this.props.handle || this.gl.createTexture();
|
|
@@ -2786,7 +2806,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
2786
2806
|
this.target = getWebGLTextureTarget(this.props);
|
|
2787
2807
|
this.loaded = false;
|
|
2788
2808
|
if (typeof ((_a = this.props) == null ? void 0 : _a.data) === "string") {
|
|
2789
|
-
Object.assign(this.props, { data: (0,
|
|
2809
|
+
Object.assign(this.props, { data: (0, import_core9.loadImage)(this.props.data) });
|
|
2790
2810
|
}
|
|
2791
2811
|
this.initialize(this.props);
|
|
2792
2812
|
Object.seal(this);
|
|
@@ -2853,7 +2873,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
2853
2873
|
this.gl.bindTexture(this.target, this.handle);
|
|
2854
2874
|
}
|
|
2855
2875
|
if (mipmaps && this.device.isWebGL1 && isNPOT(this.width, this.height)) {
|
|
2856
|
-
|
|
2876
|
+
import_core9.log.warn(`texture: ${this} is Non-Power-Of-Two, disabling mipmaps`)();
|
|
2857
2877
|
mipmaps = false;
|
|
2858
2878
|
}
|
|
2859
2879
|
this.mipmaps = mipmaps;
|
|
@@ -2947,7 +2967,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
2947
2967
|
// Call to regenerate mipmaps after modifying texture(s)
|
|
2948
2968
|
generateMipmap(params = {}) {
|
|
2949
2969
|
if (this.device.isWebGL1 && isNPOT(this.width, this.height)) {
|
|
2950
|
-
|
|
2970
|
+
import_core9.log.warn(`texture: ${this} is Non-Power-Of-Two, disabling mipmaping`)();
|
|
2951
2971
|
return this;
|
|
2952
2972
|
}
|
|
2953
2973
|
this.mipmaps = true;
|
|
@@ -3095,7 +3115,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
3095
3115
|
}
|
|
3096
3116
|
break;
|
|
3097
3117
|
default:
|
|
3098
|
-
(0,
|
|
3118
|
+
(0, import_core9.assert)(false, "Unknown image data type");
|
|
3099
3119
|
}
|
|
3100
3120
|
});
|
|
3101
3121
|
if (data && data.byteLength) {
|
|
@@ -3137,7 +3157,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
3137
3157
|
width,
|
|
3138
3158
|
height
|
|
3139
3159
|
}));
|
|
3140
|
-
(0,
|
|
3160
|
+
(0, import_core9.assert)(this.depth === 1, "texSubImage not supported for 3D textures");
|
|
3141
3161
|
if (!data) {
|
|
3142
3162
|
data = pixels;
|
|
3143
3163
|
}
|
|
@@ -3181,7 +3201,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
3181
3201
|
* rendering can be faster.
|
|
3182
3202
|
*/
|
|
3183
3203
|
copyFramebuffer(opts = {}) {
|
|
3184
|
-
|
|
3204
|
+
import_core9.log.error(
|
|
3185
3205
|
"Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})"
|
|
3186
3206
|
)();
|
|
3187
3207
|
return null;
|
|
@@ -3255,12 +3275,12 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
3255
3275
|
} else {
|
|
3256
3276
|
size = { width, height };
|
|
3257
3277
|
}
|
|
3258
|
-
(0,
|
|
3259
|
-
(0,
|
|
3278
|
+
(0, import_core9.assert)(size, "Could not deduced texture size");
|
|
3279
|
+
(0, import_core9.assert)(
|
|
3260
3280
|
width === void 0 || size.width === width,
|
|
3261
3281
|
"Deduced texture width does not match supplied width"
|
|
3262
3282
|
);
|
|
3263
|
-
(0,
|
|
3283
|
+
(0, import_core9.assert)(
|
|
3264
3284
|
height === void 0 || size.height === height,
|
|
3265
3285
|
"Deduced texture height does not match supplied height"
|
|
3266
3286
|
);
|
|
@@ -3281,7 +3301,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
3281
3301
|
this.bind();
|
|
3282
3302
|
_WEBGLTexture.FACES.forEach((face, index) => {
|
|
3283
3303
|
if (resolvedFaces[index].length > 1 && this.props.mipmaps !== false) {
|
|
3284
|
-
|
|
3304
|
+
import_core9.log.warn(`${this.id} has mipmap and multiple LODs.`)();
|
|
3285
3305
|
}
|
|
3286
3306
|
resolvedFaces[index].forEach((image, lodLevel) => {
|
|
3287
3307
|
if (width && height) {
|
|
@@ -3464,21 +3484,21 @@ function isNPOT(width, height) {
|
|
|
3464
3484
|
if (!width || !height) {
|
|
3465
3485
|
return false;
|
|
3466
3486
|
}
|
|
3467
|
-
return !(0,
|
|
3487
|
+
return !(0, import_core9.isPowerOfTwo)(width) || !(0, import_core9.isPowerOfTwo)(height);
|
|
3468
3488
|
}
|
|
3469
3489
|
function logParameters(parameters) {
|
|
3470
|
-
|
|
3490
|
+
import_core9.log.log(1, "texture sampler parameters", parameters)();
|
|
3471
3491
|
}
|
|
3472
3492
|
|
|
3473
3493
|
// src/adapter/objects/webgl-renderbuffer.ts
|
|
3474
|
-
var
|
|
3494
|
+
var import_core12 = require("@luma.gl/core");
|
|
3475
3495
|
var import_constants13 = require("@luma.gl/constants");
|
|
3476
3496
|
|
|
3477
3497
|
// src/adapter/objects/webgl-resource.ts
|
|
3478
|
-
var
|
|
3498
|
+
var import_core11 = require("@luma.gl/core");
|
|
3479
3499
|
|
|
3480
3500
|
// src/adapter/objects/constants-to-keys.ts
|
|
3481
|
-
var
|
|
3501
|
+
var import_core10 = require("@luma.gl/core");
|
|
3482
3502
|
function getKeyValue(gl, name) {
|
|
3483
3503
|
if (typeof name !== "string") {
|
|
3484
3504
|
return name;
|
|
@@ -3489,13 +3509,13 @@ function getKeyValue(gl, name) {
|
|
|
3489
3509
|
}
|
|
3490
3510
|
name = name.replace(/^.*\./, "");
|
|
3491
3511
|
const value = gl[name];
|
|
3492
|
-
(0,
|
|
3512
|
+
(0, import_core10.assert)(value !== void 0, `Accessing undefined constant GL.${name}`);
|
|
3493
3513
|
return value;
|
|
3494
3514
|
}
|
|
3495
3515
|
|
|
3496
3516
|
// src/adapter/objects/webgl-resource.ts
|
|
3497
3517
|
var ERR_RESOURCE_METHOD_UNDEFINED = "Resource subclass must define virtual methods";
|
|
3498
|
-
var WebGLResource = class extends
|
|
3518
|
+
var WebGLResource = class extends import_core11.Resource {
|
|
3499
3519
|
device;
|
|
3500
3520
|
gl;
|
|
3501
3521
|
gl2;
|
|
@@ -3511,7 +3531,7 @@ var WebGLResource = class extends import_core12.Resource {
|
|
|
3511
3531
|
const { id } = props || {};
|
|
3512
3532
|
this.gl = gl;
|
|
3513
3533
|
this.gl2 = gl;
|
|
3514
|
-
this.id = id || (0,
|
|
3534
|
+
this.id = id || (0, import_core11.uid)(this.constructor.name);
|
|
3515
3535
|
this._handle = props == null ? void 0 : props.handle;
|
|
3516
3536
|
if (this._handle === void 0) {
|
|
3517
3537
|
this._handle = this._createHandle();
|
|
@@ -3563,7 +3583,7 @@ var WebGLResource = class extends import_core12.Resource {
|
|
|
3563
3583
|
*/
|
|
3564
3584
|
getParameter(pname, props = {}) {
|
|
3565
3585
|
pname = getKeyValue(this.gl, pname);
|
|
3566
|
-
(0,
|
|
3586
|
+
(0, import_core11.assert)(pname);
|
|
3567
3587
|
const parameters = this.constructor.PARAMETERS || {};
|
|
3568
3588
|
const parameter = parameters[pname];
|
|
3569
3589
|
if (parameter) {
|
|
@@ -3611,7 +3631,7 @@ var WebGLResource = class extends import_core12.Resource {
|
|
|
3611
3631
|
*/
|
|
3612
3632
|
setParameter(pname, value) {
|
|
3613
3633
|
pname = getKeyValue(this.gl, pname);
|
|
3614
|
-
(0,
|
|
3634
|
+
(0, import_core11.assert)(pname);
|
|
3615
3635
|
const parameters = this.constructor.PARAMETERS || {};
|
|
3616
3636
|
const parameter = parameters[pname];
|
|
3617
3637
|
if (parameter) {
|
|
@@ -3639,7 +3659,7 @@ var WebGLResource = class extends import_core12.Resource {
|
|
|
3639
3659
|
}
|
|
3640
3660
|
// Install stubs for removed methods
|
|
3641
3661
|
stubRemovedMethods(className, version, methodNames) {
|
|
3642
|
-
return (0,
|
|
3662
|
+
return (0, import_core11.stubRemovedMethods)(this, className, version, methodNames);
|
|
3643
3663
|
}
|
|
3644
3664
|
// PUBLIC VIRTUAL METHODS
|
|
3645
3665
|
initialize(props) {
|
|
@@ -3742,7 +3762,7 @@ var _WEBGLRenderbuffer = class extends WebGLResource {
|
|
|
3742
3762
|
/** Creates and initializes a renderbuffer object's data store */
|
|
3743
3763
|
_initialize(props) {
|
|
3744
3764
|
const { format, width, height, samples } = props;
|
|
3745
|
-
(0,
|
|
3765
|
+
(0, import_core12.assert)(format, "Needs format");
|
|
3746
3766
|
this.trackDeallocatedMemory();
|
|
3747
3767
|
this.gl.bindRenderbuffer(import_constants13.GL.RENDERBUFFER, this.handle);
|
|
3748
3768
|
if (samples !== 0 && this.device.isWebGL2) {
|
|
@@ -3780,7 +3800,7 @@ __publicField(WEBGLRenderbuffer, "defaultProps", {
|
|
|
3780
3800
|
});
|
|
3781
3801
|
|
|
3782
3802
|
// src/adapter/resources/webgl-framebuffer.ts
|
|
3783
|
-
var WEBGLFramebuffer = class extends
|
|
3803
|
+
var WEBGLFramebuffer = class extends import_core13.Framebuffer {
|
|
3784
3804
|
device;
|
|
3785
3805
|
gl;
|
|
3786
3806
|
handle;
|
|
@@ -3915,7 +3935,7 @@ var WEBGLFramebuffer = class extends import_core14.Framebuffer {
|
|
|
3915
3935
|
gl.framebufferTexture2D(import_constants14.GL.FRAMEBUFFER, attachment, import_constants14.GL.TEXTURE_2D, texture.handle, level);
|
|
3916
3936
|
break;
|
|
3917
3937
|
default:
|
|
3918
|
-
(0,
|
|
3938
|
+
(0, import_core13.assert)(false, "Illegal texture type");
|
|
3919
3939
|
}
|
|
3920
3940
|
gl.bindTexture(texture.target, null);
|
|
3921
3941
|
}
|
|
@@ -3943,7 +3963,7 @@ function _getFrameBufferStatus(status) {
|
|
|
3943
3963
|
}
|
|
3944
3964
|
|
|
3945
3965
|
// src/adapter/webgl-canvas-context.ts
|
|
3946
|
-
var WebGLCanvasContext = class extends
|
|
3966
|
+
var WebGLCanvasContext = class extends import_core14.CanvasContext {
|
|
3947
3967
|
device;
|
|
3948
3968
|
presentationSize;
|
|
3949
3969
|
_framebuffer = null;
|
|
@@ -3995,9 +4015,9 @@ var WebGLCanvasContext = class extends import_core15.CanvasContext {
|
|
|
3995
4015
|
};
|
|
3996
4016
|
|
|
3997
4017
|
// src/context/debug/spector.ts
|
|
3998
|
-
var
|
|
4018
|
+
var import_core15 = require("@luma.gl/core");
|
|
3999
4019
|
var DEFAULT_SPECTOR_PROPS = {
|
|
4000
|
-
spector:
|
|
4020
|
+
spector: import_core15.log.get("spector") || import_core15.log.get("inspect")
|
|
4001
4021
|
};
|
|
4002
4022
|
var SPECTOR_CDN_URL = "https://spectorcdn.babylonjs.com/spector.bundle.js";
|
|
4003
4023
|
var LOG_LEVEL = 1;
|
|
@@ -4006,9 +4026,9 @@ var initialized = false;
|
|
|
4006
4026
|
async function loadSpectorJS(props) {
|
|
4007
4027
|
if (!globalThis.SPECTOR) {
|
|
4008
4028
|
try {
|
|
4009
|
-
await (0,
|
|
4029
|
+
await (0, import_core15.loadScript)(SPECTOR_CDN_URL);
|
|
4010
4030
|
} catch (error2) {
|
|
4011
|
-
|
|
4031
|
+
import_core15.log.warn(String(error2));
|
|
4012
4032
|
}
|
|
4013
4033
|
}
|
|
4014
4034
|
}
|
|
@@ -4018,7 +4038,7 @@ function initializeSpectorJS(props) {
|
|
|
4018
4038
|
return null;
|
|
4019
4039
|
}
|
|
4020
4040
|
if (!spector && globalThis.SPECTOR) {
|
|
4021
|
-
|
|
4041
|
+
import_core15.log.probe(LOG_LEVEL, "SPECTOR found and initialized")();
|
|
4022
4042
|
spector = new globalThis.SPECTOR.Spector();
|
|
4023
4043
|
if (globalThis.luma) {
|
|
4024
4044
|
globalThis.luma.spector = spector;
|
|
@@ -4030,9 +4050,9 @@ function initializeSpectorJS(props) {
|
|
|
4030
4050
|
if (!initialized) {
|
|
4031
4051
|
initialized = true;
|
|
4032
4052
|
spector.spyCanvases();
|
|
4033
|
-
spector == null ? void 0 : spector.onCaptureStarted.add((capture) =>
|
|
4053
|
+
spector == null ? void 0 : spector.onCaptureStarted.add((capture) => import_core15.log.info("Spector capture started:", capture)());
|
|
4034
4054
|
spector == null ? void 0 : spector.onCapture.add((capture) => {
|
|
4035
|
-
|
|
4055
|
+
import_core15.log.info("Spector capture complete:", capture)();
|
|
4036
4056
|
spector == null ? void 0 : spector.getResultUI();
|
|
4037
4057
|
spector == null ? void 0 : spector.resultView.display();
|
|
4038
4058
|
spector == null ? void 0 : spector.resultView.addCapture(capture);
|
|
@@ -4044,7 +4064,7 @@ function initializeSpectorJS(props) {
|
|
|
4044
4064
|
}
|
|
4045
4065
|
spector == null ? void 0 : spector.startCapture(props == null ? void 0 : props.canvas, 500);
|
|
4046
4066
|
new Promise((resolve) => setTimeout(resolve, 2e3)).then((_) => {
|
|
4047
|
-
|
|
4067
|
+
import_core15.log.info("Spector capture stopped after 2 seconds")();
|
|
4048
4068
|
spector == null ? void 0 : spector.stopCapture();
|
|
4049
4069
|
});
|
|
4050
4070
|
}
|
|
@@ -4052,7 +4072,7 @@ function initializeSpectorJS(props) {
|
|
|
4052
4072
|
}
|
|
4053
4073
|
|
|
4054
4074
|
// src/context/debug/webgl-developer-tools.ts
|
|
4055
|
-
var
|
|
4075
|
+
var import_core16 = require("@luma.gl/core");
|
|
4056
4076
|
var import_constants15 = require("@luma.gl/constants");
|
|
4057
4077
|
var import_env = require("@probe.gl/env");
|
|
4058
4078
|
var WEBGL_DEBUG_CDN_URL = "https://unpkg.com/webgl-debug@2.0.1/index.js";
|
|
@@ -4064,7 +4084,7 @@ async function loadWebGLDeveloperTools() {
|
|
|
4064
4084
|
if ((0, import_env.isBrowser)() && !globalThis.WebGLDebugUtils) {
|
|
4065
4085
|
globalThis.global = globalThis.global || globalThis;
|
|
4066
4086
|
globalThis.global.module = {};
|
|
4067
|
-
await (0,
|
|
4087
|
+
await (0, import_core16.loadScript)(WEBGL_DEBUG_CDN_URL);
|
|
4068
4088
|
}
|
|
4069
4089
|
}
|
|
4070
4090
|
function makeDebugContext(gl, props = {}) {
|
|
@@ -4079,7 +4099,7 @@ function getRealContext(gl) {
|
|
|
4079
4099
|
}
|
|
4080
4100
|
function getDebugContext(gl, props) {
|
|
4081
4101
|
if (!globalThis.WebGLDebugUtils) {
|
|
4082
|
-
|
|
4102
|
+
import_core16.log.warn("webgl-debug not loaded")();
|
|
4083
4103
|
return gl;
|
|
4084
4104
|
}
|
|
4085
4105
|
const data = getContextData2(gl);
|
|
@@ -4119,7 +4139,7 @@ function onGLError(props, err, functionName, args) {
|
|
|
4119
4139
|
const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);
|
|
4120
4140
|
const glName = props.webgl2 ? "gl2" : "gl1";
|
|
4121
4141
|
const message2 = `${errorMessage} in ${glName}.${functionName}(${functionArgs})`;
|
|
4122
|
-
|
|
4142
|
+
import_core16.log.error(message2)();
|
|
4123
4143
|
debugger;
|
|
4124
4144
|
if (props.throwOnError) {
|
|
4125
4145
|
throw new Error(message2);
|
|
@@ -4127,9 +4147,9 @@ function onGLError(props, err, functionName, args) {
|
|
|
4127
4147
|
}
|
|
4128
4148
|
function onValidateGLFunc(props, functionName, functionArgs) {
|
|
4129
4149
|
let functionString = "";
|
|
4130
|
-
if (
|
|
4150
|
+
if (import_core16.log.level >= 1) {
|
|
4131
4151
|
functionString = getFunctionString(functionName, functionArgs);
|
|
4132
|
-
|
|
4152
|
+
import_core16.log.log(1, functionString)();
|
|
4133
4153
|
}
|
|
4134
4154
|
if (props.break && props.break.length > 0) {
|
|
4135
4155
|
functionString = functionString || getFunctionString(functionName, functionArgs);
|
|
@@ -4144,7 +4164,7 @@ function onValidateGLFunc(props, functionName, functionArgs) {
|
|
|
4144
4164
|
if (props.throwOnError) {
|
|
4145
4165
|
throw new Error(`Undefined argument: ${functionString}`);
|
|
4146
4166
|
} else {
|
|
4147
|
-
|
|
4167
|
+
import_core16.log.error(`Undefined argument: ${functionString}`)();
|
|
4148
4168
|
debugger;
|
|
4149
4169
|
}
|
|
4150
4170
|
}
|
|
@@ -4152,7 +4172,7 @@ function onValidateGLFunc(props, functionName, functionArgs) {
|
|
|
4152
4172
|
}
|
|
4153
4173
|
|
|
4154
4174
|
// src/adapter/resources/webgl-shader.ts
|
|
4155
|
-
var
|
|
4175
|
+
var import_core17 = require("@luma.gl/core");
|
|
4156
4176
|
var import_constants16 = require("@luma.gl/constants");
|
|
4157
4177
|
|
|
4158
4178
|
// src/adapter/helpers/parse-shader-compiler-log.ts
|
|
@@ -4200,7 +4220,7 @@ function getMessageType(messageType) {
|
|
|
4200
4220
|
}
|
|
4201
4221
|
|
|
4202
4222
|
// src/adapter/resources/webgl-shader.ts
|
|
4203
|
-
var WEBGLShader = class extends
|
|
4223
|
+
var WEBGLShader = class extends import_core17.Shader {
|
|
4204
4224
|
device;
|
|
4205
4225
|
handle;
|
|
4206
4226
|
constructor(device, props) {
|
|
@@ -4249,13 +4269,13 @@ ${source2}`;
|
|
|
4249
4269
|
};
|
|
4250
4270
|
|
|
4251
4271
|
// src/adapter/resources/webgl-render-pass.ts
|
|
4252
|
-
var
|
|
4272
|
+
var import_core18 = require("@luma.gl/core");
|
|
4253
4273
|
var import_constants17 = require("@luma.gl/constants");
|
|
4254
4274
|
var GL_DEPTH_BUFFER_BIT = 256;
|
|
4255
4275
|
var GL_STENCIL_BUFFER_BIT = 1024;
|
|
4256
4276
|
var GL_COLOR_BUFFER_BIT = 16384;
|
|
4257
4277
|
var GL_COLOR = 6144;
|
|
4258
|
-
var WEBGLRenderPass = class extends
|
|
4278
|
+
var WEBGLRenderPass = class extends import_core18.RenderPass {
|
|
4259
4279
|
device;
|
|
4260
4280
|
/** Parameters that should be applied before each draw call */
|
|
4261
4281
|
glParameters;
|
|
@@ -4382,15 +4402,15 @@ var WEBGLRenderPass = class extends import_core19.RenderPass {
|
|
|
4382
4402
|
};
|
|
4383
4403
|
|
|
4384
4404
|
// src/adapter/resources/webgl-render-pipeline.ts
|
|
4405
|
+
var import_core20 = require("@luma.gl/core");
|
|
4385
4406
|
var import_core21 = require("@luma.gl/core");
|
|
4386
|
-
var import_core22 = require("@luma.gl/core");
|
|
4387
4407
|
var import_constants24 = require("@luma.gl/constants");
|
|
4388
4408
|
|
|
4389
4409
|
// src/adapter/helpers/get-shader-layout.ts
|
|
4390
4410
|
var import_constants21 = require("@luma.gl/constants");
|
|
4391
4411
|
|
|
4392
4412
|
// src/classic/accessor.ts
|
|
4393
|
-
var
|
|
4413
|
+
var import_core19 = require("@luma.gl/core");
|
|
4394
4414
|
var import_constants19 = require("@luma.gl/constants");
|
|
4395
4415
|
|
|
4396
4416
|
// src/classic/typed-array-utils.ts
|
|
@@ -4475,7 +4495,7 @@ var Accessor = class {
|
|
|
4475
4495
|
return ArrayType.BYTES_PER_ELEMENT;
|
|
4476
4496
|
}
|
|
4477
4497
|
static getBytesPerVertex(accessor) {
|
|
4478
|
-
(0,
|
|
4498
|
+
(0, import_core19.assert)(accessor.size);
|
|
4479
4499
|
const ArrayType = getTypedArrayFromGLType(accessor.type || import_constants19.GL.FLOAT);
|
|
4480
4500
|
return ArrayType.BYTES_PER_ELEMENT * accessor.size;
|
|
4481
4501
|
}
|
|
@@ -4504,7 +4524,7 @@ var Accessor = class {
|
|
|
4504
4524
|
// PRIVATE
|
|
4505
4525
|
// eslint-disable-next-line complexity, max-statements
|
|
4506
4526
|
_assign(props = {}) {
|
|
4507
|
-
props = (0,
|
|
4527
|
+
props = (0, import_core19.checkProps)("Accessor", props, PROP_CHECKS);
|
|
4508
4528
|
if (props.type !== void 0) {
|
|
4509
4529
|
this.type = props.type;
|
|
4510
4530
|
if (props.type === import_constants19.GL.INT || props.type === import_constants19.GL.UNSIGNED_INT) {
|
|
@@ -5002,7 +5022,7 @@ function getGLPrimitive(topology) {
|
|
|
5002
5022
|
|
|
5003
5023
|
// src/adapter/resources/webgl-render-pipeline.ts
|
|
5004
5024
|
var LOG_PROGRAM_PERF_PRIORITY = 4;
|
|
5005
|
-
var WEBGLRenderPipeline = class extends
|
|
5025
|
+
var WEBGLRenderPipeline = class extends import_core20.RenderPipeline {
|
|
5006
5026
|
/** The WebGL device that created this render pipeline */
|
|
5007
5027
|
device;
|
|
5008
5028
|
/** Handle to underlying WebGL program */
|
|
@@ -5028,8 +5048,8 @@ var WEBGLRenderPipeline = class extends import_core21.RenderPipeline {
|
|
|
5028
5048
|
this.device = device;
|
|
5029
5049
|
this.handle = this.props.handle || this.device.gl.createProgram();
|
|
5030
5050
|
this.device.setSpectorMetadata(this.handle, { id: this.props.id });
|
|
5031
|
-
this.vs = (0,
|
|
5032
|
-
this.fs = (0,
|
|
5051
|
+
this.vs = (0, import_core20.cast)(props.vs);
|
|
5052
|
+
this.fs = (0, import_core20.cast)(props.fs);
|
|
5033
5053
|
const { varyings, bufferMode = import_constants24.GL.SEPARATE_ATTRIBS } = props;
|
|
5034
5054
|
if (varyings && varyings.length > 0) {
|
|
5035
5055
|
this.device.assertWebGL2();
|
|
@@ -5038,7 +5058,7 @@ var WEBGLRenderPipeline = class extends import_core21.RenderPipeline {
|
|
|
5038
5058
|
}
|
|
5039
5059
|
this._compileAndLink();
|
|
5040
5060
|
this.introspectedLayout = getShaderLayout(this.device.gl, this.handle);
|
|
5041
|
-
this.shaderLayout = (0,
|
|
5061
|
+
this.shaderLayout = (0, import_core21.mergeShaderLayout)(this.introspectedLayout, props.shaderLayout);
|
|
5042
5062
|
}
|
|
5043
5063
|
destroy() {
|
|
5044
5064
|
if (this.handle) {
|
|
@@ -5086,13 +5106,13 @@ var WEBGLRenderPipeline = class extends import_core21.RenderPipeline {
|
|
|
5086
5106
|
const binding = this.shaderLayout.bindings.find((binding2) => binding2.name === name) || this.shaderLayout.bindings.find((binding2) => binding2.name === `${name}Uniforms`);
|
|
5087
5107
|
if (!binding) {
|
|
5088
5108
|
const validBindings = this.shaderLayout.bindings.map((binding2) => `"${binding2.name}"`).join(", ");
|
|
5089
|
-
|
|
5109
|
+
import_core20.log.warn(
|
|
5090
5110
|
`Unknown binding "${name}" in render pipeline "${this.id}", expected one of ${validBindings}`
|
|
5091
5111
|
)();
|
|
5092
5112
|
continue;
|
|
5093
5113
|
}
|
|
5094
5114
|
if (!value) {
|
|
5095
|
-
|
|
5115
|
+
import_core20.log.warn(`Unsetting binding "${name}" in render pipeline "${this.id}"`)();
|
|
5096
5116
|
}
|
|
5097
5117
|
switch (binding.type) {
|
|
5098
5118
|
case "uniform":
|
|
@@ -5106,7 +5126,7 @@ var WEBGLRenderPipeline = class extends import_core21.RenderPipeline {
|
|
|
5106
5126
|
}
|
|
5107
5127
|
break;
|
|
5108
5128
|
case "sampler":
|
|
5109
|
-
|
|
5129
|
+
import_core20.log.warn(`Ignoring sampler ${name}`)();
|
|
5110
5130
|
break;
|
|
5111
5131
|
default:
|
|
5112
5132
|
throw new Error(binding.type);
|
|
@@ -5115,9 +5135,9 @@ var WEBGLRenderPipeline = class extends import_core21.RenderPipeline {
|
|
|
5115
5135
|
}
|
|
5116
5136
|
}
|
|
5117
5137
|
setUniforms(uniforms) {
|
|
5118
|
-
const { bindings } = (0,
|
|
5138
|
+
const { bindings } = (0, import_core20.splitUniformsAndBindings)(uniforms);
|
|
5119
5139
|
Object.keys(bindings).forEach((name) => {
|
|
5120
|
-
|
|
5140
|
+
import_core20.log.warn(
|
|
5121
5141
|
`Unsupported value "${JSON.stringify(bindings[name])}" used in setUniforms() for key ${name}. Use setBindings() instead?`
|
|
5122
5142
|
)();
|
|
5123
5143
|
});
|
|
@@ -5197,10 +5217,10 @@ var WEBGLRenderPipeline = class extends import_core21.RenderPipeline {
|
|
|
5197
5217
|
const { gl } = this.device;
|
|
5198
5218
|
gl.attachShader(this.handle, this.vs.handle);
|
|
5199
5219
|
gl.attachShader(this.handle, this.fs.handle);
|
|
5200
|
-
|
|
5220
|
+
import_core20.log.time(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
|
|
5201
5221
|
gl.linkProgram(this.handle);
|
|
5202
|
-
|
|
5203
|
-
if (!gl.debug &&
|
|
5222
|
+
import_core20.log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
|
|
5223
|
+
if (!gl.debug && import_core20.log.level === 0) {
|
|
5204
5224
|
}
|
|
5205
5225
|
const linked = gl.getProgramParameter(this.handle, gl.LINK_STATUS);
|
|
5206
5226
|
if (!linked) {
|
|
@@ -5295,7 +5315,7 @@ var WEBGLRenderPipeline = class extends import_core21.RenderPipeline {
|
|
|
5295
5315
|
if (value instanceof WEBGLTexture) {
|
|
5296
5316
|
texture = value;
|
|
5297
5317
|
} else if (value instanceof WEBGLFramebuffer && value.colorAttachments[0] instanceof WEBGLTexture) {
|
|
5298
|
-
|
|
5318
|
+
import_core20.log.warn(
|
|
5299
5319
|
"Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead"
|
|
5300
5320
|
)();
|
|
5301
5321
|
texture = value.colorAttachments[0];
|
|
@@ -5330,15 +5350,15 @@ var WEBGLRenderPipeline = class extends import_core21.RenderPipeline {
|
|
|
5330
5350
|
};
|
|
5331
5351
|
|
|
5332
5352
|
// src/adapter/resources/webgl-command-encoder.ts
|
|
5333
|
-
var
|
|
5353
|
+
var import_core23 = require("@luma.gl/core");
|
|
5334
5354
|
|
|
5335
5355
|
// src/adapter/resources/webgl-command-buffer.ts
|
|
5336
|
-
var
|
|
5356
|
+
var import_core22 = require("@luma.gl/core");
|
|
5337
5357
|
var import_constants25 = require("@luma.gl/constants");
|
|
5338
|
-
function
|
|
5358
|
+
function cast2(value) {
|
|
5339
5359
|
return value;
|
|
5340
5360
|
}
|
|
5341
|
-
var WEBGLCommandBuffer = class extends
|
|
5361
|
+
var WEBGLCommandBuffer = class extends import_core22.CommandBuffer {
|
|
5342
5362
|
device;
|
|
5343
5363
|
commands = [];
|
|
5344
5364
|
constructor(device) {
|
|
@@ -5365,8 +5385,8 @@ var WEBGLCommandBuffer = class extends import_core23.CommandBuffer {
|
|
|
5365
5385
|
}
|
|
5366
5386
|
};
|
|
5367
5387
|
function _copyBufferToBuffer(device, options) {
|
|
5368
|
-
const source =
|
|
5369
|
-
const destination =
|
|
5388
|
+
const source = cast2(options.source);
|
|
5389
|
+
const destination = cast2(options.destination);
|
|
5370
5390
|
const gl2 = device.assertWebGL2();
|
|
5371
5391
|
if (gl2) {
|
|
5372
5392
|
gl2.bindBuffer(import_constants25.GL.COPY_READ_BUFFER, source.handle);
|
|
@@ -5516,7 +5536,7 @@ function _copyTextureToTexture(device, options) {
|
|
|
5516
5536
|
return texture;
|
|
5517
5537
|
}
|
|
5518
5538
|
function getFramebuffer(source) {
|
|
5519
|
-
if (source instanceof
|
|
5539
|
+
if (source instanceof import_core22.Texture) {
|
|
5520
5540
|
const { width, height, id } = source;
|
|
5521
5541
|
const framebuffer = source.device.createFramebuffer({
|
|
5522
5542
|
id: `framebuffer-for-${id}`,
|
|
@@ -5530,7 +5550,7 @@ function getFramebuffer(source) {
|
|
|
5530
5550
|
}
|
|
5531
5551
|
|
|
5532
5552
|
// src/adapter/resources/webgl-command-encoder.ts
|
|
5533
|
-
var WEBGLCommandEncoder = class extends
|
|
5553
|
+
var WEBGLCommandEncoder = class extends import_core23.CommandEncoder {
|
|
5534
5554
|
device;
|
|
5535
5555
|
commandBuffer;
|
|
5536
5556
|
constructor(device, props) {
|
|
@@ -5575,10 +5595,10 @@ var WEBGLCommandEncoder = class extends import_core24.CommandEncoder {
|
|
|
5575
5595
|
};
|
|
5576
5596
|
|
|
5577
5597
|
// src/adapter/resources/webgl-vertex-array.ts
|
|
5578
|
-
var
|
|
5598
|
+
var import_core24 = require("@luma.gl/core");
|
|
5579
5599
|
var import_constants26 = require("@luma.gl/constants");
|
|
5580
5600
|
var import_env2 = require("@probe.gl/env");
|
|
5581
|
-
var WEBGLVertexArray = class extends
|
|
5601
|
+
var WEBGLVertexArray = class extends import_core24.VertexArray {
|
|
5582
5602
|
get [Symbol.toStringTag]() {
|
|
5583
5603
|
return "VertexArray";
|
|
5584
5604
|
}
|
|
@@ -5752,8 +5772,8 @@ var WEBGLVertexArray = class extends import_core25.VertexArray {
|
|
|
5752
5772
|
this.buffer = this.buffer || this.device.createBuffer({ byteLength });
|
|
5753
5773
|
updateNeeded = updateNeeded || !compareConstantArrayValues(constantValue, this.bufferValue);
|
|
5754
5774
|
if (updateNeeded) {
|
|
5755
|
-
const typedArray = (0,
|
|
5756
|
-
(0,
|
|
5775
|
+
const typedArray = (0, import_core24.getScratchArray)(value.constructor, length);
|
|
5776
|
+
(0, import_core24.fillArray)({ target: typedArray, source: constantValue, start: 0, count: length });
|
|
5757
5777
|
this.buffer.write(typedArray);
|
|
5758
5778
|
this.bufferValue = value;
|
|
5759
5779
|
}
|
|
@@ -5779,9 +5799,9 @@ function compareConstantArrayValues(v1, v2) {
|
|
|
5779
5799
|
}
|
|
5780
5800
|
|
|
5781
5801
|
// src/adapter/resources/webgl-transform-feedback.ts
|
|
5782
|
-
var
|
|
5802
|
+
var import_core25 = require("@luma.gl/core");
|
|
5783
5803
|
var import_constants27 = require("@luma.gl/constants");
|
|
5784
|
-
var WEBGLTransformFeedback = class extends
|
|
5804
|
+
var WEBGLTransformFeedback = class extends import_core25.TransformFeedback {
|
|
5785
5805
|
device;
|
|
5786
5806
|
gl2;
|
|
5787
5807
|
handle;
|
|
@@ -5845,7 +5865,7 @@ var WEBGLTransformFeedback = class extends import_core26.TransformFeedback {
|
|
|
5845
5865
|
const { buffer, byteLength, byteOffset } = this._getBufferRange(bufferOrRange);
|
|
5846
5866
|
if (location < 0) {
|
|
5847
5867
|
this.unusedBuffers[locationOrName] = buffer;
|
|
5848
|
-
|
|
5868
|
+
import_core25.log.warn(`${this.id} unusedBuffers varying buffer ${locationOrName}`)();
|
|
5849
5869
|
return;
|
|
5850
5870
|
}
|
|
5851
5871
|
this.buffers[location] = { buffer, byteLength, byteOffset };
|
|
@@ -5933,7 +5953,7 @@ function isIndex(value) {
|
|
|
5933
5953
|
|
|
5934
5954
|
// src/adapter/webgl-device.ts
|
|
5935
5955
|
var LOG_LEVEL2 = 1;
|
|
5936
|
-
var _WebGLDevice = class extends
|
|
5956
|
+
var _WebGLDevice = class extends import_core26.Device {
|
|
5937
5957
|
static isSupported() {
|
|
5938
5958
|
return typeof WebGLRenderingContext !== "undefined" || isHeadlessGLRegistered();
|
|
5939
5959
|
}
|
|
@@ -5965,7 +5985,7 @@ var _WebGLDevice = class extends import_core27.Device {
|
|
|
5965
5985
|
if (gl instanceof _WebGLDevice) {
|
|
5966
5986
|
return gl;
|
|
5967
5987
|
}
|
|
5968
|
-
if ((gl == null ? void 0 : gl.device) instanceof
|
|
5988
|
+
if ((gl == null ? void 0 : gl.device) instanceof import_core26.Device) {
|
|
5969
5989
|
return gl.device;
|
|
5970
5990
|
}
|
|
5971
5991
|
if (!isWebGL3(gl)) {
|
|
@@ -5974,29 +5994,34 @@ var _WebGLDevice = class extends import_core27.Device {
|
|
|
5974
5994
|
return new _WebGLDevice({ gl });
|
|
5975
5995
|
}
|
|
5976
5996
|
static async create(props = {}) {
|
|
5977
|
-
|
|
5997
|
+
import_core26.log.groupCollapsed(LOG_LEVEL2, "WebGLDevice created")();
|
|
5978
5998
|
if (typeof props.canvas === "string") {
|
|
5979
|
-
await
|
|
5999
|
+
await import_core26.CanvasContext.pageLoaded;
|
|
5980
6000
|
}
|
|
5981
|
-
if (
|
|
6001
|
+
if (import_core26.log.get("debug") || props.debug) {
|
|
5982
6002
|
await loadWebGLDeveloperTools();
|
|
5983
6003
|
}
|
|
5984
6004
|
const { spector: spector2 } = props;
|
|
5985
|
-
if (
|
|
6005
|
+
if (import_core26.log.get("spector") || spector2) {
|
|
5986
6006
|
await loadSpectorJS();
|
|
5987
6007
|
}
|
|
5988
|
-
|
|
6008
|
+
import_core26.log.probe(LOG_LEVEL2 + 1, "DOM is loaded")();
|
|
5989
6009
|
if (props.gl && props.gl.device) {
|
|
5990
6010
|
return _WebGLDevice.attach(props.gl);
|
|
5991
6011
|
}
|
|
5992
|
-
|
|
6012
|
+
const device = new _WebGLDevice(props);
|
|
6013
|
+
const message2 = `Created ${device.info.type}${device.debug ? " debug" : ""} context: ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;
|
|
6014
|
+
import_core26.log.probe(LOG_LEVEL2, message2)();
|
|
6015
|
+
import_core26.log.table(LOG_LEVEL2, device.info)();
|
|
6016
|
+
import_core26.log.groupEnd(LOG_LEVEL2)();
|
|
6017
|
+
return device;
|
|
5993
6018
|
}
|
|
5994
6019
|
//
|
|
5995
6020
|
// Public API
|
|
5996
6021
|
//
|
|
5997
6022
|
constructor(props) {
|
|
5998
6023
|
var _a;
|
|
5999
|
-
super({ ...props, id: props.id || (0,
|
|
6024
|
+
super({ ...props, id: props.id || (0, import_core26.uid)("webgl-device") });
|
|
6000
6025
|
const device = (_a = props.gl) == null ? void 0 : _a.device;
|
|
6001
6026
|
if (device) {
|
|
6002
6027
|
throw new Error(`WebGL context already attached to device ${device.id}`);
|
|
@@ -6031,22 +6056,19 @@ var _WebGLDevice = class extends import_core27.Device {
|
|
|
6031
6056
|
trackContextState(this.gl, {
|
|
6032
6057
|
enable: enable2,
|
|
6033
6058
|
copyState,
|
|
6034
|
-
log: (...args) =>
|
|
6059
|
+
log: (...args) => import_core26.log.log(1, ...args)()
|
|
6035
6060
|
});
|
|
6036
6061
|
if ((0, import_env3.isBrowser)() && props.debug) {
|
|
6037
6062
|
this.gl = makeDebugContext(this.gl, { ...props, webgl2: this.isWebGL2, throwOnError: true });
|
|
6038
6063
|
this.gl2 = this.gl;
|
|
6039
6064
|
this.debug = true;
|
|
6040
|
-
|
|
6041
|
-
|
|
6065
|
+
import_core26.log.level = Math.max(import_core26.log.level, 1);
|
|
6066
|
+
import_core26.log.warn("WebGL debug mode activated. Performance reduced.")();
|
|
6042
6067
|
}
|
|
6043
6068
|
if ((0, import_env3.isBrowser)() && props.spector) {
|
|
6044
6069
|
const canvas = this.handle.canvas || props.canvas;
|
|
6045
6070
|
this.spector = initializeSpectorJS({ ...this.props, canvas });
|
|
6046
6071
|
}
|
|
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
6072
|
}
|
|
6051
6073
|
/**
|
|
6052
6074
|
* Destroys the context
|
|
@@ -6227,7 +6249,7 @@ var _WebGLDevice = class extends import_core27.Device {
|
|
|
6227
6249
|
this._constants = this._constants || new Array(this.limits.maxVertexAttributes).fill(null);
|
|
6228
6250
|
const currentConstant = this._constants[location];
|
|
6229
6251
|
if (currentConstant && compareConstantArrayValues2(currentConstant, constant)) {
|
|
6230
|
-
|
|
6252
|
+
import_core26.log.info(1, `setConstantAttribute(${location}) could have been skipped, value unchanged`)();
|
|
6231
6253
|
}
|
|
6232
6254
|
this._constants[location] = constant;
|
|
6233
6255
|
switch (constant.constructor) {
|
|
@@ -6241,7 +6263,7 @@ var _WebGLDevice = class extends import_core27.Device {
|
|
|
6241
6263
|
setConstantUintArray(this, location, constant);
|
|
6242
6264
|
break;
|
|
6243
6265
|
default:
|
|
6244
|
-
(0,
|
|
6266
|
+
(0, import_core26.assert)(false);
|
|
6245
6267
|
}
|
|
6246
6268
|
}
|
|
6247
6269
|
};
|
|
@@ -6280,7 +6302,7 @@ function setConstantFloatArray(device, location, array) {
|
|
|
6280
6302
|
device.gl.vertexAttrib4fv(location, array);
|
|
6281
6303
|
break;
|
|
6282
6304
|
default:
|
|
6283
|
-
(0,
|
|
6305
|
+
(0, import_core26.assert)(false);
|
|
6284
6306
|
}
|
|
6285
6307
|
}
|
|
6286
6308
|
function setConstantIntArray(device, location, array) {
|
|
@@ -6306,7 +6328,7 @@ function compareConstantArrayValues2(v1, v2) {
|
|
|
6306
6328
|
}
|
|
6307
6329
|
|
|
6308
6330
|
// src/classic/clear.ts
|
|
6309
|
-
var
|
|
6331
|
+
var import_core27 = require("@luma.gl/core");
|
|
6310
6332
|
var GL_DEPTH_BUFFER_BIT2 = 256;
|
|
6311
6333
|
var GL_STENCIL_BUFFER_BIT2 = 1024;
|
|
6312
6334
|
var GL_COLOR_BUFFER_BIT2 = 16384;
|
|
@@ -6337,18 +6359,18 @@ function clear(gl, options) {
|
|
|
6337
6359
|
parameters.clearStencil = depth;
|
|
6338
6360
|
}
|
|
6339
6361
|
}
|
|
6340
|
-
(0,
|
|
6362
|
+
(0, import_core27.assert)(clearFlags !== 0, ERR_ARGUMENTS);
|
|
6341
6363
|
withGLParameters(device.gl, parameters, () => {
|
|
6342
6364
|
device.gl.clear(clearFlags);
|
|
6343
6365
|
});
|
|
6344
6366
|
}
|
|
6345
6367
|
|
|
6346
6368
|
// src/classic/copy-and-blit.ts
|
|
6347
|
-
var
|
|
6369
|
+
var import_core29 = require("@luma.gl/core");
|
|
6348
6370
|
var import_constants29 = require("@luma.gl/constants");
|
|
6349
6371
|
|
|
6350
6372
|
// src/classic/format-utils.ts
|
|
6351
|
-
var
|
|
6373
|
+
var import_core28 = require("@luma.gl/core");
|
|
6352
6374
|
var import_constants28 = require("@luma.gl/constants");
|
|
6353
6375
|
function glFormatToComponents(format) {
|
|
6354
6376
|
switch (format) {
|
|
@@ -6366,7 +6388,7 @@ function glFormatToComponents(format) {
|
|
|
6366
6388
|
case import_constants28.GL.RGBA32F:
|
|
6367
6389
|
return 4;
|
|
6368
6390
|
default:
|
|
6369
|
-
(0,
|
|
6391
|
+
(0, import_core28.assert)(false);
|
|
6370
6392
|
return 0;
|
|
6371
6393
|
}
|
|
6372
6394
|
}
|
|
@@ -6381,7 +6403,7 @@ function glTypeToBytes(type) {
|
|
|
6381
6403
|
case import_constants28.GL.FLOAT:
|
|
6382
6404
|
return 4;
|
|
6383
6405
|
default:
|
|
6384
|
-
(0,
|
|
6406
|
+
(0, import_core28.assert)(false);
|
|
6385
6407
|
return 0;
|
|
6386
6408
|
}
|
|
6387
6409
|
}
|
|
@@ -6404,7 +6426,7 @@ function readPixelsToArray(source, options) {
|
|
|
6404
6426
|
sourceType
|
|
6405
6427
|
} = options || {};
|
|
6406
6428
|
const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
|
|
6407
|
-
(0,
|
|
6429
|
+
(0, import_core29.assert)(framebuffer);
|
|
6408
6430
|
const { gl, handle } = framebuffer;
|
|
6409
6431
|
sourceWidth = sourceWidth || framebuffer.width;
|
|
6410
6432
|
sourceHeight = sourceHeight || framebuffer.height;
|
|
@@ -6424,7 +6446,7 @@ function readPixelsToBuffer(source, options) {
|
|
|
6424
6446
|
const { sourceX = 0, sourceY = 0, sourceFormat = import_constants29.GL.RGBA, targetByteOffset = 0 } = options || {};
|
|
6425
6447
|
let { target, sourceWidth, sourceHeight, sourceType } = options || {};
|
|
6426
6448
|
const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
|
|
6427
|
-
(0,
|
|
6449
|
+
(0, import_core29.assert)(framebuffer);
|
|
6428
6450
|
sourceWidth = sourceWidth || framebuffer.width;
|
|
6429
6451
|
sourceHeight = sourceHeight || framebuffer.height;
|
|
6430
6452
|
const webglFramebuffer = framebuffer;
|
|
@@ -6468,7 +6490,7 @@ function copyToTexture(source, target, options) {
|
|
|
6468
6490
|
// defaults to target height
|
|
6469
6491
|
} = options || {};
|
|
6470
6492
|
const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
|
|
6471
|
-
(0,
|
|
6493
|
+
(0, import_core29.assert)(framebuffer);
|
|
6472
6494
|
const webglFramebuffer = framebuffer;
|
|
6473
6495
|
const { device, handle } = webglFramebuffer;
|
|
6474
6496
|
const isSubCopy = typeof targetX !== "undefined" || typeof targetY !== "undefined" || typeof targetZ !== "undefined";
|
|
@@ -6476,10 +6498,10 @@ function copyToTexture(source, target, options) {
|
|
|
6476
6498
|
targetY = targetY || 0;
|
|
6477
6499
|
targetZ = targetZ || 0;
|
|
6478
6500
|
const prevHandle = device.gl.bindFramebuffer(import_constants29.GL.FRAMEBUFFER, handle);
|
|
6479
|
-
(0,
|
|
6501
|
+
(0, import_core29.assert)(target);
|
|
6480
6502
|
let texture = null;
|
|
6481
6503
|
let textureTarget;
|
|
6482
|
-
if (target instanceof
|
|
6504
|
+
if (target instanceof import_core29.Texture) {
|
|
6483
6505
|
texture = target;
|
|
6484
6506
|
width = Number.isFinite(width) ? width : texture.width;
|
|
6485
6507
|
height = Number.isFinite(height) ? height : texture.height;
|
|
@@ -6543,7 +6565,7 @@ function copyToTexture(source, target, options) {
|
|
|
6543
6565
|
return texture;
|
|
6544
6566
|
}
|
|
6545
6567
|
function getFramebuffer2(source) {
|
|
6546
|
-
if (!(source instanceof
|
|
6568
|
+
if (!(source instanceof import_core29.Framebuffer)) {
|
|
6547
6569
|
return { framebuffer: toFramebuffer(source), deleteFramebuffer: true };
|
|
6548
6570
|
}
|
|
6549
6571
|
return { framebuffer: source, deleteFramebuffer: false };
|