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

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 (64) hide show
  1. package/dist/adapter/helpers/get-shader-layout-from-glsl.js +11 -8
  2. package/dist/adapter/helpers/get-shader-layout-from-glsl.js.map +1 -1
  3. package/dist/adapter/helpers/parse-shader-compiler-log.d.ts +1 -1
  4. package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
  5. package/dist/adapter/helpers/parse-shader-compiler-log.js +20 -0
  6. package/dist/adapter/helpers/parse-shader-compiler-log.js.map +1 -1
  7. package/dist/adapter/resources/webgl-command-buffer.d.ts +2 -3
  8. package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
  9. package/dist/adapter/resources/webgl-command-buffer.js +9 -5
  10. package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
  11. package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
  12. package/dist/adapter/resources/webgl-render-pass.js +5 -0
  13. package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
  14. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  15. package/dist/adapter/resources/webgl-render-pipeline.js +1 -2
  16. package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
  17. package/dist/adapter/resources/webgl-transform-feedback.js +5 -5
  18. package/dist/adapter/resources/webgl-transform-feedback.js.map +1 -1
  19. package/dist/adapter/webgl-adapter.d.ts.map +1 -1
  20. package/dist/adapter/webgl-adapter.js +3 -4
  21. package/dist/adapter/webgl-adapter.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 +25 -11
  25. package/dist/adapter/webgl-device.js.map +1 -1
  26. package/dist/context/debug/spector.d.ts.map +1 -1
  27. package/dist/context/debug/spector.js +4 -4
  28. package/dist/context/debug/spector.js.map +1 -1
  29. package/dist/context/debug/webgl-developer-tools.js +2 -0
  30. package/dist/context/debug/webgl-developer-tools.js.map +1 -1
  31. package/dist/context/helpers/create-browser-context.d.ts.map +1 -1
  32. package/dist/context/helpers/create-browser-context.js +6 -8
  33. package/dist/context/helpers/create-browser-context.js.map +1 -1
  34. package/dist/context/helpers/webgl-context-data.d.ts +5 -1
  35. package/dist/context/helpers/webgl-context-data.d.ts.map +1 -1
  36. package/dist/context/helpers/webgl-context-data.js +9 -10
  37. package/dist/context/helpers/webgl-context-data.js.map +1 -1
  38. package/dist/context/parameters/unified-parameter-api.d.ts +1 -1
  39. package/dist/context/parameters/unified-parameter-api.js +2 -2
  40. package/dist/context/parameters/unified-parameter-api.js.map +1 -1
  41. package/dist/context/state-tracker/webgl-state-tracker.js +2 -2
  42. package/dist/context/state-tracker/webgl-state-tracker.js.map +1 -1
  43. package/dist/dist.dev.js +104 -49
  44. package/dist/dist.min.js +2 -2
  45. package/dist/index.cjs +108 -44
  46. package/dist/index.cjs.map +4 -4
  47. package/dist/utils/fill-array.js +1 -1
  48. package/dist/utils/fill-array.js.map +1 -1
  49. package/package.json +4 -4
  50. package/src/adapter/helpers/get-shader-layout-from-glsl.ts +11 -9
  51. package/src/adapter/helpers/parse-shader-compiler-log.ts +23 -1
  52. package/src/adapter/resources/webgl-command-buffer.ts +18 -22
  53. package/src/adapter/resources/webgl-render-pass.ts +6 -0
  54. package/src/adapter/resources/webgl-render-pipeline.ts +1 -2
  55. package/src/adapter/resources/webgl-transform-feedback.ts +5 -5
  56. package/src/adapter/webgl-adapter.ts +3 -4
  57. package/src/adapter/webgl-device.ts +26 -15
  58. package/src/context/debug/spector.ts +4 -4
  59. package/src/context/debug/webgl-developer-tools.ts +2 -0
  60. package/src/context/helpers/create-browser-context.ts +8 -8
  61. package/src/context/helpers/webgl-context-data.ts +17 -11
  62. package/src/context/parameters/unified-parameter-api.ts +2 -2
  63. package/src/context/state-tracker/webgl-state-tracker.ts +2 -2
  64. package/src/utils/fill-array.ts +1 -1
package/dist/dist.dev.js CHANGED
@@ -847,6 +847,24 @@ var __exports__ = (() => {
847
847
  }
848
848
  });
849
849
 
850
+ // src/context/helpers/webgl-context-data.ts
851
+ function getWebGLContextData(gl) {
852
+ const contextData = gl.luma || {
853
+ _polyfilled: false,
854
+ extensions: {},
855
+ softwareRenderer: false
856
+ };
857
+ contextData._polyfilled ??= false;
858
+ contextData.extensions ||= {};
859
+ gl.luma = contextData;
860
+ return contextData;
861
+ }
862
+ var init_webgl_context_data = __esm({
863
+ "src/context/helpers/webgl-context-data.ts"() {
864
+ "use strict";
865
+ }
866
+ });
867
+
850
868
  // src/context/debug/spector.ts
851
869
  async function loadSpectorJS(props) {
852
870
  if (!globalThis.SPECTOR) {
@@ -888,9 +906,10 @@ var __exports__ = (() => {
888
906
  }
889
907
  if (props.gl) {
890
908
  const gl = props.gl;
891
- const device = gl.device;
909
+ const contextData = getWebGLContextData(gl);
910
+ const device = contextData.device;
892
911
  spector?.startCapture(props.gl, 500);
893
- gl.device = device;
912
+ contextData.device = device;
894
913
  new Promise((resolve) => setTimeout(resolve, 2e3)).then((_) => {
895
914
  import_core.log.info("Spector capture stopped after 2 seconds")();
896
915
  spector?.stopCapture();
@@ -904,6 +923,7 @@ var __exports__ = (() => {
904
923
  "use strict";
905
924
  import_core = __toESM(require_core(), 1);
906
925
  init_load_script();
926
+ init_webgl_context_data();
907
927
  LOG_LEVEL = 1;
908
928
  spector = null;
909
929
  initialized = false;
@@ -1000,7 +1020,7 @@ var __exports__ = (() => {
1000
1020
  });
1001
1021
 
1002
1022
  // src/context/debug/webgl-developer-tools.ts
1003
- function getWebGLContextData(gl) {
1023
+ function getWebGLContextData2(gl) {
1004
1024
  gl.luma = gl.luma || {};
1005
1025
  return gl.luma;
1006
1026
  }
@@ -1015,7 +1035,7 @@ var __exports__ = (() => {
1015
1035
  return props.debugWebGL || props.traceWebGL ? getDebugContext(gl, props) : getRealContext(gl);
1016
1036
  }
1017
1037
  function getRealContext(gl) {
1018
- const data = getWebGLContextData(gl);
1038
+ const data = getWebGLContextData2(gl);
1019
1039
  return data.realContext ? data.realContext : gl;
1020
1040
  }
1021
1041
  function getDebugContext(gl, props) {
@@ -1023,7 +1043,7 @@ var __exports__ = (() => {
1023
1043
  import_core2.log.warn("webgl-debug not loaded")();
1024
1044
  return gl;
1025
1045
  }
1026
- const data = getWebGLContextData(gl);
1046
+ const data = getWebGLContextData2(gl);
1027
1047
  if (data.debugContext) {
1028
1048
  return data.debugContext;
1029
1049
  }
@@ -1045,6 +1065,7 @@ var __exports__ = (() => {
1045
1065
  const debugContext = Object.create(WebGLDebugContext);
1046
1066
  data.realContext = gl;
1047
1067
  data.debugContext = debugContext;
1068
+ debugContext.luma = data;
1048
1069
  debugContext.debug = true;
1049
1070
  return debugContext;
1050
1071
  }
@@ -1629,7 +1650,7 @@ var __exports__ = (() => {
1629
1650
  }
1630
1651
  }
1631
1652
  }
1632
- const cache = gl.state && gl.state.cache;
1653
+ const cache = gl.lumaState?.cache;
1633
1654
  if (cache) {
1634
1655
  for (const key in compositeSetters) {
1635
1656
  const compositeSetter = GL_COMPOSITE_PARAMETER_SETTERS[key];
@@ -1752,7 +1773,7 @@ var __exports__ = (() => {
1752
1773
  init_webgl_parameter_tables();
1753
1774
  WebGLStateTracker = class {
1754
1775
  static get(gl) {
1755
- return gl.state;
1776
+ return gl.lumaState;
1756
1777
  }
1757
1778
  gl;
1758
1779
  program = null;
@@ -1790,7 +1811,7 @@ var __exports__ = (() => {
1790
1811
  throw new Error("WebGLStateTracker");
1791
1812
  }
1792
1813
  this.initialized = true;
1793
- this.gl.state = this;
1814
+ this.gl.lumaState = this;
1794
1815
  installProgramSpy(gl);
1795
1816
  for (const key in GL_HOOKED_SETTERS) {
1796
1817
  const setter = GL_HOOKED_SETTERS[key];
@@ -1850,13 +1871,11 @@ var __exports__ = (() => {
1850
1871
  if (!gl && webglProps.failIfMajorPerformanceCaveat) {
1851
1872
  errorMessage ||= "Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.";
1852
1873
  }
1874
+ let softwareRenderer = false;
1853
1875
  if (!gl && allowSoftwareRenderer) {
1854
1876
  webglProps.failIfMajorPerformanceCaveat = false;
1855
1877
  gl = canvas.getContext("webgl2", webglProps);
1856
- if (gl) {
1857
- gl.luma ||= {};
1858
- gl.luma.softwareRenderer = true;
1859
- }
1878
+ softwareRenderer = true;
1860
1879
  }
1861
1880
  if (!gl) {
1862
1881
  gl = canvas.getContext("webgl", {});
@@ -1869,6 +1888,8 @@ var __exports__ = (() => {
1869
1888
  errorMessage ||= "Your browser does not support WebGL";
1870
1889
  throw new Error(`Failed to create WebGL context: ${errorMessage}`);
1871
1890
  }
1891
+ const luma = getWebGLContextData(gl);
1892
+ luma.softwareRenderer = softwareRenderer;
1872
1893
  const { onContextLost, onContextRestored } = props;
1873
1894
  canvas.addEventListener("webglcontextlost", (event) => onContextLost(event), false);
1874
1895
  canvas.addEventListener(
@@ -1876,7 +1897,6 @@ var __exports__ = (() => {
1876
1897
  (event) => onContextRestored(event),
1877
1898
  false
1878
1899
  );
1879
- gl.luma ||= {};
1880
1900
  return gl;
1881
1901
  } finally {
1882
1902
  canvas.removeEventListener("webglcontextcreationerror", onCreateError, false);
@@ -1885,6 +1905,7 @@ var __exports__ = (() => {
1885
1905
  var init_create_browser_context = __esm({
1886
1906
  "src/context/helpers/create-browser-context.ts"() {
1887
1907
  "use strict";
1908
+ init_webgl_context_data();
1888
1909
  }
1889
1910
  });
1890
1911
 
@@ -2815,9 +2836,20 @@ var __exports__ = (() => {
2815
2836
  if (line.length <= 1) {
2816
2837
  continue;
2817
2838
  }
2839
+ const lineWithTrimmedWhitespace = line.trim();
2818
2840
  const segments = line.split(":");
2841
+ const trimmedMessageType = segments[0]?.trim();
2819
2842
  if (segments.length === 2) {
2820
2843
  const [messageType2, message2] = segments;
2844
+ if (!messageType2 || !message2) {
2845
+ messages.push({
2846
+ message: lineWithTrimmedWhitespace,
2847
+ type: getMessageType(trimmedMessageType || "info"),
2848
+ lineNum: 0,
2849
+ linePos: 0
2850
+ });
2851
+ continue;
2852
+ }
2821
2853
  messages.push({
2822
2854
  message: message2.trim(),
2823
2855
  type: getMessageType(messageType2),
@@ -2827,6 +2859,15 @@ var __exports__ = (() => {
2827
2859
  continue;
2828
2860
  }
2829
2861
  const [messageType, linePosition, lineNumber, ...rest] = segments;
2862
+ if (!messageType || !linePosition || !lineNumber) {
2863
+ messages.push({
2864
+ message: segments.slice(1).join(":").trim() || lineWithTrimmedWhitespace,
2865
+ type: getMessageType(trimmedMessageType || "info"),
2866
+ lineNum: 0,
2867
+ linePos: 0
2868
+ });
2869
+ continue;
2870
+ }
2830
2871
  let lineNum = parseInt(lineNumber, 10);
2831
2872
  if (isNaN(lineNum)) {
2832
2873
  lineNum = 0;
@@ -4068,7 +4109,11 @@ ${source}`;
4068
4109
  const uniformOffset = gl.getActiveUniforms(program, uniformIndices, 35387 /* UNIFORM_OFFSET */);
4069
4110
  const uniformStride = gl.getActiveUniforms(program, uniformIndices, 35388 /* UNIFORM_ARRAY_STRIDE */);
4070
4111
  for (let i = 0; i < blockInfo.uniformCount; ++i) {
4071
- const activeInfo = gl.getActiveUniform(program, uniformIndices[i]);
4112
+ const uniformIndex = uniformIndices[i];
4113
+ if (uniformIndex === void 0) {
4114
+ continue;
4115
+ }
4116
+ const activeInfo = gl.getActiveUniform(program, uniformIndex);
4072
4117
  if (!activeInfo) {
4073
4118
  throw new Error("activeInfo");
4074
4119
  }
@@ -4099,13 +4144,12 @@ ${source}`;
4099
4144
  }
4100
4145
  const UNIFORM_NAME_REGEXP = /([^[]*)(\[[0-9]+\])?/;
4101
4146
  const matches = UNIFORM_NAME_REGEXP.exec(name);
4102
- if (!matches || matches.length < 2) {
4103
- throw new Error(`Failed to parse GLSL uniform name ${name}`);
4104
- }
4147
+ const uniformName = (0, import_core15.assertDefined)(matches?.[1], `Failed to parse GLSL uniform name ${name}`);
4105
4148
  return {
4106
- name: matches[1],
4107
- length: matches[2] ? 1 : 0,
4108
- isArray: Boolean(matches[2])
4149
+ name: uniformName,
4150
+ // TODO - is this a bug, shouldn't we return the value?
4151
+ length: matches?.[2] ? 1 : 0,
4152
+ isArray: Boolean(matches?.[2])
4109
4153
  };
4110
4154
  }
4111
4155
  var import_core15;
@@ -4569,7 +4613,7 @@ ${source}`;
4569
4613
  if (location === 4294967295 /* INVALID_INDEX */) {
4570
4614
  throw new Error(`Invalid uniform block name ${name}`);
4571
4615
  }
4572
- gl.uniformBlockBinding(this.handle, uniformBufferIndex, location);
4616
+ gl.uniformBlockBinding(this.handle, location, uniformBufferIndex);
4573
4617
  if (value instanceof WEBGLBuffer) {
4574
4618
  gl.bindBufferBase(35345 /* UNIFORM_BUFFER */, uniformBufferIndex, value.handle);
4575
4619
  } else {
@@ -4665,7 +4709,7 @@ ${source}`;
4665
4709
  height = options.sourceTexture.height,
4666
4710
  depthOrArrayLayers = 0,
4667
4711
  /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */
4668
- origin = [0, 0],
4712
+ origin = [0, 0, 0],
4669
4713
  /** Destination buffer */
4670
4714
  destinationBuffer,
4671
4715
  /** Offset, in bytes, from the beginning of the buffer to the start of the image data (default 0) */
@@ -4694,9 +4738,8 @@ ${source}`;
4694
4738
  const webglBuffer = destinationBuffer;
4695
4739
  const sourceWidth = width || framebuffer.width;
4696
4740
  const sourceHeight = height || framebuffer.height;
4697
- const sourceParams = getTextureFormatWebGL(
4698
- framebuffer.colorAttachments[0].texture.props.format
4699
- );
4741
+ const colorAttachment0 = (0, import_core17.assertDefined)(framebuffer.colorAttachments[0]);
4742
+ const sourceParams = getTextureFormatWebGL(colorAttachment0.texture.props.format);
4700
4743
  const sourceFormat = sourceParams.format;
4701
4744
  const sourceType = sourceParams.type;
4702
4745
  device.gl.bindBuffer(35051 /* PIXEL_PACK_BUFFER */, webglBuffer.handle);
@@ -4731,7 +4774,7 @@ ${source}`;
4731
4774
  /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy from. */
4732
4775
  origin = [0, 0],
4733
4776
  /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to. */
4734
- destinationOrigin = [0, 0],
4777
+ destinationOrigin = [0, 0, 0],
4735
4778
  /** Texture to copy to/from. */
4736
4779
  destinationTexture
4737
4780
  /** Mip-map level of the texture to copy to/from. (Default 0) */
@@ -4747,7 +4790,7 @@ ${source}`;
4747
4790
  // depthOrArrayLayers = 0
4748
4791
  } = options;
4749
4792
  const { framebuffer, destroyFramebuffer } = getFramebuffer(sourceTexture);
4750
- const [sourceX, sourceY] = origin;
4793
+ const [sourceX = 0, sourceY = 0] = origin;
4751
4794
  const [destinationX, destinationY, destinationZ] = destinationOrigin;
4752
4795
  const prevHandle = device.gl.bindFramebuffer(
4753
4796
  36160 /* FRAMEBUFFER */,
@@ -4871,6 +4914,9 @@ ${source}`;
4871
4914
  constructor(device, props) {
4872
4915
  super(device, props);
4873
4916
  this.device = device;
4917
+ if (!props?.framebuffer) {
4918
+ device.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();
4919
+ }
4874
4920
  let viewport;
4875
4921
  if (!props?.parameters?.viewport) {
4876
4922
  if (props?.framebuffer) {
@@ -5098,7 +5144,7 @@ ${source}`;
5098
5144
  const total = count * length;
5099
5145
  let copied = 0;
5100
5146
  for (let i = start; copied < length; copied++) {
5101
- target2[i++] = source[copied];
5147
+ target2[i++] = source[copied] ?? 0;
5102
5148
  }
5103
5149
  while (copied < total) {
5104
5150
  if (copied < total - copied) {
@@ -5389,8 +5435,8 @@ ${source}`;
5389
5435
  this.buffers = {};
5390
5436
  this.unusedBuffers = {};
5391
5437
  this.bind(() => {
5392
- for (const bufferName in buffers) {
5393
- this.setBuffer(bufferName, buffers[bufferName]);
5438
+ for (const [bufferName, buffer] of Object.entries(buffers)) {
5439
+ this.setBuffer(bufferName, buffer);
5394
5440
  }
5395
5441
  });
5396
5442
  }
@@ -5412,7 +5458,7 @@ ${source}`;
5412
5458
  return this.buffers[locationOrName] || null;
5413
5459
  }
5414
5460
  const location = this._getVaryingIndex(locationOrName);
5415
- return location >= 0 ? this.buffers[location] : null;
5461
+ return this.buffers[location] ?? null;
5416
5462
  }
5417
5463
  bind(funcOrHandle = this.handle) {
5418
5464
  if (typeof funcOrHandle !== "function") {
@@ -5459,8 +5505,8 @@ ${source}`;
5459
5505
  * cannot be bound to 'TRANSFORM_FEEDBACK_BUFFER' target.
5460
5506
  */
5461
5507
  _bindBuffers() {
5462
- for (const bufferIndex in this.buffers) {
5463
- const { buffer, byteLength, byteOffset } = this._getBufferRange(this.buffers[bufferIndex]);
5508
+ for (const [bufferIndex, bufferEntry] of Object.entries(this.buffers)) {
5509
+ const { buffer, byteLength, byteOffset } = this._getBufferRange(bufferEntry);
5464
5510
  this._bindBuffer(Number(bufferIndex), buffer, byteOffset, byteLength);
5465
5511
  }
5466
5512
  }
@@ -5886,6 +5932,7 @@ ${source}`;
5886
5932
  import_core25 = __toESM(require_core(), 1);
5887
5933
  init_webgl_state_tracker();
5888
5934
  init_create_browser_context();
5935
+ init_webgl_context_data();
5889
5936
  init_webgl_device_info();
5890
5937
  init_webgl_device_features();
5891
5938
  init_webgl_device_limits();
@@ -5910,6 +5957,12 @@ ${source}`;
5910
5957
  init_with_parameters();
5911
5958
  init_webgl_extensions();
5912
5959
  WebGLDevice = class extends import_core25.Device {
5960
+ static getDeviceFromContext(gl) {
5961
+ if (!gl) {
5962
+ return null;
5963
+ }
5964
+ return gl.luma?.device ?? null;
5965
+ }
5913
5966
  // Public `Device` API
5914
5967
  /** type of this device */
5915
5968
  type = "webgl";
@@ -5931,7 +5984,7 @@ ${source}`;
5931
5984
  // @ts-ignore TODO fix
5932
5985
  _constants;
5933
5986
  /** State used by luma.gl classes - TODO - not used? */
5934
- _extensions = {};
5987
+ extensions;
5935
5988
  _polyfilled = false;
5936
5989
  /** Instance of Spector.js (if initialized) */
5937
5990
  spectorJS;
@@ -5958,7 +6011,8 @@ ${source}`;
5958
6011
  if (!canvasContextProps) {
5959
6012
  throw new Error("WebGLDevice requires props.createCanvasContext to be set");
5960
6013
  }
5961
- let device = canvasContextProps.canvas?.gl?.device;
6014
+ const existingContext = canvasContextProps.canvas?.gl ?? null;
6015
+ let device = WebGLDevice.getDeviceFromContext(existingContext);
5962
6016
  if (device) {
5963
6017
  throw new Error(`WebGL context already attached to device ${device.id}`);
5964
6018
  }
@@ -5992,7 +6046,7 @@ ${source}`;
5992
6046
  if (!gl) {
5993
6047
  throw new Error("WebGL context creation failed");
5994
6048
  }
5995
- device = gl.device;
6049
+ device = WebGLDevice.getDeviceFromContext(gl);
5996
6050
  if (device) {
5997
6051
  if (props._reuseDevices) {
5998
6052
  import_core25.log.log(
@@ -6000,6 +6054,7 @@ ${source}`;
6000
6054
  `Not creating a new Device, instead returning a reference to Device ${device.id} already attached to WebGL context`,
6001
6055
  device
6002
6056
  )();
6057
+ this.canvasContext.destroy();
6003
6058
  device._reused = true;
6004
6059
  return device;
6005
6060
  }
@@ -6008,14 +6063,12 @@ ${source}`;
6008
6063
  this.handle = gl;
6009
6064
  this.gl = gl;
6010
6065
  this.spectorJS = initializeSpectorJS({ ...this.props, gl: this.handle });
6011
- this.gl.device = this;
6012
- this.info = getDeviceInfo(this.gl, this._extensions);
6066
+ const contextData = getWebGLContextData(this.handle);
6067
+ contextData.device = this;
6068
+ this.extensions = contextData.extensions || (contextData.extensions = {});
6069
+ this.info = getDeviceInfo(this.gl, this.extensions);
6013
6070
  this.limits = new WebGLDeviceLimits(this.gl);
6014
- this.features = new WebGLDeviceFeatures(
6015
- this.gl,
6016
- this._extensions,
6017
- this.props._disabledFeatures
6018
- );
6071
+ this.features = new WebGLDeviceFeatures(this.gl, this.extensions, this.props._disabledFeatures);
6019
6072
  if (this.props._initializeFeatures) {
6020
6073
  this.features.initializeFeatures();
6021
6074
  }
@@ -6044,7 +6097,8 @@ ${source}`;
6044
6097
  */
6045
6098
  destroy() {
6046
6099
  if (!this.props._reuseDevices && !this._reused) {
6047
- delete this.gl.device;
6100
+ const contextData = getWebGLContextData(this.handle);
6101
+ contextData.device = null;
6048
6102
  }
6049
6103
  }
6050
6104
  get isLost() {
@@ -6132,7 +6186,7 @@ ${source}`;
6132
6186
  resetGLParameters(this.gl);
6133
6187
  }
6134
6188
  _getDeviceSpecificTextureFormatCapabilities(capabilities) {
6135
- return getTextureFormatCapabilitiesWebGL(this.gl, capabilities, this._extensions);
6189
+ return getTextureFormatCapabilitiesWebGL(this.gl, capabilities, this.extensions);
6136
6190
  }
6137
6191
  //
6138
6192
  // WebGL-only API (not part of `Device` API)
@@ -6222,8 +6276,8 @@ ${source}`;
6222
6276
  }
6223
6277
  /** Ensure extensions are only requested once */
6224
6278
  getExtension(name) {
6225
- getWebGLExtension(this.gl, name, this._extensions);
6226
- return this._extensions;
6279
+ getWebGLExtension(this.gl, name, this.extensions);
6280
+ return this.extensions;
6227
6281
  }
6228
6282
  // INTERNAL SUPPORT METHODS FOR WEBGL RESOURCES
6229
6283
  /**
@@ -6291,8 +6345,9 @@ ${source}`;
6291
6345
  if (gl instanceof WebGLDevice2) {
6292
6346
  return gl;
6293
6347
  }
6294
- if (gl?.device instanceof WebGLDevice2) {
6295
- return gl.device;
6348
+ const existingDevice = WebGLDevice2.getDeviceFromContext(gl);
6349
+ if (existingDevice) {
6350
+ return existingDevice;
6296
6351
  }
6297
6352
  if (!isWebGL(gl)) {
6298
6353
  throw new Error("Invalid WebGL2RenderingContext");