@luma.gl/webgl 9.0.0-alpha.52 → 9.0.0-alpha.54

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 (29) hide show
  1. package/dist/adapter/converters/sampler-parameters.d.ts +2 -8
  2. package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
  3. package/dist/adapter/converters/sampler-parameters.js +12 -107
  4. package/dist/adapter/converters/sampler-parameters.js.map +1 -1
  5. package/dist/adapter/device-helpers/get-device-info.d.ts.map +1 -1
  6. package/dist/adapter/device-helpers/get-device-info.js +21 -3
  7. package/dist/adapter/device-helpers/get-device-info.js.map +1 -1
  8. package/dist/adapter/resources/webgl-buffer.d.ts +4 -7
  9. package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
  10. package/dist/adapter/resources/webgl-buffer.js +13 -19
  11. package/dist/adapter/resources/webgl-buffer.js.map +1 -1
  12. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  13. package/dist/adapter/resources/webgl-texture.js +2 -3
  14. package/dist/adapter/resources/webgl-texture.js.map +1 -1
  15. package/dist/adapter/webgl-device.d.ts.map +1 -1
  16. package/dist/adapter/webgl-device.js +9 -7
  17. package/dist/adapter/webgl-device.js.map +1 -1
  18. package/dist/context/polyfill/polyfill-context.js +5 -2
  19. package/dist/context/polyfill/polyfill-context.js.map +1 -1
  20. package/dist/dist.dev.js +87 -65
  21. package/dist/index.cjs +161 -148
  22. package/dist.min.js +38 -38
  23. package/package.json +5 -5
  24. package/src/adapter/converters/sampler-parameters.ts +26 -151
  25. package/src/adapter/device-helpers/get-device-info.ts +24 -5
  26. package/src/adapter/resources/webgl-buffer.ts +46 -56
  27. package/src/adapter/resources/webgl-texture.ts +3 -4
  28. package/src/adapter/webgl-device.ts +13 -10
  29. package/src/context/polyfill/polyfill-context.ts +6 -2
package/dist/dist.dev.js CHANGED
@@ -671,7 +671,7 @@ var __exports__ = (() => {
671
671
  id: "@probe.gl/log"
672
672
  });
673
673
 
674
- // ../core/src/lib/utils/log.ts
674
+ // ../core/src/utils/log.ts
675
675
  var log = new Log({
676
676
  id: "luma.gl"
677
677
  });
@@ -867,7 +867,7 @@ var __exports__ = (() => {
867
867
  }
868
868
  };
869
869
 
870
- // ../core/src/lib/utils/stats-manager.ts
870
+ // ../core/src/utils/stats-manager.ts
871
871
  var StatsManager = class {
872
872
  stats = /* @__PURE__ */ new Map();
873
873
  getStats(name2) {
@@ -886,14 +886,14 @@ var __exports__ = (() => {
886
886
 
887
887
  // ../core/src/init.ts
888
888
  function initializeLuma() {
889
- const VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
889
+ const VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "running from source";
890
890
  const STARTUP_MESSAGE = "set luma.log.level=1 (or higher) to trace rendering";
891
891
  if (globalThis.luma && globalThis.luma.VERSION !== VERSION3) {
892
892
  throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${VERSION3}`);
893
893
  }
894
894
  if (!globalThis.luma) {
895
895
  if (isBrowser()) {
896
- log.log(1, `luma.gl ${VERSION3} - ${STARTUP_MESSAGE}`)();
896
+ log.log(1, `${VERSION3} - ${STARTUP_MESSAGE}`)();
897
897
  }
898
898
  globalThis.luma = globalThis.luma || {
899
899
  VERSION: VERSION3,
@@ -906,7 +906,7 @@ var __exports__ = (() => {
906
906
  }
907
907
  var VERSION2 = initializeLuma();
908
908
 
909
- // ../core/src/lib/utils/is-array.ts
909
+ // ../core/src/utils/is-array.ts
910
910
  function isTypedArray(value) {
911
911
  return ArrayBuffer.isView(value) && !(value instanceof DataView) ? value : null;
912
912
  }
@@ -917,7 +917,7 @@ var __exports__ = (() => {
917
917
  return isTypedArray(value);
918
918
  }
919
919
 
920
- // ../core/src/lib/utils/utils.ts
920
+ // ../core/src/utils/utils.ts
921
921
  var uidCounters = {};
922
922
  function uid(id = "id") {
923
923
  uidCounters[id] = uidCounters[id] || 1;
@@ -1051,14 +1051,20 @@ var __exports__ = (() => {
1051
1051
  this.usage = props.usage || 0;
1052
1052
  this.indexType = deducedProps.indexType;
1053
1053
  }
1054
- write(data, byteOffset) {
1054
+ readSyncWebGL2(byteOffset, byteLength) {
1055
1055
  throw new Error("not implemented");
1056
1056
  }
1057
- readAsync(byteOffset, byteLength) {
1058
- throw new Error("not implemented");
1059
- }
1060
- getData() {
1061
- throw new Error("not implemented");
1057
+ debugData = new ArrayBuffer(0);
1058
+ _setDebugData(data, byteOffset, byteLength) {
1059
+ const buffer = ArrayBuffer.isView(data) ? data.buffer : data;
1060
+ const debugDataLength = Math.min(data ? data.byteLength : byteLength, _Buffer.DEBUG_DATA_MAX_LENGTH);
1061
+ if (data === null) {
1062
+ this.debugData = new ArrayBuffer(debugDataLength);
1063
+ } else if (byteOffset === 0 && byteLength === data.byteLength) {
1064
+ this.debugData = buffer.slice(0, debugDataLength);
1065
+ } else {
1066
+ this.debugData = buffer.slice(byteOffset, byteOffset + debugDataLength);
1067
+ }
1062
1068
  }
1063
1069
  };
1064
1070
  var Buffer2 = _Buffer;
@@ -1081,6 +1087,7 @@ var __exports__ = (() => {
1081
1087
  __publicField(Buffer2, "STORAGE", 128);
1082
1088
  __publicField(Buffer2, "INDIRECT", 256);
1083
1089
  __publicField(Buffer2, "QUERY_RESOLVE", 512);
1090
+ __publicField(Buffer2, "DEBUG_DATA_MAX_LENGTH", 32);
1084
1091
 
1085
1092
  // ../core/src/adapter/device.ts
1086
1093
  var _Device = class {
@@ -1155,6 +1162,13 @@ var __exports__ = (() => {
1155
1162
  });
1156
1163
  __publicField(Device, "VERSION", VERSION2);
1157
1164
 
1165
+ // ../core/src/utils/assert.ts
1166
+ function assert2(condition, message2) {
1167
+ if (!condition) {
1168
+ throw new Error(message2 || "luma.gl: assertion failed.");
1169
+ }
1170
+ }
1171
+
1158
1172
  // ../core/src/adapter/canvas-context.ts
1159
1173
  var isPage = isBrowser() && typeof document !== "undefined";
1160
1174
  var isPageLoaded = () => isPage && document.readyState === "complete";
@@ -2103,14 +2117,7 @@ ${htmlLog}
2103
2117
  buffers: {}
2104
2118
  });
2105
2119
 
2106
- // ../core/src/lib/utils/assert.ts
2107
- function assert2(condition, message2) {
2108
- if (!condition) {
2109
- throw new Error(message2 || "luma.gl: assertion failed.");
2110
- }
2111
- }
2112
-
2113
- // ../core/src/lib/utils/array-utils-flat.ts
2120
+ // ../core/src/utils/array-utils-flat.ts
2114
2121
  var arrayBuffer;
2115
2122
  function getScratchArrayBuffer(byteLength) {
2116
2123
  if (!arrayBuffer || arrayBuffer.byteLength < byteLength) {
@@ -2247,7 +2254,7 @@ ${htmlLog}
2247
2254
  };
2248
2255
  }
2249
2256
 
2250
- // ../core/src/lib/utils/cast.ts
2257
+ // ../core/src/utils/cast.ts
2251
2258
  function cast(value) {
2252
2259
  return value;
2253
2260
  }
@@ -2272,7 +2279,7 @@ ${htmlLog}
2272
2279
  return result;
2273
2280
  }
2274
2281
 
2275
- // ../core/src/lib/utils/stub-methods.ts
2282
+ // ../core/src/utils/stub-methods.ts
2276
2283
  function stubRemovedMethods(instance, className, version, methodNames) {
2277
2284
  const upgradeMessage = `See luma.gl ${version} Upgrade Guide at https://luma.gl/docs/upgrade-guide`;
2278
2285
  const prototype = Object.getPrototypeOf(instance);
@@ -2287,7 +2294,7 @@ ${htmlLog}
2287
2294
  });
2288
2295
  }
2289
2296
 
2290
- // ../core/src/lib/utils/check-props.ts
2297
+ // ../core/src/utils/check-props.ts
2291
2298
  function checkProps(className, props, propChecks) {
2292
2299
  const {
2293
2300
  removedProps = {},
@@ -2319,7 +2326,7 @@ ${htmlLog}
2319
2326
  return newProps || props;
2320
2327
  }
2321
2328
 
2322
- // ../core/src/lib/utils/load-file.ts
2329
+ // ../core/src/utils/load-file.ts
2323
2330
  var pathPrefix = "";
2324
2331
  async function loadImage(url, opts) {
2325
2332
  return new Promise((resolve, reject) => {
@@ -2904,9 +2911,12 @@ ${htmlLog}
2904
2911
  function initializeExtensions(gl) {
2905
2912
  const contextState = getContextData(gl);
2906
2913
  const EXTENSIONS = gl.getSupportedExtensions() || [];
2914
+ const IGNORE_EXTENSIONS = ["WEBGL_polygon_mode"];
2907
2915
  for (const extensionName of EXTENSIONS) {
2908
- const extension = gl.getExtension(extensionName);
2909
- contextState._extensions[extensionName] = extension;
2916
+ if (!IGNORE_EXTENSIONS.includes(extensionName)) {
2917
+ const extension = gl.getExtension(extensionName);
2918
+ contextState._extensions[extensionName] = extension;
2919
+ }
2910
2920
  }
2911
2921
  }
2912
2922
  function installPolyfills(gl, polyfills) {
@@ -3663,11 +3673,13 @@ ${htmlLog}
3663
3673
  const version = gl.getParameter(7938);
3664
3674
  const gpu = identifyGPUVendor(vendor, renderer);
3665
3675
  const gpuBackend = identifyGPUBackend(vendor, renderer);
3676
+ const gpuType = identifyGPUType(vendor, renderer);
3666
3677
  const shadingLanguage = "glsl";
3667
3678
  const shadingLanguageVersion = isWebGL2(gl) ? 300 : 100;
3668
3679
  return {
3669
3680
  type: isWebGL2(gl) ? "webgl2" : "webgl",
3670
3681
  gpu,
3682
+ gpuType,
3671
3683
  gpuBackend,
3672
3684
  vendor,
3673
3685
  renderer,
@@ -3695,14 +3707,30 @@ ${htmlLog}
3695
3707
  return "unknown";
3696
3708
  }
3697
3709
  function identifyGPUBackend(vendor, renderer) {
3698
- if (/ANGLE/i.exec(vendor) || /ANGLE/i.exec(renderer)) {
3699
- return "angle";
3700
- }
3701
3710
  if (/Metal/i.exec(vendor) || /Metal/i.exec(renderer)) {
3702
3711
  return "metal";
3703
3712
  }
3713
+ if (/ANGLE/i.exec(vendor) || /ANGLE/i.exec(renderer)) {
3714
+ return "opengl";
3715
+ }
3704
3716
  return "unknown";
3705
3717
  }
3718
+ function identifyGPUType(vendor, renderer) {
3719
+ if (/SwiftShader/i.exec(vendor) || /SwiftShader/i.exec(renderer)) {
3720
+ return "cpu";
3721
+ }
3722
+ const gpuVendor = identifyGPUVendor(vendor, renderer);
3723
+ switch (gpuVendor) {
3724
+ case "intel":
3725
+ return "integrated";
3726
+ case "software":
3727
+ return "cpu";
3728
+ case "unknown":
3729
+ return "unknown";
3730
+ default:
3731
+ return "discrete";
3732
+ }
3733
+ }
3706
3734
 
3707
3735
  // src/adapter/device-helpers/is-old-ie.ts
3708
3736
  function isOldIE(opts = {}) {
@@ -5036,6 +5064,17 @@ void main(void) {}`;
5036
5064
  }
5037
5065
  return params;
5038
5066
  }
5067
+ function updateSamplerParametersForNPOT(parameters) {
5068
+ const newParameters = {
5069
+ ...parameters
5070
+ };
5071
+ if (parameters[10241] !== 9728) {
5072
+ newParameters[10241] = 9729;
5073
+ }
5074
+ newParameters[10242] = 33071;
5075
+ newParameters[10243] = 33071;
5076
+ return newParameters;
5077
+ }
5039
5078
  function convertAddressMode(addressMode) {
5040
5079
  switch (addressMode) {
5041
5080
  case "clamp-to-edge":
@@ -5065,23 +5104,10 @@ void main(void) {}`;
5065
5104
  return mipmapFilter === "nearest" ? 9985 : 9987;
5066
5105
  }
5067
5106
  }
5068
- function updateSamplerParametersForNPOT(parameters) {
5069
- const newParameters = {
5070
- ...parameters
5071
- };
5072
- if (parameters[10241] !== 9728) {
5073
- newParameters[10241] = 9729;
5074
- }
5075
- newParameters[10242] = 33071;
5076
- newParameters[10243] = 33071;
5077
- return newParameters;
5078
- }
5079
5107
 
5080
5108
  // src/adapter/resources/webgl-buffer.ts
5081
- var DEBUG_DATA_LENGTH = 10;
5082
5109
  var WEBGLBuffer = class extends Buffer2 {
5083
5110
  glIndexType = 5123;
5084
- debugData = null;
5085
5111
  constructor(device, props = {}) {
5086
5112
  super(device, props);
5087
5113
  this.device = device;
@@ -5096,7 +5122,6 @@ void main(void) {}`;
5096
5122
  this.glTarget = getWebGLTarget(this.props.usage);
5097
5123
  this.glUsage = getWebGLUsage(this.props.usage);
5098
5124
  this.glIndexType = this.props.indexType === "uint32" ? 5125 : 5123;
5099
- this.debugData = null;
5100
5125
  if (props.data) {
5101
5126
  this._initWithData(props.data, props.byteOffset, props.byteLength);
5102
5127
  } else {
@@ -5104,17 +5129,15 @@ void main(void) {}`;
5104
5129
  }
5105
5130
  }
5106
5131
  _initWithData(data, byteOffset = 0, byteLength = data.byteLength + byteOffset) {
5107
- assert2(ArrayBuffer.isView(data));
5108
- const glTarget = this._getWriteTarget();
5132
+ const glTarget = this.glTarget;
5109
5133
  this.gl.bindBuffer(glTarget, this.handle);
5110
5134
  this.gl.bufferData(glTarget, byteLength, this.glUsage);
5111
5135
  this.gl.bufferSubData(glTarget, byteOffset, data);
5112
5136
  this.gl.bindBuffer(glTarget, null);
5113
- this.debugData = data.slice(0, DEBUG_DATA_LENGTH);
5114
5137
  this.bytesUsed = byteLength;
5115
5138
  this.byteLength = byteLength;
5139
+ this._setDebugData(data, byteOffset, byteLength);
5116
5140
  this.trackAllocatedMemory(byteLength);
5117
- return this;
5118
5141
  }
5119
5142
  _initWithByteLength(byteLength) {
5120
5143
  assert2(byteLength >= 0);
@@ -5122,13 +5145,14 @@ void main(void) {}`;
5122
5145
  if (byteLength === 0) {
5123
5146
  data = new Float32Array(0);
5124
5147
  }
5125
- const glTarget = this._getWriteTarget();
5148
+ const glTarget = this.glTarget;
5126
5149
  this.gl.bindBuffer(glTarget, this.handle);
5127
5150
  this.gl.bufferData(glTarget, data, this.glUsage);
5128
5151
  this.gl.bindBuffer(glTarget, null);
5129
- this.debugData = null;
5130
5152
  this.bytesUsed = byteLength;
5131
5153
  this.byteLength = byteLength;
5154
+ this._setDebugData(null, 0, byteLength);
5155
+ this.trackAllocatedMemory(byteLength);
5132
5156
  return this;
5133
5157
  }
5134
5158
  destroy() {
@@ -5152,26 +5176,22 @@ void main(void) {}`;
5152
5176
  this.gl.bufferSubData(glTarget, byteOffset, data);
5153
5177
  }
5154
5178
  this.gl.bindBuffer(glTarget, null);
5179
+ this._setDebugData(data, byteOffset, data.byteLength);
5155
5180
  }
5156
5181
  async readAsync(byteOffset = 0, byteLength) {
5182
+ return this.readSyncWebGL2(byteOffset, byteLength);
5183
+ }
5184
+ readSyncWebGL2(byteOffset = 0, byteLength) {
5157
5185
  this.device.assertWebGL2();
5158
- byteLength = byteLength ?? this.byteLength;
5186
+ byteLength = byteLength ?? this.byteLength - byteOffset;
5159
5187
  const data = new Uint8Array(byteLength);
5160
5188
  const dstOffset = 0;
5161
5189
  this.gl.bindBuffer(36662, this.handle);
5162
5190
  this.gl2.getBufferSubData(36662, byteOffset, data, dstOffset, byteLength);
5163
5191
  this.gl.bindBuffer(36662, null);
5192
+ this._setDebugData(data, byteOffset, byteLength);
5164
5193
  return data;
5165
5194
  }
5166
- _invalidateDebugData() {
5167
- this.debugData = null;
5168
- }
5169
- _getWriteTarget() {
5170
- return this.glTarget;
5171
- }
5172
- _getReadTarget() {
5173
- return this.glTarget;
5174
- }
5175
5195
  };
5176
5196
  function getWebGLTarget(usage) {
5177
5197
  if (usage & Buffer2.INDEX) {
@@ -5258,7 +5278,7 @@ void main(void) {}`;
5258
5278
  format: "rgba8unorm",
5259
5279
  ...props
5260
5280
  });
5261
- this.device = cast(device);
5281
+ this.device = device;
5262
5282
  this.gl = this.device.gl;
5263
5283
  this.gl2 = this.device.gl2;
5264
5284
  this.handle = this.props.handle || this.gl.createTexture();
@@ -8731,7 +8751,7 @@ ${source2}`;
8731
8751
  });
8732
8752
  }
8733
8753
  static async create(props = {}) {
8734
- log.groupCollapsed(LOG_LEVEL2, "WebGLDevice created");
8754
+ log.groupCollapsed(LOG_LEVEL2, "WebGLDevice created")();
8735
8755
  if (typeof props.canvas === "string") {
8736
8756
  await CanvasContext.pageLoaded;
8737
8757
  }
@@ -8748,7 +8768,12 @@ ${source2}`;
8748
8768
  if (props.gl && props.gl.device) {
8749
8769
  return _WebGLDevice.attach(props.gl);
8750
8770
  }
8751
- return new _WebGLDevice(props);
8771
+ const device = new _WebGLDevice(props);
8772
+ const message2 = `Created ${device.info.type}${device.debug ? " debug" : ""} context: ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;
8773
+ log.probe(LOG_LEVEL2, message2)();
8774
+ log.table(LOG_LEVEL2, device.info)();
8775
+ log.groupEnd(LOG_LEVEL2)();
8776
+ return device;
8752
8777
  }
8753
8778
  constructor(props) {
8754
8779
  super({
@@ -8815,9 +8840,6 @@ ${source2}`;
8815
8840
  canvas
8816
8841
  });
8817
8842
  }
8818
- const message2 = `Created ${this.info.type}${this.debug ? " debug" : ""} context: ${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;
8819
- log.probe(LOG_LEVEL2, message2)();
8820
- log.groupEnd(LOG_LEVEL2)();
8821
8843
  }
8822
8844
  destroy() {
8823
8845
  const ext = this.gl.getExtension("STACKGL_destroy_context");