@luma.gl/webgl 9.1.0-beta.8 → 9.2.0-alpha.1

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 (186) hide show
  1. package/dist/adapter/converters/device-parameters.js +14 -9
  2. package/dist/adapter/converters/device-parameters.js.map +1 -1
  3. package/dist/adapter/converters/shader-formats.d.ts +67 -8
  4. package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
  5. package/dist/adapter/converters/shader-formats.js +82 -52
  6. package/dist/adapter/converters/shader-formats.js.map +1 -1
  7. package/dist/adapter/converters/webgl-shadertypes.d.ts +20 -0
  8. package/dist/adapter/converters/webgl-shadertypes.d.ts.map +1 -0
  9. package/dist/adapter/converters/webgl-shadertypes.js +123 -0
  10. package/dist/adapter/converters/webgl-shadertypes.js.map +1 -0
  11. package/dist/adapter/converters/webgl-texture-table.js +5 -5
  12. package/dist/adapter/converters/webgl-texture-table.js.map +1 -1
  13. package/dist/adapter/converters/{vertex-formats.d.ts → webgl-vertex-formats.d.ts} +4 -4
  14. package/dist/adapter/converters/webgl-vertex-formats.d.ts.map +1 -0
  15. package/dist/adapter/converters/{vertex-formats.js → webgl-vertex-formats.js} +1 -1
  16. package/dist/adapter/converters/webgl-vertex-formats.js.map +1 -0
  17. package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
  18. package/dist/adapter/device-helpers/webgl-device-features.js.map +1 -1
  19. package/dist/adapter/device-helpers/webgl-device-limits.d.ts +1 -1
  20. package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -1
  21. package/dist/adapter/device-helpers/webgl-device-limits.js +1 -1
  22. package/dist/adapter/device-helpers/webgl-device-limits.js.map +1 -1
  23. package/dist/adapter/helpers/format-utils.d.ts +3 -2
  24. package/dist/adapter/helpers/format-utils.d.ts.map +1 -1
  25. package/dist/adapter/helpers/format-utils.js.map +1 -1
  26. package/dist/adapter/helpers/{get-shader-layout.d.ts → get-shader-layout-from-glsl.d.ts} +1 -1
  27. package/dist/adapter/helpers/get-shader-layout-from-glsl.d.ts.map +1 -0
  28. package/dist/adapter/helpers/{get-shader-layout.js → get-shader-layout-from-glsl.js} +12 -35
  29. package/dist/adapter/helpers/get-shader-layout-from-glsl.js.map +1 -0
  30. package/dist/adapter/helpers/set-uniform.d.ts +2 -2
  31. package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
  32. package/dist/adapter/helpers/set-uniform.js.map +1 -1
  33. package/dist/adapter/helpers/webgl-texture-utils.d.ts +2 -25
  34. package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -1
  35. package/dist/adapter/helpers/webgl-texture-utils.js +10 -99
  36. package/dist/adapter/helpers/webgl-texture-utils.js.map +1 -1
  37. package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
  38. package/dist/adapter/resources/webgl-buffer.js +2 -2
  39. package/dist/adapter/resources/webgl-buffer.js.map +1 -1
  40. package/dist/adapter/resources/webgl-command-buffer.d.ts +2 -2
  41. package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
  42. package/dist/adapter/resources/webgl-command-buffer.js +4 -4
  43. package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
  44. package/dist/adapter/resources/webgl-command-encoder.d.ts +6 -2
  45. package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
  46. package/dist/adapter/resources/webgl-command-encoder.js +9 -4
  47. package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
  48. package/dist/adapter/resources/webgl-external-texture.js +1 -0
  49. package/dist/adapter/resources/webgl-external-texture.js.map +1 -1
  50. package/dist/adapter/resources/webgl-query-set.d.ts.map +1 -1
  51. package/dist/adapter/resources/webgl-query-set.js +5 -1
  52. package/dist/adapter/resources/webgl-query-set.js.map +1 -1
  53. package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
  54. package/dist/adapter/resources/webgl-render-pass.js +8 -5
  55. package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
  56. package/dist/adapter/resources/webgl-render-pipeline.d.ts +2 -3
  57. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  58. package/dist/adapter/resources/webgl-render-pipeline.js +16 -20
  59. package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
  60. package/dist/adapter/resources/webgl-sampler.js +1 -1
  61. package/dist/adapter/resources/webgl-sampler.js.map +1 -1
  62. package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
  63. package/dist/adapter/resources/webgl-shader.js +4 -1
  64. package/dist/adapter/resources/webgl-shader.js.map +1 -1
  65. package/dist/adapter/resources/webgl-texture-view.js +1 -1
  66. package/dist/adapter/resources/webgl-texture-view.js.map +1 -1
  67. package/dist/adapter/resources/webgl-texture.d.ts +21 -66
  68. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  69. package/dist/adapter/resources/webgl-texture.js +148 -324
  70. package/dist/adapter/resources/webgl-texture.js.map +1 -1
  71. package/dist/adapter/resources/webgl-transform-feedback.d.ts +1 -1
  72. package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
  73. package/dist/adapter/resources/webgl-transform-feedback.js +1 -1
  74. package/dist/adapter/resources/webgl-transform-feedback.js.map +1 -1
  75. package/dist/adapter/resources/webgl-vertex-array.d.ts +1 -1
  76. package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
  77. package/dist/adapter/resources/webgl-vertex-array.js +3 -2
  78. package/dist/adapter/resources/webgl-vertex-array.js.map +1 -1
  79. package/dist/adapter/webgl-adapter.d.ts +4 -3
  80. package/dist/adapter/webgl-adapter.d.ts.map +1 -1
  81. package/dist/adapter/webgl-adapter.js +16 -7
  82. package/dist/adapter/webgl-adapter.js.map +1 -1
  83. package/dist/adapter/webgl-canvas-context.d.ts +1 -19
  84. package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
  85. package/dist/adapter/webgl-canvas-context.js +3 -31
  86. package/dist/adapter/webgl-canvas-context.js.map +1 -1
  87. package/dist/adapter/webgl-device.d.ts +8 -15
  88. package/dist/adapter/webgl-device.d.ts.map +1 -1
  89. package/dist/adapter/webgl-device.js +15 -16
  90. package/dist/adapter/webgl-device.js.map +1 -1
  91. package/dist/context/debug/spector-types.d.ts.map +1 -1
  92. package/dist/context/debug/spector-types.js +3 -0
  93. package/dist/context/debug/spector-types.js.map +1 -1
  94. package/dist/context/debug/spector.js.map +1 -1
  95. package/dist/context/debug/webgl-developer-tools.js.map +1 -1
  96. package/dist/context/helpers/webgl-extensions.d.ts.map +1 -1
  97. package/dist/context/helpers/webgl-extensions.js +3 -0
  98. package/dist/context/helpers/webgl-extensions.js.map +1 -1
  99. package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
  100. package/dist/context/parameters/unified-parameter-api.js +7 -0
  101. package/dist/context/parameters/unified-parameter-api.js.map +1 -1
  102. package/dist/context/parameters/webgl-parameter-tables.d.ts +1 -1
  103. package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
  104. package/dist/context/parameters/webgl-parameter-tables.js +1 -0
  105. package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
  106. package/dist/context/polyfills/polyfill-webgl1-extensions.d.ts.map +1 -1
  107. package/dist/context/polyfills/polyfill-webgl1-extensions.js +1 -0
  108. package/dist/context/polyfills/polyfill-webgl1-extensions.js.map +1 -1
  109. package/dist/context/state-tracker/deep-array-equal.d.ts +2 -1
  110. package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
  111. package/dist/context/state-tracker/deep-array-equal.js +4 -5
  112. package/dist/context/state-tracker/deep-array-equal.js.map +1 -1
  113. package/dist/context/state-tracker/webgl-state-tracker.d.ts.map +1 -1
  114. package/dist/context/state-tracker/webgl-state-tracker.js +4 -1
  115. package/dist/context/state-tracker/webgl-state-tracker.js.map +1 -1
  116. package/dist/context/state-tracker/with-parameters.js.map +1 -1
  117. package/dist/dist.dev.js +4719 -4777
  118. package/dist/dist.min.js +2 -2
  119. package/dist/index.cjs +3848 -3944
  120. package/dist/index.cjs.map +4 -4
  121. package/dist/index.d.ts +1 -3
  122. package/dist/index.d.ts.map +1 -1
  123. package/dist/index.js +1 -3
  124. package/dist/index.js.map +1 -1
  125. package/package.json +4 -4
  126. package/src/adapter/converters/device-parameters.ts +19 -9
  127. package/src/adapter/converters/shader-formats.ts +50 -24
  128. package/src/adapter/converters/webgl-shadertypes.ts +152 -0
  129. package/src/adapter/converters/webgl-texture-table.ts +7 -7
  130. package/src/adapter/converters/{vertex-formats.ts → webgl-vertex-formats.ts} +3 -3
  131. package/src/adapter/device-helpers/webgl-device-features.ts +1 -1
  132. package/src/adapter/device-helpers/webgl-device-limits.ts +1 -1
  133. package/src/adapter/helpers/format-utils.ts +2 -2
  134. package/src/adapter/helpers/{get-shader-layout.ts → get-shader-layout-from-glsl.ts} +20 -50
  135. package/src/adapter/helpers/set-uniform.ts +2 -2
  136. package/src/adapter/helpers/webgl-texture-utils.ts +12 -127
  137. package/src/adapter/resources/webgl-buffer.ts +2 -2
  138. package/src/adapter/resources/webgl-command-buffer.ts +5 -5
  139. package/src/adapter/resources/webgl-command-encoder.ts +17 -8
  140. package/src/adapter/resources/webgl-query-set.ts +5 -1
  141. package/src/adapter/resources/webgl-render-pass.ts +11 -8
  142. package/src/adapter/resources/webgl-render-pipeline.ts +20 -30
  143. package/src/adapter/resources/webgl-sampler.ts +1 -1
  144. package/src/adapter/resources/webgl-shader.ts +4 -1
  145. package/src/adapter/resources/webgl-texture-view.ts +1 -1
  146. package/src/adapter/resources/webgl-texture.ts +180 -398
  147. package/src/adapter/resources/webgl-transform-feedback.ts +2 -2
  148. package/src/adapter/resources/webgl-vertex-array.ts +4 -3
  149. package/src/adapter/webgl-adapter.ts +20 -8
  150. package/src/adapter/webgl-canvas-context.ts +3 -32
  151. package/src/adapter/webgl-device.ts +21 -25
  152. package/src/context/debug/spector-types.ts +5 -0
  153. package/src/context/debug/spector.ts +1 -1
  154. package/src/context/debug/webgl-developer-tools.ts +8 -3
  155. package/src/context/helpers/webgl-extensions.ts +3 -0
  156. package/src/context/parameters/unified-parameter-api.ts +9 -2
  157. package/src/context/parameters/webgl-parameter-tables.ts +2 -0
  158. package/src/context/polyfills/polyfill-webgl1-extensions.ts +1 -0
  159. package/src/context/state-tracker/deep-array-equal.ts +11 -6
  160. package/src/context/state-tracker/webgl-state-tracker.ts +5 -1
  161. package/src/context/state-tracker/with-parameters.ts +1 -1
  162. package/src/index.ts +1 -5
  163. package/dist/adapter/converters/vertex-formats.d.ts.map +0 -1
  164. package/dist/adapter/converters/vertex-formats.js.map +0 -1
  165. package/dist/adapter/helpers/decode-webgl-types.d.ts +0 -26
  166. package/dist/adapter/helpers/decode-webgl-types.d.ts.map +0 -1
  167. package/dist/adapter/helpers/decode-webgl-types.js +0 -102
  168. package/dist/adapter/helpers/decode-webgl-types.js.map +0 -1
  169. package/dist/adapter/helpers/get-shader-layout.d.ts.map +0 -1
  170. package/dist/adapter/helpers/get-shader-layout.js.map +0 -1
  171. package/dist/adapter/helpers/typed-array-utils.d.ts +0 -44
  172. package/dist/adapter/helpers/typed-array-utils.d.ts.map +0 -1
  173. package/dist/adapter/helpers/typed-array-utils.js +0 -107
  174. package/dist/adapter/helpers/typed-array-utils.js.map +0 -1
  175. package/dist/deprecated/accessor.d.ts +0 -53
  176. package/dist/deprecated/accessor.d.ts.map +0 -1
  177. package/dist/deprecated/accessor.js +0 -177
  178. package/dist/deprecated/accessor.js.map +0 -1
  179. package/dist/utils/split-uniforms-and-bindings.d.ts +0 -9
  180. package/dist/utils/split-uniforms-and-bindings.d.ts.map +0 -1
  181. package/dist/utils/split-uniforms-and-bindings.js +0 -21
  182. package/dist/utils/split-uniforms-and-bindings.js.map +0 -1
  183. package/src/adapter/helpers/decode-webgl-types.ts +0 -134
  184. package/src/adapter/helpers/typed-array-utils.ts +0 -129
  185. package/src/deprecated/accessor.ts +0 -225
  186. package/src/utils/split-uniforms-and-bindings.ts +0 -31
@@ -102,7 +102,7 @@ export class WEBGLTransformFeedback extends TransformFeedback {
102
102
  return location >= 0 ? this.buffers[location] : null;
103
103
  }
104
104
 
105
- bind(funcOrHandle = this.handle) {
105
+ bind(funcOrHandle: (() => void) | WebGLTransformFeedback | null = this.handle) {
106
106
  if (typeof funcOrHandle !== 'function') {
107
107
  this.gl.bindTransformFeedback(GL.TRANSFORM_FEEDBACK, funcOrHandle);
108
108
  return this;
@@ -148,7 +148,7 @@ export class WEBGLTransformFeedback extends TransformFeedback {
148
148
  return Number(locationOrName);
149
149
  }
150
150
 
151
- for (const varying of this.layout.varyings) {
151
+ for (const varying of this.layout.varyings || []) {
152
152
  if (locationOrName === varying.name) {
153
153
  return varying.location;
154
154
  }
@@ -11,7 +11,7 @@ import {getBrowser} from '@probe.gl/env';
11
11
  import {WebGLDevice} from '../webgl-device';
12
12
  import {WEBGLBuffer} from '../resources/webgl-buffer';
13
13
 
14
- import {getGLFromVertexType} from '../converters/vertex-formats';
14
+ import {getGLFromVertexType} from '../converters/webgl-vertex-formats';
15
15
  import {fillArray} from '../../utils/fill-array';
16
16
 
17
17
  /** VertexArrayObject wrapper */
@@ -25,7 +25,7 @@ export class WEBGLVertexArray extends VertexArray {
25
25
 
26
26
  /** Attribute 0 buffer constant */
27
27
  private buffer: WEBGLBuffer | null = null;
28
- private bufferValue = null;
28
+ private bufferValue: TypedArray | null = null;
29
29
 
30
30
  /** * Attribute 0 can not be disable on most desktop OpenGL based browsers */
31
31
  static isConstantAttributeZeroSupported(device: Device): boolean {
@@ -233,7 +233,8 @@ export class WEBGLVertexArray extends VertexArray {
233
233
  this.buffer = this.buffer || this.device.createBuffer({byteLength});
234
234
 
235
235
  // Reallocate and update contents if needed
236
- updateNeeded = updateNeeded || !compareConstantArrayValues(constantValue, this.bufferValue);
236
+ // @ts-ignore TODO fix types
237
+ updateNeeded ||= !compareConstantArrayValues(constantValue, this.bufferValue);
237
238
 
238
239
  if (updateNeeded) {
239
240
  // Create a typed array that is big enough, and fill it with the required data
@@ -2,8 +2,8 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
+ import type {WebGLDevice} from './webgl-device';
5
6
  import {Adapter, Device, DeviceProps, log} from '@luma.gl/core';
6
- import {WebGLDevice} from './webgl-device';
7
7
  import {enforceWebGL2} from '../context/polyfills/polyfill-webgl1-extensions';
8
8
  import {loadSpectorJS, DEFAULT_SPECTOR_PROPS} from '../context/debug/spector';
9
9
  import {loadWebGLDeveloperTools} from '../context/debug/webgl-developer-tools';
@@ -16,12 +16,13 @@ export class WebGLAdapter extends Adapter {
16
16
 
17
17
  constructor() {
18
18
  super();
19
-
20
19
  // Add spector default props to device default props, so that runtime settings are observed
21
20
  Device.defaultProps = {...Device.defaultProps, ...DEFAULT_SPECTOR_PROPS};
21
+ }
22
22
 
23
- // @ts-ignore DEPRECATED For backwards compatibility luma.registerDevices
24
- WebGLDevice.adapter = this;
23
+ /** Force any created WebGL contexts to be WebGL2 contexts, polyfilled with WebGL1 extensions */
24
+ enforceWebGL2(enable: boolean): void {
25
+ enforceWebGL2(enable);
25
26
  }
26
27
 
27
28
  /** Check if WebGL 2 is available */
@@ -29,9 +30,17 @@ export class WebGLAdapter extends Adapter {
29
30
  return typeof WebGL2RenderingContext !== 'undefined';
30
31
  }
31
32
 
32
- /** Force any created WebGL contexts to be WebGL2 contexts, polyfilled with WebGL1 extensions */
33
- enforceWebGL2(enable: boolean): void {
34
- enforceWebGL2(enable);
33
+ override isDeviceHandle(handle: unknown): boolean {
34
+ // WebGL
35
+ if (typeof WebGL2RenderingContext !== 'undefined' && handle instanceof WebGL2RenderingContext) {
36
+ return true;
37
+ }
38
+
39
+ if (typeof WebGLRenderingContext !== 'undefined' && handle instanceof WebGLRenderingContext) {
40
+ log.warn('WebGL1 is not supported', handle)();
41
+ }
42
+
43
+ return false;
35
44
  }
36
45
 
37
46
  /**
@@ -41,11 +50,12 @@ export class WebGLAdapter extends Adapter {
41
50
  * @returns
42
51
  */
43
52
  async attach(gl: Device | WebGL2RenderingContext): Promise<WebGLDevice> {
53
+ const {WebGLDevice} = await import('./webgl-device');
44
54
  if (gl instanceof WebGLDevice) {
45
55
  return gl;
46
56
  }
47
57
  // @ts-expect-error
48
- if (gl?.device instanceof Device) {
58
+ if (gl?.device instanceof WebGLDevice) {
49
59
  // @ts-expect-error
50
60
  return gl.device as WebGLDevice;
51
61
  }
@@ -56,6 +66,8 @@ export class WebGLAdapter extends Adapter {
56
66
  }
57
67
 
58
68
  async create(props: DeviceProps = {}): Promise<WebGLDevice> {
69
+ const {WebGLDevice} = await import('./webgl-device');
70
+
59
71
  log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created')();
60
72
 
61
73
  const promises: Promise<unknown>[] = [];
@@ -27,7 +27,7 @@ export class WebGLCanvasContext extends CanvasContext {
27
27
 
28
28
  // Base class constructor cannot access derived methods/fields, so we need to call these functions in the subclass constructor
29
29
  this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);
30
- this.updateSize([this.drawingBufferWidth, this.drawingBufferHeight]);
30
+ this._updateDevice();
31
31
  }
32
32
 
33
33
  getCurrentFramebuffer(): WEBGLFramebuffer {
@@ -36,36 +36,7 @@ export class WebGLCanvasContext extends CanvasContext {
36
36
  return this._framebuffer;
37
37
  }
38
38
 
39
- updateSize(size: [number, number]): void {}
39
+ // IMPLEMENTATION OF ABSTRACT METHODS
40
40
 
41
- /**
42
- * Resize the canvas' drawing buffer.
43
- *
44
- * Can match the canvas CSS size, and optionally also consider devicePixelRatio
45
- * Can be called every frame
46
- *
47
- * Regardless of size, the drawing buffer will always be scaled to the viewport, but
48
- * for best visual results, usually set to either:
49
- * canvas CSS width x canvas CSS height
50
- * canvas CSS width * devicePixelRatio x canvas CSS height * devicePixelRatio
51
- * See http://webgl2fundamentals.org/webgl/lessons/webgl-resizing-the-canvas.html
52
- */
53
- resize(options?: {width?: number; height?: number; useDevicePixels?: boolean | number}): void {
54
- if (!this.device.gl) return;
55
-
56
- // Resize browser context. TODO - this likely needs to be rewritten
57
- if (this.canvas) {
58
- const devicePixelRatio = this.getDevicePixelRatio(options?.useDevicePixels);
59
- this._setDevicePixelRatio(devicePixelRatio, options);
60
- return;
61
- }
62
- }
63
-
64
- commit() {
65
- // gl.commit was ultimately removed from the WebGL standard??
66
- // if (this.offScreen && this.gl.commit) {
67
- // // @ts-expect-error gl.commit is not officially part of WebGL2RenderingContext
68
- // this.gl.commit();
69
- // }
70
- }
41
+ _updateDevice(): void {}
71
42
  }
@@ -25,10 +25,6 @@ import type {
25
25
  RenderPipelineProps,
26
26
  ComputePipeline,
27
27
  ComputePipelineProps,
28
- // RenderPass,
29
- RenderPassProps,
30
- ComputePass,
31
- ComputePassProps,
32
28
  // CommandEncoder,
33
29
  CommandEncoderProps,
34
30
  TransformFeedbackProps,
@@ -54,9 +50,9 @@ import {WEBGLShader} from './resources/webgl-shader';
54
50
  import {WEBGLSampler} from './resources/webgl-sampler';
55
51
  import {WEBGLTexture} from './resources/webgl-texture';
56
52
  import {WEBGLFramebuffer} from './resources/webgl-framebuffer';
57
- import {WEBGLRenderPass} from './resources/webgl-render-pass';
58
53
  import {WEBGLRenderPipeline} from './resources/webgl-render-pipeline';
59
54
  import {WEBGLCommandEncoder} from './resources/webgl-command-encoder';
55
+ import {WEBGLCommandBuffer} from './resources/webgl-command-buffer';
60
56
  import {WEBGLVertexArray} from './resources/webgl-vertex-array';
61
57
  import {WEBGLTransformFeedback} from './resources/webgl-transform-feedback';
62
58
  import {WEBGLQuerySet} from './resources/webgl-query-set';
@@ -87,6 +83,8 @@ export class WebGLDevice extends Device {
87
83
  readonly preferredColorFormat = 'rgba8unorm';
88
84
  readonly preferredDepthFormat = 'depth24plus';
89
85
 
86
+ commandEncoder: WEBGLCommandEncoder;
87
+
90
88
  readonly lost: Promise<{reason: 'destroyed'; message: string}>;
91
89
 
92
90
  private _resolveContextLost?: (value: {reason: 'destroyed'; message: string}) => void;
@@ -95,20 +93,25 @@ export class WebGLDevice extends Device {
95
93
  readonly gl: WebGL2RenderingContext;
96
94
  readonly debug: boolean = false;
97
95
 
98
- /** State used by luma.gl classes: TODO - move to canvasContext*/
99
- readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};
96
+ /** Store constants */
97
+ // @ts-ignore TODO fix
98
+ _constants: (TypedArray | null)[];
100
99
 
101
100
  /** State used by luma.gl classes - TODO - not used? */
102
101
  readonly _extensions: GLExtensions = {};
103
102
  _polyfilled: boolean = false;
104
103
 
105
104
  /** Instance of Spector.js (if initialized) */
106
- spectorJS: Spector;
105
+ spectorJS: Spector | null;
107
106
 
108
107
  //
109
108
  // Public API
110
109
  //
111
110
 
111
+ override toString(): string {
112
+ return `${this[Symbol.toStringTag]}(${this.id})`;
113
+ }
114
+
112
115
  constructor(props: DeviceProps) {
113
116
  super({...props, id: props.id || uid('webgl-device')});
114
117
 
@@ -205,6 +208,8 @@ export class WebGLDevice extends Device {
205
208
  log.level = Math.max(log.level, 1);
206
209
  }
207
210
  }
211
+
212
+ this.commandEncoder = new WEBGLCommandEncoder(this, {id: `${this}-command-encoder`});
208
213
  }
209
214
 
210
215
  /**
@@ -264,20 +269,10 @@ export class WebGLDevice extends Device {
264
269
  return new WEBGLRenderPipeline(this, props);
265
270
  }
266
271
 
267
- beginRenderPass(props: RenderPassProps): WEBGLRenderPass {
268
- return new WEBGLRenderPass(this, props);
269
- }
270
-
271
272
  createComputePipeline(props?: ComputePipelineProps): ComputePipeline {
272
273
  throw new Error('ComputePipeline not supported in WebGL');
273
274
  }
274
275
 
275
- beginComputePass(props: ComputePassProps): ComputePass {
276
- throw new Error('ComputePass not supported in WebGL');
277
- }
278
-
279
- private renderPass: WEBGLRenderPass | null = null;
280
-
281
276
  override createCommandEncoder(props: CommandEncoderProps = {}): WEBGLCommandEncoder {
282
277
  return new WEBGLCommandEncoder(this, props);
283
278
  }
@@ -287,10 +282,14 @@ export class WebGLDevice extends Device {
287
282
  * https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/commit
288
283
  * Chrome's offscreen canvas does not require gl.commit
289
284
  */
290
- submit(): void {
291
- this.renderPass?.end();
292
- this.renderPass = null;
293
- // this.canvasContext.commit();
285
+ submit(commandBuffer: WEBGLCommandBuffer): void {
286
+ if (!commandBuffer) {
287
+ commandBuffer = this.commandEncoder.finish();
288
+ this.commandEncoder.destroy();
289
+ this.commandEncoder = this.createCommandEncoder({id: `${this.id}-default-encoder`});
290
+ }
291
+
292
+ commandBuffer._executeCommands();
294
293
  }
295
294
 
296
295
  //
@@ -421,9 +420,6 @@ export class WebGLDevice extends Device {
421
420
  }, {});
422
421
  }
423
422
 
424
- /** Store constants */
425
- _constants: (TypedArray | null)[];
426
-
427
423
  /**
428
424
  * Set a constant value for a location. Disabled attributes at that location will read from this value
429
425
  * @note WebGL constants are stored globally on the WebGL context, not the VertexArray
@@ -1,6 +1,8 @@
1
1
  // Forked from https://github.com/BabylonJS/Spector.js/blob/master/dist/spector.d.ts
2
2
  /* eslint-disable camelcase, no-shadow */
3
3
 
4
+ // @ts-nocheck
5
+
4
6
  interface IEvent<T> {
5
7
  add(callback: (element: T) => void, context?: any): number;
6
8
  remove(id: number): void;
@@ -1071,8 +1073,11 @@ export abstract class Spector {
1071
1073
  }
1072
1074
  protected static tryGetContextFromHelperField: unknown;
1073
1075
  protected static tryGetContextFromCanvas: unknown;
1076
+ // @ts-ignore TODO
1074
1077
  readonly onCaptureStarted: IEvent<any>;
1078
+ // @ts-ignore TODO
1075
1079
  readonly onCapture: IEvent<ICapture>;
1080
+ // @ts-ignore TODO
1076
1081
  readonly onError: IEvent<string>;
1077
1082
  protected readonly logger;
1078
1083
  protected readonly timeSpy;
@@ -19,7 +19,7 @@ type SpectorProps = {
19
19
 
20
20
  const LOG_LEVEL = 1;
21
21
 
22
- let spector: Spector = null;
22
+ let spector: Spector | null = null;
23
23
  let initialized: boolean = false;
24
24
 
25
25
  declare global {
@@ -112,7 +112,7 @@ function getDebugContext(
112
112
 
113
113
  // DEBUG TRACING
114
114
 
115
- function getFunctionString(functionName: string, functionArgs): string {
115
+ function getFunctionString(functionName: string, functionArgs: unknown[]): string {
116
116
  // Cover bug in webgl-debug-tools
117
117
  functionArgs = Array.from(functionArgs).map(arg => (arg === undefined ? 'undefined' : arg));
118
118
  let args = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, functionArgs);
@@ -120,7 +120,12 @@ function getFunctionString(functionName: string, functionArgs): string {
120
120
  return `gl.${functionName}(${args})`;
121
121
  }
122
122
 
123
- function onGLError(props: DebugContextProps, err, functionName: string, args: any[]): void {
123
+ function onGLError(
124
+ props: DebugContextProps,
125
+ err: number,
126
+ functionName: string,
127
+ args: unknown[]
128
+ ): void {
124
129
  // Cover bug in webgl-debug-tools
125
130
  args = Array.from(args).map(arg => (arg === undefined ? 'undefined' : arg));
126
131
  const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);
@@ -135,7 +140,7 @@ function onGLError(props: DebugContextProps, err, functionName: string, args: an
135
140
  function onValidateGLFunc(
136
141
  props: DebugContextProps,
137
142
  functionName: string,
138
- functionArgs: any[]
143
+ functionArgs: unknown[]
139
144
  ): void {
140
145
  let functionString: string = '';
141
146
  if (log.level >= 1) {
@@ -10,8 +10,11 @@ export function getWebGLExtension(
10
10
  name: string,
11
11
  extensions: GLExtensions
12
12
  ): unknown {
13
+ // @ts-ignore TODO
13
14
  if (extensions[name] === undefined) {
15
+ // @ts-ignore TODO
14
16
  extensions[name] = gl.getExtension(name) || null;
15
17
  }
18
+ // @ts-ignore TODO
16
19
  return extensions[name];
17
20
  }
@@ -32,16 +32,19 @@ export function setGLParameters(gl: WebGL2RenderingContext, parameters: GLParame
32
32
 
33
33
  for (const key in parameters) {
34
34
  const glConstant = Number(key);
35
+ // @ts-ignore TODO
35
36
  const setter = GL_PARAMETER_SETTERS[key];
36
37
  if (setter) {
37
38
  // Composite setters should only be called once, so save them
38
39
  if (typeof setter === 'string') {
40
+ // @ts-ignore TODO
39
41
  compositeSetters[setter] = true;
40
42
  } else {
41
43
  // if (gl[glConstant] !== undefined) {
42
44
  // TODO - added above check since this is being called on WebGL2 parameters in WebGL1...
43
45
  // TODO - deep equal on values? only call setter if value has changed?
44
46
  // NOTE - the setter will automatically update this.state
47
+ // @ts-ignore TODO
45
48
  setter(gl, parameters[key], glConstant);
46
49
  }
47
50
  }
@@ -59,6 +62,7 @@ export function setGLParameters(gl: WebGL2RenderingContext, parameters: GLParame
59
62
  if (cache) {
60
63
  for (const key in compositeSetters) {
61
64
  // TODO - avoid calling composite setters if values have not changed.
65
+ // @ts-ignore TODO
62
66
  const compositeSetter = GL_COMPOSITE_PARAMETER_SETTERS[key];
63
67
  // Note - if `trackContextState` has been called,
64
68
  // the setter will automatically update this.state.cache
@@ -92,15 +96,18 @@ export function getGLParameters(
92
96
  if (typeof parameters === 'number') {
93
97
  // single GL enum
94
98
  const key = parameters;
99
+ // @ts-ignore TODO
95
100
  const getter = GL_PARAMETER_GETTERS[key];
96
101
  return getter ? getter(gl, key) : gl.getParameter(key);
97
102
  }
98
103
 
99
104
  const parameterKeys = Array.isArray(parameters) ? parameters : Object.keys(parameters);
100
105
 
101
- const state = {};
106
+ const state: GLParameters = {};
102
107
  for (const key of parameterKeys) {
108
+ // @ts-ignore TODO
103
109
  const getter = GL_PARAMETER_GETTERS[key];
110
+ // @ts-ignore TODO
104
111
  state[key] = getter ? getter(gl, Number(key)) : gl.getParameter(Number(key));
105
112
  }
106
113
  return state;
@@ -119,7 +126,7 @@ export function resetGLParameters(gl: WebGL2RenderingContext): void {
119
126
  // Helpers
120
127
 
121
128
  // Returns true if given object is empty, false otherwise.
122
- function isObjectEmpty(object) {
129
+ function isObjectEmpty(object: Record<string, unknown>): boolean {
123
130
  // @ts-ignore dummy key variable
124
131
  for (const key in object) {
125
132
  return false;
@@ -2,6 +2,8 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
+ // @ts-nocheck TODO fix
6
+
5
7
  // Tables describing WebGL parameters
6
8
  import {GL, GLParameters} from '@luma.gl/constants';
7
9
 
@@ -132,6 +132,7 @@ export function polyfillWebGL1Extensions(gl: WebGL2RenderingContext): void {
132
132
 
133
133
  // Injected extensions
134
134
  if (extensionName in boundExtensions) {
135
+ // @ts-ignore TODO string index
135
136
  return boundExtensions[extensionName];
136
137
  }
137
138
 
@@ -2,16 +2,17 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
+ import {TypedArray} from '@luma.gl/core';
6
+
5
7
  /** deeply compare two arrays */
6
- export function deepArrayEqual(x: any, y: any): boolean {
8
+ export function deepArrayEqual(
9
+ x: unknown | unknown[] | TypedArray,
10
+ y: unknown | unknown[] | TypedArray
11
+ ): boolean {
7
12
  if (x === y) {
8
13
  return true;
9
14
  }
10
- const isArrayX = Array.isArray(x) || ArrayBuffer.isView(x);
11
- const isArrayY = Array.isArray(y) || ArrayBuffer.isView(y);
12
- // @ts-expect-error TODO fix
13
- if (isArrayX && isArrayY && x.length === y.length) {
14
- // @ts-expect-error TODO fix
15
+ if (isArray(x) && isArray(y) && x.length === y.length) {
15
16
  for (let i = 0; i < x.length; ++i) {
16
17
  if (x[i] !== y[i]) {
17
18
  return false;
@@ -21,3 +22,7 @@ export function deepArrayEqual(x: any, y: any): boolean {
21
22
  }
22
23
  return false;
23
24
  }
25
+
26
+ function isArray(x: unknown): x is unknown[] {
27
+ return Array.isArray(x) || ArrayBuffer.isView(x);
28
+ }
@@ -2,6 +2,8 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
+ // @ts-nocheck TODO - fix
6
+
5
7
  import {setGLParameters, getGLParameters} from '../parameters/unified-parameter-api';
6
8
  import {deepArrayEqual} from './deep-array-equal';
7
9
  import {
@@ -66,7 +68,9 @@ export class WebGLStateTracker {
66
68
  * temporarily modifying, and then restoring state.
67
69
  */
68
70
  trackState(gl: WebGL2RenderingContext, options?: {copyState?: boolean}): void {
69
- this.cache = options.copyState ? getGLParameters(gl) : Object.assign({}, GL_PARAMETER_DEFAULTS);
71
+ this.cache = options?.copyState
72
+ ? getGLParameters(gl)
73
+ : Object.assign({}, GL_PARAMETER_DEFAULTS);
70
74
 
71
75
  if (this.initialized) {
72
76
  throw new Error('WebGLStateTracker');
@@ -51,7 +51,7 @@ export function withGLParameters(
51
51
  // Helpers
52
52
 
53
53
  // Returns true if given object is empty, false otherwise.
54
- function isObjectEmpty(object) {
54
+ function isObjectEmpty(object: unknown): boolean {
55
55
  // @ts-ignore - dummy key variable
56
56
  for (const key in object) {
57
57
  return false;
package/src/index.ts CHANGED
@@ -37,16 +37,12 @@ export {WEBGLVertexArray} from './adapter/resources/webgl-vertex-array';
37
37
  // WebGL adapter classes
38
38
  export {WEBGLTransformFeedback} from './adapter/resources/webgl-transform-feedback';
39
39
 
40
- // WebGL adapter classes
41
- export {Accessor} from './deprecated/accessor';
42
- export type {AccessorObject} from './types';
43
-
44
40
  // Unified parameter API
45
41
 
46
42
  export {setDeviceParameters, withDeviceParameters} from './adapter/converters/device-parameters';
47
43
 
48
44
  // HELPERS - EXPERIMENTAL
49
- export {getShaderLayoutFromGLSL} from './adapter/helpers/get-shader-layout';
45
+ export {getShaderLayoutFromGLSL} from './adapter/helpers/get-shader-layout-from-glsl';
50
46
  export {WebGLStateTracker} from './context/state-tracker/webgl-state-tracker';
51
47
 
52
48
  // DEPRECATED TEST EXPORTS
@@ -1 +0,0 @@
1
- {"version":3,"file":"vertex-formats.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/vertex-formats.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AACtC,OAAO,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,eAAe,CAAC;AAEvD,KAAK,UAAU,GACX,EAAE,CAAC,aAAa,GAChB,EAAE,CAAC,IAAI,GACP,EAAE,CAAC,cAAc,GACjB,EAAE,CAAC,KAAK,GACR,EAAE,CAAC,YAAY,GACf,EAAE,CAAC,GAAG,GACN,EAAE,CAAC,UAAU,GACb,EAAE,CAAC,KAAK,CAAC;AAEb,0CAA0C;AAC1C,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,YAAY,CAa/F;AAED,sCAAsC;AACtC,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,UAAQ,GAAG,UAAU,CAepF;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,UAAU,GAElB,EAAE,CAAC,aAAa,GAChB,EAAE,CAAC,IAAI,GACP,EAAE,CAAC,cAAc,GACjB,EAAE,CAAC,KAAK,GACR,EAAE,CAAC,YAAY,GACf,EAAE,CAAC,GAAG,GACN,EAAE,CAAC,UAAU,GACb,EAAE,CAAC,KAAK,CAqBX"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vertex-formats.js","sourceRoot":"","sources":["../../../src/adapter/converters/vertex-formats.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAatC,0CAA0C;AAC1C,MAAM,UAAU,qBAAqB,CAAC,IAAgB,EAAE,UAAyB;IAC/E,MAAM,IAAI,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACvC,kBAAkB;IAClB,QAAQ,UAAU,EAAE,CAAC;QACnB,kDAAkD;QAClD,KAAK,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC;QACpB,KAAK,CAAC,CAAC,CAAC,OAAO,GAAG,IAAI,IAAI,CAAC;QAC3B,kDAAkD;QAClD,KAAK,CAAC,CAAC,CAAC,OAAO,GAAG,IAAI,IAAI,CAAC;QAC3B,KAAK,CAAC,CAAC,CAAC,OAAO,GAAG,IAAI,IAAI,CAAC;IAC7B,CAAC;IACD,yBAAyB;IACzB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;AACtC,CAAC;AAED,sCAAsC;AACtC,MAAM,UAAU,mBAAmB,CAAC,IAAgB,EAAE,UAAU,GAAG,KAAK;IACtE,kBAAkB;IAClB,QAAQ,IAAI,EAAE,CAAC;QACb,+DAA+D;QAC/D,WAAa,OAAO,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;QACrD,WAAsB,OAAO,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;QAC9D,WAAe,OAAO,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;QACxD,WAAwB,OAAO,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;QACjE,WAAc,OAAO,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;QACtD,WAAuB,OAAO,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC;QAC9D,WAAe,OAAO,SAAS,CAAC;QAChC,WAAoB,OAAO,SAAS,CAAC;IACvC,CAAC;IACD,yBAAyB;IACzB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,QAAoB;IAUpB,kBAAkB;IAClB,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,OAAO,CAAC,CAAC,YAAwB;QACtC,KAAK,OAAO,CAAC,CAAC,YAAe;QAC7B,KAAK,QAAQ,CAAC,CAAC,YAAwB;QACvC,KAAK,QAAQ,CAAC,CAAC,YAAe;QAC9B,KAAK,QAAQ,CAAC,CAAC,YAAyB;QACxC,KAAK,QAAQ,CAAC,CAAC,YAAgB;QAC/B,KAAK,SAAS,CAAC,CAAC,YAAyB;QACzC,KAAK,SAAS,CAAC,CAAC,YAAgB;QAChC,KAAK,QAAQ,CAAC,CAAC,YAAuB;QACtC,KAAK,QAAQ,CAAC,CAAC,YAAc;QAC7B,+DAA+D;QAC/D,0CAA0C;QAC1C,iCAAiC;QACjC,KAAK,SAAS,CAAC,CAAC,YAAqB;QACrC,KAAK,SAAS,CAAC,CAAC,YAAgB;IAClC,CAAC;IACD,yBAAyB;IACzB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;AACpC,CAAC"}
@@ -1,26 +0,0 @@
1
- import { ShaderUniformType, ShaderAttributeType, VertexFormat } from '@luma.gl/core';
2
- import { GL, GLUniformType, GLCompositeType, GLDataType } from '@luma.gl/constants';
3
- /** Check is uniform is of sampler type */
4
- export declare function isSamplerUniform(type: GLUniformType): boolean;
5
- /** Decomposes a composite type (GL.VEC3) into a basic type (GL.FLOAT) and components (3) */
6
- export declare function decodeGLUniformType(glUniformType: GL): {
7
- format: ShaderUniformType;
8
- components: number;
9
- glType: GLDataType;
10
- };
11
- /** Decomposes a composite type (GL.VEC3) into a basic type (GL.FLOAT) and components (3) */
12
- export declare function decodeGLAttributeType(glAttributeType: GL): {
13
- attributeType: ShaderAttributeType;
14
- vertexFormat: VertexFormat;
15
- components: number;
16
- };
17
- /** Decomposes a composite type GL.VEC3 into a basic type (GL.FLOAT) and components (3) */
18
- export declare function decomposeCompositeGLDataType(compositeGLDataType: GLCompositeType): {
19
- type: GLDataType;
20
- components: number;
21
- } | null;
22
- export declare function getCompositeGLDataType(type: GL, components: any): {
23
- glType: GLDataType;
24
- name: string;
25
- } | null;
26
- //# sourceMappingURL=decode-webgl-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decode-webgl-types.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/decode-webgl-types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,iBAAiB,EAAE,mBAAmB,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AACnF,OAAO,EAAC,EAAE,EAAE,aAAa,EAAiB,eAAe,EAAE,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAEjG,0CAA0C;AAC1C,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAE7D;AA2DD,4FAA4F;AAC5F,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,EAAE,GAAG;IACtD,MAAM,EAAE,iBAAiB,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,UAAU,CAAC;CACpB,CAOA;AAED,4FAA4F;AAC5F,wBAAgB,qBAAqB,CAAC,eAAe,EAAE,EAAE,GAAG;IAC1D,aAAa,EAAE,mBAAmB,CAAC;IACnC,YAAY,EAAE,YAAY,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;CAEpB,CASA;AAED,0FAA0F;AAC1F,wBAAgB,4BAA4B,CAC1C,mBAAmB,EAAE,eAAe,GACnC;IAAC,IAAI,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAC,GAAG,IAAI,CAO/C;AAED,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,EAAE,EACR,UAAU,KAAA,GACT;IAAC,MAAM,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GAAG,IAAI,CAkB3C"}
@@ -1,102 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
- import { GL } from '@luma.gl/constants';
5
- /** Check is uniform is of sampler type */
6
- export function isSamplerUniform(type) {
7
- return SAMPLER_TYPES.includes(type);
8
- }
9
- const SAMPLER_TYPES = [
10
- 35678,
11
- 35680,
12
- 35679,
13
- 35682,
14
- 36289,
15
- 36292,
16
- 36293,
17
- 36298,
18
- 36299,
19
- 36300,
20
- 36303,
21
- 36306,
22
- 36307,
23
- 36308,
24
- 36311
25
- ];
26
- // Composite types table
27
- const COMPOSITE_GL_TYPES = {
28
- [5126]: [5126, 1, 'float', 'f32', 'float32'],
29
- [35664]: [5126, 2, 'vec2', 'vec2<f32>', 'float32x2'],
30
- [35665]: [5126, 3, 'vec3', 'vec3<f32>', 'float32x3'],
31
- [35666]: [5126, 4, 'vec4', 'vec4<f32>', 'float32x4'],
32
- [5124]: [5124, 1, 'int', 'i32', 'sint32'],
33
- [35667]: [5124, 2, 'ivec2', 'vec2<i32>', 'sint32x2'],
34
- [35668]: [5124, 3, 'ivec3', 'vec3<i32>', 'sint32x3'],
35
- [35669]: [5124, 4, 'ivec4', 'vec4<i32>', 'sint32x4'],
36
- [5125]: [5125, 1, 'uint', 'u32', 'uint32'],
37
- [36294]: [5125, 2, 'uvec2', 'vec2<u32>', 'uint32x2'],
38
- [36295]: [5125, 3, 'uvec3', 'vec3<u32>', 'uint32x3'],
39
- [36296]: [5125, 4, 'uvec4', 'vec4<u32>', 'uint32x4'],
40
- [35670]: [5126, 1, 'bool', 'f32', 'float32'],
41
- [35671]: [5126, 2, 'bvec2', 'vec2<f32>', 'float32x2'],
42
- [35672]: [5126, 3, 'bvec3', 'vec3<f32>', 'float32x3'],
43
- [35673]: [5126, 4, 'bvec4', 'vec4<f32>', 'float32x4'],
44
- // TODO - are sizes/components below correct?
45
- [35674]: [5126, 8, 'mat2', 'mat2x2<f32>'], // 4
46
- [35685]: [5126, 8, 'mat2x3', 'mat2x3<f32>'], // 6
47
- [35686]: [5126, 8, 'mat2x4', 'mat2x4<f32>'], // 8
48
- [35687]: [5126, 12, 'mat3x2', 'mat3x2<f32>'], // 6
49
- [35675]: [5126, 12, 'mat3', 'mat3x3<f32>'], // 9
50
- [35688]: [5126, 12, 'mat3x4', 'mat3x4<f32>'], // 12
51
- [35689]: [5126, 16, 'mat4x2', 'mat4x2<f32>'], // 8
52
- [35690]: [5126, 16, 'mat4x3', 'mat4x3<f32>'], // 12
53
- [35676]: [5126, 16, 'mat4', 'mat4x4<f32>'] // 16
54
- };
55
- /** Decomposes a composite type (GL.VEC3) into a basic type (GL.FLOAT) and components (3) */
56
- export function decodeGLUniformType(glUniformType) {
57
- const typeAndSize = COMPOSITE_GL_TYPES[glUniformType];
58
- if (!typeAndSize) {
59
- throw new Error('uniform');
60
- }
61
- const [glType, components, , format] = typeAndSize;
62
- return { format, components, glType };
63
- }
64
- /** Decomposes a composite type (GL.VEC3) into a basic type (GL.FLOAT) and components (3) */
65
- export function decodeGLAttributeType(glAttributeType) {
66
- const typeAndSize = COMPOSITE_GL_TYPES[glAttributeType];
67
- if (!typeAndSize) {
68
- throw new Error('attribute');
69
- }
70
- const [, components, , shaderType, vertexFormat] = typeAndSize;
71
- // TODO sanity - if (shaderType.startsWith('mat' ...))
72
- const attributeType = shaderType;
73
- return { attributeType, vertexFormat, components }; // , glType};
74
- }
75
- /** Decomposes a composite type GL.VEC3 into a basic type (GL.FLOAT) and components (3) */
76
- export function decomposeCompositeGLDataType(compositeGLDataType) {
77
- const typeAndSize = COMPOSITE_GL_TYPES[compositeGLDataType];
78
- if (!typeAndSize) {
79
- return null;
80
- }
81
- const [type, components] = typeAndSize;
82
- return { type, components };
83
- }
84
- export function getCompositeGLDataType(type, components) {
85
- switch (type) {
86
- case 5120:
87
- case 5121:
88
- case 5122:
89
- case 5123:
90
- type = 5126;
91
- break;
92
- default:
93
- }
94
- for (const glType in COMPOSITE_GL_TYPES) {
95
- const [compType, compComponents, name] = COMPOSITE_GL_TYPES[glType];
96
- if (compType === type && compComponents === components) {
97
- return { glType: Number(glType), name };
98
- }
99
- }
100
- return null;
101
- }
102
- //# sourceMappingURL=decode-webgl-types.js.map