@luma.gl/webgl 9.1.0-beta.8 → 9.1.0-beta.9

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 (42) hide show
  1. package/dist/adapter/converters/webgl-texture-table.js +1 -1
  2. package/dist/adapter/converters/webgl-texture-table.js.map +1 -1
  3. package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
  4. package/dist/adapter/resources/webgl-buffer.js +1 -3
  5. package/dist/adapter/resources/webgl-buffer.js.map +1 -1
  6. package/dist/adapter/resources/webgl-framebuffer.js +2 -2
  7. package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
  8. package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
  9. package/dist/adapter/resources/webgl-render-pass.js +2 -4
  10. package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
  11. package/dist/adapter/resources/webgl-render-pipeline.d.ts +0 -1
  12. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  13. package/dist/adapter/resources/webgl-render-pipeline.js +4 -11
  14. package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
  15. package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
  16. package/dist/adapter/resources/webgl-shader.js +1 -5
  17. package/dist/adapter/resources/webgl-shader.js.map +1 -1
  18. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  19. package/dist/adapter/resources/webgl-texture.js +1 -6
  20. package/dist/adapter/resources/webgl-texture.js.map +1 -1
  21. package/dist/adapter/webgl-canvas-context.d.ts +6 -3
  22. package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
  23. package/dist/adapter/webgl-canvas-context.js +17 -6
  24. package/dist/adapter/webgl-canvas-context.js.map +1 -1
  25. package/dist/adapter/webgl-device.d.ts +6 -10
  26. package/dist/adapter/webgl-device.d.ts.map +1 -1
  27. package/dist/adapter/webgl-device.js +12 -15
  28. package/dist/adapter/webgl-device.js.map +1 -1
  29. package/dist/dist.dev.js +34 -41
  30. package/dist/dist.min.js +2 -2
  31. package/dist/index.cjs +34 -41
  32. package/dist/index.cjs.map +2 -2
  33. package/package.json +3 -3
  34. package/src/adapter/converters/webgl-texture-table.ts +2 -2
  35. package/src/adapter/resources/webgl-buffer.ts +1 -3
  36. package/src/adapter/resources/webgl-framebuffer.ts +2 -2
  37. package/src/adapter/resources/webgl-render-pass.ts +2 -5
  38. package/src/adapter/resources/webgl-render-pipeline.ts +5 -12
  39. package/src/adapter/resources/webgl-shader.ts +1 -7
  40. package/src/adapter/resources/webgl-texture.ts +1 -6
  41. package/src/adapter/webgl-canvas-context.ts +19 -8
  42. package/src/adapter/webgl-device.ts +16 -25
package/dist/index.cjs CHANGED
@@ -963,7 +963,7 @@ var WEBGL_TEXTURE_FORMATS = {
963
963
  // , filter: true},
964
964
  "rg11b10ufloat": { gl: 35898, rb: true },
965
965
  "rgb10a2unorm": { gl: 32857, rb: true },
966
- "rgb10a2uint": { gl: 36975, rb: true },
966
+ "rgb10a2uint-webgl": { gl: 36975, rb: true },
967
967
  // 48-bit formats
968
968
  "rgb16unorm-webgl": { gl: 32852 },
969
969
  // rgb not renderable
@@ -1345,7 +1345,7 @@ var WEBGLFramebuffer = class extends import_core4.Framebuffer {
1345
1345
  this.gl = device.gl;
1346
1346
  this.handle = this.props.handle || isDefaultFramebuffer ? this.props.handle : this.gl.createFramebuffer();
1347
1347
  if (!isDefaultFramebuffer) {
1348
- device._setWebGLDebugMetadata(this.handle, this, { spector: this.props });
1348
+ device.setSpectorMetadata(this.handle, { id: this.props.id, props: this.props });
1349
1349
  this.autoCreateAttachmentTextures();
1350
1350
  this.updateAttachments();
1351
1351
  }
@@ -1445,7 +1445,9 @@ function _getFrameBufferStatus(status) {
1445
1445
  // dist/adapter/webgl-canvas-context.js
1446
1446
  var WebGLCanvasContext = class extends import_core5.CanvasContext {
1447
1447
  device;
1448
- handle = null;
1448
+ format = "rgba8unorm";
1449
+ depthStencilFormat = "depth24plus";
1450
+ presentationSize;
1449
1451
  _framebuffer = null;
1450
1452
  get [Symbol.toStringTag]() {
1451
1453
  return "WebGLCanvasContext";
@@ -1453,14 +1455,23 @@ var WebGLCanvasContext = class extends import_core5.CanvasContext {
1453
1455
  constructor(device, props) {
1454
1456
  super(props);
1455
1457
  this.device = device;
1458
+ this.presentationSize = [-1, -1];
1456
1459
  this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);
1457
- this.updateSize([this.drawingBufferWidth, this.drawingBufferHeight]);
1460
+ this.update();
1458
1461
  }
1459
1462
  getCurrentFramebuffer() {
1463
+ this.update();
1460
1464
  this._framebuffer = this._framebuffer || new WEBGLFramebuffer(this.device, { handle: null });
1461
1465
  return this._framebuffer;
1462
1466
  }
1463
- updateSize(size) {
1467
+ /** Resizes and updates render targets if necessary */
1468
+ update() {
1469
+ const size = this.getPixelSize();
1470
+ const sizeChanged = size[0] !== this.presentationSize[0] || size[1] !== this.presentationSize[1];
1471
+ if (sizeChanged) {
1472
+ this.presentationSize = size;
1473
+ this.resize();
1474
+ }
1464
1475
  }
1465
1476
  /**
1466
1477
  * Resize the canvas' drawing buffer.
@@ -1479,7 +1490,7 @@ var WebGLCanvasContext = class extends import_core5.CanvasContext {
1479
1490
  return;
1480
1491
  if (this.canvas) {
1481
1492
  const devicePixelRatio = this.getDevicePixelRatio(options == null ? void 0 : options.useDevicePixels);
1482
- this._setDevicePixelRatio(devicePixelRatio, options);
1493
+ this.setDevicePixelRatio(devicePixelRatio, options);
1483
1494
  return;
1484
1495
  }
1485
1496
  }
@@ -1681,9 +1692,7 @@ var WEBGLBuffer = class extends import_core8.Buffer {
1681
1692
  this.gl = this.device.gl;
1682
1693
  const handle = typeof props === "object" ? props.handle : void 0;
1683
1694
  this.handle = handle || this.gl.createBuffer();
1684
- device._setWebGLDebugMetadata(this.handle, this, {
1685
- spector: { ...this.props, data: typeof this.props.data }
1686
- });
1695
+ device.setSpectorMetadata(this.handle, { ...this.props, data: typeof this.props.data });
1687
1696
  this.glTarget = getWebGLTarget(this.props.usage);
1688
1697
  this.glUsage = getWebGLUsage(this.props.usage);
1689
1698
  this.glIndexType = this.props.indexType === "uint32" ? 5125 : 5123;
@@ -1850,7 +1859,6 @@ var WEBGLShader = class extends import_core9.Shader {
1850
1859
  default:
1851
1860
  throw new Error(this.props.stage);
1852
1861
  }
1853
- device._setWebGLDebugMetadata(this.handle, this, { spector: this.props });
1854
1862
  this._compile(this.source);
1855
1863
  }
1856
1864
  destroy() {
@@ -1858,7 +1866,6 @@ var WEBGLShader = class extends import_core9.Shader {
1858
1866
  this.removeStats();
1859
1867
  this.device.gl.deleteShader(this.handle);
1860
1868
  this.destroyed = true;
1861
- this.handle.destroyed = true;
1862
1869
  }
1863
1870
  }
1864
1871
  get asyncCompilationStatus() {
@@ -2664,12 +2671,7 @@ var WEBGLTexture = class extends import_core14.Texture {
2664
2671
  // eslint-disable-next-line max-statements
2665
2672
  _initialize(propsWithData) {
2666
2673
  this.handle = this.props.handle || this.gl.createTexture();
2667
- this.device._setWebGLDebugMetadata(this.handle, this, {
2668
- spector: {
2669
- ...this.props,
2670
- data: propsWithData.data
2671
- }
2672
- });
2674
+ this.device.setSpectorMetadata(this.handle, { ...this.props, data: propsWithData.data });
2673
2675
  let { width, height } = propsWithData;
2674
2676
  if (!width || !height) {
2675
2677
  const textureSize = import_core14.Texture.getTextureDataSize(propsWithData.data);
@@ -2995,14 +2997,13 @@ var WEBGLRenderPass = class extends import_core15.RenderPass {
2995
2997
  const { width, height } = props.framebuffer;
2996
2998
  viewport = [0, 0, width, height];
2997
2999
  } else {
2998
- const [width, height] = device.getDefaultCanvasContext().getDrawingBufferSize();
3000
+ const [width, height] = device.getCanvasContext().getDrawingBufferSize();
2999
3001
  viewport = [0, 0, width, height];
3000
3002
  }
3001
3003
  }
3002
3004
  this.device.pushState();
3003
3005
  this.setParameters({ viewport, ...this.props.parameters });
3004
- const webglFramebuffer = this.props.framebuffer;
3005
- if (webglFramebuffer == null ? void 0 : webglFramebuffer.handle) {
3006
+ if (this.props.framebuffer) {
3006
3007
  const drawBuffers = this.props.framebuffer.colorAttachments.map((_, i) => 36064 + i);
3007
3008
  this.device.gl.drawBuffers(drawBuffers);
3008
3009
  } else {
@@ -3587,14 +3588,11 @@ var WEBGLRenderPipeline = class extends import_core16.RenderPipeline {
3587
3588
  _uniformCount = 0;
3588
3589
  _uniformSetters = {};
3589
3590
  // TODO are these used?
3590
- get [Symbol.toStringTag]() {
3591
- return "WEBGLRenderPipeline";
3592
- }
3593
3591
  constructor(device, props) {
3594
3592
  super(device, props);
3595
3593
  this.device = device;
3596
3594
  this.handle = this.props.handle || this.device.gl.createProgram();
3597
- this.device._setWebGLDebugMetadata(this.handle, this, { spector: { id: this.props.id } });
3595
+ this.device.setSpectorMetadata(this.handle, { id: this.props.id });
3598
3596
  this.vs = props.vs;
3599
3597
  this.fs = props.fs;
3600
3598
  const { varyings, bufferMode = 35981 } = props;
@@ -3603,18 +3601,15 @@ var WEBGLRenderPipeline = class extends import_core16.RenderPipeline {
3603
3601
  this.device.gl.transformFeedbackVaryings(this.handle, varyings, bufferMode);
3604
3602
  }
3605
3603
  this._linkShaders();
3606
- import_core16.log.time(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();
3604
+ import_core16.log.time(1, `RenderPipeline ${this.id} - shaderLayout introspection`)();
3607
3605
  this.introspectedLayout = getShaderLayoutFromGLSL(this.device.gl, this.handle);
3608
- import_core16.log.timeEnd(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();
3606
+ import_core16.log.timeEnd(1, `RenderPipeline ${this.id} - shaderLayout introspection`)();
3609
3607
  this.shaderLayout = mergeShaderLayout(this.introspectedLayout, props.shaderLayout);
3610
3608
  }
3611
3609
  destroy() {
3612
3610
  if (this.handle) {
3613
- this.device.gl.useProgram(null);
3614
3611
  this.device.gl.deleteProgram(this.handle);
3615
3612
  this.destroyed = true;
3616
- this.handle.destroyed = true;
3617
- this.handle = null;
3618
3613
  }
3619
3614
  }
3620
3615
  /**
@@ -4654,7 +4649,9 @@ var WEBGLQuerySet = class extends import_core21.QuerySet {
4654
4649
 
4655
4650
  // dist/adapter/webgl-device.js
4656
4651
  var WebGLDevice = class extends import_core22.Device {
4652
+ //
4657
4653
  // Public `Device` API
4654
+ //
4658
4655
  /** type of this device */
4659
4656
  type = "webgl";
4660
4657
  /** The underlying WebGL context */
@@ -4663,8 +4660,6 @@ var WebGLDevice = class extends import_core22.Device {
4663
4660
  limits;
4664
4661
  info;
4665
4662
  canvasContext;
4666
- preferredColorFormat = "rgba8unorm";
4667
- preferredDepthFormat = "depth24plus";
4668
4663
  lost;
4669
4664
  _resolveContextLost;
4670
4665
  /** WebGL2 context. */
@@ -4731,6 +4726,7 @@ var WebGLDevice = class extends import_core22.Device {
4731
4726
  if (this.props._initializeFeatures) {
4732
4727
  this.features.initializeFeatures();
4733
4728
  }
4729
+ this.canvasContext.resize();
4734
4730
  const glState = new WebGLStateTracker(this.gl, {
4735
4731
  log: (...args) => import_core22.log.log(1, ...args)()
4736
4732
  });
@@ -4871,6 +4867,13 @@ var WebGLDevice = class extends import_core22.Device {
4871
4867
  const webglState = WebGLStateTracker.get(this.gl);
4872
4868
  webglState.pop();
4873
4869
  }
4870
+ /**
4871
+ * Storing data on a special field on WebGLObjects makes that data visible in SPECTOR chrome debug extension
4872
+ * luma.gl ids and props can be inspected
4873
+ */
4874
+ setSpectorMetadata(handle, props) {
4875
+ handle.__SPECTOR_Metadata = props;
4876
+ }
4874
4877
  /**
4875
4878
  * Returns the GL.<KEY> constant that corresponds to a numeric value of a GL constant
4876
4879
  * Be aware that there are some duplicates especially for constants that are 0,
@@ -4930,16 +4933,6 @@ var WebGLDevice = class extends import_core22.Device {
4930
4933
  getWebGLExtension(this.gl, name, this._extensions);
4931
4934
  return this._extensions;
4932
4935
  }
4933
- // INTERNAL SUPPORT METHODS FOR WEBGL RESOURCES
4934
- /**
4935
- * Storing data on a special field on WebGLObjects makes that data visible in SPECTOR chrome debug extension
4936
- * luma.gl ids and props can be inspected
4937
- */
4938
- _setWebGLDebugMetadata(handle, resource, options) {
4939
- handle.luma = resource;
4940
- const spectorMetadata = { props: options.spector, id: options.spector.id };
4941
- handle.__SPECTOR_Metadata = spectorMetadata;
4942
- }
4943
4936
  };
4944
4937
  function setConstantFloatArray(device, location, array) {
4945
4938
  switch (array.length) {