@luma.gl/webgl 9.0.0-beta.5 → 9.0.0-beta.6

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 (181) hide show
  1. package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
  2. package/dist/adapter/converters/device-parameters.js +71 -11
  3. package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
  4. package/dist/adapter/converters/sampler-parameters.js +3 -2
  5. package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
  6. package/dist/adapter/converters/shader-formats.js +40 -20
  7. package/dist/adapter/converters/texture-formats.d.ts +10 -7
  8. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  9. package/dist/adapter/converters/texture-formats.js +76 -64
  10. package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
  11. package/dist/adapter/converters/vertex-formats.js +2 -1
  12. package/dist/adapter/device-helpers/webgl-device-features.d.ts +18 -5
  13. package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
  14. package/dist/adapter/device-helpers/webgl-device-features.js +77 -43
  15. package/dist/adapter/device-helpers/webgl-device-info.d.ts +2 -1
  16. package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -1
  17. package/dist/adapter/device-helpers/webgl-device-info.js +17 -14
  18. package/dist/adapter/device-helpers/webgl-device-limits.d.ts +33 -48
  19. package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -1
  20. package/dist/adapter/device-helpers/webgl-device-limits.js +42 -87
  21. package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -1
  22. package/dist/adapter/helpers/decode-webgl-types.js +2 -1
  23. package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
  24. package/dist/adapter/helpers/get-shader-layout.js +6 -5
  25. package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
  26. package/dist/adapter/helpers/parse-shader-compiler-log.js +3 -2
  27. package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
  28. package/dist/adapter/helpers/set-uniform.js +2 -1
  29. package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
  30. package/dist/adapter/helpers/webgl-topology-utils.js +2 -1
  31. package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
  32. package/dist/adapter/objects/constants-to-keys.js +2 -1
  33. package/dist/adapter/objects/webgl-renderbuffer.d.ts +2 -2
  34. package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
  35. package/dist/adapter/objects/webgl-renderbuffer.js +24 -11
  36. package/dist/adapter/objects/webgl-resource.d.ts +2 -24
  37. package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
  38. package/dist/adapter/objects/webgl-resource.js +6 -100
  39. package/dist/adapter/resources/webgl-buffer.d.ts +1 -1
  40. package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
  41. package/dist/adapter/resources/webgl-buffer.js +2 -1
  42. package/dist/adapter/resources/webgl-command-buffer.d.ts +1 -1
  43. package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
  44. package/dist/adapter/resources/webgl-command-buffer.js +7 -6
  45. package/dist/adapter/resources/webgl-command-encoder.d.ts +8 -3
  46. package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
  47. package/dist/adapter/resources/webgl-command-encoder.js +4 -2
  48. package/dist/adapter/resources/webgl-external-texture.js +3 -2
  49. package/dist/adapter/resources/webgl-framebuffer.d.ts +6 -8
  50. package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
  51. package/dist/adapter/resources/webgl-framebuffer.js +25 -23
  52. package/dist/adapter/resources/webgl-query-set.d.ts +44 -0
  53. package/dist/adapter/resources/webgl-query-set.d.ts.map +1 -0
  54. package/dist/adapter/resources/webgl-query-set.js +136 -0
  55. package/dist/adapter/resources/webgl-render-pass.d.ts +3 -1
  56. package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
  57. package/dist/adapter/resources/webgl-render-pass.js +15 -7
  58. package/dist/adapter/resources/webgl-render-pipeline.d.ts +4 -5
  59. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  60. package/dist/adapter/resources/webgl-render-pipeline.js +34 -49
  61. package/dist/adapter/resources/webgl-sampler.d.ts +1 -1
  62. package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
  63. package/dist/adapter/resources/webgl-sampler.js +3 -2
  64. package/dist/adapter/resources/webgl-shader.d.ts +3 -2
  65. package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
  66. package/dist/adapter/resources/webgl-shader.js +12 -6
  67. package/dist/adapter/resources/webgl-texture-view.d.ts +14 -0
  68. package/dist/adapter/resources/webgl-texture-view.d.ts.map +1 -0
  69. package/dist/adapter/resources/webgl-texture-view.js +18 -0
  70. package/dist/adapter/resources/webgl-texture.d.ts +4 -3
  71. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  72. package/dist/adapter/resources/webgl-texture.js +12 -7
  73. package/dist/adapter/resources/webgl-transform-feedback.d.ts +1 -1
  74. package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
  75. package/dist/adapter/resources/webgl-transform-feedback.js +2 -2
  76. package/dist/adapter/resources/webgl-vertex-array.d.ts +3 -3
  77. package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
  78. package/dist/adapter/resources/webgl-vertex-array.js +5 -4
  79. package/dist/adapter/webgl-canvas-context.d.ts +2 -2
  80. package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
  81. package/dist/adapter/webgl-canvas-context.js +3 -2
  82. package/dist/adapter/webgl-device.d.ts +29 -27
  83. package/dist/adapter/webgl-device.d.ts.map +1 -1
  84. package/dist/adapter/webgl-device.js +90 -94
  85. package/dist/classic/accessor.d.ts.map +1 -1
  86. package/dist/classic/accessor.js +4 -3
  87. package/dist/classic/clear.d.ts.map +1 -1
  88. package/dist/classic/clear.js +3 -2
  89. package/dist/classic/copy-and-blit.d.ts +1 -1
  90. package/dist/classic/copy-and-blit.d.ts.map +1 -1
  91. package/dist/classic/copy-and-blit.js +5 -4
  92. package/dist/classic/format-utils.d.ts +2 -2
  93. package/dist/classic/format-utils.d.ts.map +1 -1
  94. package/dist/classic/format-utils.js +2 -1
  95. package/dist/classic/typed-array-utils.d.ts.map +1 -1
  96. package/dist/classic/typed-array-utils.js +2 -1
  97. package/dist/context/debug/spector.d.ts.map +1 -1
  98. package/dist/context/debug/spector.js +2 -1
  99. package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
  100. package/dist/context/debug/webgl-developer-tools.js +7 -6
  101. package/dist/context/helpers/create-browser-context.d.ts +35 -0
  102. package/dist/context/helpers/create-browser-context.d.ts.map +1 -0
  103. package/dist/context/helpers/create-browser-context.js +67 -0
  104. package/dist/context/helpers/webgl-context-data.d.ts +13 -0
  105. package/dist/context/helpers/webgl-context-data.d.ts.map +1 -0
  106. package/dist/context/helpers/webgl-context-data.js +21 -0
  107. package/dist/context/helpers/webgl-extensions.d.ts +4 -0
  108. package/dist/context/helpers/webgl-extensions.d.ts.map +1 -0
  109. package/dist/context/helpers/webgl-extensions.js +10 -0
  110. package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
  111. package/dist/context/parameters/unified-parameter-api.js +4 -3
  112. package/dist/context/parameters/webgl-parameter-tables.d.ts +10 -0
  113. package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
  114. package/dist/context/parameters/webgl-parameter-tables.js +29 -16
  115. package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
  116. package/dist/context/state-tracker/deep-array-equal.js +2 -1
  117. package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
  118. package/dist/context/state-tracker/track-context-state.js +5 -4
  119. package/dist/context/state-tracker/with-parameters.d.ts +1 -1
  120. package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
  121. package/dist/context/state-tracker/with-parameters.js +5 -4
  122. package/dist/dist.dev.js +941 -730
  123. package/dist/index.cjs +732 -565
  124. package/dist/index.cjs.map +4 -4
  125. package/dist/index.d.ts +25 -25
  126. package/dist/index.d.ts.map +1 -1
  127. package/dist/index.js +24 -23
  128. package/dist/types.d.ts.map +1 -1
  129. package/dist/types.js +2 -1
  130. package/dist.min.js +5 -5
  131. package/package.json +4 -4
  132. package/src/adapter/converters/device-parameters.ts +105 -16
  133. package/src/adapter/converters/sampler-parameters.ts +12 -3
  134. package/src/adapter/converters/shader-formats.ts +47 -22
  135. package/src/adapter/converters/texture-formats.ts +87 -66
  136. package/src/adapter/converters/vertex-formats.ts +3 -3
  137. package/src/adapter/device-helpers/webgl-device-features.ts +83 -51
  138. package/src/adapter/device-helpers/webgl-device-info.ts +28 -19
  139. package/src/adapter/device-helpers/webgl-device-limits.ts +46 -150
  140. package/src/adapter/helpers/decode-webgl-types.ts +13 -7
  141. package/src/adapter/helpers/get-shader-layout.ts +4 -3
  142. package/src/adapter/helpers/parse-shader-compiler-log.ts +10 -6
  143. package/src/adapter/helpers/set-uniform.ts +2 -1
  144. package/src/adapter/helpers/webgl-topology-utils.ts +10 -3
  145. package/src/adapter/objects/constants-to-keys.ts +2 -1
  146. package/src/adapter/objects/webgl-renderbuffer.ts +35 -13
  147. package/src/adapter/objects/webgl-resource.ts +6 -124
  148. package/src/adapter/resources/webgl-buffer.ts +4 -3
  149. package/src/adapter/resources/webgl-command-buffer.ts +5 -5
  150. package/src/adapter/resources/webgl-command-encoder.ts +14 -11
  151. package/src/adapter/resources/webgl-external-texture.ts +3 -2
  152. package/src/adapter/resources/webgl-framebuffer.ts +34 -29
  153. package/src/adapter/resources/webgl-query-set.ts +171 -0
  154. package/src/adapter/resources/webgl-render-pass.ts +17 -8
  155. package/src/adapter/resources/webgl-render-pipeline.ts +41 -48
  156. package/src/adapter/resources/webgl-sampler.ts +2 -1
  157. package/src/adapter/resources/webgl-shader.ts +12 -5
  158. package/src/adapter/resources/webgl-texture-view.ts +28 -0
  159. package/src/adapter/resources/webgl-texture.ts +9 -2
  160. package/src/adapter/resources/webgl-transform-feedback.ts +2 -7
  161. package/src/adapter/resources/webgl-vertex-array.ts +4 -3
  162. package/src/adapter/webgl-canvas-context.ts +6 -4
  163. package/src/adapter/webgl-device.ts +94 -90
  164. package/src/classic/accessor.ts +5 -4
  165. package/src/classic/clear.ts +12 -6
  166. package/src/classic/copy-and-blit.ts +11 -4
  167. package/src/classic/format-utils.ts +2 -1
  168. package/src/classic/typed-array-utils.ts +3 -7
  169. package/src/context/debug/spector.ts +9 -6
  170. package/src/context/debug/webgl-developer-tools.ts +27 -14
  171. package/src/context/{context → helpers}/create-browser-context.ts +3 -2
  172. package/src/context/helpers/webgl-context-data.ts +31 -0
  173. package/src/context/helpers/webgl-extensions.ts +17 -0
  174. package/src/context/parameters/unified-parameter-api.ts +2 -1
  175. package/src/context/parameters/webgl-parameter-tables.ts +69 -32
  176. package/src/context/state-tracker/deep-array-equal.ts +2 -1
  177. package/src/context/state-tracker/track-context-state.ts +11 -6
  178. package/src/context/state-tracker/with-parameters.ts +7 -2
  179. package/src/index.ts +3 -2
  180. package/src/types.ts +2 -1
  181. package/src/context/context/context-data.ts +0 -44
@@ -1,12 +1,14 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
  import { Texture, log, assert, loadImage, isObjectEmpty } from '@luma.gl/core';
4
5
  import { GL } from '@luma.gl/constants';
5
- import { withGLParameters } from '../../context/state-tracker/with-parameters';
6
- import { convertTextureFormatToGL, getWebGLTextureParameters, getTextureFormatBytesPerPixel } from '../converters/texture-formats';
7
- import { convertSamplerParametersToWebGL } from '../converters/sampler-parameters';
8
- import { WEBGLBuffer } from './webgl-buffer';
9
- import { WEBGLSampler } from './webgl-sampler';
6
+ import { withGLParameters } from "../../context/state-tracker/with-parameters.js";
7
+ import { convertTextureFormatToGL, getWebGLTextureParameters, getTextureFormatBytesPerPixel } from "../converters/texture-formats.js";
8
+ import { convertSamplerParametersToWebGL } from "../converters/sampler-parameters.js";
9
+ import { WEBGLBuffer } from "./webgl-buffer.js";
10
+ import { WEBGLSampler } from "./webgl-sampler.js";
11
+ import { WEBGLTextureView } from "./webgl-texture-view.js";
10
12
  export const DEFAULT_WEBGL_TEXTURE_PROPS = {
11
13
  // deprecated
12
14
  parameters: {},
@@ -32,8 +34,9 @@ export class WEBGLTexture extends Texture {
32
34
  device;
33
35
  gl;
34
36
  handle;
35
- /** Sampler object (currently unused) */
37
+ // (TODO - currently unused in WebGL, but WebGL 2 does support sampler objects) */
36
38
  sampler = undefined;
39
+ view = undefined;
37
40
  // data;
38
41
  glFormat = undefined;
39
42
  type = undefined;
@@ -158,6 +161,8 @@ export class WEBGLTexture extends Texture {
158
161
  // Set texture sampler parameters
159
162
  this.setSampler(props.sampler);
160
163
  this._setSamplerParameters(parameters);
164
+ // @ts-ignore
165
+ this.view = new WEBGLTextureView(this.device, { ...this.props, texture: this });
161
166
  if (mipmaps) {
162
167
  this.generateMipmap();
163
168
  }
@@ -1,6 +1,6 @@
1
1
  import type { PrimitiveTopology, ShaderLayout, TransformFeedbackProps } from '@luma.gl/core';
2
2
  import { TransformFeedback, Buffer, BufferRange } from '@luma.gl/core';
3
- import { WebGLDevice } from '../webgl-device';
3
+ import { WebGLDevice } from "../webgl-device.js";
4
4
  export declare class WEBGLTransformFeedback extends TransformFeedback {
5
5
  readonly device: WebGLDevice;
6
6
  readonly gl: WebGL2RenderingContext;
@@ -1 +1 @@
1
- {"version":3,"file":"webgl-transform-feedback.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-transform-feedback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAE,YAAY,EAAE,sBAAsB,EAAC,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAM,iBAAiB,EAAE,MAAM,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAE1E,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAI5C,qBAAa,sBAAuB,SAAQ,iBAAiB;IAC3D,QAAQ,CAAC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GAAG,MAAM,GAAG,WAAW,GAAG,IAAI;IAQvE,IAAI,CAAC,YAAY,yBAAc;IAqB/B,MAAM;IAMN,0CAA0C;IAC1C,SAAS,CAAC,eAAe,CACvB,aAAa,EAAE,MAAM,GAAG;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAC,GACjF,QAAQ,CAAC,WAAW,CAAC;IAWxB,SAAS,CAAC,gBAAgB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;IAcnE;;;OAGG;IACH,SAAS,CAAC,YAAY,IAAI,IAAI;IAO9B,SAAS,CAAC,cAAc,IAAI,IAAI;IAMhC,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,SAAI,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;CAQhG"}
@@ -1,7 +1,7 @@
1
1
  import { log, TransformFeedback } from '@luma.gl/core';
2
2
  import { GL } from '@luma.gl/constants';
3
- import { WEBGLBuffer } from '../..';
4
- import { getGLPrimitive } from '../helpers/webgl-topology-utils';
3
+ import { WEBGLBuffer } from "../../index.js";
4
+ import { getGLPrimitive } from "../helpers/webgl-topology-utils.js";
5
5
  export class WEBGLTransformFeedback extends TransformFeedback {
6
6
  device;
7
7
  gl;
@@ -1,7 +1,7 @@
1
1
  import type { Device, Buffer, VertexArrayProps, TypedArray } from '@luma.gl/core';
2
2
  import { VertexArray } from '@luma.gl/core';
3
3
  import { GL } from '@luma.gl/constants';
4
- import { WebGLDevice } from '../webgl-device';
4
+ import { WebGLDevice } from "../webgl-device.js";
5
5
  /** VertexArrayObject wrapper */
6
6
  export declare class WEBGLVertexArray extends VertexArray {
7
7
  get [Symbol.toStringTag](): string;
@@ -24,7 +24,7 @@ export declare class WEBGLVertexArray extends VertexArray {
24
24
  /** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */
25
25
  setBuffer(location: number, attributeBuffer: Buffer): void;
26
26
  /** Set a location in vertex attributes array to a constant value, disables the location */
27
- setConstant(location: number, value: TypedArray): void;
27
+ setConstantWebGL(location: number, value: TypedArray): void;
28
28
  init: boolean;
29
29
  bindBeforeRender(): void;
30
30
  unbindAfterRender(): void;
@@ -41,7 +41,7 @@ export declare class WEBGLVertexArray extends VertexArray {
41
41
  */
42
42
  /** Get an accessor from the */
43
43
  protected _getAccessor(location: number): {
44
- size: 1 | 2 | 4 | 3;
44
+ size: 1 | 2 | 3 | 4;
45
45
  type: GL.BYTE | GL.UNSIGNED_BYTE | GL.SHORT | GL.UNSIGNED_SHORT | GL.INT | GL.UNSIGNED_INT | GL.FLOAT | GL.HALF_FLOAT;
46
46
  stride: number;
47
47
  offset: number;
@@ -1 +1 @@
1
- {"version":3,"file":"webgl-vertex-array.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-vertex-array.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAc,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAC,WAAW,EAA6B,MAAM,eAAe,CAAC;AACtE,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAGtC,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAO5C,gCAAgC;AAChC,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAE1C;IAED,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC;IAExC,kCAAkC;IAClC,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,WAAW,CAAQ;IAE3B,6EAA6E;IAC7E,MAAM,CAAC,gCAAgC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;gBAKpD,MAAM,EAAE,WA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Q,CAAC,MAAM,EAAE,sBAAsB,CAAC;IAExC,kCAAkC;IAClC,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,WAAW,CAAQ;IAE3B,6EAA6E;IAC7E,MAAM,CAAC,gCAAgC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;gBAKpD,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,gBAAgB;IAMhD,OAAO,IAAI,IAAI;IAexB;;;;;OAKG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAgBhD,gGAAgG;IAChG,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,IAAI;IA6B1D,2FAA2F;IAClF,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI;IAKpE,IAAI,UAAS;IAEJ,gBAAgB,IAAI,IAAI;IAYxB,iBAAiB,IAAI,IAAI;IAUlC;;;;;OAKG;IACH,SAAS,CAAC,wBAAwB,IAAI,IAAI;IAU1C;;;OAGG;IAcH,gCAAgC;IAChC,SAAS,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;IAsBvC;;;;;OAKG;IACH,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,UAAO,GAAG,IAAI;IAiBxD;;;;;OAKG;IACH,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM;CA8BnE"}
@@ -1,9 +1,10 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
  import { VertexArray, getScratchArray, fillArray } from '@luma.gl/core';
4
5
  import { GL } from '@luma.gl/constants';
5
6
  import { getBrowser } from '@probe.gl/env';
6
- import { getGLFromVertexType } from '../converters/vertex-formats';
7
+ import { getGLFromVertexType } from "../converters/vertex-formats.js";
7
8
  // import {AccessorObject} from '../..';
8
9
  // import {getGLFromVertexType} from '../converters/vertex-formats';
9
10
  /** VertexArrayObject wrapper */
@@ -85,7 +86,7 @@ export class WEBGLVertexArray extends VertexArray {
85
86
  this.attributes[location] = buffer;
86
87
  }
87
88
  /** Set a location in vertex attributes array to a constant value, disables the location */
88
- setConstant(location, value) {
89
+ setConstantWebGL(location, value) {
89
90
  this._enable(location, false);
90
91
  this.attributes[location] = value;
91
92
  }
@@ -120,7 +121,7 @@ export class WEBGLVertexArray extends VertexArray {
120
121
  const constant = this.attributes[location];
121
122
  // A typed array means this is a constant
122
123
  if (ArrayBuffer.isView(constant)) {
123
- this.device.setConstantAttribute(location, constant);
124
+ this.device.setConstantAttributeWebGL(location, constant);
124
125
  }
125
126
  }
126
127
  }
@@ -1,7 +1,7 @@
1
1
  import type { CanvasContextProps } from '@luma.gl/core';
2
2
  import { CanvasContext } from '@luma.gl/core';
3
- import { WebGLDevice } from './webgl-device';
4
- import { WEBGLFramebuffer } from './resources/webgl-framebuffer';
3
+ import { WebGLDevice } from "./webgl-device.js";
4
+ import { WEBGLFramebuffer } from "./resources/webgl-framebuffer.js";
5
5
  /**
6
6
  * A WebGL Canvas Context which manages the canvas and handles drawing buffer resizing etc
7
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"webgl-canvas-context.d.ts","sourceRoot":"","sources":["../../src/adapter/webgl-canvas-context.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACtD,OAAO,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAE/D;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,aAAa;IACnD,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,OAAO,CAAC,YAAY,CAAiC;gBAEzC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,kBAAkB;IAS1D,qBAAqB,IAAI,gBAAgB;IAOzC,sDAAsD;IACtD,MAAM;IASN;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,OAAO,CAAC,EAAE;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;KAAC,GAAG,IAAI;IAW7F,MAAM;CAOP"}
1
+ {"version":3,"file":"webgl-canvas-context.d.ts","sourceRoot":"","sources":["../../src/adapter/webgl-canvas-context.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACtD,OAAO,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAC,WAAW,EAAC,0BAAuB;AAC3C,OAAO,EAAC,gBAAgB,EAAC,yCAAsC;AAE/D;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,aAAa;IACnD,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,OAAO,CAAC,YAAY,CAAiC;gBAEzC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,kBAAkB;IAS1D,qBAAqB,IAAI,gBAAgB;IAOzC,sDAAsD;IACtD,MAAM;IAUN;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,OAAO,CAAC,EAAE;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;KAAC,GAAG,IAAI;IAW7F,MAAM;CAOP"}
@@ -1,7 +1,8 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
  import { CanvasContext } from '@luma.gl/core';
4
- import { WEBGLFramebuffer } from './resources/webgl-framebuffer';
5
+ import { WEBGLFramebuffer } from "./resources/webgl-framebuffer.js";
5
6
  /**
6
7
  * A WebGL Canvas Context which manages the canvas and handles drawing buffer resizing etc
7
8
  */
@@ -1,33 +1,35 @@
1
- import type { DeviceProps, DeviceInfo, DeviceLimits, DeviceFeature, CanvasContextProps, TextureFormat, VertexArray, VertexArrayProps, Framebuffer, Buffer, Texture, TypedArray } from '@luma.gl/core';
1
+ import type { DeviceProps, DeviceInfo, CanvasContextProps, TextureFormat, VertexArray, VertexArrayProps, Framebuffer, Buffer, Texture, TypedArray } from '@luma.gl/core';
2
2
  import { Device, CanvasContext } from '@luma.gl/core';
3
- import { WebGLLimits } from './device-helpers/webgl-device-limits';
4
- import { WebGLCanvasContext } from './webgl-canvas-context';
5
- import type { BufferProps, ShaderProps, SamplerProps, TextureProps, ExternalTexture, ExternalTextureProps, FramebufferProps, RenderPipelineProps, ComputePipeline, ComputePipelineProps, RenderPassProps, ComputePass, ComputePassProps, CommandEncoderProps, TransformFeedbackProps } from '@luma.gl/core';
6
- import { WEBGLBuffer } from './resources/webgl-buffer';
7
- import { WEBGLShader } from './resources/webgl-shader';
8
- import { WEBGLSampler } from './resources/webgl-sampler';
9
- import { WEBGLTexture } from './resources/webgl-texture';
10
- import { WEBGLFramebuffer } from './resources/webgl-framebuffer';
11
- import { WEBGLRenderPass } from './resources/webgl-render-pass';
12
- import { WEBGLRenderPipeline } from './resources/webgl-render-pipeline';
13
- import { WEBGLCommandEncoder } from './resources/webgl-command-encoder';
14
- import { WEBGLTransformFeedback } from './resources/webgl-transform-feedback';
3
+ import type { GLExtensions } from '@luma.gl/constants';
4
+ import { WebGLDeviceFeatures } from "./device-helpers/webgl-device-features.js";
5
+ import { WebGLDeviceLimits } from "./device-helpers/webgl-device-limits.js";
6
+ import { WebGLCanvasContext } from "./webgl-canvas-context.js";
7
+ import type { BufferProps, ShaderProps, SamplerProps, TextureProps, ExternalTexture, ExternalTextureProps, FramebufferProps, RenderPipelineProps, ComputePipeline, ComputePipelineProps, RenderPassProps, ComputePass, ComputePassProps, CommandEncoderProps, TransformFeedbackProps, QuerySetProps } from '@luma.gl/core';
8
+ import { WEBGLBuffer } from "./resources/webgl-buffer.js";
9
+ import { WEBGLShader } from "./resources/webgl-shader.js";
10
+ import { WEBGLSampler } from "./resources/webgl-sampler.js";
11
+ import { WEBGLTexture } from "./resources/webgl-texture.js";
12
+ import { WEBGLFramebuffer } from "./resources/webgl-framebuffer.js";
13
+ import { WEBGLRenderPass } from "./resources/webgl-render-pass.js";
14
+ import { WEBGLRenderPipeline } from "./resources/webgl-render-pipeline.js";
15
+ import { WEBGLCommandEncoder } from "./resources/webgl-command-encoder.js";
16
+ import { WEBGLTransformFeedback } from "./resources/webgl-transform-feedback.js";
17
+ import { WEBGLQuerySet } from "./resources/webgl-query-set.js";
15
18
  /** WebGPU style Device API for a WebGL context */
16
19
  export declare class WebGLDevice extends Device {
17
20
  static type: string;
18
21
  static isSupported(): boolean;
22
+ /** The underlying WebGL context */
23
+ readonly handle: WebGL2RenderingContext;
24
+ features: WebGLDeviceFeatures;
25
+ limits: WebGLDeviceLimits;
19
26
  readonly info: DeviceInfo;
20
27
  readonly canvasContext: WebGLCanvasContext;
21
- readonly handle: WebGL2RenderingContext;
22
- get features(): Set<DeviceFeature>;
23
- get limits(): DeviceLimits;
24
28
  readonly lost: Promise<{
25
29
  reason: 'destroyed';
26
30
  message: string;
27
31
  }>;
28
32
  private _resolveContextLost?;
29
- private _features?;
30
- private _limits?;
31
33
  /**
32
34
  * Get a device instance from a GL context
33
35
  * Creates and instruments the device if not already created
@@ -39,7 +41,7 @@ export declare class WebGLDevice extends Device {
39
41
  constructor(props: DeviceProps);
40
42
  /**
41
43
  * Destroys the context
42
- * @note Has no effect for browser contexts, there is no browser API for destroying contexts
44
+ * @note Has no effect for WebGL browser contexts, there is no browser API for destroying contexts
43
45
  */
44
46
  destroy(): void;
45
47
  get isLost(): boolean;
@@ -54,12 +56,13 @@ export declare class WebGLDevice extends Device {
54
56
  createSampler(props: SamplerProps): WEBGLSampler;
55
57
  createShader(props: ShaderProps): WEBGLShader;
56
58
  createFramebuffer(props: FramebufferProps): WEBGLFramebuffer;
57
- createRenderPipeline(props: RenderPipelineProps): WEBGLRenderPipeline;
58
59
  createVertexArray(props: VertexArrayProps): VertexArray;
60
+ createTransformFeedback(props: TransformFeedbackProps): WEBGLTransformFeedback;
61
+ createQuerySet(props: QuerySetProps): WEBGLQuerySet;
62
+ createRenderPipeline(props: RenderPipelineProps): WEBGLRenderPipeline;
59
63
  beginRenderPass(props: RenderPassProps): WEBGLRenderPass;
60
64
  createComputePipeline(props?: ComputePipelineProps): ComputePipeline;
61
65
  beginComputePass(props: ComputePassProps): ComputePass;
62
- createTransformFeedback(props: TransformFeedbackProps): WEBGLTransformFeedback;
63
66
  private renderPass;
64
67
  getDefaultRenderPass(): WEBGLRenderPass;
65
68
  createCommandEncoder(props?: CommandEncoderProps): WEBGLCommandEncoder;
@@ -110,13 +113,10 @@ export declare class WebGLDevice extends Device {
110
113
  devicePixelRatio: number;
111
114
  };
112
115
  /** State used by luma.gl classes - TODO - not used? */
113
- readonly _extensions: Record<string, any>;
116
+ readonly _extensions: GLExtensions;
114
117
  _polyfilled: boolean;
115
118
  /** Instance of Spector.js (if initialized) */
116
- spector: any;
117
- private _webglLimits?;
118
- /** Return WebGL specific limits */
119
- get webglLimits(): WebGLLimits;
119
+ spectorJS: unknown;
120
120
  /**
121
121
  * Triggers device (or WebGL context) loss.
122
122
  * @note primarily intended for testing how application reacts to device loss
@@ -145,6 +145,8 @@ export declare class WebGLDevice extends Device {
145
145
  * so they need to be updated before every render
146
146
  * @todo - remember/cache values to avoid setting them unnecessarily?
147
147
  */
148
- setConstantAttribute(location: number, constant: TypedArray): void;
148
+ setConstantAttributeWebGL(location: number, constant: TypedArray): void;
149
+ /** Ensure extensions are only requested once */
150
+ getExtension(name: keyof GLExtensions): GLExtensions;
149
151
  }
150
152
  //# sourceMappingURL=webgl-device.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webgl-device.d.ts","sourceRoot":"","sources":["../../src/adapter/webgl-device.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,MAAM,EACN,OAAO,EACP,UAAU,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,MAAM,EAAE,aAAa,EAAmB,MAAM,eAAe,CAAC;AAUtE,OAAO,EAAkC,WAAW,EAAC,MAAM,sCAAsC,CAAC;AAClG,OAAO,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAU1D,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EAEX,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAEhB,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EAEpB,eAAe,EACf,WAAW,EACX,gBAAgB,EAEhB,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAC,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAC,mBAAmB,EAAC,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAC,mBAAmB,EAAC,MAAM,mCAAmC,CAAC;AAEtE,OAAO,EAAC,sBAAsB,EAAC,MAAM,sCA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OAAO,CAAC;IAEnB;;;OAGG;IACM,UAAU,IAAI,OAAO;IAgB9B,8DAA8D;IAC9D,SAAS,IAAI,IAAI;IAIjB,8CAA8C;IAC9C,QAAQ,IAAI,IAAI;IAIhB;;;OAGG;IACH,kBAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAMlE;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,sBAAsB,GAAG,MAAM;IAc7D,sBAAsB;IACtB,UAAU,EAAE,CAAC,UAAU,GAAG,IAAI,CAAC,EAAE,CAAC;IAElC;;;;;OAKG;IACH,yBAAyB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,IAAI;IA2BvE,gDAAgD;IAChD,YAAY,CAAC,IAAI,EAAE,MAAM,YAAY,GAAG,YAAY;CAIrD"}
@@ -1,30 +1,32 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
  import { Device, CanvasContext, log, uid, assert } from '@luma.gl/core';
4
- import { isBrowser } from '@probe.gl/env';
5
- import { popContextState, pushContextState, trackContextState } from '../context/state-tracker/track-context-state';
6
- import { createBrowserContext } from '../context/context/create-browser-context';
7
- import { getDeviceInfo } from './device-helpers/webgl-device-info';
8
- import { getDeviceFeatures } from './device-helpers/webgl-device-features';
9
- import { getDeviceLimits, getWebGLLimits } from './device-helpers/webgl-device-limits';
10
- import { WebGLCanvasContext } from './webgl-canvas-context';
11
- import { loadSpectorJS, initializeSpectorJS } from '../context/debug/spector';
12
- import { loadWebGLDeveloperTools, makeDebugContext } from '../context/debug/webgl-developer-tools';
13
- import { isTextureFormatSupported, isTextureFormatRenderable, isTextureFormatFilterable } from './converters/texture-formats';
14
- import { WEBGLBuffer } from './resources/webgl-buffer';
15
- import { WEBGLShader } from './resources/webgl-shader';
16
- import { WEBGLSampler } from './resources/webgl-sampler';
17
- import { WEBGLTexture } from './resources/webgl-texture';
18
- import { WEBGLFramebuffer } from './resources/webgl-framebuffer';
19
- import { WEBGLRenderPass } from './resources/webgl-render-pass';
20
- import { WEBGLRenderPipeline } from './resources/webgl-render-pipeline';
21
- import { WEBGLCommandEncoder } from './resources/webgl-command-encoder';
22
- import { WEBGLVertexArray } from './resources/webgl-vertex-array';
23
- import { WEBGLTransformFeedback } from './resources/webgl-transform-feedback';
24
- import { readPixelsToArray, readPixelsToBuffer } from '../classic/copy-and-blit';
25
- import { setGLParameters, getGLParameters } from '../context/parameters/unified-parameter-api';
26
- import { withGLParameters } from '../context/state-tracker/with-parameters';
27
- import { clear } from '../classic/clear';
5
+ import { popContextState, pushContextState, trackContextState } from "../context/state-tracker/track-context-state.js";
6
+ import { createBrowserContext } from "../context/helpers/create-browser-context.js";
7
+ import { getDeviceInfo } from "./device-helpers/webgl-device-info.js";
8
+ import { WebGLDeviceFeatures } from "./device-helpers/webgl-device-features.js";
9
+ import { WebGLDeviceLimits } from "./device-helpers/webgl-device-limits.js";
10
+ import { WebGLCanvasContext } from "./webgl-canvas-context.js";
11
+ import { loadSpectorJS, initializeSpectorJS } from "../context/debug/spector.js";
12
+ import { loadWebGLDeveloperTools, makeDebugContext } from "../context/debug/webgl-developer-tools.js";
13
+ import { isTextureFormatSupported, isTextureFormatRenderable, isTextureFormatFilterable } from "./converters/texture-formats.js";
14
+ import { WEBGLBuffer } from "./resources/webgl-buffer.js";
15
+ import { WEBGLShader } from "./resources/webgl-shader.js";
16
+ import { WEBGLSampler } from "./resources/webgl-sampler.js";
17
+ import { WEBGLTexture } from "./resources/webgl-texture.js";
18
+ import { WEBGLFramebuffer } from "./resources/webgl-framebuffer.js";
19
+ import { WEBGLRenderPass } from "./resources/webgl-render-pass.js";
20
+ import { WEBGLRenderPipeline } from "./resources/webgl-render-pipeline.js";
21
+ import { WEBGLCommandEncoder } from "./resources/webgl-command-encoder.js";
22
+ import { WEBGLVertexArray } from "./resources/webgl-vertex-array.js";
23
+ import { WEBGLTransformFeedback } from "./resources/webgl-transform-feedback.js";
24
+ import { WEBGLQuerySet } from "./resources/webgl-query-set.js";
25
+ import { readPixelsToArray, readPixelsToBuffer } from "../classic/copy-and-blit.js";
26
+ import { setGLParameters, getGLParameters } from "../context/parameters/unified-parameter-api.js";
27
+ import { withGLParameters } from "../context/state-tracker/with-parameters.js";
28
+ import { clear } from "../classic/clear.js";
29
+ import { getWebGLExtension } from "../context/helpers/webgl-extensions.js";
28
30
  const LOG_LEVEL = 1;
29
31
  /** WebGPU style Device API for a WebGL context */
30
32
  export class WebGLDevice extends Device {
@@ -35,21 +37,14 @@ export class WebGLDevice extends Device {
35
37
  static isSupported() {
36
38
  return typeof WebGL2RenderingContext !== 'undefined';
37
39
  }
40
+ /** The underlying WebGL context */
41
+ handle;
42
+ features;
43
+ limits;
38
44
  info;
39
45
  canvasContext;
40
- handle;
41
- get features() {
42
- this._features = this._features || getDeviceFeatures(this.gl);
43
- return this._features;
44
- }
45
- get limits() {
46
- this._limits = this._limits || getDeviceLimits(this.gl);
47
- return this._limits;
48
- }
49
46
  lost;
50
47
  _resolveContextLost;
51
- _features;
52
- _limits;
53
48
  //
54
49
  // Static methods, expected to be present by `luma.createDevice()`
55
50
  //
@@ -75,23 +70,25 @@ export class WebGLDevice extends Device {
75
70
  }
76
71
  static async create(props = {}) {
77
72
  log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created')();
78
- // Wait for page to load. Only wait when props. canvas is string
79
- // to avoid setting page onload callback unless necessary
80
- if (typeof props.canvas === 'string') {
81
- await CanvasContext.pageLoaded;
82
- }
73
+ const promises = [];
83
74
  // Load webgl and spector debug scripts from CDN if requested
84
- if (log.get('debug') || props.debug) {
85
- await loadWebGLDeveloperTools();
75
+ if (props.debug) {
76
+ promises.push(loadWebGLDeveloperTools());
86
77
  }
87
- // @ts-expect-error spector not on props
88
- const { spector } = props;
89
- if (log.get('spector') || spector) {
90
- await loadSpectorJS();
78
+ if (props.spector) {
79
+ promises.push(loadSpectorJS());
80
+ }
81
+ // Wait for page to load: if canvas is a string we need to query the DOM for the canvas element.
82
+ // We only wait when props.canvas is string to avoids setting the global page onload callback unless necessary.
83
+ if (typeof props.canvas === 'string') {
84
+ promises.push(CanvasContext.pageLoaded);
91
85
  }
86
+ // Wait for all the loads to settle before creating the context.
87
+ // The Device.create() functions are async, so in contrast to the constructor, we can `await` here.
88
+ await Promise.all(promises);
92
89
  log.probe(LOG_LEVEL + 1, 'DOM is loaded')();
93
90
  // @ts-expect-error
94
- if (props.gl && props.gl.device) {
91
+ if (props.gl?.device) {
95
92
  return WebGLDevice.attach(props.gl);
96
93
  }
97
94
  const device = new WebGLDevice(props);
@@ -116,33 +113,31 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
116
113
  throw new Error(`WebGL context already attached to device ${device.id}`);
117
114
  }
118
115
  // Create and instrument context
119
- const canvas = props.canvas || props.gl?.canvas;
116
+ const canvas = props.gl?.canvas || props.canvas;
120
117
  this.canvasContext = new WebGLCanvasContext(this, { ...props, canvas });
121
118
  this.lost = new Promise(resolve => {
122
119
  this._resolveContextLost = resolve;
123
120
  });
124
- const onContextLost = (event) => this._resolveContextLost?.({
125
- reason: 'destroyed',
126
- message: 'Computer entered sleep mode, or too many apps or browser tabs are using the GPU.'
127
- });
128
121
  let gl = props.gl || null;
129
- gl =
130
- gl ||
131
- (isBrowser()
132
- ? createBrowserContext(this.canvasContext.canvas, { ...props, onContextLost })
133
- : null);
122
+ gl ||= createBrowserContext(this.canvasContext.canvas, {
123
+ ...props,
124
+ onContextLost: (event) => this._resolveContextLost?.({
125
+ reason: 'destroyed',
126
+ message: 'Entered sleep mode, or too many apps or browser tabs are using the GPU.'
127
+ })
128
+ });
134
129
  if (!gl) {
135
130
  throw new Error('WebGL context creation failed');
136
131
  }
137
132
  this.handle = gl;
138
- this.gl = this.handle;
139
- this.canvasContext.resize();
133
+ this.gl = gl;
134
+ this.gl.device = this; // Update GL context: Link webgl context back to device
135
+ this.gl._version = 2; // Update GL context: Store WebGL version field on gl context (HACK to identify debug contexts)
140
136
  // luma Device fields
141
- this.info = getDeviceInfo(this.gl);
142
- // @ts-expect-error Link webgl context back to device
143
- this.gl.device = this;
144
- // @ts-expect-error Annotate webgl context to handle
145
- this.gl._version = this.isWebGL2 ? 2 : 1;
137
+ this.info = getDeviceInfo(this.gl, this._extensions);
138
+ this.features = new WebGLDeviceFeatures(this.gl, this._extensions);
139
+ this.limits = new WebGLDeviceLimits(this.gl);
140
+ this.canvasContext.resize();
146
141
  // Install context state tracking
147
142
  // @ts-expect-error - hidden parameters
148
143
  const { enable = true, copyState = false } = props;
@@ -152,24 +147,21 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
152
147
  log: (...args) => log.log(1, ...args)()
153
148
  });
154
149
  // DEBUG contexts: Add debug instrumentation to the context, force log level to at least 1
155
- if (isBrowser() && props.debug) {
150
+ if (props.debug) {
156
151
  this.gl = makeDebugContext(this.gl, { ...props, throwOnError: true });
157
152
  this.debug = true;
158
153
  log.level = Math.max(log.level, 1);
159
154
  log.warn('WebGL debug mode activated. Performance reduced.')();
160
155
  }
161
- // @ts-expect-error spector not on props
162
- if (isBrowser() && props.spector) {
163
- const canvas = this.handle.canvas || props.canvas;
164
- this.spector = initializeSpectorJS({ ...this.props, canvas });
156
+ if (props.spector) {
157
+ this.spectorJS = initializeSpectorJS({ ...this.props, canvas: this.handle.canvas });
165
158
  }
166
159
  }
167
160
  /**
168
161
  * Destroys the context
169
- * @note Has no effect for browser contexts, there is no browser API for destroying contexts
162
+ * @note Has no effect for WebGL browser contexts, there is no browser API for destroying contexts
170
163
  */
171
- destroy() {
172
- }
164
+ destroy() { }
173
165
  get isLost() {
174
166
  return this.gl.isContextLost();
175
167
  }
@@ -177,13 +169,13 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
177
169
  return [this.gl.drawingBufferWidth, this.gl.drawingBufferHeight];
178
170
  }
179
171
  isTextureFormatSupported(format) {
180
- return isTextureFormatSupported(this.gl, format);
172
+ return isTextureFormatSupported(this.gl, format, this._extensions);
181
173
  }
182
174
  isTextureFormatFilterable(format) {
183
- return isTextureFormatFilterable(this.gl, format);
175
+ return isTextureFormatFilterable(this.gl, format, this._extensions);
184
176
  }
185
177
  isTextureFormatRenderable(format) {
186
- return isTextureFormatRenderable(this.gl, format);
178
+ return isTextureFormatRenderable(this.gl, format, this._extensions);
187
179
  }
188
180
  // IMPLEMENTATION OF ABSTRACT DEVICE
189
181
  createCanvasContext(props) {
@@ -208,12 +200,18 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
208
200
  createFramebuffer(props) {
209
201
  return new WEBGLFramebuffer(this, props);
210
202
  }
211
- createRenderPipeline(props) {
212
- return new WEBGLRenderPipeline(this, props);
213
- }
214
203
  createVertexArray(props) {
215
204
  return new WEBGLVertexArray(this, props);
216
205
  }
206
+ createTransformFeedback(props) {
207
+ return new WEBGLTransformFeedback(this, props);
208
+ }
209
+ createQuerySet(props) {
210
+ return new WEBGLQuerySet(this, props);
211
+ }
212
+ createRenderPipeline(props) {
213
+ return new WEBGLRenderPipeline(this, props);
214
+ }
217
215
  beginRenderPass(props) {
218
216
  return new WEBGLRenderPass(this, props);
219
217
  }
@@ -223,9 +221,6 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
223
221
  beginComputePass(props) {
224
222
  throw new Error('ComputePass not supported in WebGL');
225
223
  }
226
- createTransformFeedback(props) {
227
- return new WEBGLTransformFeedback(this, props);
228
- }
229
224
  renderPass = null;
230
225
  getDefaultRenderPass() {
231
226
  this.renderPass =
@@ -250,7 +245,7 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
250
245
  }
251
246
  //
252
247
  // TEMPORARY HACKS - will be removed in v9.1
253
- //
248
+ //
254
249
  /** @deprecated - should use command encoder */
255
250
  readPixelsToArrayWebGL(source, options) {
256
251
  return readPixelsToArray(source, options);
@@ -283,20 +278,15 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
283
278
  _extensions = {};
284
279
  _polyfilled = false;
285
280
  /** Instance of Spector.js (if initialized) */
286
- spector;
287
- _webglLimits;
288
- /** Return WebGL specific limits */
289
- get webglLimits() {
290
- this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);
291
- return this._webglLimits;
292
- }
281
+ spectorJS;
293
282
  /**
294
283
  * Triggers device (or WebGL context) loss.
295
284
  * @note primarily intended for testing how application reacts to device loss
296
285
  */
297
286
  loseDevice() {
298
287
  let deviceLossTriggered = false;
299
- const ext = this.gl.getExtension('WEBGL_lose_context');
288
+ const extensions = this.getExtension('WEBGL_lose_context');
289
+ const ext = extensions.WEBGL_lose_context;
300
290
  if (ext) {
301
291
  deviceLossTriggered = true;
302
292
  ext.loseContext();
@@ -351,11 +341,12 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
351
341
  * so they need to be updated before every render
352
342
  * @todo - remember/cache values to avoid setting them unnecessarily?
353
343
  */
354
- setConstantAttribute(location, constant) {
355
- this._constants = this._constants || new Array(this.limits.maxVertexAttributes).fill(null);
344
+ setConstantAttributeWebGL(location, constant) {
345
+ const maxVertexAttributes = this.limits.maxVertexAttributes;
346
+ this._constants = this._constants || new Array(maxVertexAttributes).fill(null);
356
347
  const currentConstant = this._constants[location];
357
348
  if (currentConstant && compareConstantArrayValues(currentConstant, constant)) {
358
- log.info(1, `setConstantAttribute(${location}) could have been skipped, value unchanged`)();
349
+ log.info(1, `setConstantAttributeWebGL(${location}) could have been skipped, value unchanged`)();
359
350
  }
360
351
  this._constants[location] = constant;
361
352
  switch (constant.constructor) {
@@ -372,6 +363,11 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
372
363
  assert(false);
373
364
  }
374
365
  }
366
+ /** Ensure extensions are only requested once */
367
+ getExtension(name) {
368
+ getWebGLExtension(this.gl, name, this._extensions);
369
+ return this._extensions;
370
+ }
375
371
  }
376
372
  /** Check if supplied parameter is a WebGL2RenderingContext */
377
373
  function isWebGL(gl) {
@@ -1 +1 @@
1
- {"version":3,"file":"accessor.d.ts","sourceRoot":"","sources":["../../src/classic/accessor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqB,MAAM,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AACzE,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAGtC,QAAA,MAAM,uBAAuB;;;;;;;;CAQ5B,CAAC;AASF,qBAAa,QAAS,YAAW,cAAc;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,MAAM,CAAC,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,GAAG,MAAM;IAOtE,MAAM,CAAC,iBAAiB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM;IAY1D,MAAM,CAAC,OAAO,CAAC,GAAG,SAAS,EAAE,cAAc,EAAE,GAAG,QAAQ;gBAI5C,GAAG,SAAS,EAAE,cAAc,EAAE;IAK1C,QAAQ,IAAI,MAAM;IAOlB,IAAI,iBAAiB,IAAI,MAAM,CAE9B;IAED,IAAI,gBAAgB,IAAI,MAAM,CAE7B;IAKD,OAAO,CAAC,KAAK,GAAE,cAAmB,GAAG,IAAI;CA6E1C;AAGD,OAAO,EAAC,uBAAuB,EAAC,CAAC"}
1
+ {"version":3,"file":"accessor.d.ts","sourceRoot":"","sources":["../../src/classic/accessor.ts"],"names":[],"mappings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