@luma.gl/webgl 9.1.0-alpha.1 → 9.1.0-alpha.12

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 (109) hide show
  1. package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
  2. package/dist/adapter/converters/device-parameters.js +18 -11
  3. package/dist/adapter/converters/texture-formats.d.ts +1 -1
  4. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  5. package/dist/adapter/converters/texture-formats.js +9 -16
  6. package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
  7. package/dist/adapter/device-helpers/webgl-device-features.js +1 -3
  8. package/dist/adapter/helpers/format-utils.d.ts.map +1 -0
  9. package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
  10. package/dist/adapter/helpers/get-shader-layout.js +1 -3
  11. package/dist/adapter/helpers/typed-array-utils.d.ts.map +1 -0
  12. package/dist/adapter/helpers/webgl-texture-utils.d.ts +89 -22
  13. package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -1
  14. package/dist/adapter/helpers/webgl-texture-utils.js +220 -26
  15. package/dist/adapter/resources/webgl-framebuffer.js +1 -1
  16. package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
  17. package/dist/adapter/resources/webgl-render-pass.js +17 -4
  18. package/dist/adapter/resources/webgl-render-pipeline.d.ts +1 -3
  19. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  20. package/dist/adapter/resources/webgl-render-pipeline.js +1 -1
  21. package/dist/adapter/resources/webgl-shader.js +1 -1
  22. package/dist/adapter/resources/webgl-texture.d.ts +21 -3
  23. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  24. package/dist/adapter/resources/webgl-texture.js +49 -30
  25. package/dist/adapter/resources/webgl-transform-feedback.js +1 -1
  26. package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
  27. package/dist/adapter/resources/webgl-vertex-array.js +3 -0
  28. package/dist/adapter/webgl-adapter.d.ts +21 -0
  29. package/dist/adapter/webgl-adapter.d.ts.map +1 -0
  30. package/dist/adapter/webgl-adapter.js +91 -0
  31. package/dist/adapter/webgl-device.d.ts +16 -29
  32. package/dist/adapter/webgl-device.d.ts.map +1 -1
  33. package/dist/adapter/webgl-device.js +34 -114
  34. package/dist/context/debug/spector-types.d.ts +1108 -0
  35. package/dist/context/debug/spector-types.d.ts.map +1 -0
  36. package/dist/context/debug/spector-types.js +697 -0
  37. package/dist/context/debug/spector.d.ts +12 -8
  38. package/dist/context/debug/spector.d.ts.map +1 -1
  39. package/dist/context/debug/spector.js +23 -17
  40. package/dist/context/polyfills/polyfill-webgl1-extensions.d.ts +9 -0
  41. package/dist/context/polyfills/polyfill-webgl1-extensions.d.ts.map +1 -0
  42. package/dist/context/polyfills/polyfill-webgl1-extensions.js +181 -0
  43. package/dist/context/state-tracker/webgl-state-tracker.d.ts +43 -0
  44. package/dist/context/state-tracker/webgl-state-tracker.d.ts.map +1 -0
  45. package/dist/context/state-tracker/{track-context-state.js → webgl-state-tracker.js} +44 -74
  46. package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
  47. package/dist/context/state-tracker/with-parameters.js +5 -4
  48. package/dist/deprecated/accessor.d.ts.map +1 -0
  49. package/dist/{classic → deprecated}/accessor.js +36 -1
  50. package/dist/deprecated/clear.d.ts.map +1 -0
  51. package/dist/{classic → deprecated}/clear.js +2 -0
  52. package/dist/dist.dev.js +816 -642
  53. package/dist/dist.min.js +2 -2
  54. package/dist/index.cjs +815 -648
  55. package/dist/index.cjs.map +4 -4
  56. package/dist/index.d.ts +4 -2
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +4 -3
  59. package/dist/utils/fill-array.d.ts +4 -4
  60. package/dist/utils/fill-array.d.ts.map +1 -1
  61. package/dist/utils/split-uniforms-and-bindings.d.ts +1 -1
  62. package/dist/utils/split-uniforms-and-bindings.d.ts.map +1 -1
  63. package/dist/utils/uid.d.ts +7 -0
  64. package/dist/utils/uid.d.ts.map +1 -0
  65. package/dist/utils/uid.js +14 -0
  66. package/package.json +5 -5
  67. package/src/adapter/converters/device-parameters.ts +18 -12
  68. package/src/adapter/converters/texture-formats.ts +12 -20
  69. package/src/adapter/device-helpers/webgl-device-features.ts +5 -3
  70. package/src/adapter/helpers/get-shader-layout.ts +1 -3
  71. package/src/adapter/helpers/webgl-texture-utils.ts +366 -44
  72. package/src/adapter/resources/webgl-framebuffer.ts +1 -1
  73. package/src/adapter/resources/webgl-render-pass.ts +20 -7
  74. package/src/adapter/resources/webgl-render-pipeline.ts +12 -4
  75. package/src/adapter/resources/webgl-shader.ts +1 -1
  76. package/src/adapter/resources/webgl-texture.ts +76 -30
  77. package/src/adapter/resources/webgl-transform-feedback.ts +1 -1
  78. package/src/adapter/resources/webgl-vertex-array.ts +3 -0
  79. package/src/adapter/webgl-adapter.ts +113 -0
  80. package/src/adapter/webgl-device.ts +45 -139
  81. package/src/context/debug/spector-types.ts +1154 -0
  82. package/src/context/debug/spector.ts +38 -29
  83. package/src/context/polyfills/polyfill-webgl1-extensions.ts +202 -0
  84. package/src/context/state-tracker/{track-context-state.ts → webgl-state-tracker.ts} +55 -94
  85. package/src/context/state-tracker/with-parameters.ts +5 -4
  86. package/src/{classic → deprecated}/accessor.ts +44 -3
  87. package/src/{classic → deprecated}/clear.ts +3 -1
  88. package/src/index.ts +6 -8
  89. package/src/utils/fill-array.ts +4 -4
  90. package/src/utils/split-uniforms-and-bindings.ts +3 -3
  91. package/src/utils/uid.ts +16 -0
  92. package/dist/classic/accessor.d.ts.map +0 -1
  93. package/dist/classic/clear.d.ts.map +0 -1
  94. package/dist/classic/copy-and-blit.d.ts +0 -63
  95. package/dist/classic/copy-and-blit.d.ts.map +0 -1
  96. package/dist/classic/copy-and-blit.js +0 -193
  97. package/dist/classic/format-utils.d.ts.map +0 -1
  98. package/dist/classic/typed-array-utils.d.ts.map +0 -1
  99. package/dist/context/state-tracker/track-context-state.d.ts +0 -22
  100. package/dist/context/state-tracker/track-context-state.d.ts.map +0 -1
  101. package/src/classic/copy-and-blit.ts +0 -318
  102. /package/dist/{classic → adapter/helpers}/format-utils.d.ts +0 -0
  103. /package/dist/{classic → adapter/helpers}/format-utils.js +0 -0
  104. /package/dist/{classic → adapter/helpers}/typed-array-utils.d.ts +0 -0
  105. /package/dist/{classic → adapter/helpers}/typed-array-utils.js +0 -0
  106. /package/dist/{classic → deprecated}/accessor.d.ts +0 -0
  107. /package/dist/{classic → deprecated}/clear.d.ts +0 -0
  108. /package/src/{classic → adapter/helpers}/format-utils.ts +0 -0
  109. /package/src/{classic → adapter/helpers}/typed-array-utils.ts +0 -0
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export type { WebGLDeviceLimits } from "./adapter/device-helpers/webgl-device-limits.js";
2
+ export { webgl2Adapter } from "./adapter/webgl-adapter.js";
3
+ export type { WebGLAdapter } from "./adapter/webgl-adapter.js";
2
4
  export { WebGLDevice } from "./adapter/webgl-device.js";
3
5
  export { WebGLCanvasContext } from "./adapter/webgl-canvas-context.js";
4
6
  export { WEBGLBuffer } from "./adapter/resources/webgl-buffer.js";
@@ -11,12 +13,12 @@ export { WEBGLCommandEncoder } from "./adapter/resources/webgl-command-encoder.j
11
13
  export { WEBGLRenderPass } from "./adapter/resources/webgl-render-pass.js";
12
14
  export { WEBGLVertexArray } from "./adapter/resources/webgl-vertex-array.js";
13
15
  export { WEBGLTransformFeedback } from "./adapter/resources/webgl-transform-feedback.js";
14
- export { Accessor } from "./classic/accessor.js";
16
+ export { Accessor } from "./deprecated/accessor.js";
15
17
  export type { AccessorObject } from "./types.js";
16
18
  export { setDeviceParameters, withDeviceParameters } from "./adapter/converters/device-parameters.js";
17
19
  export { getShaderLayout } from "./adapter/helpers/get-shader-layout.js";
20
+ export { WebGLStateTracker } from "./context/state-tracker/webgl-state-tracker.js";
18
21
  export { TEXTURE_FORMATS as _TEXTURE_FORMATS } from "./adapter/converters/texture-formats.js";
19
- export { trackContextState, pushContextState, popContextState } from "./context/state-tracker/track-context-state.js";
20
22
  export { resetGLParameters, setGLParameters, getGLParameters } from "./context/parameters/unified-parameter-api.js";
21
23
  export { withGLParameters } from "./context/state-tracker/with-parameters.js";
22
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,YAAY,EAAC,iBAAiB,EAAC,wDAAqD;AAGpF,OAAO,EAAC,WAAW,EAAC,kCAA+B;AACnD,OAAO,EAAC,kBAAkB,EAAC,0CAAuC;AAGlE,OAAO,EAAC,WAAW,EAAC,4CAAyC;AAC7D,OAAO,EAAC,YAAY,EAAC,6CAA0C;AAE/D,OAAO,EAAC,WAAW,EAAC,4CAAyC;AAC7D,OAAO,EAAC,YAAY,EAAC,6CAA0C;AAC/D,OAAO,EAAC,gBAAgB,EAAC,iDAA8C;AAEvE,OAAO,EAAC,mBAAmB,EAAC,qDAAkD;AAE9E,OAAO,EAAC,mBAAmB,EAAC,qDAAkD;AAC9E,OAAO,EAAC,eAAe,EAAC,iDAA8C;AAEtE,OAAO,EAAC,gBAAgB,EAAC,kDAA+C;AAGxE,OAAO,EAAC,sBAAsB,EAAC,wDAAqD;AAGpF,OAAO,EAAC,QAAQ,EAAC,8BAA2B;AAC5C,YAAY,EAAC,cAAc,EAAC,mBAAgB;AAI5C,OAAO,EAAC,mBAAmB,EAAE,oBAAoB,EAAC,kDAA+C;AAGjG,OAAO,EAAC,eAAe,EAAC,+CAA4C;AAGpE,OAAO,EAAC,eAAe,IAAI,gBAAgB,EAAC,gDAA6C;AAIzF,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAChB,uDAAoD;AAErD,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,eAAe,EAChB,sDAAmD;AAEpD,OAAO,EAAC,gBAAgB,EAAC,mDAAgD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,YAAY,EAAC,iBAAiB,EAAC,wDAAqD;AAGpF,OAAO,EAAC,aAAa,EAAC,mCAAgC;AACtD,YAAY,EAAC,YAAY,EAAC,mCAAgC;AAG1D,OAAO,EAAC,WAAW,EAAC,kCAA+B;AACnD,OAAO,EAAC,kBAAkB,EAAC,0CAAuC;AAGlE,OAAO,EAAC,WAAW,EAAC,4CAAyC;AAC7D,OAAO,EAAC,YAAY,EAAC,6CAA0C;AAE/D,OAAO,EAAC,WAAW,EAAC,4CAAyC;AAC7D,OAAO,EAAC,YAAY,EAAC,6CAA0C;AAC/D,OAAO,EAAC,gBAAgB,EAAC,iDAA8C;AAEvE,OAAO,EAAC,mBAAmB,EAAC,qDAAkD;AAE9E,OAAO,EAAC,mBAAmB,EAAC,qDAAkD;AAC9E,OAAO,EAAC,eAAe,EAAC,iDAA8C;AAEtE,OAAO,EAAC,gBAAgB,EAAC,kDAA+C;AAGxE,OAAO,EAAC,sBAAsB,EAAC,wDAAqD;AAGpF,OAAO,EAAC,QAAQ,EAAC,iCAA8B;AAC/C,YAAY,EAAC,cAAc,EAAC,mBAAgB;AAI5C,OAAO,EAAC,mBAAmB,EAAE,oBAAoB,EAAC,kDAA+C;AAGjG,OAAO,EAAC,eAAe,EAAC,+CAA4C;AACpE,OAAO,EAAC,iBAAiB,EAAC,uDAAoD;AAG9E,OAAO,EAAC,eAAe,IAAI,gBAAgB,EAAC,gDAA6C;AAGzF,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,eAAe,EAChB,sDAAmD;AAEpD,OAAO,EAAC,gBAAgB,EAAC,mDAAgD"}
package/dist/index.js CHANGED
@@ -2,6 +2,8 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
  // WebGL adapter classes
5
+ export { webgl2Adapter } from "./adapter/webgl-adapter.js";
6
+ // WebGL Device classes
5
7
  export { WebGLDevice } from "./adapter/webgl-device.js";
6
8
  export { WebGLCanvasContext } from "./adapter/webgl-canvas-context.js";
7
9
  // WebGL Resource classes
@@ -20,15 +22,14 @@ export { WEBGLVertexArray } from "./adapter/resources/webgl-vertex-array.js";
20
22
  // WebGL adapter classes
21
23
  export { WEBGLTransformFeedback } from "./adapter/resources/webgl-transform-feedback.js";
22
24
  // WebGL adapter classes
23
- export { Accessor } from "./classic/accessor.js";
25
+ export { Accessor } from "./deprecated/accessor.js";
24
26
  // Unified parameter API
25
27
  export { setDeviceParameters, withDeviceParameters } from "./adapter/converters/device-parameters.js";
26
28
  // HELPERS - EXPERIMENTAL
27
29
  export { getShaderLayout } from "./adapter/helpers/get-shader-layout.js";
30
+ export { WebGLStateTracker } from "./context/state-tracker/webgl-state-tracker.js";
28
31
  // TEST EXPORTS
29
32
  export { TEXTURE_FORMATS as _TEXTURE_FORMATS } from "./adapter/converters/texture-formats.js";
30
33
  // DEPRECATED TEST EXPORTS
31
- // State tracking
32
- export { trackContextState, pushContextState, popContextState } from "./context/state-tracker/track-context-state.js";
33
34
  export { resetGLParameters, setGLParameters, getGLParameters } from "./context/parameters/unified-parameter-api.js";
34
35
  export { withGLParameters } from "./context/state-tracker/with-parameters.js";
@@ -1,8 +1,8 @@
1
- import type { NumberArray } from '@math.gl/types';
1
+ import type { NumericArray } from '@math.gl/types';
2
2
  export declare function fillArray(options: {
3
- target: NumberArray;
4
- source: NumberArray;
3
+ target: NumericArray;
4
+ source: NumericArray;
5
5
  start?: number;
6
6
  count?: number;
7
- }): NumberArray;
7
+ }): NumericArray;
8
8
  //# sourceMappingURL=fill-array.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fill-array.d.ts","sourceRoot":"","sources":["../../src/utils/fill-array.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAGhD,wBAAgB,SAAS,CAAC,OAAO,EAAE;IACjC,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,WAAW,CAsBd"}
1
+ {"version":3,"file":"fill-array.d.ts","sourceRoot":"","sources":["../../src/utils/fill-array.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAGjD,wBAAgB,SAAS,CAAC,OAAO,EAAE;IACjC,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,YAAY,CAsBf"}
@@ -1,5 +1,5 @@
1
1
  import type { UniformValue, Binding } from '@luma.gl/core';
2
- export declare function isUniformValue(value: unknown): boolean;
2
+ export declare function isUniformValue(value: unknown): value is UniformValue;
3
3
  type UniformsAndBindings = {
4
4
  bindings: Record<string, Binding>;
5
5
  uniforms: Record<string, UniformValue>;
@@ -1 +1 @@
1
- {"version":3,"file":"split-uniforms-and-bindings.d.ts","sourceRoot":"","sources":["../../src/utils/split-uniforms-and-bindings.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAGzD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEtD;AAED,KAAK,mBAAmB,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACxC,CAAC;AAEF,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,CAAC,GAC/C,mBAAmB,CAYrB"}
1
+ {"version":3,"file":"split-uniforms-and-bindings.d.ts","sourceRoot":"","sources":["../../src/utils/split-uniforms-and-bindings.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAGzD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEpE;AAED,KAAK,mBAAmB,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACxC,CAAC;AAEF,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,CAAC,GAC/C,mBAAmB,CAYrB"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Returns a UID.
3
+ * @param id= - Identifier base name
4
+ * @return uid
5
+ **/
6
+ export declare function uid(id?: string): string;
7
+ //# sourceMappingURL=uid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uid.d.ts","sourceRoot":"","sources":["../../src/utils/uid.ts"],"names":[],"mappings":"AAMA;;;;IAII;AACJ,wBAAgB,GAAG,CAAC,EAAE,GAAE,MAAa,GAAG,MAAM,CAI7C"}
@@ -0,0 +1,14 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ const uidCounters = {};
5
+ /**
6
+ * Returns a UID.
7
+ * @param id= - Identifier base name
8
+ * @return uid
9
+ **/
10
+ export function uid(id = 'id') {
11
+ uidCounters[id] = uidCounters[id] || 1;
12
+ const count = uidCounters[id]++;
13
+ return `${id}-${count}`;
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma.gl/webgl",
3
- "version": "9.1.0-alpha.1",
3
+ "version": "9.1.0-alpha.12",
4
4
  "description": "WebGL2 adapter for the luma.gl core API",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,12 +40,12 @@
40
40
  "prepublishOnly": "npm run build-minified-bundle && npm run build-dev-bundle"
41
41
  },
42
42
  "peerDependencies": {
43
- "@luma.gl/core": "^9.0.0-beta"
43
+ "@luma.gl/core": "9.1.0-alpha.10"
44
44
  },
45
45
  "dependencies": {
46
- "@luma.gl/constants": "9.1.0-alpha.1",
47
- "@math.gl/types": "^4.0.0",
46
+ "@luma.gl/constants": "9.1.0-alpha.12",
47
+ "@math.gl/types": "4.1.0-alpha.3",
48
48
  "@probe.gl/env": "^4.0.8"
49
49
  },
50
- "gitHead": "bc5c11c87f1e4db857e701688ca1410d7f51fd0f"
50
+ "gitHead": "61b0080d5beb5284b8bdcec5cf59e13cda65295a"
51
51
  }
@@ -14,7 +14,6 @@ import type {
14
14
  GLProvokingVertex,
15
15
  GLStencilOp
16
16
  } from '@luma.gl/constants';
17
- import {pushContextState, popContextState} from '../../context/state-tracker/track-context-state';
18
17
  import {setGLParameters} from '../../context/parameters/unified-parameter-api';
19
18
  import {WebGLDevice} from '../webgl-device';
20
19
 
@@ -41,13 +40,13 @@ export function withDeviceAndGLParameters<T = unknown>(
41
40
 
42
41
  // Wrap in a try-catch to ensure that parameters are restored on exceptions
43
42
  const webglDevice = device as WebGLDevice;
44
- pushContextState(webglDevice.gl);
43
+ webglDevice.pushState();
45
44
  try {
46
45
  setDeviceParameters(device, parameters);
47
46
  setGLParameters(webglDevice.gl, glParameters);
48
47
  return func(device);
49
48
  } finally {
50
- popContextState(webglDevice.gl);
49
+ webglDevice.popState();
51
50
  }
52
51
  }
53
52
 
@@ -72,12 +71,12 @@ export function withGLParameters<T = unknown>(
72
71
 
73
72
  // Wrap in a try-catch to ensure that parameters are restored on exceptions
74
73
  const webglDevice = device as WebGLDevice;
75
- pushContextState(webglDevice.gl);
74
+ webglDevice.pushState();
76
75
  try {
77
76
  setGLParameters(webglDevice.gl, parameters);
78
77
  return func(device);
79
78
  } finally {
80
- popContextState(webglDevice.gl);
79
+ webglDevice.popState();
81
80
  }
82
81
  }
83
82
 
@@ -99,15 +98,14 @@ export function withDeviceParameters<T = unknown>(
99
98
  return func(device);
100
99
  }
101
100
 
102
- // Wrap in a try-catch to ensure that parameters are restored on exceptions
103
- // @ts-expect-error
104
- pushContextState(device.gl);
101
+ // Wrap in a try-catch to ensure that parameters are restored on exceptions'
102
+ const webglDevice = device as WebGLDevice;
103
+ webglDevice.pushState();
105
104
  try {
106
105
  setDeviceParameters(device, parameters);
107
106
  return func(device);
108
107
  } finally {
109
- // @ts-expect-error
110
- popContextState(device.gl);
108
+ webglDevice.popState();
111
109
  }
112
110
  }
113
111
 
@@ -280,10 +278,18 @@ export function setDeviceParameters(device: Device, parameters: Parameters) {
280
278
  // },
281
279
 
282
280
  // COLOR STATE
281
+ switch (parameters.blend) {
282
+ case true:
283
+ gl.enable(GL.BLEND);
284
+ break;
285
+ case false:
286
+ gl.disable(GL.BLEND);
287
+ break;
288
+ default:
289
+ // leave WebGL blend state unchanged if `parameters.blend` is not set
290
+ }
283
291
 
284
292
  if (parameters.blendColorOperation || parameters.blendAlphaOperation) {
285
- gl.enable(GL.BLEND);
286
-
287
293
  const colorEquation = convertBlendOperationToEquation(
288
294
  'blendColorOperation',
289
295
  parameters.blendColorOperation || 'add'
@@ -141,15 +141,6 @@ type Format = {
141
141
  */
142
142
  // prettier-ignore
143
143
  export const TEXTURE_FORMATS: Record<TextureFormat, Format> = {
144
- // Unsized formats that leave the precision up to the driver. TODO - Fix bpp constants
145
- 'rgb8unorm-unsized': {gl: GL.RGB, b: 4, c: 2, bpp: 4,
146
- dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_6_5]},
147
- 'rgba8unorm-unsized': {gl: GL.RGBA, b: 4, c: 2, bpp: 4,
148
- dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_4_4_4_4, GL.UNSIGNED_SHORT_5_5_5_1]},
149
- // 'r8unorm-unsized': {gl: GL.LUMINANCE, b: 4, c: 2, bpp: 4},
150
- // 'rgb8unorm-srgb-unsized': {gl: GL.SRGB_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
151
- // 'rgba8unorm-srgb-unsized': {gl: GL.SRGB_ALPHA_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
152
-
153
144
  // 8-bit formats
154
145
  'r8unorm': {gl: GL.R8, b: 1, c: 1, rb: true},
155
146
  'r8snorm': {gl: GL.R8_SNORM, b: 1, c: 1, render: snorm8_renderable},
@@ -239,9 +230,6 @@ export const TEXTURE_FORMATS: Record<TextureFormat, Format> = {
239
230
  // The depth component of the "depth24plus" and "depth24plus-stencil8" formats may be implemented as either a 24-bit depth value or a "depth32float" value.
240
231
  'depth24plus-stencil8': {gl: GL.DEPTH24_STENCIL8, b: 4, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT, rb: true, depthTexture: true,
241
232
  dataFormat: GL.DEPTH_STENCIL, types: [GL.UNSIGNED_INT_24_8]},
242
- // "depth24unorm-stencil8" feature
243
- 'depth24unorm-stencil8': {gl: GL.DEPTH24_STENCIL8, b: 4, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT,
244
- dataFormat: GL.DEPTH_STENCIL, types: [GL.UNSIGNED_INT_24_8], rb: true},
245
233
  // "depth32float-stencil8" feature - TODO below is render buffer only?
246
234
  'depth32float-stencil8': {gl: GL.DEPTH32F_STENCIL8, b: 5, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT,
247
235
  dataFormat: GL.DEPTH_STENCIL, types: [GL.FLOAT_32_UNSIGNED_INT_24_8_REV], rb: true},
@@ -469,6 +457,10 @@ export function isTextureFormatSupported(
469
457
  if (info.gl === undefined) {
470
458
  return false;
471
459
  }
460
+ const feature = info.f;
461
+ if (feature) {
462
+ return checkTextureFeature(gl, feature, extensions);
463
+ }
472
464
  // Check extensions
473
465
  const extension = info.x || info.gl2ext;
474
466
  if (extension) {
@@ -509,7 +501,7 @@ export function getTextureFormatSupport(
509
501
 
510
502
  // Support Check that we have a GL constant
511
503
  let supported = info.gl === undefined;
512
- supported = supported && checkTextureFeature(gl, info.f as DeviceFeature, extensions);
504
+ supported = supported && checkTextureFeature(gl, info.f, extensions);
513
505
 
514
506
  // Filtering
515
507
  // const filterable = info.filter
@@ -521,8 +513,8 @@ export function getTextureFormatSupport(
521
513
 
522
514
  return {
523
515
  supported,
524
- renderable: supported && checkTextureFeature(gl, info.render as DeviceFeature, extensions),
525
- filterable: supported && checkTextureFeature(gl, info.filter as DeviceFeature, extensions),
516
+ renderable: supported && checkTextureFeature(gl, info.render, extensions),
517
+ filterable: supported && checkTextureFeature(gl, info.filter, extensions),
526
518
  blendable: false, // tod,
527
519
  storable: false
528
520
  };
@@ -586,13 +578,12 @@ export function getTextureFormatWebGL(format: TextureFormat): {
586
578
  internalFormat: webglFormat,
587
579
  format:
588
580
  formatData?.dataFormat ||
589
- getWebGLPixelDataFormat(decoded.format, decoded.integer, decoded.normalized, webglFormat),
581
+ getWebGLPixelDataFormat(decoded.channels, decoded.integer, decoded.normalized, webglFormat),
590
582
  // depth formats don't have a type
591
583
  type: decoded.dataType
592
584
  ? getGLFromVertexType(decoded.dataType)
593
585
  : formatData?.types?.[0] || GL.UNSIGNED_BYTE,
594
- // @ts-expect-error
595
- compressed: decoded.compressed
586
+ compressed: decoded.compressed || false
596
587
  };
597
588
  }
598
589
 
@@ -619,7 +610,7 @@ export function getTextureFormatBytesPerPixel(format: TextureFormat): number {
619
610
  // DATA TYPE HELPERS
620
611
 
621
612
  export function getWebGLPixelDataFormat(
622
- dataFormat: string,
613
+ channels: 'r' | 'rg' | 'rgb' | 'rgba' | 'bgra',
623
614
  integer: boolean,
624
615
  normalized: boolean,
625
616
  format: GL
@@ -629,11 +620,12 @@ export function getWebGLPixelDataFormat(
629
620
  return format;
630
621
  }
631
622
  // prettier-ignore
632
- switch (dataFormat) {
623
+ switch (channels) {
633
624
  case 'r': return integer && !normalized ? GL.RED_INTEGER : GL.RED;
634
625
  case 'rg': return integer && !normalized ? GL.RG_INTEGER : GL.RG;
635
626
  case 'rgb': return integer && !normalized ? GL.RGB_INTEGER : GL.RGB;
636
627
  case 'rgba': return integer && !normalized ? GL.RGBA_INTEGER : GL.RGBA;
628
+ case 'bgra': throw new Error('bgra pixels not supported by WebGL');
637
629
  default: return GL.RGBA;
638
630
  }
639
631
  }
@@ -8,8 +8,11 @@
8
8
  import {DeviceFeature, DeviceFeatures} from '@luma.gl/core';
9
9
  import {GLExtensions} from '@luma.gl/constants';
10
10
  import {getWebGLExtension} from '../../context/helpers/webgl-extensions';
11
- import {isTextureFeature, checkTextureFeature} from '../converters/texture-formats';
12
- import {TEXTURE_FEATURES} from '../converters/texture-formats';
11
+ import {
12
+ isTextureFeature,
13
+ checkTextureFeature,
14
+ TEXTURE_FEATURES
15
+ } from '../converters/texture-formats';
13
16
 
14
17
  /**
15
18
  * Defines luma.gl "feature" names and semantics
@@ -21,7 +24,6 @@ const WEBGL_FEATURES: Partial<Record<DeviceFeature, boolean | string>> = {
21
24
  // 'timestamp-query' // GPUQueryType "timestamp-query"
22
25
  // "indirect-first-instance"
23
26
  // Textures are handled by getTextureFeatures()
24
- // 'depth24unorm-stencil8' // GPUTextureFormat 'depth24unorm-stencil8'
25
27
  // 'depth32float-stencil8' // GPUTextureFormat 'depth32float-stencil8'
26
28
 
27
29
  // optional WebGL features
@@ -11,7 +11,6 @@ import type {
11
11
  } from '@luma.gl/core';
12
12
 
13
13
  import {GL} from '@luma.gl/constants';
14
- import {Accessor} from '../../classic/accessor'; // TODO - should NOT depend on classic API
15
14
  import {decodeGLUniformType, decodeGLAttributeType, isSamplerUniform} from './decode-webgl-types';
16
15
 
17
16
  /**
@@ -143,8 +142,7 @@ function readVaryings(gl: WebGL2RenderingContext, program: WebGLProgram): Varyin
143
142
  }
144
143
  const {name, type: compositeType, size} = activeInfo;
145
144
  const {glType, components} = decodeGLUniformType(compositeType);
146
- const accessor = new Accessor({type: glType, size: size * components});
147
- const varying = {location, name, accessor}; // Base values
145
+ const varying = {location, name, type: glType, size: size * components}; // Base values
148
146
  varyings.push(varying);
149
147
  }
150
148