@deck.gl/google-maps 9.2.11 → 9.3.0-alpha.1

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/dist.dev.js CHANGED
@@ -904,16 +904,15 @@ var __exports__ = (() => {
904
904
  const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);
905
905
  const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);
906
906
  const message2 = `${errorMessage} in gl.${functionName}(${functionArgs})`;
907
- import_core3.log.error(message2)();
907
+ import_core3.log.error("%cWebGL", "color: white; background: red; padding: 2px 6px; border-radius: 3px;", message2)();
908
908
  debugger;
909
+ throw new Error(message2);
909
910
  }
910
911
  function onValidateGLFunc(props, functionName, functionArgs) {
911
912
  let functionString = "";
912
- if (import_core3.log.level >= 1) {
913
+ if (props.traceWebGL && import_core3.log.level >= 1) {
913
914
  functionString = getFunctionString(functionName, functionArgs);
914
- if (props.traceWebGL) {
915
- import_core3.log.log(1, functionString)();
916
- }
915
+ import_core3.log.info(1, "%cWebGL", "color: white; background: blue; padding: 2px 6px; border-radius: 3px;", functionString)();
917
916
  }
918
917
  for (const arg of functionArgs) {
919
918
  if (arg === void 0) {
@@ -1619,38 +1618,53 @@ var __exports__ = (() => {
1619
1618
  // ../../node_modules/@luma.gl/webgl/dist/context/helpers/create-browser-context.js
1620
1619
  function createBrowserContext(canvas, props, webglContextAttributes) {
1621
1620
  let errorMessage = "";
1621
+ const onCreateError = (event) => {
1622
+ const statusMessage = event.statusMessage;
1623
+ if (statusMessage) {
1624
+ errorMessage ||= statusMessage;
1625
+ }
1626
+ };
1627
+ canvas.addEventListener("webglcontextcreationerror", onCreateError, false);
1628
+ const allowSoftwareRenderer = webglContextAttributes.failIfMajorPerformanceCaveat !== true;
1622
1629
  const webglProps = {
1623
1630
  preserveDrawingBuffer: true,
1624
- // failIfMajorPerformanceCaveat: true,
1625
- ...webglContextAttributes
1631
+ ...webglContextAttributes,
1632
+ // Always start by requesting a high-performance context.
1633
+ failIfMajorPerformanceCaveat: true
1626
1634
  };
1627
1635
  let gl = null;
1628
- gl ||= canvas.getContext("webgl2", webglProps);
1629
- if (webglProps.failIfMajorPerformanceCaveat) {
1630
- errorMessage ||= "Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.";
1631
- }
1632
- if (!gl && !webglContextAttributes.failIfMajorPerformanceCaveat) {
1633
- webglProps.failIfMajorPerformanceCaveat = false;
1634
- gl = canvas.getContext("webgl2", webglProps);
1635
- gl.luma ||= {};
1636
- gl.luma.softwareRenderer = true;
1637
- }
1638
- if (!gl) {
1639
- gl = canvas.getContext("webgl", {});
1640
- if (gl) {
1641
- gl = null;
1642
- errorMessage ||= "Your browser only supports WebGL1";
1636
+ try {
1637
+ gl ||= canvas.getContext("webgl2", webglProps);
1638
+ if (!gl && webglProps.failIfMajorPerformanceCaveat) {
1639
+ errorMessage ||= "Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.";
1643
1640
  }
1641
+ if (!gl && allowSoftwareRenderer) {
1642
+ webglProps.failIfMajorPerformanceCaveat = false;
1643
+ gl = canvas.getContext("webgl2", webglProps);
1644
+ if (gl) {
1645
+ gl.luma ||= {};
1646
+ gl.luma.softwareRenderer = true;
1647
+ }
1648
+ }
1649
+ if (!gl) {
1650
+ gl = canvas.getContext("webgl", {});
1651
+ if (gl) {
1652
+ gl = null;
1653
+ errorMessage ||= "Your browser only supports WebGL1";
1654
+ }
1655
+ }
1656
+ if (!gl) {
1657
+ errorMessage ||= "Your browser does not support WebGL";
1658
+ throw new Error(`Failed to create WebGL context: ${errorMessage}`);
1659
+ }
1660
+ const { onContextLost, onContextRestored } = props;
1661
+ canvas.addEventListener("webglcontextlost", (event) => onContextLost(event), false);
1662
+ canvas.addEventListener("webglcontextrestored", (event) => onContextRestored(event), false);
1663
+ gl.luma ||= {};
1664
+ return gl;
1665
+ } finally {
1666
+ canvas.removeEventListener("webglcontextcreationerror", onCreateError, false);
1644
1667
  }
1645
- if (!gl) {
1646
- errorMessage ||= "Your browser does not support WebGL";
1647
- throw new Error(`Failed to create WebGL context: ${errorMessage}`);
1648
- }
1649
- const { onContextLost, onContextRestored } = props;
1650
- canvas.addEventListener("webglcontextlost", (event) => onContextLost(event), false);
1651
- canvas.addEventListener("webglcontextrestored", (event) => onContextRestored(event), false);
1652
- gl.luma ||= {};
1653
- return gl;
1654
1668
  }
1655
1669
  var init_create_browser_context = __esm({
1656
1670
  "../../node_modules/@luma.gl/webgl/dist/context/helpers/create-browser-context.js"() {
@@ -2387,14 +2401,24 @@ var __exports__ = (() => {
2387
2401
  super(props);
2388
2402
  this.device = device;
2389
2403
  this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);
2390
- this._updateDevice();
2391
- }
2392
- getCurrentFramebuffer() {
2393
- this._framebuffer = this._framebuffer || new WEBGLFramebuffer(this.device, { handle: null });
2394
- return this._framebuffer;
2404
+ this._configureDevice();
2395
2405
  }
2396
2406
  // IMPLEMENTATION OF ABSTRACT METHODS
2397
- _updateDevice() {
2407
+ _configureDevice() {
2408
+ const shouldResize = this.drawingBufferWidth !== this._framebuffer?.width || this.drawingBufferHeight !== this._framebuffer?.height;
2409
+ if (shouldResize) {
2410
+ this._framebuffer?.resize([this.drawingBufferWidth, this.drawingBufferHeight]);
2411
+ }
2412
+ }
2413
+ _getCurrentFramebuffer() {
2414
+ this._framebuffer ||= new WEBGLFramebuffer(this.device, {
2415
+ id: "canvas-context-framebuffer",
2416
+ handle: null,
2417
+ // Setting handle to null returns a reference to the default WebGL framebuffer
2418
+ width: this.drawingBufferWidth,
2419
+ height: this.drawingBufferHeight
2420
+ });
2421
+ return this._framebuffer;
2398
2422
  }
2399
2423
  };
2400
2424
  }
@@ -3127,6 +3151,115 @@ ${source}`;
3127
3151
  }
3128
3152
  });
3129
3153
 
3154
+ // ../../node_modules/@luma.gl/webgl/dist/adapter/converters/webgl-shadertypes.js
3155
+ function convertDataTypeToGLDataType(normalizedType) {
3156
+ return NORMALIZED_SHADER_TYPE_TO_WEBGL[normalizedType];
3157
+ }
3158
+ function convertGLUniformTypeToShaderVariableType(glUniformType) {
3159
+ return WEBGL_SHADER_TYPES[glUniformType];
3160
+ }
3161
+ function isGLSamplerType(type) {
3162
+ return Boolean(WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[type]);
3163
+ }
3164
+ function getTextureBindingFromGLSamplerType(glSamplerType) {
3165
+ return WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[glSamplerType];
3166
+ }
3167
+ var WEBGL_SHADER_TYPES, WEBGL_SAMPLER_TO_TEXTURE_BINDINGS, NORMALIZED_SHADER_TYPE_TO_WEBGL;
3168
+ var init_webgl_shadertypes = __esm({
3169
+ "../../node_modules/@luma.gl/webgl/dist/adapter/converters/webgl-shadertypes.js"() {
3170
+ WEBGL_SHADER_TYPES = {
3171
+ [5126]: "f32",
3172
+ [35664]: "vec2<f32>",
3173
+ [35665]: "vec3<f32>",
3174
+ [35666]: "vec4<f32>",
3175
+ [5124]: "i32",
3176
+ [35667]: "vec2<i32>",
3177
+ [35668]: "vec3<i32>",
3178
+ [35669]: "vec4<i32>",
3179
+ [5125]: "u32",
3180
+ [36294]: "vec2<u32>",
3181
+ [36295]: "vec3<u32>",
3182
+ [36296]: "vec4<u32>",
3183
+ [35670]: "f32",
3184
+ [35671]: "vec2<f32>",
3185
+ [35672]: "vec3<f32>",
3186
+ [35673]: "vec4<f32>",
3187
+ // TODO - are sizes/components below correct?
3188
+ [35674]: "mat2x2<f32>",
3189
+ [35685]: "mat2x3<f32>",
3190
+ [35686]: "mat2x4<f32>",
3191
+ [35687]: "mat3x2<f32>",
3192
+ [35675]: "mat3x3<f32>",
3193
+ [35688]: "mat3x4<f32>",
3194
+ [35689]: "mat4x2<f32>",
3195
+ [35690]: "mat4x3<f32>",
3196
+ [35676]: "mat4x4<f32>"
3197
+ };
3198
+ WEBGL_SAMPLER_TO_TEXTURE_BINDINGS = {
3199
+ [35678]: { viewDimension: "2d", sampleType: "float" },
3200
+ [35680]: { viewDimension: "cube", sampleType: "float" },
3201
+ [35679]: { viewDimension: "3d", sampleType: "float" },
3202
+ [35682]: { viewDimension: "3d", sampleType: "depth" },
3203
+ [36289]: { viewDimension: "2d-array", sampleType: "float" },
3204
+ [36292]: { viewDimension: "2d-array", sampleType: "depth" },
3205
+ [36293]: { viewDimension: "cube", sampleType: "float" },
3206
+ [36298]: { viewDimension: "2d", sampleType: "sint" },
3207
+ [36299]: { viewDimension: "3d", sampleType: "sint" },
3208
+ [36300]: { viewDimension: "cube", sampleType: "sint" },
3209
+ [36303]: { viewDimension: "2d-array", sampleType: "uint" },
3210
+ [36306]: { viewDimension: "2d", sampleType: "uint" },
3211
+ [36307]: { viewDimension: "3d", sampleType: "uint" },
3212
+ [36308]: { viewDimension: "cube", sampleType: "uint" },
3213
+ [36311]: { viewDimension: "2d-array", sampleType: "uint" }
3214
+ };
3215
+ NORMALIZED_SHADER_TYPE_TO_WEBGL = {
3216
+ uint8: 5121,
3217
+ sint8: 5120,
3218
+ unorm8: 5121,
3219
+ snorm8: 5120,
3220
+ uint16: 5123,
3221
+ sint16: 5122,
3222
+ unorm16: 5123,
3223
+ snorm16: 5122,
3224
+ uint32: 5125,
3225
+ sint32: 5124,
3226
+ // WebGPU does not support normalized 32 bit integer attributes
3227
+ // 'unorm32': GL.UNSIGNED_INT,
3228
+ // 'snorm32': GL.INT,
3229
+ float16: 5131,
3230
+ float32: 5126
3231
+ };
3232
+ }
3233
+ });
3234
+
3235
+ // ../../node_modules/@luma.gl/webgl/dist/adapter/converters/shader-formats.js
3236
+ function convertGLDataTypeToDataType(type) {
3237
+ return GL_DATA_TYPE_MAP[type];
3238
+ }
3239
+ var GL_DATA_TYPE_MAP;
3240
+ var init_shader_formats = __esm({
3241
+ "../../node_modules/@luma.gl/webgl/dist/adapter/converters/shader-formats.js"() {
3242
+ GL_DATA_TYPE_MAP = {
3243
+ [5124]: "sint32",
3244
+ [5125]: "uint32",
3245
+ [5122]: "sint16",
3246
+ [5123]: "uint16",
3247
+ [5120]: "sint8",
3248
+ [5121]: "uint8",
3249
+ [5126]: "float32",
3250
+ [5131]: "float16",
3251
+ [33635]: "uint16",
3252
+ [32819]: "uint16",
3253
+ [32820]: "uint16",
3254
+ [33640]: "uint32",
3255
+ [35899]: "uint32",
3256
+ [35902]: "uint32",
3257
+ [34042]: "uint32",
3258
+ [36269]: "uint32"
3259
+ };
3260
+ }
3261
+ });
3262
+
3130
3263
  // ../../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-texture.js
3131
3264
  function getWebGLTextureTarget(dimension) {
3132
3265
  switch (dimension) {
@@ -3148,7 +3281,7 @@ ${source}`;
3148
3281
  function getWebGLCubeFaceTarget(glTarget, dimension, level) {
3149
3282
  return dimension === "cube" ? 34069 + level : glTarget;
3150
3283
  }
3151
- var import_core14, WEBGLTexture;
3284
+ var import_core14, import_core15, WEBGLTexture;
3152
3285
  var init_webgl_texture = __esm({
3153
3286
  "../../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-texture.js"() {
3154
3287
  import_core14 = __toESM(require_core2(), 1);
@@ -3156,6 +3289,9 @@ ${source}`;
3156
3289
  init_sampler_parameters();
3157
3290
  init_with_parameters();
3158
3291
  init_webgl_texture_view();
3292
+ init_webgl_shadertypes();
3293
+ init_shader_formats();
3294
+ import_core15 = __toESM(require_core2(), 1);
3159
3295
  WEBGLTexture = class extends import_core14.Texture {
3160
3296
  // readonly MAX_ATTRIBUTES: number;
3161
3297
  device;
@@ -3185,8 +3321,10 @@ ${source}`;
3185
3321
  // state
3186
3322
  /** Texture binding slot - TODO - move to texture view? */
3187
3323
  _textureUnit = 0;
3324
+ /** Chached framebuffer */
3325
+ _framebuffer = null;
3188
3326
  constructor(device, props) {
3189
- super(device, props);
3327
+ super(device, props, { byteAlignment: 1 });
3190
3328
  this.device = device;
3191
3329
  this.gl = this.device.gl;
3192
3330
  const formatInfo = getTextureFormatWebGL(this.props.format);
@@ -3219,6 +3357,8 @@ ${source}`;
3219
3357
  }
3220
3358
  destroy() {
3221
3359
  if (this.handle) {
3360
+ this._framebuffer?.destroy();
3361
+ this._framebuffer = null;
3222
3362
  this.gl.deleteTexture(this.handle);
3223
3363
  this.removeStats();
3224
3364
  this.trackDeallocatedMemory("Texture");
@@ -3233,11 +3373,37 @@ ${source}`;
3233
3373
  const parameters = convertSamplerParametersToWebGL(this.sampler.props);
3234
3374
  this._setSamplerParameters(parameters);
3235
3375
  }
3376
+ copyExternalImage(options_) {
3377
+ const options = this._normalizeCopyExternalImageOptions(options_);
3378
+ if (options.sourceX || options.sourceY) {
3379
+ throw new Error("WebGL does not support sourceX/sourceY)");
3380
+ }
3381
+ const { glFormat, glType } = this;
3382
+ const { image, depth, mipLevel, x, y, z, width, height } = options;
3383
+ const glTarget = getWebGLCubeFaceTarget(this.glTarget, this.dimension, z);
3384
+ const glParameters = options.flipY ? { [37440]: true } : {};
3385
+ this.gl.bindTexture(this.glTarget, this.handle);
3386
+ withGLParameters(this.gl, glParameters, () => {
3387
+ switch (this.dimension) {
3388
+ case "2d":
3389
+ case "cube":
3390
+ this.gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, glType, image);
3391
+ break;
3392
+ case "2d-array":
3393
+ case "3d":
3394
+ this.gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, image);
3395
+ break;
3396
+ default:
3397
+ }
3398
+ });
3399
+ this.gl.bindTexture(this.glTarget, null);
3400
+ return { width: options.width, height: options.height };
3401
+ }
3236
3402
  copyImageData(options_) {
3237
3403
  const options = this._normalizeCopyImageDataOptions(options_);
3238
3404
  const typedArray = options.data;
3239
- const { width, height, depth } = this;
3240
- const { mipLevel = 0, byteOffset = 0, x = 0, y = 0, z = 0 } = options;
3405
+ const { width, height, depth, z = 0 } = options;
3406
+ const { mipLevel = 0, byteOffset = 0, x = 0, y = 0 } = options;
3241
3407
  const { glFormat, glType, compressed } = this;
3242
3408
  const glTarget = getWebGLCubeFaceTarget(this.glTarget, this.dimension, z);
3243
3409
  let unpackRowLength;
@@ -3251,10 +3417,11 @@ ${source}`;
3251
3417
  }
3252
3418
  }
3253
3419
  const glParameters = !this.compressed ? {
3420
+ [3317]: this.byteAlignment,
3254
3421
  ...unpackRowLength !== void 0 ? { [3314]: unpackRowLength } : {},
3255
3422
  [32878]: options.rowsPerImage
3256
3423
  } : {};
3257
- this.gl.bindTexture(glTarget, this.handle);
3424
+ this.gl.bindTexture(this.glTarget, this.handle);
3258
3425
  withGLParameters(this.gl, glParameters, () => {
3259
3426
  switch (this.dimension) {
3260
3427
  case "2d":
@@ -3276,35 +3443,92 @@ ${source}`;
3276
3443
  default:
3277
3444
  }
3278
3445
  });
3279
- this.gl.bindTexture(glTarget, null);
3446
+ this.gl.bindTexture(this.glTarget, null);
3280
3447
  }
3281
- copyExternalImage(options_) {
3282
- const options = this._normalizeCopyExternalImageOptions(options_);
3283
- if (options.sourceX || options.sourceY) {
3284
- throw new Error("WebGL does not support sourceX/sourceY)");
3285
- }
3286
- const { glFormat, glType } = this;
3287
- const { image, depth, mipLevel, x, y, z, width, height } = options;
3448
+ readBuffer(options = {}, buffer) {
3449
+ throw new Error("readBuffer not implemented");
3450
+ }
3451
+ async readDataAsync(options = {}) {
3452
+ return this.readDataSyncWebGL(options);
3453
+ }
3454
+ writeBuffer(buffer, options_ = {}) {
3455
+ }
3456
+ writeData(data, options_ = {}) {
3457
+ const options = this._normalizeTextureWriteOptions(options_);
3458
+ const typedArray = ArrayBuffer.isView(data) ? data : new Uint8Array(data);
3459
+ const {} = this;
3460
+ const { width, height, mipLevel, x, y, z } = options;
3461
+ const { glFormat, glType, compressed } = this;
3462
+ const depth = 0;
3288
3463
  const glTarget = getWebGLCubeFaceTarget(this.glTarget, this.dimension, depth);
3289
- const glParameters = options.flipY ? { [37440]: true } : {};
3290
- this.gl.bindTexture(this.glTarget, this.handle);
3464
+ const glParameters = !this.compressed ? {
3465
+ // WebGL does not require byte alignment, but allows it to be specified
3466
+ [3317]: this.byteAlignment
3467
+ // [GL.UNPACK_ROW_LENGTH]: bytesPerRow,
3468
+ // [GL.UNPACK_IMAGE_HEIGHT]: rowsPerImage
3469
+ } : {};
3470
+ this.gl.bindTexture(glTarget, this.handle);
3471
+ this.gl.bindBuffer(35052, null);
3291
3472
  withGLParameters(this.gl, glParameters, () => {
3292
3473
  switch (this.dimension) {
3293
3474
  case "2d":
3294
3475
  case "cube":
3295
- this.gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, glType, image);
3476
+ if (compressed) {
3477
+ this.gl.compressedTexSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, typedArray);
3478
+ } else {
3479
+ this.gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, glType, typedArray);
3480
+ }
3296
3481
  break;
3297
3482
  case "2d-array":
3298
3483
  case "3d":
3299
- this.gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, image);
3484
+ if (compressed) {
3485
+ this.gl.compressedTexSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, typedArray);
3486
+ } else {
3487
+ this.gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, typedArray);
3488
+ }
3300
3489
  break;
3301
3490
  default:
3302
3491
  }
3303
3492
  });
3304
- this.gl.bindTexture(this.glTarget, null);
3305
- return { width: options.width, height: options.height };
3493
+ this.gl.bindTexture(glTarget, null);
3494
+ }
3495
+ // IMPLEMENTATION SPECIFIC
3496
+ /** @todo - for now we always use 1 for maximum compatibility, we can fine tune later */
3497
+ _getRowByteAlignment(format, width) {
3498
+ return 1;
3499
+ }
3500
+ /**
3501
+ * Wraps a given texture into a framebuffer object, that can be further used
3502
+ * to read data from the texture object.
3503
+ */
3504
+ _getFramebuffer() {
3505
+ this._framebuffer ||= this.device.createFramebuffer({
3506
+ id: `framebuffer-for-${this.id}`,
3507
+ width: this.width,
3508
+ height: this.height,
3509
+ colorAttachments: [this]
3510
+ });
3511
+ return this._framebuffer;
3306
3512
  }
3307
3513
  // WEBGL SPECIFIC
3514
+ readDataSyncWebGL(options_ = {}) {
3515
+ const options = this._normalizeTextureReadOptions(options_);
3516
+ const memoryLayout = this.computeMemoryLayout(options);
3517
+ const shaderType = convertGLDataTypeToDataType(this.glType);
3518
+ const ArrayType = (0, import_core15.getTypedArrayConstructor)(shaderType);
3519
+ const targetArray = new ArrayType(memoryLayout.byteLength);
3520
+ const signedType = (0, import_core15.getDataType)(targetArray);
3521
+ const sourceType = convertDataTypeToGLDataType(signedType);
3522
+ const framebuffer = this._getFramebuffer();
3523
+ const prevHandle = this.gl.bindFramebuffer(36160, framebuffer.handle);
3524
+ this.gl.readBuffer(36064);
3525
+ this.gl.readPixels(options.x, options.y, options.width, options.height, this.glFormat, sourceType, targetArray);
3526
+ this.gl.bindFramebuffer(36160, prevHandle || null);
3527
+ return targetArray.buffer;
3528
+ }
3529
+ /**
3530
+ * @note - this is used by the DynamicTexture class to generate mipmaps on WebGL
3531
+ */
3308
3532
  generateMipmapsWebGL(options) {
3309
3533
  const isFilterableAndRenderable = this.device.isTextureFormatRenderable(this.props.format) && this.device.isTextureFormatFilterable(this.props.format);
3310
3534
  if (!isFilterableAndRenderable) {
@@ -3384,87 +3608,6 @@ ${source}`;
3384
3608
  }
3385
3609
  });
3386
3610
 
3387
- // ../../node_modules/@luma.gl/webgl/dist/adapter/converters/webgl-shadertypes.js
3388
- function convertDataTypeToGLDataType(normalizedType) {
3389
- return NORMALIZED_SHADER_TYPE_TO_WEBGL[normalizedType];
3390
- }
3391
- function convertGLUniformTypeToShaderVariableType(glUniformType) {
3392
- return WEBGL_SHADER_TYPES[glUniformType];
3393
- }
3394
- function isGLSamplerType(type) {
3395
- return Boolean(WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[type]);
3396
- }
3397
- function getTextureBindingFromGLSamplerType(glSamplerType) {
3398
- return WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[glSamplerType];
3399
- }
3400
- var WEBGL_SHADER_TYPES, WEBGL_SAMPLER_TO_TEXTURE_BINDINGS, NORMALIZED_SHADER_TYPE_TO_WEBGL;
3401
- var init_webgl_shadertypes = __esm({
3402
- "../../node_modules/@luma.gl/webgl/dist/adapter/converters/webgl-shadertypes.js"() {
3403
- WEBGL_SHADER_TYPES = {
3404
- [5126]: "f32",
3405
- [35664]: "vec2<f32>",
3406
- [35665]: "vec3<f32>",
3407
- [35666]: "vec4<f32>",
3408
- [5124]: "i32",
3409
- [35667]: "vec2<i32>",
3410
- [35668]: "vec3<i32>",
3411
- [35669]: "vec4<i32>",
3412
- [5125]: "u32",
3413
- [36294]: "vec2<u32>",
3414
- [36295]: "vec3<u32>",
3415
- [36296]: "vec4<u32>",
3416
- [35670]: "f32",
3417
- [35671]: "vec2<f32>",
3418
- [35672]: "vec3<f32>",
3419
- [35673]: "vec4<f32>",
3420
- // TODO - are sizes/components below correct?
3421
- [35674]: "mat2x2<f32>",
3422
- [35685]: "mat2x3<f32>",
3423
- [35686]: "mat2x4<f32>",
3424
- [35687]: "mat3x2<f32>",
3425
- [35675]: "mat3x3<f32>",
3426
- [35688]: "mat3x4<f32>",
3427
- [35689]: "mat4x2<f32>",
3428
- [35690]: "mat4x3<f32>",
3429
- [35676]: "mat4x4<f32>"
3430
- };
3431
- WEBGL_SAMPLER_TO_TEXTURE_BINDINGS = {
3432
- [35678]: { viewDimension: "2d", sampleType: "float" },
3433
- [35680]: { viewDimension: "cube", sampleType: "float" },
3434
- [35679]: { viewDimension: "3d", sampleType: "float" },
3435
- [35682]: { viewDimension: "3d", sampleType: "depth" },
3436
- [36289]: { viewDimension: "2d-array", sampleType: "float" },
3437
- [36292]: { viewDimension: "2d-array", sampleType: "depth" },
3438
- [36293]: { viewDimension: "cube", sampleType: "float" },
3439
- [36298]: { viewDimension: "2d", sampleType: "sint" },
3440
- [36299]: { viewDimension: "3d", sampleType: "sint" },
3441
- [36300]: { viewDimension: "cube", sampleType: "sint" },
3442
- [36303]: { viewDimension: "2d-array", sampleType: "uint" },
3443
- [36306]: { viewDimension: "2d", sampleType: "uint" },
3444
- [36307]: { viewDimension: "3d", sampleType: "uint" },
3445
- [36308]: { viewDimension: "cube", sampleType: "uint" },
3446
- [36311]: { viewDimension: "2d-array", sampleType: "uint" }
3447
- };
3448
- NORMALIZED_SHADER_TYPE_TO_WEBGL = {
3449
- uint8: 5121,
3450
- sint8: 5120,
3451
- unorm8: 5121,
3452
- snorm8: 5120,
3453
- uint16: 5123,
3454
- sint16: 5122,
3455
- unorm16: 5123,
3456
- snorm16: 5122,
3457
- uint32: 5125,
3458
- sint32: 5124,
3459
- // WebGPU does not support normalized 32 bit integer attributes
3460
- // 'unorm32': GL.UNSIGNED_INT,
3461
- // 'snorm32': GL.INT,
3462
- float16: 5131,
3463
- float32: 5126
3464
- };
3465
- }
3466
- });
3467
-
3468
3611
  // ../../node_modules/@luma.gl/webgl/dist/adapter/helpers/get-shader-layout-from-glsl.js
3469
3612
  function getShaderLayoutFromGLSL(gl, program) {
3470
3613
  const shaderLayout = {
@@ -3556,7 +3699,7 @@ ${source}`;
3556
3699
  }
3557
3700
  const { name, type: glUniformType, size } = activeInfo;
3558
3701
  const uniformType = convertGLUniformTypeToShaderVariableType(glUniformType);
3559
- const { type, components } = (0, import_core15.getVariableShaderTypeInfo)(uniformType);
3702
+ const { type, components } = (0, import_core16.getVariableShaderTypeInfo)(uniformType);
3560
3703
  varyings.push({ location, name, type, size: size * components });
3561
3704
  }
3562
3705
  varyings.sort((a, b) => a.location - b.location);
@@ -3657,10 +3800,10 @@ ${source}`;
3657
3800
  isArray: Boolean(matches[2])
3658
3801
  };
3659
3802
  }
3660
- var import_core15;
3803
+ var import_core16;
3661
3804
  var init_get_shader_layout_from_glsl = __esm({
3662
3805
  "../../node_modules/@luma.gl/webgl/dist/adapter/helpers/get-shader-layout-from-glsl.js"() {
3663
- import_core15 = __toESM(require_core2(), 1);
3806
+ import_core16 = __toESM(require_core2(), 1);
3664
3807
  init_webgl_shadertypes();
3665
3808
  }
3666
3809
  });
@@ -3801,7 +3944,7 @@ ${source}`;
3801
3944
  for (const attribute of overrideLayout?.attributes || []) {
3802
3945
  const baseAttribute = mergedLayout.attributes.find((attr) => attr.name === attribute.name);
3803
3946
  if (!baseAttribute) {
3804
- import_core16.log.warn(`shader layout attribute ${attribute.name} not present in shader`);
3947
+ import_core17.log.warn(`shader layout attribute ${attribute.name} not present in shader`);
3805
3948
  } else {
3806
3949
  baseAttribute.type = attribute.type || baseAttribute.type;
3807
3950
  baseAttribute.stepMode = attribute.stepMode || baseAttribute.stepMode;
@@ -3809,10 +3952,10 @@ ${source}`;
3809
3952
  }
3810
3953
  return mergedLayout;
3811
3954
  }
3812
- var import_core16, LOG_PROGRAM_PERF_PRIORITY, WEBGLRenderPipeline;
3955
+ var import_core17, LOG_PROGRAM_PERF_PRIORITY, WEBGLRenderPipeline;
3813
3956
  var init_webgl_render_pipeline = __esm({
3814
3957
  "../../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-render-pipeline.js"() {
3815
- import_core16 = __toESM(require_core2(), 1);
3958
+ import_core17 = __toESM(require_core2(), 1);
3816
3959
  init_get_shader_layout_from_glsl();
3817
3960
  init_device_parameters();
3818
3961
  init_set_uniform();
@@ -3822,7 +3965,7 @@ ${source}`;
3822
3965
  init_webgl_texture_view();
3823
3966
  init_webgl_topology_utils();
3824
3967
  LOG_PROGRAM_PERF_PRIORITY = 4;
3825
- WEBGLRenderPipeline = class extends import_core16.RenderPipeline {
3968
+ WEBGLRenderPipeline = class extends import_core17.RenderPipeline {
3826
3969
  /** The WebGL device that created this render pipeline */
3827
3970
  device;
3828
3971
  /** Handle to underlying WebGL program */
@@ -3858,9 +4001,9 @@ ${source}`;
3858
4001
  this.device.gl.transformFeedbackVaryings(this.handle, varyings, bufferMode);
3859
4002
  }
3860
4003
  this._linkShaders();
3861
- import_core16.log.time(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();
4004
+ import_core17.log.time(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();
3862
4005
  this.introspectedLayout = getShaderLayoutFromGLSL(this.device.gl, this.handle);
3863
- import_core16.log.timeEnd(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();
4006
+ import_core17.log.timeEnd(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();
3864
4007
  this.shaderLayout = props.shaderLayout ? mergeShaderLayout(this.introspectedLayout, props.shaderLayout) : this.introspectedLayout;
3865
4008
  }
3866
4009
  destroy() {
@@ -3882,12 +4025,12 @@ ${source}`;
3882
4025
  if (!binding) {
3883
4026
  const validBindings = this.shaderLayout.bindings.map((binding_) => `"${binding_.name}"`).join(", ");
3884
4027
  if (!options?.disableWarnings) {
3885
- import_core16.log.warn(`No binding "${name}" in render pipeline "${this.id}", expected one of ${validBindings}`, value)();
4028
+ import_core17.log.warn(`No binding "${name}" in render pipeline "${this.id}", expected one of ${validBindings}`, value)();
3886
4029
  }
3887
4030
  continue;
3888
4031
  }
3889
4032
  if (!value) {
3890
- import_core16.log.warn(`Unsetting binding "${name}" in render pipeline "${this.id}"`)();
4033
+ import_core17.log.warn(`Unsetting binding "${name}" in render pipeline "${this.id}"`)();
3891
4034
  }
3892
4035
  switch (binding.type) {
3893
4036
  case "uniform":
@@ -3901,7 +4044,7 @@ ${source}`;
3901
4044
  }
3902
4045
  break;
3903
4046
  case "sampler":
3904
- import_core16.log.warn(`Ignoring sampler ${name}`)();
4047
+ import_core17.log.warn(`Ignoring sampler ${name}`)();
3905
4048
  break;
3906
4049
  default:
3907
4050
  throw new Error(binding.type);
@@ -3933,11 +4076,11 @@ ${source}`;
3933
4076
  const isIndexed = Boolean(vertexArray.indexBuffer);
3934
4077
  const glIndexType = vertexArray.indexBuffer?.glIndexType;
3935
4078
  if (this.linkStatus !== "success") {
3936
- import_core16.log.info(2, `RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)();
4079
+ import_core17.log.info(2, `RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)();
3937
4080
  return false;
3938
4081
  }
3939
4082
  if (!this._areTexturesRenderable()) {
3940
- import_core16.log.info(2, `RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)();
4083
+ import_core17.log.info(2, `RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)();
3941
4084
  return false;
3942
4085
  }
3943
4086
  this.device.gl.useProgram(this.handle);
@@ -3979,19 +4122,19 @@ ${source}`;
3979
4122
  const { gl } = this.device;
3980
4123
  gl.attachShader(this.handle, this.vs.handle);
3981
4124
  gl.attachShader(this.handle, this.fs.handle);
3982
- import_core16.log.time(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
4125
+ import_core17.log.time(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
3983
4126
  gl.linkProgram(this.handle);
3984
- import_core16.log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
3985
- if (import_core16.log.level === 0) {
4127
+ import_core17.log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
4128
+ if (import_core17.log.level === 0) {
3986
4129
  }
3987
4130
  if (!this.device.features.has("compilation-status-async-webgl")) {
3988
4131
  const status2 = this._getLinkStatus();
3989
4132
  this._reportLinkStatus(status2);
3990
4133
  return;
3991
4134
  }
3992
- import_core16.log.once(1, "RenderPipeline linking is asynchronous")();
4135
+ import_core17.log.once(1, "RenderPipeline linking is asynchronous")();
3993
4136
  await this._waitForLinkComplete();
3994
- import_core16.log.info(2, `RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();
4137
+ import_core17.log.info(2, `RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();
3995
4138
  const status = this._getLinkStatus();
3996
4139
  this._reportLinkStatus(status);
3997
4140
  }
@@ -4076,7 +4219,7 @@ ${source}`;
4076
4219
  let texturesRenderable = true;
4077
4220
  for (const bindingInfo of this.shaderLayout.bindings) {
4078
4221
  if (!this.bindings[bindingInfo.name] && !this.bindings[bindingInfo.name.replace(/Uniforms$/, "")]) {
4079
- import_core16.log.warn(`Binding ${bindingInfo.name} not found in ${this.id}`)();
4222
+ import_core17.log.warn(`Binding ${bindingInfo.name} not found in ${this.id}`)();
4080
4223
  texturesRenderable = false;
4081
4224
  }
4082
4225
  }
@@ -4130,7 +4273,7 @@ ${source}`;
4130
4273
  } else if (value instanceof WEBGLTexture) {
4131
4274
  texture = value;
4132
4275
  } else if (value instanceof WEBGLFramebuffer && value.colorAttachments[0] instanceof WEBGLTextureView) {
4133
- import_core16.log.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")();
4276
+ import_core17.log.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")();
4134
4277
  texture = value.colorAttachments[0].texture;
4135
4278
  } else {
4136
4279
  throw new Error("No texture");
@@ -4297,7 +4440,7 @@ ${source}`;
4297
4440
  }
4298
4441
  }
4299
4442
  function getFramebuffer(source) {
4300
- if (source instanceof import_core17.Texture) {
4443
+ if (source instanceof import_core18.Texture) {
4301
4444
  const { width, height, id } = source;
4302
4445
  const framebuffer = source.device.createFramebuffer({
4303
4446
  id: `framebuffer-for-${id}`,
@@ -4309,13 +4452,13 @@ ${source}`;
4309
4452
  }
4310
4453
  return { framebuffer: source, destroyFramebuffer: false };
4311
4454
  }
4312
- var import_core17, WEBGLCommandBuffer;
4455
+ var import_core18, WEBGLCommandBuffer;
4313
4456
  var init_webgl_command_buffer = __esm({
4314
4457
  "../../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-command-buffer.js"() {
4315
- import_core17 = __toESM(require_core2(), 1);
4458
+ import_core18 = __toESM(require_core2(), 1);
4316
4459
  init_webgl_texture();
4317
4460
  init_webgl_texture_table();
4318
- WEBGLCommandBuffer = class extends import_core17.CommandBuffer {
4461
+ WEBGLCommandBuffer = class extends import_core18.CommandBuffer {
4319
4462
  device;
4320
4463
  handle = null;
4321
4464
  commands = [];
@@ -4348,14 +4491,14 @@ ${source}`;
4348
4491
  });
4349
4492
 
4350
4493
  // ../../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-render-pass.js
4351
- var import_core18, COLOR_CHANNELS, WEBGLRenderPass;
4494
+ var import_core19, COLOR_CHANNELS, WEBGLRenderPass;
4352
4495
  var init_webgl_render_pass = __esm({
4353
4496
  "../../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-render-pass.js"() {
4354
- import_core18 = __toESM(require_core2(), 1);
4497
+ import_core19 = __toESM(require_core2(), 1);
4355
4498
  init_with_parameters();
4356
4499
  init_unified_parameter_api();
4357
4500
  COLOR_CHANNELS = [1, 2, 4, 8];
4358
- WEBGLRenderPass = class extends import_core18.RenderPass {
4501
+ WEBGLRenderPass = class extends import_core19.RenderPass {
4359
4502
  device;
4360
4503
  handle = null;
4361
4504
  /** Parameters that should be applied before each draw call */
@@ -4379,7 +4522,7 @@ ${source}`;
4379
4522
  if (this.props.framebuffer && webglFramebuffer?.handle) {
4380
4523
  const drawBuffers = this.props.framebuffer.colorAttachments.map((_, i) => 36064 + i);
4381
4524
  this.device.gl.drawBuffers(drawBuffers);
4382
- } else {
4525
+ } else if (!this.props.framebuffer) {
4383
4526
  this.device.gl.drawBuffers([1029]);
4384
4527
  }
4385
4528
  this.clear();
@@ -4425,9 +4568,9 @@ ${source}`;
4425
4568
  if (parameters.blendConstant) {
4426
4569
  glParameters.blendColor = parameters.blendConstant;
4427
4570
  }
4428
- if (parameters.stencilReference) {
4429
- console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL");
4571
+ if (parameters.stencilReference !== void 0) {
4430
4572
  glParameters[2967] = parameters.stencilReference;
4573
+ glParameters[36003] = parameters.stencilReference;
4431
4574
  }
4432
4575
  if ("colorMask" in parameters) {
4433
4576
  glParameters.colorMask = COLOR_CHANNELS.map((channel) => Boolean(channel & parameters.colorMask));
@@ -4505,13 +4648,13 @@ ${source}`;
4505
4648
  });
4506
4649
 
4507
4650
  // ../../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-command-encoder.js
4508
- var import_core19, WEBGLCommandEncoder;
4651
+ var import_core20, WEBGLCommandEncoder;
4509
4652
  var init_webgl_command_encoder = __esm({
4510
4653
  "../../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-command-encoder.js"() {
4511
- import_core19 = __toESM(require_core2(), 1);
4654
+ import_core20 = __toESM(require_core2(), 1);
4512
4655
  init_webgl_command_buffer();
4513
4656
  init_webgl_render_pass();
4514
- WEBGLCommandEncoder = class extends import_core19.CommandEncoder {
4657
+ WEBGLCommandEncoder = class extends import_core20.CommandEncoder {
4515
4658
  device;
4516
4659
  handle = null;
4517
4660
  commandBuffer;
@@ -4601,14 +4744,14 @@ ${source}`;
4601
4744
  }
4602
4745
  return true;
4603
4746
  }
4604
- var import_core20, WEBGLVertexArray;
4747
+ var import_core21, WEBGLVertexArray;
4605
4748
  var init_webgl_vertex_array = __esm({
4606
4749
  "../../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-vertex-array.js"() {
4607
- import_core20 = __toESM(require_core2(), 1);
4750
+ import_core21 = __toESM(require_core2(), 1);
4608
4751
  init_dist2();
4609
4752
  init_webgl_vertex_formats();
4610
4753
  init_fill_array();
4611
- WEBGLVertexArray = class extends import_core20.VertexArray {
4754
+ WEBGLVertexArray = class extends import_core21.VertexArray {
4612
4755
  get [Symbol.toStringTag]() {
4613
4756
  return "VertexArray";
4614
4757
  }
@@ -4774,7 +4917,7 @@ ${source}`;
4774
4917
  this.buffer = this.buffer || this.device.createBuffer({ byteLength });
4775
4918
  updateNeeded ||= !compareConstantArrayValues(constantValue, this.bufferValue);
4776
4919
  if (updateNeeded) {
4777
- const typedArray = (0, import_core20.getScratchArray)(value.constructor, length);
4920
+ const typedArray = (0, import_core21.getScratchArray)(value.constructor, length);
4778
4921
  fillArray({ target: typedArray, source: constantValue, start: 0, count: length });
4779
4922
  this.buffer.write(typedArray);
4780
4923
  this.bufferValue = value;
@@ -4792,13 +4935,13 @@ ${source}`;
4792
4935
  }
4793
4936
  return /^\d+$/.test(value);
4794
4937
  }
4795
- var import_core21, WEBGLTransformFeedback;
4938
+ var import_core22, WEBGLTransformFeedback;
4796
4939
  var init_webgl_transform_feedback = __esm({
4797
4940
  "../../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-transform-feedback.js"() {
4798
- import_core21 = __toESM(require_core2(), 1);
4941
+ import_core22 = __toESM(require_core2(), 1);
4799
4942
  init_dist3();
4800
4943
  init_webgl_topology_utils();
4801
- WEBGLTransformFeedback = class extends import_core21.TransformFeedback {
4944
+ WEBGLTransformFeedback = class extends import_core22.TransformFeedback {
4802
4945
  device;
4803
4946
  gl;
4804
4947
  handle;
@@ -4861,7 +5004,7 @@ ${source}`;
4861
5004
  const { buffer, byteLength, byteOffset } = this._getBufferRange(bufferOrRange);
4862
5005
  if (location < 0) {
4863
5006
  this.unusedBuffers[locationOrName] = buffer;
4864
- import_core21.log.warn(`${this.id} unusedBuffers varying buffer ${locationOrName}`)();
5007
+ import_core22.log.warn(`${this.id} unusedBuffers varying buffer ${locationOrName}`)();
4865
5008
  return;
4866
5009
  }
4867
5010
  this.buffers[location] = { buffer, byteLength, byteOffset };
@@ -4944,11 +5087,11 @@ ${source}`;
4944
5087
  });
4945
5088
 
4946
5089
  // ../../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-query-set.js
4947
- var import_core22, WEBGLQuerySet;
5090
+ var import_core23, WEBGLQuerySet;
4948
5091
  var init_webgl_query_set = __esm({
4949
5092
  "../../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-query-set.js"() {
4950
- import_core22 = __toESM(require_core2(), 1);
4951
- WEBGLQuerySet = class extends import_core22.QuerySet {
5093
+ import_core23 = __toESM(require_core2(), 1);
5094
+ WEBGLQuerySet = class extends import_core23.QuerySet {
4952
5095
  device;
4953
5096
  handle;
4954
5097
  target = null;
@@ -5081,6 +5224,56 @@ ${source}`;
5081
5224
  }
5082
5225
  });
5083
5226
 
5227
+ // ../../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-fence.js
5228
+ var import_core24, WEBGLFence;
5229
+ var init_webgl_fence = __esm({
5230
+ "../../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-fence.js"() {
5231
+ import_core24 = __toESM(require_core2(), 1);
5232
+ WEBGLFence = class extends import_core24.Fence {
5233
+ device;
5234
+ gl;
5235
+ handle;
5236
+ signaled;
5237
+ _signaled = false;
5238
+ constructor(device, props = {}) {
5239
+ super(device, {});
5240
+ this.device = device;
5241
+ this.gl = device.gl;
5242
+ const sync = this.props.handle || this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE, 0);
5243
+ if (!sync) {
5244
+ throw new Error("Failed to create WebGL fence");
5245
+ }
5246
+ this.handle = sync;
5247
+ this.signaled = new Promise((resolve) => {
5248
+ const poll = () => {
5249
+ const status = this.gl.clientWaitSync(this.handle, 0, 0);
5250
+ if (status === this.gl.ALREADY_SIGNALED || status === this.gl.CONDITION_SATISFIED) {
5251
+ this._signaled = true;
5252
+ resolve();
5253
+ } else {
5254
+ setTimeout(poll, 1);
5255
+ }
5256
+ };
5257
+ poll();
5258
+ });
5259
+ }
5260
+ isSignaled() {
5261
+ if (this._signaled) {
5262
+ return true;
5263
+ }
5264
+ const status = this.gl.getSyncParameter(this.handle, this.gl.SYNC_STATUS);
5265
+ this._signaled = status === this.gl.SIGNALED;
5266
+ return this._signaled;
5267
+ }
5268
+ destroy() {
5269
+ if (!this.destroyed) {
5270
+ this.gl.deleteSync(this.handle);
5271
+ }
5272
+ }
5273
+ };
5274
+ }
5275
+ });
5276
+
5084
5277
  // ../../node_modules/@luma.gl/webgl/dist/adapter/helpers/format-utils.js
5085
5278
  function glFormatToComponents(format) {
5086
5279
  switch (format) {
@@ -5126,34 +5319,6 @@ ${source}`;
5126
5319
  }
5127
5320
  });
5128
5321
 
5129
- // ../../node_modules/@luma.gl/webgl/dist/adapter/converters/shader-formats.js
5130
- function convertGLDataTypeToDataType(type) {
5131
- return GL_DATA_TYPE_MAP[type];
5132
- }
5133
- var GL_DATA_TYPE_MAP;
5134
- var init_shader_formats = __esm({
5135
- "../../node_modules/@luma.gl/webgl/dist/adapter/converters/shader-formats.js"() {
5136
- GL_DATA_TYPE_MAP = {
5137
- [5124]: "sint32",
5138
- [5125]: "uint32",
5139
- [5122]: "sint16",
5140
- [5123]: "uint16",
5141
- [5120]: "sint8",
5142
- [5121]: "uint8",
5143
- [5126]: "float32",
5144
- [5131]: "float16",
5145
- [33635]: "uint16",
5146
- [32819]: "uint16",
5147
- [32820]: "uint16",
5148
- [33640]: "uint32",
5149
- [35899]: "uint32",
5150
- [35902]: "uint32",
5151
- [34042]: "uint32",
5152
- [36269]: "uint32"
5153
- };
5154
- }
5155
- });
5156
-
5157
5322
  // ../../node_modules/@luma.gl/webgl/dist/adapter/helpers/webgl-texture-utils.js
5158
5323
  function readPixelsToArray(source, options) {
5159
5324
  const {
@@ -5183,7 +5348,7 @@ ${source}`;
5183
5348
  sourceFormat ||= texture?.glFormat || 6408;
5184
5349
  sourceType ||= texture?.glType || 5121;
5185
5350
  target2 = getPixelArray(target2, sourceType, sourceFormat, sourceWidth, sourceHeight, sourceDepth);
5186
- const signedType = (0, import_core23.getDataType)(target2);
5351
+ const signedType = (0, import_core25.getDataType)(target2);
5187
5352
  sourceType = sourceType || convertDataTypeToGLDataType(signedType);
5188
5353
  const prevHandle = gl.bindFramebuffer(36160, handle);
5189
5354
  gl.readBuffer(36064 + sourceAttachment);
@@ -5226,7 +5391,7 @@ ${source}`;
5226
5391
  return webglBufferTarget;
5227
5392
  }
5228
5393
  function getFramebuffer2(source) {
5229
- if (!(source instanceof import_core23.Framebuffer)) {
5394
+ if (!(source instanceof import_core25.Framebuffer)) {
5230
5395
  return { framebuffer: toFramebuffer(source), deleteFramebuffer: true };
5231
5396
  }
5232
5397
  return { framebuffer: source, deleteFramebuffer: false };
@@ -5248,14 +5413,14 @@ ${source}`;
5248
5413
  }
5249
5414
  glType ||= 5121;
5250
5415
  const shaderType = convertGLDataTypeToDataType(glType);
5251
- const ArrayType = (0, import_core23.getTypedArrayConstructor)(shaderType);
5416
+ const ArrayType = (0, import_core25.getTypedArrayConstructor)(shaderType);
5252
5417
  const components = glFormatToComponents(glFormat);
5253
5418
  return new ArrayType(width * height * components);
5254
5419
  }
5255
- var import_core23;
5420
+ var import_core25;
5256
5421
  var init_webgl_texture_utils = __esm({
5257
5422
  "../../node_modules/@luma.gl/webgl/dist/adapter/helpers/webgl-texture-utils.js"() {
5258
- import_core23 = __toESM(require_core2(), 1);
5423
+ import_core25 = __toESM(require_core2(), 1);
5259
5424
  init_webgl_shadertypes();
5260
5425
  init_format_utils();
5261
5426
  init_shader_formats();
@@ -5297,10 +5462,10 @@ ${source}`;
5297
5462
  }
5298
5463
  return true;
5299
5464
  }
5300
- var import_core24, WebGLDevice;
5465
+ var import_core26, WebGLDevice;
5301
5466
  var init_webgl_device = __esm({
5302
5467
  "../../node_modules/@luma.gl/webgl/dist/adapter/webgl-device.js"() {
5303
- import_core24 = __toESM(require_core2(), 1);
5468
+ import_core26 = __toESM(require_core2(), 1);
5304
5469
  init_webgl_state_tracker();
5305
5470
  init_create_browser_context();
5306
5471
  init_webgl_device_info();
@@ -5321,11 +5486,12 @@ ${source}`;
5321
5486
  init_webgl_vertex_array();
5322
5487
  init_webgl_transform_feedback();
5323
5488
  init_webgl_query_set();
5489
+ init_webgl_fence();
5324
5490
  init_webgl_texture_utils();
5325
5491
  init_unified_parameter_api();
5326
5492
  init_with_parameters();
5327
5493
  init_webgl_extensions();
5328
- WebGLDevice = class extends import_core24.Device {
5494
+ WebGLDevice = class extends import_core26.Device {
5329
5495
  // Public `Device` API
5330
5496
  /** type of this device */
5331
5497
  type = "webgl";
@@ -5370,7 +5536,7 @@ ${source}`;
5370
5536
  }
5371
5537
  constructor(props) {
5372
5538
  super({ ...props, id: props.id || uid("webgl-device") });
5373
- const canvasContextProps = import_core24.Device._getCanvasContextProps(props);
5539
+ const canvasContextProps = import_core26.Device._getCanvasContextProps(props);
5374
5540
  if (!canvasContextProps) {
5375
5541
  throw new Error("WebGLDevice requires props.createCanvasContext to be set");
5376
5542
  }
@@ -5389,6 +5555,9 @@ ${source}`;
5389
5555
  if (props.powerPreference !== void 0) {
5390
5556
  webglContextAttributes.powerPreference = props.powerPreference;
5391
5557
  }
5558
+ if (props.failIfMajorPerformanceCaveat !== void 0) {
5559
+ webglContextAttributes.failIfMajorPerformanceCaveat = props.failIfMajorPerformanceCaveat;
5560
+ }
5392
5561
  const externalGLContext = this.props._handle;
5393
5562
  const gl = externalGLContext || createBrowserContext(this.canvasContext.canvas, {
5394
5563
  onContextLost: (event) => this._resolveContextLost?.({
@@ -5404,7 +5573,7 @@ ${source}`;
5404
5573
  device = gl.device;
5405
5574
  if (device) {
5406
5575
  if (props._reuseDevices) {
5407
- import_core24.log.log(1, `Not creating a new Device, instead returning a reference to Device ${device.id} already attached to WebGL context`, device)();
5576
+ import_core26.log.log(1, `Not creating a new Device, instead returning a reference to Device ${device.id} already attached to WebGL context`, device)();
5408
5577
  device._reused = true;
5409
5578
  return device;
5410
5579
  }
@@ -5414,7 +5583,6 @@ ${source}`;
5414
5583
  this.gl = gl;
5415
5584
  this.spectorJS = initializeSpectorJS({ ...this.props, gl: this.handle });
5416
5585
  this.gl.device = this;
5417
- this.gl._version = 2;
5418
5586
  this.info = getDeviceInfo(this.gl, this._extensions);
5419
5587
  this.limits = new WebGLDeviceLimits(this.gl);
5420
5588
  this.features = new WebGLDeviceFeatures(this.gl, this._extensions, this.props._disabledFeatures);
@@ -5422,17 +5590,15 @@ ${source}`;
5422
5590
  this.features.initializeFeatures();
5423
5591
  }
5424
5592
  const glState = new WebGLStateTracker(this.gl, {
5425
- log: (...args) => import_core24.log.log(1, ...args)()
5593
+ log: (...args) => import_core26.log.log(1, ...args)()
5426
5594
  });
5427
5595
  glState.trackState(this.gl, { copyState: false });
5428
- const debugWebGL = props.debugWebGL || props.debug;
5429
- const traceWebGL = props.debugWebGL;
5430
- if (debugWebGL) {
5431
- this.gl = makeDebugContext(this.gl, { debugWebGL, traceWebGL });
5432
- import_core24.log.warn("WebGL debug mode activated. Performance reduced.")();
5433
- if (props.debugWebGL) {
5434
- import_core24.log.level = Math.max(import_core24.log.level, 1);
5435
- }
5596
+ if (props.debug || props.debugWebGL) {
5597
+ this.gl = makeDebugContext(this.gl, { debugWebGL: true, traceWebGL: props.debugWebGL });
5598
+ import_core26.log.warn("WebGL debug mode activated. Performance reduced.")();
5599
+ }
5600
+ if (props.debugWebGL) {
5601
+ import_core26.log.level = Math.max(import_core26.log.level, 1);
5436
5602
  }
5437
5603
  this.commandEncoder = new WEBGLCommandEncoder(this, { id: `${this}-command-encoder` });
5438
5604
  }
@@ -5455,9 +5621,6 @@ ${source}`;
5455
5621
  return this.gl.isContextLost();
5456
5622
  }
5457
5623
  // IMPLEMENTATION OF ABSTRACT DEVICE
5458
- getTextureByteAlignment() {
5459
- return 4;
5460
- }
5461
5624
  createCanvasContext(props) {
5462
5625
  throw new Error("WebGL only supports a single canvas");
5463
5626
  }
@@ -5489,6 +5652,9 @@ ${source}`;
5489
5652
  createQuerySet(props) {
5490
5653
  return new WEBGLQuerySet(this, props);
5491
5654
  }
5655
+ createFence() {
5656
+ return new WEBGLFence(this);
5657
+ }
5492
5658
  createRenderPipeline(props) {
5493
5659
  return new WEBGLRenderPipeline(this, props);
5494
5660
  }
@@ -5532,7 +5698,7 @@ ${source}`;
5532
5698
  return withGLParameters(this.gl, parameters, func);
5533
5699
  }
5534
5700
  resetWebGL() {
5535
- import_core24.log.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")();
5701
+ import_core26.log.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")();
5536
5702
  resetGLParameters(this.gl);
5537
5703
  }
5538
5704
  _getDeviceSpecificTextureFormatCapabilities(capabilities) {
@@ -5604,7 +5770,7 @@ ${source}`;
5604
5770
  this._constants = this._constants || new Array(maxVertexAttributes).fill(null);
5605
5771
  const currentConstant = this._constants[location];
5606
5772
  if (currentConstant && compareConstantArrayValues2(currentConstant, constant)) {
5607
- import_core24.log.info(1, `setConstantAttributeWebGL(${location}) could have been skipped, value unchanged`)();
5773
+ import_core26.log.info(1, `setConstantAttributeWebGL(${location}) could have been skipped, value unchanged`)();
5608
5774
  }
5609
5775
  this._constants[location] = constant;
5610
5776
  switch (constant.constructor) {
@@ -5670,7 +5836,7 @@ ${source}`;
5670
5836
  init_dist3();
5671
5837
 
5672
5838
  // src/utils.ts
5673
- var import_core25 = __toESM(require_core(), 1);
5839
+ var import_core27 = __toESM(require_core(), 1);
5674
5840
 
5675
5841
  // ../../node_modules/@math.gl/core/dist/lib/common.js
5676
5842
  var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
@@ -7612,13 +7778,13 @@ ${source}`;
7612
7778
  mousemove: null,
7613
7779
  mouseout: null
7614
7780
  };
7615
- const newDeck = new import_core25.Deck({
7781
+ const newDeck = new import_core27.Deck({
7616
7782
  ...props,
7617
7783
  // Default to true for high-DPI displays, but allow user override
7618
7784
  useDevicePixels: props.useDevicePixels ?? true,
7619
7785
  style: props.interleaved ? null : { pointerEvents: "none" },
7620
7786
  parent: getContainer(overlay, props.style),
7621
- views: new import_core25.MapView({ repeat: true }),
7787
+ views: new import_core27.MapView({ repeat: true }),
7622
7788
  initialViewState: {
7623
7789
  longitude: 0,
7624
7790
  latitude: 0,