@luma.gl/webgl 9.2.5 → 9.3.0-alpha.2

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.
Files changed (49) hide show
  1. package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
  2. package/dist/adapter/resources/webgl-buffer.js +1 -0
  3. package/dist/adapter/resources/webgl-buffer.js.map +1 -1
  4. package/dist/adapter/resources/webgl-fence.d.ts +14 -0
  5. package/dist/adapter/resources/webgl-fence.d.ts.map +1 -0
  6. package/dist/adapter/resources/webgl-fence.js +49 -0
  7. package/dist/adapter/resources/webgl-fence.js.map +1 -0
  8. package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
  9. package/dist/adapter/resources/webgl-render-pass.js +4 -6
  10. package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
  11. package/dist/adapter/resources/webgl-texture.d.ts +21 -4
  12. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  13. package/dist/adapter/resources/webgl-texture.js +148 -22
  14. package/dist/adapter/resources/webgl-texture.js.map +1 -1
  15. package/dist/adapter/webgl-adapter.d.ts.map +1 -1
  16. package/dist/adapter/webgl-adapter.js +19 -19
  17. package/dist/adapter/webgl-adapter.js.map +1 -1
  18. package/dist/adapter/webgl-canvas-context.d.ts +2 -2
  19. package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
  20. package/dist/adapter/webgl-canvas-context.js +16 -6
  21. package/dist/adapter/webgl-canvas-context.js.map +1 -1
  22. package/dist/adapter/webgl-device.d.ts +2 -1
  23. package/dist/adapter/webgl-device.d.ts.map +1 -1
  24. package/dist/adapter/webgl-device.js +14 -13
  25. package/dist/adapter/webgl-device.js.map +1 -1
  26. package/dist/context/debug/webgl-developer-tools.js +4 -6
  27. package/dist/context/debug/webgl-developer-tools.js.map +1 -1
  28. package/dist/context/helpers/create-browser-context.d.ts.map +1 -1
  29. package/dist/context/helpers/create-browser-context.js +47 -35
  30. package/dist/context/helpers/create-browser-context.js.map +1 -1
  31. package/dist/dist.dev.js +468 -274
  32. package/dist/dist.min.js +2 -2
  33. package/dist/index.cjs +447 -275
  34. package/dist/index.cjs.map +4 -4
  35. package/dist/index.d.ts +1 -0
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +1 -0
  38. package/dist/index.js.map +1 -1
  39. package/package.json +4 -4
  40. package/src/adapter/resources/webgl-buffer.ts +1 -0
  41. package/src/adapter/resources/webgl-fence.ts +55 -0
  42. package/src/adapter/resources/webgl-render-pass.ts +4 -6
  43. package/src/adapter/resources/webgl-texture.ts +209 -37
  44. package/src/adapter/webgl-adapter.ts +23 -20
  45. package/src/adapter/webgl-canvas-context.ts +19 -8
  46. package/src/adapter/webgl-device.ts +15 -14
  47. package/src/context/debug/webgl-developer-tools.ts +13 -6
  48. package/src/context/helpers/create-browser-context.ts +54 -43
  49. package/src/index.ts +1 -0
package/dist/dist.dev.js CHANGED
@@ -1059,16 +1059,24 @@ var __exports__ = (() => {
1059
1059
  const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);
1060
1060
  const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);
1061
1061
  const message2 = `${errorMessage} in gl.${functionName}(${functionArgs})`;
1062
- import_core2.log.error(message2)();
1062
+ import_core2.log.error(
1063
+ "%cWebGL",
1064
+ "color: white; background: red; padding: 2px 6px; border-radius: 3px;",
1065
+ message2
1066
+ )();
1063
1067
  debugger;
1068
+ throw new Error(message2);
1064
1069
  }
1065
1070
  function onValidateGLFunc(props, functionName, functionArgs) {
1066
1071
  let functionString = "";
1067
- if (import_core2.log.level >= 1) {
1072
+ if (props.traceWebGL && import_core2.log.level >= 1) {
1068
1073
  functionString = getFunctionString(functionName, functionArgs);
1069
- if (props.traceWebGL) {
1070
- import_core2.log.log(1, functionString)();
1071
- }
1074
+ import_core2.log.info(
1075
+ 1,
1076
+ "%cWebGL",
1077
+ "color: white; background: blue; padding: 2px 6px; border-radius: 3px;",
1078
+ functionString
1079
+ )();
1072
1080
  }
1073
1081
  for (const arg of functionArgs) {
1074
1082
  if (arg === void 0) {
@@ -1822,42 +1830,57 @@ var __exports__ = (() => {
1822
1830
  // src/context/helpers/create-browser-context.ts
1823
1831
  function createBrowserContext(canvas, props, webglContextAttributes) {
1824
1832
  let errorMessage = "";
1833
+ const onCreateError = (event) => {
1834
+ const statusMessage = event.statusMessage;
1835
+ if (statusMessage) {
1836
+ errorMessage ||= statusMessage;
1837
+ }
1838
+ };
1839
+ canvas.addEventListener("webglcontextcreationerror", onCreateError, false);
1840
+ const allowSoftwareRenderer = webglContextAttributes.failIfMajorPerformanceCaveat !== true;
1825
1841
  const webglProps = {
1826
1842
  preserveDrawingBuffer: true,
1827
- // failIfMajorPerformanceCaveat: true,
1828
- ...webglContextAttributes
1843
+ ...webglContextAttributes,
1844
+ // Always start by requesting a high-performance context.
1845
+ failIfMajorPerformanceCaveat: true
1829
1846
  };
1830
1847
  let gl = null;
1831
- gl ||= canvas.getContext("webgl2", webglProps);
1832
- if (webglProps.failIfMajorPerformanceCaveat) {
1833
- errorMessage ||= "Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.";
1834
- }
1835
- if (!gl && !webglContextAttributes.failIfMajorPerformanceCaveat) {
1836
- webglProps.failIfMajorPerformanceCaveat = false;
1837
- gl = canvas.getContext("webgl2", webglProps);
1838
- gl.luma ||= {};
1839
- gl.luma.softwareRenderer = true;
1840
- }
1841
- if (!gl) {
1842
- gl = canvas.getContext("webgl", {});
1843
- if (gl) {
1844
- gl = null;
1845
- errorMessage ||= "Your browser only supports WebGL1";
1848
+ try {
1849
+ gl ||= canvas.getContext("webgl2", webglProps);
1850
+ if (!gl && webglProps.failIfMajorPerformanceCaveat) {
1851
+ errorMessage ||= "Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.";
1846
1852
  }
1853
+ if (!gl && allowSoftwareRenderer) {
1854
+ webglProps.failIfMajorPerformanceCaveat = false;
1855
+ gl = canvas.getContext("webgl2", webglProps);
1856
+ if (gl) {
1857
+ gl.luma ||= {};
1858
+ gl.luma.softwareRenderer = true;
1859
+ }
1860
+ }
1861
+ if (!gl) {
1862
+ gl = canvas.getContext("webgl", {});
1863
+ if (gl) {
1864
+ gl = null;
1865
+ errorMessage ||= "Your browser only supports WebGL1";
1866
+ }
1867
+ }
1868
+ if (!gl) {
1869
+ errorMessage ||= "Your browser does not support WebGL";
1870
+ throw new Error(`Failed to create WebGL context: ${errorMessage}`);
1871
+ }
1872
+ const { onContextLost, onContextRestored } = props;
1873
+ canvas.addEventListener("webglcontextlost", (event) => onContextLost(event), false);
1874
+ canvas.addEventListener(
1875
+ "webglcontextrestored",
1876
+ (event) => onContextRestored(event),
1877
+ false
1878
+ );
1879
+ gl.luma ||= {};
1880
+ return gl;
1881
+ } finally {
1882
+ canvas.removeEventListener("webglcontextcreationerror", onCreateError, false);
1847
1883
  }
1848
- if (!gl) {
1849
- errorMessage ||= "Your browser does not support WebGL";
1850
- throw new Error(`Failed to create WebGL context: ${errorMessage}`);
1851
- }
1852
- const { onContextLost, onContextRestored } = props;
1853
- canvas.addEventListener("webglcontextlost", (event) => onContextLost(event), false);
1854
- canvas.addEventListener(
1855
- "webglcontextrestored",
1856
- (event) => onContextRestored(event),
1857
- false
1858
- );
1859
- gl.luma ||= {};
1860
- return gl;
1861
1884
  }
1862
1885
  var init_create_browser_context = __esm({
1863
1886
  "src/context/helpers/create-browser-context.ts"() {
@@ -2608,14 +2631,24 @@ var __exports__ = (() => {
2608
2631
  super(props);
2609
2632
  this.device = device;
2610
2633
  this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);
2611
- this._updateDevice();
2612
- }
2613
- getCurrentFramebuffer() {
2614
- this._framebuffer = this._framebuffer || new WEBGLFramebuffer(this.device, { handle: null });
2615
- return this._framebuffer;
2634
+ this._configureDevice();
2616
2635
  }
2617
2636
  // IMPLEMENTATION OF ABSTRACT METHODS
2618
- _updateDevice() {
2637
+ _configureDevice() {
2638
+ const shouldResize = this.drawingBufferWidth !== this._framebuffer?.width || this.drawingBufferHeight !== this._framebuffer?.height;
2639
+ if (shouldResize) {
2640
+ this._framebuffer?.resize([this.drawingBufferWidth, this.drawingBufferHeight]);
2641
+ }
2642
+ }
2643
+ _getCurrentFramebuffer() {
2644
+ this._framebuffer ||= new WEBGLFramebuffer(this.device, {
2645
+ id: "canvas-context-framebuffer",
2646
+ handle: null,
2647
+ // Setting handle to null returns a reference to the default WebGL framebuffer
2648
+ width: this.drawingBufferWidth,
2649
+ height: this.drawingBufferHeight
2650
+ });
2651
+ return this._framebuffer;
2619
2652
  }
2620
2653
  };
2621
2654
  }
@@ -3400,6 +3433,127 @@ ${source}`;
3400
3433
  }
3401
3434
  });
3402
3435
 
3436
+ // src/adapter/converters/webgl-shadertypes.ts
3437
+ function convertDataTypeToGLDataType(normalizedType) {
3438
+ return NORMALIZED_SHADER_TYPE_TO_WEBGL[normalizedType];
3439
+ }
3440
+ function convertGLUniformTypeToShaderVariableType(glUniformType) {
3441
+ return WEBGL_SHADER_TYPES[glUniformType];
3442
+ }
3443
+ function isGLSamplerType(type) {
3444
+ return Boolean(WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[type]);
3445
+ }
3446
+ function getTextureBindingFromGLSamplerType(glSamplerType) {
3447
+ return WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[glSamplerType];
3448
+ }
3449
+ var WEBGL_SHADER_TYPES, WEBGL_SAMPLER_TO_TEXTURE_BINDINGS, NORMALIZED_SHADER_TYPE_TO_WEBGL, WEBGL_TO_NORMALIZED_DATA_TYPE;
3450
+ var init_webgl_shadertypes = __esm({
3451
+ "src/adapter/converters/webgl-shadertypes.ts"() {
3452
+ "use strict";
3453
+ WEBGL_SHADER_TYPES = {
3454
+ [5126 /* FLOAT */]: "f32",
3455
+ [35664 /* FLOAT_VEC2 */]: "vec2<f32>",
3456
+ [35665 /* FLOAT_VEC3 */]: "vec3<f32>",
3457
+ [35666 /* FLOAT_VEC4 */]: "vec4<f32>",
3458
+ [5124 /* INT */]: "i32",
3459
+ [35667 /* INT_VEC2 */]: "vec2<i32>",
3460
+ [35668 /* INT_VEC3 */]: "vec3<i32>",
3461
+ [35669 /* INT_VEC4 */]: "vec4<i32>",
3462
+ [5125 /* UNSIGNED_INT */]: "u32",
3463
+ [36294 /* UNSIGNED_INT_VEC2 */]: "vec2<u32>",
3464
+ [36295 /* UNSIGNED_INT_VEC3 */]: "vec3<u32>",
3465
+ [36296 /* UNSIGNED_INT_VEC4 */]: "vec4<u32>",
3466
+ [35670 /* BOOL */]: "f32",
3467
+ [35671 /* BOOL_VEC2 */]: "vec2<f32>",
3468
+ [35672 /* BOOL_VEC3 */]: "vec3<f32>",
3469
+ [35673 /* BOOL_VEC4 */]: "vec4<f32>",
3470
+ // TODO - are sizes/components below correct?
3471
+ [35674 /* FLOAT_MAT2 */]: "mat2x2<f32>",
3472
+ [35685 /* FLOAT_MAT2x3 */]: "mat2x3<f32>",
3473
+ [35686 /* FLOAT_MAT2x4 */]: "mat2x4<f32>",
3474
+ [35687 /* FLOAT_MAT3x2 */]: "mat3x2<f32>",
3475
+ [35675 /* FLOAT_MAT3 */]: "mat3x3<f32>",
3476
+ [35688 /* FLOAT_MAT3x4 */]: "mat3x4<f32>",
3477
+ [35689 /* FLOAT_MAT4x2 */]: "mat4x2<f32>",
3478
+ [35690 /* FLOAT_MAT4x3 */]: "mat4x3<f32>",
3479
+ [35676 /* FLOAT_MAT4 */]: "mat4x4<f32>"
3480
+ };
3481
+ WEBGL_SAMPLER_TO_TEXTURE_BINDINGS = {
3482
+ [35678 /* SAMPLER_2D */]: { viewDimension: "2d", sampleType: "float" },
3483
+ [35680 /* SAMPLER_CUBE */]: { viewDimension: "cube", sampleType: "float" },
3484
+ [35679 /* SAMPLER_3D */]: { viewDimension: "3d", sampleType: "float" },
3485
+ [35682 /* SAMPLER_2D_SHADOW */]: { viewDimension: "3d", sampleType: "depth" },
3486
+ [36289 /* SAMPLER_2D_ARRAY */]: { viewDimension: "2d-array", sampleType: "float" },
3487
+ [36292 /* SAMPLER_2D_ARRAY_SHADOW */]: { viewDimension: "2d-array", sampleType: "depth" },
3488
+ [36293 /* SAMPLER_CUBE_SHADOW */]: { viewDimension: "cube", sampleType: "float" },
3489
+ [36298 /* INT_SAMPLER_2D */]: { viewDimension: "2d", sampleType: "sint" },
3490
+ [36299 /* INT_SAMPLER_3D */]: { viewDimension: "3d", sampleType: "sint" },
3491
+ [36300 /* INT_SAMPLER_CUBE */]: { viewDimension: "cube", sampleType: "sint" },
3492
+ [36303 /* INT_SAMPLER_2D_ARRAY */]: { viewDimension: "2d-array", sampleType: "uint" },
3493
+ [36306 /* UNSIGNED_INT_SAMPLER_2D */]: { viewDimension: "2d", sampleType: "uint" },
3494
+ [36307 /* UNSIGNED_INT_SAMPLER_3D */]: { viewDimension: "3d", sampleType: "uint" },
3495
+ [36308 /* UNSIGNED_INT_SAMPLER_CUBE */]: { viewDimension: "cube", sampleType: "uint" },
3496
+ [36311 /* UNSIGNED_INT_SAMPLER_2D_ARRAY */]: { viewDimension: "2d-array", sampleType: "uint" }
3497
+ };
3498
+ NORMALIZED_SHADER_TYPE_TO_WEBGL = {
3499
+ uint8: 5121 /* UNSIGNED_BYTE */,
3500
+ sint8: 5120 /* BYTE */,
3501
+ unorm8: 5121 /* UNSIGNED_BYTE */,
3502
+ snorm8: 5120 /* BYTE */,
3503
+ uint16: 5123 /* UNSIGNED_SHORT */,
3504
+ sint16: 5122 /* SHORT */,
3505
+ unorm16: 5123 /* UNSIGNED_SHORT */,
3506
+ snorm16: 5122 /* SHORT */,
3507
+ uint32: 5125 /* UNSIGNED_INT */,
3508
+ sint32: 5124 /* INT */,
3509
+ // WebGPU does not support normalized 32 bit integer attributes
3510
+ // 'unorm32': GL.UNSIGNED_INT,
3511
+ // 'snorm32': GL.INT,
3512
+ float16: 5131 /* HALF_FLOAT */,
3513
+ float32: 5126 /* FLOAT */
3514
+ };
3515
+ WEBGL_TO_NORMALIZED_DATA_TYPE = {
3516
+ [5120 /* BYTE */]: ["sint8", "snorm16"],
3517
+ [5121 /* UNSIGNED_BYTE */]: ["uint8", "unorm8"],
3518
+ [5122 /* SHORT */]: ["sint16", "unorm16"],
3519
+ [5123 /* UNSIGNED_SHORT */]: ["uint16", "unorm16"],
3520
+ [5124 /* INT */]: ["sint32", "sint32"],
3521
+ [5125 /* UNSIGNED_INT */]: ["uint32", "uint32"],
3522
+ [5126 /* FLOAT */]: ["float32", "float32"],
3523
+ [5131 /* HALF_FLOAT */]: ["float16", "float16"]
3524
+ };
3525
+ }
3526
+ });
3527
+
3528
+ // src/adapter/converters/shader-formats.ts
3529
+ function convertGLDataTypeToDataType(type) {
3530
+ return GL_DATA_TYPE_MAP[type];
3531
+ }
3532
+ var GL_DATA_TYPE_MAP;
3533
+ var init_shader_formats = __esm({
3534
+ "src/adapter/converters/shader-formats.ts"() {
3535
+ "use strict";
3536
+ GL_DATA_TYPE_MAP = {
3537
+ [5124 /* INT */]: "sint32",
3538
+ [5125 /* UNSIGNED_INT */]: "uint32",
3539
+ [5122 /* SHORT */]: "sint16",
3540
+ [5123 /* UNSIGNED_SHORT */]: "uint16",
3541
+ [5120 /* BYTE */]: "sint8",
3542
+ [5121 /* UNSIGNED_BYTE */]: "uint8",
3543
+ [5126 /* FLOAT */]: "float32",
3544
+ [5131 /* HALF_FLOAT */]: "float16",
3545
+ [33635 /* UNSIGNED_SHORT_5_6_5 */]: "uint16",
3546
+ [32819 /* UNSIGNED_SHORT_4_4_4_4 */]: "uint16",
3547
+ [32820 /* UNSIGNED_SHORT_5_5_5_1 */]: "uint16",
3548
+ [33640 /* UNSIGNED_INT_2_10_10_10_REV */]: "uint32",
3549
+ [35899 /* UNSIGNED_INT_10F_11F_11F_REV */]: "uint32",
3550
+ [35902 /* UNSIGNED_INT_5_9_9_9_REV */]: "uint32",
3551
+ [34042 /* UNSIGNED_INT_24_8 */]: "uint32",
3552
+ [36269 /* FLOAT_32_UNSIGNED_INT_24_8_REV */]: "uint32"
3553
+ };
3554
+ }
3555
+ });
3556
+
3403
3557
  // src/adapter/resources/webgl-texture.ts
3404
3558
  function getWebGLTextureTarget(dimension) {
3405
3559
  switch (dimension) {
@@ -3421,7 +3575,7 @@ ${source}`;
3421
3575
  function getWebGLCubeFaceTarget(glTarget, dimension, level) {
3422
3576
  return dimension === "cube" ? 34069 /* TEXTURE_CUBE_MAP_POSITIVE_X */ + level : glTarget;
3423
3577
  }
3424
- var import_core13, WEBGLTexture;
3578
+ var import_core13, import_core14, WEBGLTexture;
3425
3579
  var init_webgl_texture = __esm({
3426
3580
  "src/adapter/resources/webgl-texture.ts"() {
3427
3581
  "use strict";
@@ -3430,6 +3584,9 @@ ${source}`;
3430
3584
  init_sampler_parameters();
3431
3585
  init_with_parameters();
3432
3586
  init_webgl_texture_view();
3587
+ init_webgl_shadertypes();
3588
+ init_shader_formats();
3589
+ import_core14 = __toESM(require_core(), 1);
3433
3590
  WEBGLTexture = class extends import_core13.Texture {
3434
3591
  // readonly MAX_ATTRIBUTES: number;
3435
3592
  device;
@@ -3459,8 +3616,10 @@ ${source}`;
3459
3616
  // state
3460
3617
  /** Texture binding slot - TODO - move to texture view? */
3461
3618
  _textureUnit = 0;
3619
+ /** Chached framebuffer */
3620
+ _framebuffer = null;
3462
3621
  constructor(device, props) {
3463
- super(device, props);
3622
+ super(device, props, { byteAlignment: 1 });
3464
3623
  this.device = device;
3465
3624
  this.gl = this.device.gl;
3466
3625
  const formatInfo = getTextureFormatWebGL(this.props.format);
@@ -3493,6 +3652,8 @@ ${source}`;
3493
3652
  }
3494
3653
  destroy() {
3495
3654
  if (this.handle) {
3655
+ this._framebuffer?.destroy();
3656
+ this._framebuffer = null;
3496
3657
  this.gl.deleteTexture(this.handle);
3497
3658
  this.removeStats();
3498
3659
  this.trackDeallocatedMemory("Texture");
@@ -3507,11 +3668,37 @@ ${source}`;
3507
3668
  const parameters = convertSamplerParametersToWebGL(this.sampler.props);
3508
3669
  this._setSamplerParameters(parameters);
3509
3670
  }
3671
+ copyExternalImage(options_) {
3672
+ const options = this._normalizeCopyExternalImageOptions(options_);
3673
+ if (options.sourceX || options.sourceY) {
3674
+ throw new Error("WebGL does not support sourceX/sourceY)");
3675
+ }
3676
+ const { glFormat, glType } = this;
3677
+ const { image, depth, mipLevel, x, y, z, width, height } = options;
3678
+ const glTarget = getWebGLCubeFaceTarget(this.glTarget, this.dimension, z);
3679
+ const glParameters = options.flipY ? { [37440 /* UNPACK_FLIP_Y_WEBGL */]: true } : {};
3680
+ this.gl.bindTexture(this.glTarget, this.handle);
3681
+ withGLParameters(this.gl, glParameters, () => {
3682
+ switch (this.dimension) {
3683
+ case "2d":
3684
+ case "cube":
3685
+ this.gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, glType, image);
3686
+ break;
3687
+ case "2d-array":
3688
+ case "3d":
3689
+ this.gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, image);
3690
+ break;
3691
+ default:
3692
+ }
3693
+ });
3694
+ this.gl.bindTexture(this.glTarget, null);
3695
+ return { width: options.width, height: options.height };
3696
+ }
3510
3697
  copyImageData(options_) {
3511
3698
  const options = this._normalizeCopyImageDataOptions(options_);
3512
3699
  const typedArray = options.data;
3513
- const { width, height, depth } = this;
3514
- const { mipLevel = 0, byteOffset = 0, x = 0, y = 0, z = 0 } = options;
3700
+ const { width, height, depth, z = 0 } = options;
3701
+ const { mipLevel = 0, byteOffset = 0, x = 0, y = 0 } = options;
3515
3702
  const { glFormat, glType, compressed } = this;
3516
3703
  const glTarget = getWebGLCubeFaceTarget(this.glTarget, this.dimension, z);
3517
3704
  let unpackRowLength;
@@ -3527,10 +3714,11 @@ ${source}`;
3527
3714
  }
3528
3715
  }
3529
3716
  const glParameters = !this.compressed ? {
3717
+ [3317 /* UNPACK_ALIGNMENT */]: this.byteAlignment,
3530
3718
  ...unpackRowLength !== void 0 ? { [3314 /* UNPACK_ROW_LENGTH */]: unpackRowLength } : {},
3531
3719
  [32878 /* UNPACK_IMAGE_HEIGHT */]: options.rowsPerImage
3532
3720
  } : {};
3533
- this.gl.bindTexture(glTarget, this.handle);
3721
+ this.gl.bindTexture(this.glTarget, this.handle);
3534
3722
  withGLParameters(this.gl, glParameters, () => {
3535
3723
  switch (this.dimension) {
3536
3724
  case "2d":
@@ -3552,35 +3740,103 @@ ${source}`;
3552
3740
  default:
3553
3741
  }
3554
3742
  });
3555
- this.gl.bindTexture(glTarget, null);
3743
+ this.gl.bindTexture(this.glTarget, null);
3556
3744
  }
3557
- copyExternalImage(options_) {
3558
- const options = this._normalizeCopyExternalImageOptions(options_);
3559
- if (options.sourceX || options.sourceY) {
3560
- throw new Error("WebGL does not support sourceX/sourceY)");
3561
- }
3562
- const { glFormat, glType } = this;
3563
- const { image, depth, mipLevel, x, y, z, width, height } = options;
3745
+ readBuffer(options = {}, buffer) {
3746
+ throw new Error("readBuffer not implemented");
3747
+ }
3748
+ async readDataAsync(options = {}) {
3749
+ return this.readDataSyncWebGL(options);
3750
+ }
3751
+ writeBuffer(buffer, options_ = {}) {
3752
+ }
3753
+ writeData(data, options_ = {}) {
3754
+ const options = this._normalizeTextureWriteOptions(options_);
3755
+ const typedArray = ArrayBuffer.isView(data) ? data : new Uint8Array(data);
3756
+ const {} = this;
3757
+ const { width, height, mipLevel, x, y, z } = options;
3758
+ const { glFormat, glType, compressed } = this;
3759
+ const depth = 0;
3564
3760
  const glTarget = getWebGLCubeFaceTarget(this.glTarget, this.dimension, depth);
3565
- const glParameters = options.flipY ? { [37440 /* UNPACK_FLIP_Y_WEBGL */]: true } : {};
3566
- this.gl.bindTexture(this.glTarget, this.handle);
3761
+ const glParameters = !this.compressed ? {
3762
+ // WebGL does not require byte alignment, but allows it to be specified
3763
+ [3317 /* UNPACK_ALIGNMENT */]: this.byteAlignment
3764
+ // [GL.UNPACK_ROW_LENGTH]: bytesPerRow,
3765
+ // [GL.UNPACK_IMAGE_HEIGHT]: rowsPerImage
3766
+ } : {};
3767
+ this.gl.bindTexture(glTarget, this.handle);
3768
+ this.gl.bindBuffer(35052 /* PIXEL_UNPACK_BUFFER */, null);
3567
3769
  withGLParameters(this.gl, glParameters, () => {
3568
3770
  switch (this.dimension) {
3569
3771
  case "2d":
3570
3772
  case "cube":
3571
- this.gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, glType, image);
3773
+ if (compressed) {
3774
+ this.gl.compressedTexSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, typedArray);
3775
+ } else {
3776
+ this.gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, glType, typedArray);
3777
+ }
3572
3778
  break;
3573
3779
  case "2d-array":
3574
3780
  case "3d":
3575
- this.gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, image);
3781
+ if (compressed) {
3782
+ this.gl.compressedTexSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, typedArray);
3783
+ } else {
3784
+ this.gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, typedArray);
3785
+ }
3576
3786
  break;
3577
3787
  default:
3578
3788
  }
3579
3789
  });
3580
- this.gl.bindTexture(this.glTarget, null);
3581
- return { width: options.width, height: options.height };
3790
+ this.gl.bindTexture(glTarget, null);
3791
+ }
3792
+ // IMPLEMENTATION SPECIFIC
3793
+ /** @todo - for now we always use 1 for maximum compatibility, we can fine tune later */
3794
+ _getRowByteAlignment(format, width) {
3795
+ return 1;
3796
+ }
3797
+ /**
3798
+ * Wraps a given texture into a framebuffer object, that can be further used
3799
+ * to read data from the texture object.
3800
+ */
3801
+ _getFramebuffer() {
3802
+ this._framebuffer ||= this.device.createFramebuffer({
3803
+ id: `framebuffer-for-${this.id}`,
3804
+ width: this.width,
3805
+ height: this.height,
3806
+ colorAttachments: [this]
3807
+ });
3808
+ return this._framebuffer;
3582
3809
  }
3583
3810
  // WEBGL SPECIFIC
3811
+ readDataSyncWebGL(options_ = {}) {
3812
+ const options = this._normalizeTextureReadOptions(options_);
3813
+ const memoryLayout = this.computeMemoryLayout(options);
3814
+ const shaderType = convertGLDataTypeToDataType(this.glType);
3815
+ const ArrayType = (0, import_core14.getTypedArrayConstructor)(shaderType);
3816
+ const targetArray = new ArrayType(memoryLayout.byteLength);
3817
+ const signedType = (0, import_core14.getDataType)(targetArray);
3818
+ const sourceType = convertDataTypeToGLDataType(signedType);
3819
+ const framebuffer = this._getFramebuffer();
3820
+ const prevHandle = this.gl.bindFramebuffer(
3821
+ 36160 /* FRAMEBUFFER */,
3822
+ framebuffer.handle
3823
+ );
3824
+ this.gl.readBuffer(36064 /* COLOR_ATTACHMENT0 */);
3825
+ this.gl.readPixels(
3826
+ options.x,
3827
+ options.y,
3828
+ options.width,
3829
+ options.height,
3830
+ this.glFormat,
3831
+ sourceType,
3832
+ targetArray
3833
+ );
3834
+ this.gl.bindFramebuffer(36160 /* FRAMEBUFFER */, prevHandle || null);
3835
+ return targetArray.buffer;
3836
+ }
3837
+ /**
3838
+ * @note - this is used by the DynamicTexture class to generate mipmaps on WebGL
3839
+ */
3584
3840
  generateMipmapsWebGL(options) {
3585
3841
  const isFilterableAndRenderable = this.device.isTextureFormatRenderable(this.props.format) && this.device.isTextureFormatFilterable(this.props.format);
3586
3842
  if (!isFilterableAndRenderable) {
@@ -3660,98 +3916,6 @@ ${source}`;
3660
3916
  }
3661
3917
  });
3662
3918
 
3663
- // src/adapter/converters/webgl-shadertypes.ts
3664
- function convertDataTypeToGLDataType(normalizedType) {
3665
- return NORMALIZED_SHADER_TYPE_TO_WEBGL[normalizedType];
3666
- }
3667
- function convertGLUniformTypeToShaderVariableType(glUniformType) {
3668
- return WEBGL_SHADER_TYPES[glUniformType];
3669
- }
3670
- function isGLSamplerType(type) {
3671
- return Boolean(WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[type]);
3672
- }
3673
- function getTextureBindingFromGLSamplerType(glSamplerType) {
3674
- return WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[glSamplerType];
3675
- }
3676
- var WEBGL_SHADER_TYPES, WEBGL_SAMPLER_TO_TEXTURE_BINDINGS, NORMALIZED_SHADER_TYPE_TO_WEBGL, WEBGL_TO_NORMALIZED_DATA_TYPE;
3677
- var init_webgl_shadertypes = __esm({
3678
- "src/adapter/converters/webgl-shadertypes.ts"() {
3679
- "use strict";
3680
- WEBGL_SHADER_TYPES = {
3681
- [5126 /* FLOAT */]: "f32",
3682
- [35664 /* FLOAT_VEC2 */]: "vec2<f32>",
3683
- [35665 /* FLOAT_VEC3 */]: "vec3<f32>",
3684
- [35666 /* FLOAT_VEC4 */]: "vec4<f32>",
3685
- [5124 /* INT */]: "i32",
3686
- [35667 /* INT_VEC2 */]: "vec2<i32>",
3687
- [35668 /* INT_VEC3 */]: "vec3<i32>",
3688
- [35669 /* INT_VEC4 */]: "vec4<i32>",
3689
- [5125 /* UNSIGNED_INT */]: "u32",
3690
- [36294 /* UNSIGNED_INT_VEC2 */]: "vec2<u32>",
3691
- [36295 /* UNSIGNED_INT_VEC3 */]: "vec3<u32>",
3692
- [36296 /* UNSIGNED_INT_VEC4 */]: "vec4<u32>",
3693
- [35670 /* BOOL */]: "f32",
3694
- [35671 /* BOOL_VEC2 */]: "vec2<f32>",
3695
- [35672 /* BOOL_VEC3 */]: "vec3<f32>",
3696
- [35673 /* BOOL_VEC4 */]: "vec4<f32>",
3697
- // TODO - are sizes/components below correct?
3698
- [35674 /* FLOAT_MAT2 */]: "mat2x2<f32>",
3699
- [35685 /* FLOAT_MAT2x3 */]: "mat2x3<f32>",
3700
- [35686 /* FLOAT_MAT2x4 */]: "mat2x4<f32>",
3701
- [35687 /* FLOAT_MAT3x2 */]: "mat3x2<f32>",
3702
- [35675 /* FLOAT_MAT3 */]: "mat3x3<f32>",
3703
- [35688 /* FLOAT_MAT3x4 */]: "mat3x4<f32>",
3704
- [35689 /* FLOAT_MAT4x2 */]: "mat4x2<f32>",
3705
- [35690 /* FLOAT_MAT4x3 */]: "mat4x3<f32>",
3706
- [35676 /* FLOAT_MAT4 */]: "mat4x4<f32>"
3707
- };
3708
- WEBGL_SAMPLER_TO_TEXTURE_BINDINGS = {
3709
- [35678 /* SAMPLER_2D */]: { viewDimension: "2d", sampleType: "float" },
3710
- [35680 /* SAMPLER_CUBE */]: { viewDimension: "cube", sampleType: "float" },
3711
- [35679 /* SAMPLER_3D */]: { viewDimension: "3d", sampleType: "float" },
3712
- [35682 /* SAMPLER_2D_SHADOW */]: { viewDimension: "3d", sampleType: "depth" },
3713
- [36289 /* SAMPLER_2D_ARRAY */]: { viewDimension: "2d-array", sampleType: "float" },
3714
- [36292 /* SAMPLER_2D_ARRAY_SHADOW */]: { viewDimension: "2d-array", sampleType: "depth" },
3715
- [36293 /* SAMPLER_CUBE_SHADOW */]: { viewDimension: "cube", sampleType: "float" },
3716
- [36298 /* INT_SAMPLER_2D */]: { viewDimension: "2d", sampleType: "sint" },
3717
- [36299 /* INT_SAMPLER_3D */]: { viewDimension: "3d", sampleType: "sint" },
3718
- [36300 /* INT_SAMPLER_CUBE */]: { viewDimension: "cube", sampleType: "sint" },
3719
- [36303 /* INT_SAMPLER_2D_ARRAY */]: { viewDimension: "2d-array", sampleType: "uint" },
3720
- [36306 /* UNSIGNED_INT_SAMPLER_2D */]: { viewDimension: "2d", sampleType: "uint" },
3721
- [36307 /* UNSIGNED_INT_SAMPLER_3D */]: { viewDimension: "3d", sampleType: "uint" },
3722
- [36308 /* UNSIGNED_INT_SAMPLER_CUBE */]: { viewDimension: "cube", sampleType: "uint" },
3723
- [36311 /* UNSIGNED_INT_SAMPLER_2D_ARRAY */]: { viewDimension: "2d-array", sampleType: "uint" }
3724
- };
3725
- NORMALIZED_SHADER_TYPE_TO_WEBGL = {
3726
- uint8: 5121 /* UNSIGNED_BYTE */,
3727
- sint8: 5120 /* BYTE */,
3728
- unorm8: 5121 /* UNSIGNED_BYTE */,
3729
- snorm8: 5120 /* BYTE */,
3730
- uint16: 5123 /* UNSIGNED_SHORT */,
3731
- sint16: 5122 /* SHORT */,
3732
- unorm16: 5123 /* UNSIGNED_SHORT */,
3733
- snorm16: 5122 /* SHORT */,
3734
- uint32: 5125 /* UNSIGNED_INT */,
3735
- sint32: 5124 /* INT */,
3736
- // WebGPU does not support normalized 32 bit integer attributes
3737
- // 'unorm32': GL.UNSIGNED_INT,
3738
- // 'snorm32': GL.INT,
3739
- float16: 5131 /* HALF_FLOAT */,
3740
- float32: 5126 /* FLOAT */
3741
- };
3742
- WEBGL_TO_NORMALIZED_DATA_TYPE = {
3743
- [5120 /* BYTE */]: ["sint8", "snorm16"],
3744
- [5121 /* UNSIGNED_BYTE */]: ["uint8", "unorm8"],
3745
- [5122 /* SHORT */]: ["sint16", "unorm16"],
3746
- [5123 /* UNSIGNED_SHORT */]: ["uint16", "unorm16"],
3747
- [5124 /* INT */]: ["sint32", "sint32"],
3748
- [5125 /* UNSIGNED_INT */]: ["uint32", "uint32"],
3749
- [5126 /* FLOAT */]: ["float32", "float32"],
3750
- [5131 /* HALF_FLOAT */]: ["float16", "float16"]
3751
- };
3752
- }
3753
- });
3754
-
3755
3919
  // src/adapter/helpers/get-shader-layout-from-glsl.ts
3756
3920
  function getShaderLayoutFromGLSL(gl, program) {
3757
3921
  const shaderLayout = {
@@ -3843,7 +4007,7 @@ ${source}`;
3843
4007
  }
3844
4008
  const { name, type: glUniformType, size } = activeInfo;
3845
4009
  const uniformType = convertGLUniformTypeToShaderVariableType(glUniformType);
3846
- const { type, components } = (0, import_core14.getVariableShaderTypeInfo)(uniformType);
4010
+ const { type, components } = (0, import_core15.getVariableShaderTypeInfo)(uniformType);
3847
4011
  varyings.push({ location, name, type, size: size * components });
3848
4012
  }
3849
4013
  varyings.sort((a, b) => a.location - b.location);
@@ -3944,11 +4108,11 @@ ${source}`;
3944
4108
  isArray: Boolean(matches[2])
3945
4109
  };
3946
4110
  }
3947
- var import_core14;
4111
+ var import_core15;
3948
4112
  var init_get_shader_layout_from_glsl = __esm({
3949
4113
  "src/adapter/helpers/get-shader-layout-from-glsl.ts"() {
3950
4114
  "use strict";
3951
- import_core14 = __toESM(require_core(), 1);
4115
+ import_core15 = __toESM(require_core(), 1);
3952
4116
  init_webgl_shadertypes();
3953
4117
  }
3954
4118
  });
@@ -4091,7 +4255,7 @@ ${source}`;
4091
4255
  for (const attribute of overrideLayout?.attributes || []) {
4092
4256
  const baseAttribute = mergedLayout.attributes.find((attr) => attr.name === attribute.name);
4093
4257
  if (!baseAttribute) {
4094
- import_core15.log.warn(`shader layout attribute ${attribute.name} not present in shader`);
4258
+ import_core16.log.warn(`shader layout attribute ${attribute.name} not present in shader`);
4095
4259
  } else {
4096
4260
  baseAttribute.type = attribute.type || baseAttribute.type;
4097
4261
  baseAttribute.stepMode = attribute.stepMode || baseAttribute.stepMode;
@@ -4099,11 +4263,11 @@ ${source}`;
4099
4263
  }
4100
4264
  return mergedLayout;
4101
4265
  }
4102
- var import_core15, LOG_PROGRAM_PERF_PRIORITY, WEBGLRenderPipeline;
4266
+ var import_core16, LOG_PROGRAM_PERF_PRIORITY, WEBGLRenderPipeline;
4103
4267
  var init_webgl_render_pipeline = __esm({
4104
4268
  "src/adapter/resources/webgl-render-pipeline.ts"() {
4105
4269
  "use strict";
4106
- import_core15 = __toESM(require_core(), 1);
4270
+ import_core16 = __toESM(require_core(), 1);
4107
4271
  init_get_shader_layout_from_glsl();
4108
4272
  init_device_parameters();
4109
4273
  init_set_uniform();
@@ -4113,7 +4277,7 @@ ${source}`;
4113
4277
  init_webgl_texture_view();
4114
4278
  init_webgl_topology_utils();
4115
4279
  LOG_PROGRAM_PERF_PRIORITY = 4;
4116
- WEBGLRenderPipeline = class extends import_core15.RenderPipeline {
4280
+ WEBGLRenderPipeline = class extends import_core16.RenderPipeline {
4117
4281
  /** The WebGL device that created this render pipeline */
4118
4282
  device;
4119
4283
  /** Handle to underlying WebGL program */
@@ -4149,9 +4313,9 @@ ${source}`;
4149
4313
  this.device.gl.transformFeedbackVaryings(this.handle, varyings, bufferMode);
4150
4314
  }
4151
4315
  this._linkShaders();
4152
- import_core15.log.time(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();
4316
+ import_core16.log.time(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();
4153
4317
  this.introspectedLayout = getShaderLayoutFromGLSL(this.device.gl, this.handle);
4154
- import_core15.log.timeEnd(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();
4318
+ import_core16.log.timeEnd(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();
4155
4319
  this.shaderLayout = props.shaderLayout ? mergeShaderLayout(this.introspectedLayout, props.shaderLayout) : this.introspectedLayout;
4156
4320
  }
4157
4321
  destroy() {
@@ -4173,7 +4337,7 @@ ${source}`;
4173
4337
  if (!binding) {
4174
4338
  const validBindings = this.shaderLayout.bindings.map((binding_) => `"${binding_.name}"`).join(", ");
4175
4339
  if (!options?.disableWarnings) {
4176
- import_core15.log.warn(
4340
+ import_core16.log.warn(
4177
4341
  `No binding "${name}" in render pipeline "${this.id}", expected one of ${validBindings}`,
4178
4342
  value
4179
4343
  )();
@@ -4181,7 +4345,7 @@ ${source}`;
4181
4345
  continue;
4182
4346
  }
4183
4347
  if (!value) {
4184
- import_core15.log.warn(`Unsetting binding "${name}" in render pipeline "${this.id}"`)();
4348
+ import_core16.log.warn(`Unsetting binding "${name}" in render pipeline "${this.id}"`)();
4185
4349
  }
4186
4350
  switch (binding.type) {
4187
4351
  case "uniform":
@@ -4195,7 +4359,7 @@ ${source}`;
4195
4359
  }
4196
4360
  break;
4197
4361
  case "sampler":
4198
- import_core15.log.warn(`Ignoring sampler ${name}`)();
4362
+ import_core16.log.warn(`Ignoring sampler ${name}`)();
4199
4363
  break;
4200
4364
  default:
4201
4365
  throw new Error(binding.type);
@@ -4227,11 +4391,11 @@ ${source}`;
4227
4391
  const isIndexed = Boolean(vertexArray.indexBuffer);
4228
4392
  const glIndexType = vertexArray.indexBuffer?.glIndexType;
4229
4393
  if (this.linkStatus !== "success") {
4230
- import_core15.log.info(2, `RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)();
4394
+ import_core16.log.info(2, `RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)();
4231
4395
  return false;
4232
4396
  }
4233
4397
  if (!this._areTexturesRenderable()) {
4234
- import_core15.log.info(2, `RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)();
4398
+ import_core16.log.info(2, `RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)();
4235
4399
  return false;
4236
4400
  }
4237
4401
  this.device.gl.useProgram(this.handle);
@@ -4278,19 +4442,19 @@ ${source}`;
4278
4442
  const { gl } = this.device;
4279
4443
  gl.attachShader(this.handle, this.vs.handle);
4280
4444
  gl.attachShader(this.handle, this.fs.handle);
4281
- import_core15.log.time(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
4445
+ import_core16.log.time(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
4282
4446
  gl.linkProgram(this.handle);
4283
- import_core15.log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
4284
- if (import_core15.log.level === 0) {
4447
+ import_core16.log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
4448
+ if (import_core16.log.level === 0) {
4285
4449
  }
4286
4450
  if (!this.device.features.has("compilation-status-async-webgl")) {
4287
4451
  const status2 = this._getLinkStatus();
4288
4452
  this._reportLinkStatus(status2);
4289
4453
  return;
4290
4454
  }
4291
- import_core15.log.once(1, "RenderPipeline linking is asynchronous")();
4455
+ import_core16.log.once(1, "RenderPipeline linking is asynchronous")();
4292
4456
  await this._waitForLinkComplete();
4293
- import_core15.log.info(2, `RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();
4457
+ import_core16.log.info(2, `RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();
4294
4458
  const status = this._getLinkStatus();
4295
4459
  this._reportLinkStatus(status);
4296
4460
  }
@@ -4378,7 +4542,7 @@ ${source}`;
4378
4542
  let texturesRenderable = true;
4379
4543
  for (const bindingInfo of this.shaderLayout.bindings) {
4380
4544
  if (!this.bindings[bindingInfo.name] && !this.bindings[bindingInfo.name.replace(/Uniforms$/, "")]) {
4381
- import_core15.log.warn(`Binding ${bindingInfo.name} not found in ${this.id}`)();
4545
+ import_core16.log.warn(`Binding ${bindingInfo.name} not found in ${this.id}`)();
4382
4546
  texturesRenderable = false;
4383
4547
  }
4384
4548
  }
@@ -4432,7 +4596,7 @@ ${source}`;
4432
4596
  } else if (value instanceof WEBGLTexture) {
4433
4597
  texture = value;
4434
4598
  } else if (value instanceof WEBGLFramebuffer && value.colorAttachments[0] instanceof WEBGLTextureView) {
4435
- import_core15.log.warn(
4599
+ import_core16.log.warn(
4436
4600
  "Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead"
4437
4601
  )();
4438
4602
  texture = value.colorAttachments[0].texture;
@@ -4639,7 +4803,7 @@ ${source}`;
4639
4803
  }
4640
4804
  }
4641
4805
  function getFramebuffer(source) {
4642
- if (source instanceof import_core16.Texture) {
4806
+ if (source instanceof import_core17.Texture) {
4643
4807
  const { width, height, id } = source;
4644
4808
  const framebuffer = source.device.createFramebuffer({
4645
4809
  id: `framebuffer-for-${id}`,
@@ -4651,14 +4815,14 @@ ${source}`;
4651
4815
  }
4652
4816
  return { framebuffer: source, destroyFramebuffer: false };
4653
4817
  }
4654
- var import_core16, WEBGLCommandBuffer;
4818
+ var import_core17, WEBGLCommandBuffer;
4655
4819
  var init_webgl_command_buffer = __esm({
4656
4820
  "src/adapter/resources/webgl-command-buffer.ts"() {
4657
4821
  "use strict";
4658
- import_core16 = __toESM(require_core(), 1);
4822
+ import_core17 = __toESM(require_core(), 1);
4659
4823
  init_webgl_texture();
4660
4824
  init_webgl_texture_table();
4661
- WEBGLCommandBuffer = class extends import_core16.CommandBuffer {
4825
+ WEBGLCommandBuffer = class extends import_core17.CommandBuffer {
4662
4826
  device;
4663
4827
  handle = null;
4664
4828
  commands = [];
@@ -4691,15 +4855,15 @@ ${source}`;
4691
4855
  });
4692
4856
 
4693
4857
  // src/adapter/resources/webgl-render-pass.ts
4694
- var import_core17, COLOR_CHANNELS, WEBGLRenderPass;
4858
+ var import_core18, COLOR_CHANNELS, WEBGLRenderPass;
4695
4859
  var init_webgl_render_pass = __esm({
4696
4860
  "src/adapter/resources/webgl-render-pass.ts"() {
4697
4861
  "use strict";
4698
- import_core17 = __toESM(require_core(), 1);
4862
+ import_core18 = __toESM(require_core(), 1);
4699
4863
  init_with_parameters();
4700
4864
  init_unified_parameter_api();
4701
4865
  COLOR_CHANNELS = [1, 2, 4, 8];
4702
- WEBGLRenderPass = class extends import_core17.RenderPass {
4866
+ WEBGLRenderPass = class extends import_core18.RenderPass {
4703
4867
  device;
4704
4868
  handle = null;
4705
4869
  /** Parameters that should be applied before each draw call */
@@ -4725,7 +4889,7 @@ ${source}`;
4725
4889
  (_, i) => 36064 /* COLOR_ATTACHMENT0 */ + i
4726
4890
  );
4727
4891
  this.device.gl.drawBuffers(drawBuffers);
4728
- } else {
4892
+ } else if (!this.props.framebuffer) {
4729
4893
  this.device.gl.drawBuffers([1029 /* BACK */]);
4730
4894
  }
4731
4895
  this.clear();
@@ -4771,9 +4935,9 @@ ${source}`;
4771
4935
  if (parameters.blendConstant) {
4772
4936
  glParameters.blendColor = parameters.blendConstant;
4773
4937
  }
4774
- if (parameters.stencilReference) {
4775
- console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL");
4938
+ if (parameters.stencilReference !== void 0) {
4776
4939
  glParameters[2967 /* STENCIL_REF */] = parameters.stencilReference;
4940
+ glParameters[36003 /* STENCIL_BACK_REF */] = parameters.stencilReference;
4777
4941
  }
4778
4942
  if ("colorMask" in parameters) {
4779
4943
  glParameters.colorMask = COLOR_CHANNELS.map(
@@ -4873,14 +5037,14 @@ ${source}`;
4873
5037
  });
4874
5038
 
4875
5039
  // src/adapter/resources/webgl-command-encoder.ts
4876
- var import_core18, WEBGLCommandEncoder;
5040
+ var import_core19, WEBGLCommandEncoder;
4877
5041
  var init_webgl_command_encoder = __esm({
4878
5042
  "src/adapter/resources/webgl-command-encoder.ts"() {
4879
5043
  "use strict";
4880
- import_core18 = __toESM(require_core(), 1);
5044
+ import_core19 = __toESM(require_core(), 1);
4881
5045
  init_webgl_command_buffer();
4882
5046
  init_webgl_render_pass();
4883
- WEBGLCommandEncoder = class extends import_core18.CommandEncoder {
5047
+ WEBGLCommandEncoder = class extends import_core19.CommandEncoder {
4884
5048
  device;
4885
5049
  handle = null;
4886
5050
  commandBuffer;
@@ -4971,15 +5135,15 @@ ${source}`;
4971
5135
  }
4972
5136
  return true;
4973
5137
  }
4974
- var import_core19, WEBGLVertexArray;
5138
+ var import_core20, WEBGLVertexArray;
4975
5139
  var init_webgl_vertex_array = __esm({
4976
5140
  "src/adapter/resources/webgl-vertex-array.ts"() {
4977
5141
  "use strict";
4978
- import_core19 = __toESM(require_core(), 1);
5142
+ import_core20 = __toESM(require_core(), 1);
4979
5143
  init_dist();
4980
5144
  init_webgl_vertex_formats();
4981
5145
  init_fill_array();
4982
- WEBGLVertexArray = class extends import_core19.VertexArray {
5146
+ WEBGLVertexArray = class extends import_core20.VertexArray {
4983
5147
  get [Symbol.toStringTag]() {
4984
5148
  return "VertexArray";
4985
5149
  }
@@ -5147,7 +5311,7 @@ ${source}`;
5147
5311
  this.buffer = this.buffer || this.device.createBuffer({ byteLength });
5148
5312
  updateNeeded ||= !compareConstantArrayValues(constantValue, this.bufferValue);
5149
5313
  if (updateNeeded) {
5150
- const typedArray = (0, import_core19.getScratchArray)(value.constructor, length);
5314
+ const typedArray = (0, import_core20.getScratchArray)(value.constructor, length);
5151
5315
  fillArray({ target: typedArray, source: constantValue, start: 0, count: length });
5152
5316
  this.buffer.write(typedArray);
5153
5317
  this.bufferValue = value;
@@ -5165,14 +5329,14 @@ ${source}`;
5165
5329
  }
5166
5330
  return /^\d+$/.test(value);
5167
5331
  }
5168
- var import_core20, WEBGLTransformFeedback;
5332
+ var import_core21, WEBGLTransformFeedback;
5169
5333
  var init_webgl_transform_feedback = __esm({
5170
5334
  "src/adapter/resources/webgl-transform-feedback.ts"() {
5171
5335
  "use strict";
5172
- import_core20 = __toESM(require_core(), 1);
5336
+ import_core21 = __toESM(require_core(), 1);
5173
5337
  init_src2();
5174
5338
  init_webgl_topology_utils();
5175
- WEBGLTransformFeedback = class extends import_core20.TransformFeedback {
5339
+ WEBGLTransformFeedback = class extends import_core21.TransformFeedback {
5176
5340
  device;
5177
5341
  gl;
5178
5342
  handle;
@@ -5235,7 +5399,7 @@ ${source}`;
5235
5399
  const { buffer, byteLength, byteOffset } = this._getBufferRange(bufferOrRange);
5236
5400
  if (location < 0) {
5237
5401
  this.unusedBuffers[locationOrName] = buffer;
5238
- import_core20.log.warn(`${this.id} unusedBuffers varying buffer ${locationOrName}`)();
5402
+ import_core21.log.warn(`${this.id} unusedBuffers varying buffer ${locationOrName}`)();
5239
5403
  return;
5240
5404
  }
5241
5405
  this.buffers[location] = { buffer, byteLength, byteOffset };
@@ -5318,12 +5482,12 @@ ${source}`;
5318
5482
  });
5319
5483
 
5320
5484
  // src/adapter/resources/webgl-query-set.ts
5321
- var import_core21, WEBGLQuerySet;
5485
+ var import_core22, WEBGLQuerySet;
5322
5486
  var init_webgl_query_set = __esm({
5323
5487
  "src/adapter/resources/webgl-query-set.ts"() {
5324
5488
  "use strict";
5325
- import_core21 = __toESM(require_core(), 1);
5326
- WEBGLQuerySet = class extends import_core21.QuerySet {
5489
+ import_core22 = __toESM(require_core(), 1);
5490
+ WEBGLQuerySet = class extends import_core22.QuerySet {
5327
5491
  device;
5328
5492
  handle;
5329
5493
  target = null;
@@ -5461,6 +5625,57 @@ ${source}`;
5461
5625
  }
5462
5626
  });
5463
5627
 
5628
+ // src/adapter/resources/webgl-fence.ts
5629
+ var import_core23, WEBGLFence;
5630
+ var init_webgl_fence = __esm({
5631
+ "src/adapter/resources/webgl-fence.ts"() {
5632
+ "use strict";
5633
+ import_core23 = __toESM(require_core(), 1);
5634
+ WEBGLFence = class extends import_core23.Fence {
5635
+ device;
5636
+ gl;
5637
+ handle;
5638
+ signaled;
5639
+ _signaled = false;
5640
+ constructor(device, props = {}) {
5641
+ super(device, {});
5642
+ this.device = device;
5643
+ this.gl = device.gl;
5644
+ const sync = this.props.handle || this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE, 0);
5645
+ if (!sync) {
5646
+ throw new Error("Failed to create WebGL fence");
5647
+ }
5648
+ this.handle = sync;
5649
+ this.signaled = new Promise((resolve) => {
5650
+ const poll = () => {
5651
+ const status = this.gl.clientWaitSync(this.handle, 0, 0);
5652
+ if (status === this.gl.ALREADY_SIGNALED || status === this.gl.CONDITION_SATISFIED) {
5653
+ this._signaled = true;
5654
+ resolve();
5655
+ } else {
5656
+ setTimeout(poll, 1);
5657
+ }
5658
+ };
5659
+ poll();
5660
+ });
5661
+ }
5662
+ isSignaled() {
5663
+ if (this._signaled) {
5664
+ return true;
5665
+ }
5666
+ const status = this.gl.getSyncParameter(this.handle, this.gl.SYNC_STATUS);
5667
+ this._signaled = status === this.gl.SIGNALED;
5668
+ return this._signaled;
5669
+ }
5670
+ destroy() {
5671
+ if (!this.destroyed) {
5672
+ this.gl.deleteSync(this.handle);
5673
+ }
5674
+ }
5675
+ };
5676
+ }
5677
+ });
5678
+
5464
5679
  // src/adapter/helpers/format-utils.ts
5465
5680
  function glFormatToComponents(format) {
5466
5681
  switch (format) {
@@ -5507,35 +5722,6 @@ ${source}`;
5507
5722
  }
5508
5723
  });
5509
5724
 
5510
- // src/adapter/converters/shader-formats.ts
5511
- function convertGLDataTypeToDataType(type) {
5512
- return GL_DATA_TYPE_MAP[type];
5513
- }
5514
- var GL_DATA_TYPE_MAP;
5515
- var init_shader_formats = __esm({
5516
- "src/adapter/converters/shader-formats.ts"() {
5517
- "use strict";
5518
- GL_DATA_TYPE_MAP = {
5519
- [5124 /* INT */]: "sint32",
5520
- [5125 /* UNSIGNED_INT */]: "uint32",
5521
- [5122 /* SHORT */]: "sint16",
5522
- [5123 /* UNSIGNED_SHORT */]: "uint16",
5523
- [5120 /* BYTE */]: "sint8",
5524
- [5121 /* UNSIGNED_BYTE */]: "uint8",
5525
- [5126 /* FLOAT */]: "float32",
5526
- [5131 /* HALF_FLOAT */]: "float16",
5527
- [33635 /* UNSIGNED_SHORT_5_6_5 */]: "uint16",
5528
- [32819 /* UNSIGNED_SHORT_4_4_4_4 */]: "uint16",
5529
- [32820 /* UNSIGNED_SHORT_5_5_5_1 */]: "uint16",
5530
- [33640 /* UNSIGNED_INT_2_10_10_10_REV */]: "uint32",
5531
- [35899 /* UNSIGNED_INT_10F_11F_11F_REV */]: "uint32",
5532
- [35902 /* UNSIGNED_INT_5_9_9_9_REV */]: "uint32",
5533
- [34042 /* UNSIGNED_INT_24_8 */]: "uint32",
5534
- [36269 /* FLOAT_32_UNSIGNED_INT_24_8_REV */]: "uint32"
5535
- };
5536
- }
5537
- });
5538
-
5539
5725
  // src/adapter/helpers/webgl-texture-utils.ts
5540
5726
  function readPixelsToArray(source, options) {
5541
5727
  const {
@@ -5565,7 +5751,7 @@ ${source}`;
5565
5751
  sourceFormat ||= texture?.glFormat || 6408 /* RGBA */;
5566
5752
  sourceType ||= texture?.glType || 5121 /* UNSIGNED_BYTE */;
5567
5753
  target2 = getPixelArray(target2, sourceType, sourceFormat, sourceWidth, sourceHeight, sourceDepth);
5568
- const signedType = (0, import_core22.getDataType)(target2);
5754
+ const signedType = (0, import_core24.getDataType)(target2);
5569
5755
  sourceType = sourceType || convertDataTypeToGLDataType(signedType);
5570
5756
  const prevHandle = gl.bindFramebuffer(
5571
5757
  36160 /* FRAMEBUFFER */,
@@ -5617,7 +5803,7 @@ ${source}`;
5617
5803
  return webglBufferTarget;
5618
5804
  }
5619
5805
  function getFramebuffer2(source) {
5620
- if (!(source instanceof import_core22.Framebuffer)) {
5806
+ if (!(source instanceof import_core24.Framebuffer)) {
5621
5807
  return { framebuffer: toFramebuffer(source), deleteFramebuffer: true };
5622
5808
  }
5623
5809
  return { framebuffer: source, deleteFramebuffer: false };
@@ -5639,15 +5825,15 @@ ${source}`;
5639
5825
  }
5640
5826
  glType ||= 5121 /* UNSIGNED_BYTE */;
5641
5827
  const shaderType = convertGLDataTypeToDataType(glType);
5642
- const ArrayType = (0, import_core22.getTypedArrayConstructor)(shaderType);
5828
+ const ArrayType = (0, import_core24.getTypedArrayConstructor)(shaderType);
5643
5829
  const components = glFormatToComponents(glFormat);
5644
5830
  return new ArrayType(width * height * components);
5645
5831
  }
5646
- var import_core22;
5832
+ var import_core24;
5647
5833
  var init_webgl_texture_utils = __esm({
5648
5834
  "src/adapter/helpers/webgl-texture-utils.ts"() {
5649
5835
  "use strict";
5650
- import_core22 = __toESM(require_core(), 1);
5836
+ import_core24 = __toESM(require_core(), 1);
5651
5837
  init_webgl_shadertypes();
5652
5838
  init_format_utils();
5653
5839
  init_shader_formats();
@@ -5693,11 +5879,11 @@ ${source}`;
5693
5879
  }
5694
5880
  return true;
5695
5881
  }
5696
- var import_core23, WebGLDevice;
5882
+ var import_core25, WebGLDevice;
5697
5883
  var init_webgl_device = __esm({
5698
5884
  "src/adapter/webgl-device.ts"() {
5699
5885
  "use strict";
5700
- import_core23 = __toESM(require_core(), 1);
5886
+ import_core25 = __toESM(require_core(), 1);
5701
5887
  init_webgl_state_tracker();
5702
5888
  init_create_browser_context();
5703
5889
  init_webgl_device_info();
@@ -5718,11 +5904,12 @@ ${source}`;
5718
5904
  init_webgl_vertex_array();
5719
5905
  init_webgl_transform_feedback();
5720
5906
  init_webgl_query_set();
5907
+ init_webgl_fence();
5721
5908
  init_webgl_texture_utils();
5722
5909
  init_unified_parameter_api();
5723
5910
  init_with_parameters();
5724
5911
  init_webgl_extensions();
5725
- WebGLDevice = class extends import_core23.Device {
5912
+ WebGLDevice = class extends import_core25.Device {
5726
5913
  // Public `Device` API
5727
5914
  /** type of this device */
5728
5915
  type = "webgl";
@@ -5767,7 +5954,7 @@ ${source}`;
5767
5954
  }
5768
5955
  constructor(props) {
5769
5956
  super({ ...props, id: props.id || uid("webgl-device") });
5770
- const canvasContextProps = import_core23.Device._getCanvasContextProps(props);
5957
+ const canvasContextProps = import_core25.Device._getCanvasContextProps(props);
5771
5958
  if (!canvasContextProps) {
5772
5959
  throw new Error("WebGLDevice requires props.createCanvasContext to be set");
5773
5960
  }
@@ -5786,6 +5973,9 @@ ${source}`;
5786
5973
  if (props.powerPreference !== void 0) {
5787
5974
  webglContextAttributes.powerPreference = props.powerPreference;
5788
5975
  }
5976
+ if (props.failIfMajorPerformanceCaveat !== void 0) {
5977
+ webglContextAttributes.failIfMajorPerformanceCaveat = props.failIfMajorPerformanceCaveat;
5978
+ }
5789
5979
  const externalGLContext = this.props._handle;
5790
5980
  const gl = externalGLContext || createBrowserContext(
5791
5981
  this.canvasContext.canvas,
@@ -5805,7 +5995,7 @@ ${source}`;
5805
5995
  device = gl.device;
5806
5996
  if (device) {
5807
5997
  if (props._reuseDevices) {
5808
- import_core23.log.log(
5998
+ import_core25.log.log(
5809
5999
  1,
5810
6000
  `Not creating a new Device, instead returning a reference to Device ${device.id} already attached to WebGL context`,
5811
6001
  device
@@ -5819,7 +6009,6 @@ ${source}`;
5819
6009
  this.gl = gl;
5820
6010
  this.spectorJS = initializeSpectorJS({ ...this.props, gl: this.handle });
5821
6011
  this.gl.device = this;
5822
- this.gl._version = 2;
5823
6012
  this.info = getDeviceInfo(this.gl, this._extensions);
5824
6013
  this.limits = new WebGLDeviceLimits(this.gl);
5825
6014
  this.features = new WebGLDeviceFeatures(
@@ -5831,17 +6020,15 @@ ${source}`;
5831
6020
  this.features.initializeFeatures();
5832
6021
  }
5833
6022
  const glState = new WebGLStateTracker(this.gl, {
5834
- log: (...args) => import_core23.log.log(1, ...args)()
6023
+ log: (...args) => import_core25.log.log(1, ...args)()
5835
6024
  });
5836
6025
  glState.trackState(this.gl, { copyState: false });
5837
- const debugWebGL = props.debugWebGL || props.debug;
5838
- const traceWebGL = props.debugWebGL;
5839
- if (debugWebGL) {
5840
- this.gl = makeDebugContext(this.gl, { debugWebGL, traceWebGL });
5841
- import_core23.log.warn("WebGL debug mode activated. Performance reduced.")();
5842
- if (props.debugWebGL) {
5843
- import_core23.log.level = Math.max(import_core23.log.level, 1);
5844
- }
6026
+ if (props.debug || props.debugWebGL) {
6027
+ this.gl = makeDebugContext(this.gl, { debugWebGL: true, traceWebGL: props.debugWebGL });
6028
+ import_core25.log.warn("WebGL debug mode activated. Performance reduced.")();
6029
+ }
6030
+ if (props.debugWebGL) {
6031
+ import_core25.log.level = Math.max(import_core25.log.level, 1);
5845
6032
  }
5846
6033
  this.commandEncoder = new WEBGLCommandEncoder(this, { id: `${this}-command-encoder` });
5847
6034
  }
@@ -5864,9 +6051,6 @@ ${source}`;
5864
6051
  return this.gl.isContextLost();
5865
6052
  }
5866
6053
  // IMPLEMENTATION OF ABSTRACT DEVICE
5867
- getTextureByteAlignment() {
5868
- return 4;
5869
- }
5870
6054
  createCanvasContext(props) {
5871
6055
  throw new Error("WebGL only supports a single canvas");
5872
6056
  }
@@ -5898,6 +6082,9 @@ ${source}`;
5898
6082
  createQuerySet(props) {
5899
6083
  return new WEBGLQuerySet(this, props);
5900
6084
  }
6085
+ createFence() {
6086
+ return new WEBGLFence(this);
6087
+ }
5901
6088
  createRenderPipeline(props) {
5902
6089
  return new WEBGLRenderPipeline(this, props);
5903
6090
  }
@@ -5941,7 +6128,7 @@ ${source}`;
5941
6128
  return withGLParameters(this.gl, parameters, func);
5942
6129
  }
5943
6130
  resetWebGL() {
5944
- import_core23.log.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")();
6131
+ import_core25.log.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")();
5945
6132
  resetGLParameters(this.gl);
5946
6133
  }
5947
6134
  _getDeviceSpecificTextureFormatCapabilities(capabilities) {
@@ -6013,7 +6200,7 @@ ${source}`;
6013
6200
  this._constants = this._constants || new Array(maxVertexAttributes).fill(null);
6014
6201
  const currentConstant = this._constants[location];
6015
6202
  if (currentConstant && compareConstantArrayValues2(currentConstant, constant)) {
6016
- import_core23.log.info(
6203
+ import_core25.log.info(
6017
6204
  1,
6018
6205
  `setConstantAttributeWebGL(${location}) could have been skipped, value unchanged`
6019
6206
  )();
@@ -6057,23 +6244,23 @@ ${source}`;
6057
6244
  if (typeof WebGL2RenderingContext !== "undefined" && gl instanceof WebGL2RenderingContext) {
6058
6245
  return true;
6059
6246
  }
6060
- return Boolean(gl && Number.isFinite(gl._version));
6247
+ return Boolean(gl && typeof gl.createVertexArray === "function");
6061
6248
  }
6062
- var import_core24, LOG_LEVEL2, WebGLAdapter, webgl2Adapter;
6249
+ var import_core26, LOG_LEVEL2, WebGLAdapter, webgl2Adapter;
6063
6250
  var init_webgl_adapter = __esm({
6064
6251
  "src/adapter/webgl-adapter.ts"() {
6065
6252
  "use strict";
6066
- import_core24 = __toESM(require_core(), 1);
6253
+ import_core26 = __toESM(require_core(), 1);
6067
6254
  init_polyfill_webgl1_extensions();
6068
6255
  init_spector();
6069
6256
  init_webgl_developer_tools();
6070
6257
  LOG_LEVEL2 = 1;
6071
- WebGLAdapter = class extends import_core24.Adapter {
6258
+ WebGLAdapter = class extends import_core26.Adapter {
6072
6259
  /** type of device's created by this adapter */
6073
6260
  type = "webgl";
6074
6261
  constructor() {
6075
6262
  super();
6076
- import_core24.Device.defaultProps = { ...import_core24.Device.defaultProps, ...DEFAULT_SPECTOR_PROPS };
6263
+ import_core26.Device.defaultProps = { ...import_core26.Device.defaultProps, ...DEFAULT_SPECTOR_PROPS };
6077
6264
  }
6078
6265
  /** Force any created WebGL contexts to be WebGL2 contexts, polyfilled with WebGL1 extensions */
6079
6266
  enforceWebGL2(enable2) {
@@ -6088,7 +6275,7 @@ ${source}`;
6088
6275
  return true;
6089
6276
  }
6090
6277
  if (typeof WebGLRenderingContext !== "undefined" && handle instanceof WebGLRenderingContext) {
6091
- import_core24.log.warn("WebGL1 is not supported", handle)();
6278
+ import_core26.log.warn("WebGL1 is not supported", handle)();
6092
6279
  }
6093
6280
  return false;
6094
6281
  }
@@ -6119,28 +6306,33 @@ ${source}`;
6119
6306
  }
6120
6307
  async create(props = {}) {
6121
6308
  const { WebGLDevice: WebGLDevice2 } = await Promise.resolve().then(() => (init_webgl_device(), webgl_device_exports));
6122
- import_core24.log.groupCollapsed(LOG_LEVEL2, "WebGLDevice created")();
6123
- try {
6124
- const promises = [];
6125
- if (props.debugWebGL || props.debug) {
6126
- promises.push(loadWebGLDeveloperTools());
6127
- }
6128
- if (props.debugSpectorJS) {
6129
- promises.push(loadSpectorJS(props));
6130
- }
6131
- const results = await Promise.allSettled(promises);
6132
- for (const result of results) {
6133
- if (result.status === "rejected") {
6134
- import_core24.log.error(`Failed to initialize debug libraries ${result.reason}`)();
6135
- }
6309
+ const promises = [];
6310
+ if (props.debugWebGL || props.debug) {
6311
+ promises.push(loadWebGLDeveloperTools());
6312
+ }
6313
+ if (props.debugSpectorJS) {
6314
+ promises.push(loadSpectorJS(props));
6315
+ }
6316
+ const results = await Promise.allSettled(promises);
6317
+ for (const result of results) {
6318
+ if (result.status === "rejected") {
6319
+ import_core26.log.error(`Failed to initialize debug libraries ${result.reason}`)();
6136
6320
  }
6321
+ }
6322
+ try {
6137
6323
  const device = new WebGLDevice2(props);
6324
+ import_core26.log.groupCollapsed(LOG_LEVEL2, `WebGLDevice ${device.id} created`)();
6138
6325
  const message2 = `${device._reused ? "Reusing" : "Created"} device with WebGL2 ${device.props.debug ? "debug " : ""}context: ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;
6139
- import_core24.log.probe(LOG_LEVEL2, message2)();
6140
- import_core24.log.table(LOG_LEVEL2, device.info)();
6326
+ import_core26.log.probe(LOG_LEVEL2, message2)();
6327
+ import_core26.log.table(LOG_LEVEL2, device.info)();
6141
6328
  return device;
6142
6329
  } finally {
6143
- import_core24.log.groupEnd(LOG_LEVEL2)();
6330
+ import_core26.log.groupEnd(LOG_LEVEL2)();
6331
+ import_core26.log.info(
6332
+ LOG_LEVEL2,
6333
+ `%cWebGL call tracing: luma.log.set('debug-webgl') `,
6334
+ "color: white; background: blue; padding: 2px 6px; border-radius: 3px;"
6335
+ )();
6144
6336
  }
6145
6337
  }
6146
6338
  };
@@ -6160,6 +6352,7 @@ ${source}`;
6160
6352
  init_webgl_shader();
6161
6353
  init_webgl_sampler();
6162
6354
  init_webgl_framebuffer();
6355
+ init_webgl_fence();
6163
6356
  init_webgl_render_pipeline();
6164
6357
  init_webgl_command_encoder();
6165
6358
  init_webgl_render_pass();
@@ -6178,6 +6371,7 @@ ${source}`;
6178
6371
  __export(bundle_exports, {
6179
6372
  WEBGLBuffer: () => WEBGLBuffer,
6180
6373
  WEBGLCommandEncoder: () => WEBGLCommandEncoder,
6374
+ WEBGLFence: () => WEBGLFence,
6181
6375
  WEBGLFramebuffer: () => WEBGLFramebuffer,
6182
6376
  WEBGLRenderPass: () => WEBGLRenderPass,
6183
6377
  WEBGLRenderPipeline: () => WEBGLRenderPipeline,