@luma.gl/webgl 9.0.11 → 9.1.0-alpha.2

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 (123) hide show
  1. package/LICENSE +34 -0
  2. package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
  3. package/dist/adapter/converters/device-parameters.js +12 -1
  4. package/dist/adapter/converters/texture-formats.d.ts +22 -16
  5. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  6. package/dist/adapter/converters/texture-formats.js +31 -32
  7. package/dist/adapter/device-helpers/webgl-device-features.js +1 -1
  8. package/dist/adapter/device-helpers/webgl-device-limits.js +1 -1
  9. package/dist/adapter/helpers/webgl-texture-utils.d.ts +300 -0
  10. package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -0
  11. package/dist/adapter/helpers/webgl-texture-utils.js +368 -0
  12. package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
  13. package/dist/adapter/helpers/webgl-topology-utils.js +0 -4
  14. package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
  15. package/dist/adapter/resources/webgl-buffer.js +2 -2
  16. package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
  17. package/dist/adapter/resources/webgl-command-buffer.js +6 -9
  18. package/dist/adapter/resources/webgl-framebuffer.d.ts +32 -5
  19. package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
  20. package/dist/adapter/resources/webgl-framebuffer.js +42 -60
  21. package/dist/adapter/resources/webgl-render-pass.d.ts +3 -2
  22. package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
  23. package/dist/adapter/resources/webgl-render-pass.js +1 -3
  24. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  25. package/dist/adapter/resources/webgl-render-pipeline.js +45 -20
  26. package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
  27. package/dist/adapter/resources/webgl-shader.js +2 -2
  28. package/dist/adapter/resources/webgl-texture-view.d.ts +1 -1
  29. package/dist/adapter/resources/webgl-texture-view.d.ts.map +1 -1
  30. package/dist/adapter/resources/webgl-texture-view.js +1 -1
  31. package/dist/adapter/resources/webgl-texture.d.ts +58 -172
  32. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  33. package/dist/adapter/resources/webgl-texture.js +402 -510
  34. package/dist/adapter/resources/webgl-transform-feedback.js +1 -1
  35. package/dist/adapter/resources/webgl-vertex-array.d.ts +3 -2
  36. package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
  37. package/dist/adapter/resources/webgl-vertex-array.js +5 -2
  38. package/dist/adapter/webgl-canvas-context.d.ts +3 -1
  39. package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
  40. package/dist/adapter/webgl-canvas-context.js +2 -0
  41. package/dist/adapter/webgl-device.d.ts +4 -3
  42. package/dist/adapter/webgl-device.d.ts.map +1 -1
  43. package/dist/adapter/webgl-device.js +6 -5
  44. package/dist/classic/accessor.d.ts +22 -1
  45. package/dist/classic/accessor.d.ts.map +1 -1
  46. package/dist/classic/accessor.js +1 -9
  47. package/dist/classic/clear.d.ts.map +1 -1
  48. package/dist/classic/clear.js +2 -5
  49. package/dist/classic/copy-and-blit.d.ts +2 -1
  50. package/dist/classic/copy-and-blit.d.ts.map +1 -1
  51. package/dist/classic/copy-and-blit.js +11 -9
  52. package/dist/classic/format-utils.d.ts.map +1 -1
  53. package/dist/classic/format-utils.js +0 -3
  54. package/dist/classic/typed-array-utils.d.ts +1 -1
  55. package/dist/classic/typed-array-utils.d.ts.map +1 -1
  56. package/dist/context/debug/spector.d.ts.map +1 -1
  57. package/dist/context/debug/spector.js +2 -1
  58. package/dist/context/debug/webgl-developer-tools.d.ts +1 -1
  59. package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
  60. package/dist/context/debug/webgl-developer-tools.js +2 -5
  61. package/dist/context/parameters/webgl-parameter-tables.js +1 -1
  62. package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
  63. package/dist/context/state-tracker/track-context-state.js +5 -6
  64. package/dist/dist.dev.js +872 -1262
  65. package/dist/dist.min.js +2 -2
  66. package/dist/index.cjs +861 -1138
  67. package/dist/index.cjs.map +4 -4
  68. package/dist/index.d.ts +0 -4
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.js +0 -3
  71. package/dist/utils/fill-array.d.ts +8 -0
  72. package/dist/utils/fill-array.d.ts.map +1 -0
  73. package/dist/utils/fill-array.js +26 -0
  74. package/dist/utils/load-script.d.ts +8 -0
  75. package/dist/utils/load-script.d.ts.map +1 -0
  76. package/dist/utils/load-script.js +26 -0
  77. package/dist/utils/split-uniforms-and-bindings.d.ts +9 -0
  78. package/dist/utils/split-uniforms-and-bindings.d.ts.map +1 -0
  79. package/dist/utils/split-uniforms-and-bindings.js +20 -0
  80. package/package.json +6 -5
  81. package/src/adapter/converters/device-parameters.ts +13 -1
  82. package/src/adapter/converters/texture-formats.ts +45 -42
  83. package/src/adapter/device-helpers/webgl-device-features.ts +1 -1
  84. package/src/adapter/device-helpers/webgl-device-limits.ts +1 -1
  85. package/src/adapter/helpers/webgl-texture-utils.ts +481 -0
  86. package/src/adapter/helpers/webgl-topology-utils.ts +0 -4
  87. package/src/adapter/resources/webgl-buffer.ts +2 -2
  88. package/src/adapter/resources/webgl-command-buffer.ts +8 -10
  89. package/src/adapter/resources/webgl-framebuffer.ts +22 -56
  90. package/src/adapter/resources/webgl-render-pass.ts +4 -5
  91. package/src/adapter/resources/webgl-render-pipeline.ts +48 -23
  92. package/src/adapter/resources/webgl-shader.ts +3 -3
  93. package/src/adapter/resources/webgl-texture-view.ts +1 -3
  94. package/src/adapter/resources/webgl-texture.ts +432 -784
  95. package/src/adapter/resources/webgl-transform-feedback.ts +1 -1
  96. package/src/adapter/resources/webgl-vertex-array.ts +11 -7
  97. package/src/adapter/webgl-canvas-context.ts +4 -1
  98. package/src/adapter/webgl-device.ts +10 -18
  99. package/src/classic/accessor.ts +31 -11
  100. package/src/classic/clear.ts +3 -6
  101. package/src/classic/copy-and-blit.ts +19 -19
  102. package/src/classic/format-utils.ts +0 -3
  103. package/src/classic/typed-array-utils.ts +1 -1
  104. package/src/context/debug/spector.ts +2 -1
  105. package/src/context/debug/webgl-developer-tools.ts +3 -7
  106. package/src/context/parameters/webgl-parameter-tables.ts +3 -3
  107. package/src/context/state-tracker/track-context-state.ts +5 -6
  108. package/src/index.ts +0 -6
  109. package/src/utils/fill-array.ts +35 -0
  110. package/src/utils/load-script.ts +30 -0
  111. package/src/utils/split-uniforms-and-bindings.ts +31 -0
  112. package/dist/adapter/objects/constants-to-keys.d.ts +0 -3
  113. package/dist/adapter/objects/constants-to-keys.d.ts.map +0 -1
  114. package/dist/adapter/objects/constants-to-keys.js +0 -22
  115. package/dist/adapter/objects/webgl-renderbuffer.d.ts +0 -43
  116. package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +0 -1
  117. package/dist/adapter/objects/webgl-renderbuffer.js +0 -95
  118. package/dist/adapter/objects/webgl-resource.d.ts +0 -32
  119. package/dist/adapter/objects/webgl-resource.d.ts.map +0 -1
  120. package/dist/adapter/objects/webgl-resource.js +0 -114
  121. package/src/adapter/objects/constants-to-keys.ts +0 -27
  122. package/src/adapter/objects/webgl-renderbuffer.ts +0 -132
  123. package/src/adapter/objects/webgl-resource.ts +0 -183
package/LICENSE ADDED
@@ -0,0 +1,34 @@
1
+ luma.gl is provided under the MIT license
2
+
3
+ Copyright (c) 2020 vis.gl contributors
4
+
5
+ This software includes parts initially developed by Uber and open sourced under MIT license.
6
+ Copyright (c) 2015 Uber Technologies, Inc.
7
+
8
+ This software includes parts of PhiloGL (https://github.com/philogb/philogl)
9
+ under MIT license. PhiloGL parts Copyright © 2013 Sencha Labs.
10
+
11
+ This software includes adaptations of some postprocessing code from
12
+ THREE.js (https://github.com/mrdoob/three.js/) under MIT license.
13
+ THREE.js parts Copyright © 2010-2018 three.js authors.
14
+
15
+ Additional attribution given in specific source files.
16
+
17
+ Permission is hereby granted, free of charge, to any person obtaining a copy
18
+ of this software and associated documentation files (the "Software"), to deal
19
+ in the Software without restriction, including without limitation the rights
20
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
+ copies of the Software, and to permit persons to whom the Software is
22
+ furnished to do so, subject to the following conditions:
23
+
24
+ The above copyright notice and this permission notice shall be included in
25
+ all copies or substantial portions of the Software.
26
+
27
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
33
+ THE SOFTWARE.
34
+
@@ -1 +1 @@
1
- {"version":3,"file":"device-parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/device-parameters.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAgD,MAAM,eAAe,CAAC;AAClG,OAAO,EAAC,MAAM,EAAsB,UAAU,EAA+B,MAAM,eAAe,CAAC;AAEnG,OAAO,KAAK,EAGV,UAAU,EACV,YAAY,EAIb,MAAM,oBAAoB,CAAC;AAO5B;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,GAAG,OAAO,EACnD,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,GAC3B,CAAC,CAgBH;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,OAAO,EAC1C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,YAAY,EACxB,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,GAC3B,CAAC,CAeH;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,GAAG,OAAO,EAC9C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,GAC3B,CAAC,CAgBH;AAED,kCAAkC;AAClC,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,QAwMzE;AAyBD,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,UAAU,CAW5F;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,eAAe,CAW9F"}
1
+ {"version":3,"file":"device-parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/device-parameters.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAgD,MAAM,eAAe,CAAC;AAClG,OAAO,EAAC,MAAM,EAAO,UAAU,EAA+B,MAAM,eAAe,CAAC;AAEpF,OAAO,KAAK,EAGV,UAAU,EACV,YAAY,EAIb,MAAM,oBAAoB,CAAC;AAO5B;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,GAAG,OAAO,EACnD,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,GAC3B,CAAC,CAgBH;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,OAAO,EAC1C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,YAAY,EACxB,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,GAC3B,CAAC,CAeH;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,GAAG,OAAO,EAC9C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,GAC3B,CAAC,CAgBH;AAED,kCAAkC;AAClC,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,QAwMzE;AAyBD,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,UAAU,CAW5F;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,eAAe,CAW9F"}
@@ -1,7 +1,7 @@
1
1
  // luma.gl
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
- import { log, isObjectEmpty } from '@luma.gl/core';
4
+ import { log } from '@luma.gl/core';
5
5
  import { GL } from '@luma.gl/constants';
6
6
  import { pushContextState, popContextState } from "../../context/state-tracker/track-context-state.js";
7
7
  import { setGLParameters } from "../../context/parameters/unified-parameter-api.js";
@@ -328,3 +328,14 @@ function map(parameter, value, valueMap) {
328
328
  function mapBoolean(parameter, value) {
329
329
  return value;
330
330
  }
331
+ /** Returns true if given object is empty, false otherwise. */
332
+ function isObjectEmpty(obj) {
333
+ let isEmpty = true;
334
+ // @ts-ignore key is unused
335
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
336
+ for (const key in obj) {
337
+ isEmpty = false;
338
+ break;
339
+ }
340
+ return isEmpty;
341
+ }
@@ -1,5 +1,5 @@
1
1
  import type { TextureFormat, DeviceFeature } from '@luma.gl/core';
2
- import { GL, GLExtensions } from '@luma.gl/constants';
2
+ import { GL, GLPixelType, GLExtensions, GLTexelDataFormat } from '@luma.gl/constants';
3
3
  export declare const TEXTURE_FEATURES: Partial<Record<DeviceFeature, string[]>>;
4
4
  /** Return a list of texture feature strings (for Device.features). Mainly compressed texture support */
5
5
  export declare function isTextureFeature(feature: DeviceFeature): boolean;
@@ -27,8 +27,8 @@ type Format = {
27
27
  filter?: DeviceFeature;
28
28
  /** If not supported on WebGPU */
29
29
  wgpu?: false;
30
- types?: number[];
31
- dataFormat?: GL;
30
+ types?: GLPixelType[];
31
+ dataFormat?: GLTexelDataFormat;
32
32
  /** Depth and stencil format attachment points. If set, needs to be a Renderbuffer unless depthTexture is set */
33
33
  attachment?: GL.DEPTH_ATTACHMENT | GL.STENCIL_ATTACHMENT | GL.DEPTH_STENCIL_ATTACHMENT;
34
34
  /** if depthTexture is set this is a depth/stencil format that can be set to a texture */
@@ -44,14 +44,6 @@ export declare const TEXTURE_FORMATS: Record<TextureFormat, Format>;
44
44
  /** Checks if a texture format is supported */
45
45
  export declare function isTextureFormatSupported(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): boolean;
46
46
  export declare function isRenderbufferFormatSupported(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): boolean;
47
- /**
48
- * Map WebGL texture formats (GL constants) to WebGPU-style TextureFormat strings
49
- */
50
- export declare function convertGLToTextureFormat(format: GL | TextureFormat): TextureFormat;
51
- /**
52
- * Map WebGPU style texture format strings to GL constants
53
- */
54
- export declare function convertTextureFormatToGL(format: TextureFormat): GL | undefined;
55
47
  /** Checks if a texture format is supported */
56
48
  export declare function getTextureFormatSupport(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): {
57
49
  supported: boolean;
@@ -64,14 +56,28 @@ export declare function getTextureFormatSupport(gl: WebGL2RenderingContext, form
64
56
  export declare function isTextureFormatFilterable(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): boolean;
65
57
  export declare function isTextureFormatRenderable(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): boolean;
66
58
  /** Get parameters necessary to work with format in WebGL: internalFormat, dataFormat, type, compressed, */
67
- export declare function getWebGLTextureParameters(format: TextureFormat): {
68
- format: GL;
69
- dataFormat: GL;
70
- type: number;
71
- compressed: any;
59
+ export declare function getTextureFormatWebGL(format: TextureFormat): {
60
+ internalFormat: GL;
61
+ format: GLTexelDataFormat;
62
+ type: GLPixelType;
63
+ compressed: boolean;
72
64
  };
73
65
  export declare function getDepthStencilAttachmentWebGL(format: TextureFormat): GL.DEPTH_ATTACHMENT | GL.STENCIL_ATTACHMENT | GL.DEPTH_STENCIL_ATTACHMENT;
74
66
  /** TODO - VERY roundabout legacy way of calculating bytes per pixel */
75
67
  export declare function getTextureFormatBytesPerPixel(format: TextureFormat): number;
68
+ export declare function getWebGLPixelDataFormat(dataFormat: string, integer: boolean, normalized: boolean, format: GL): GLTexelDataFormat;
76
69
  export {};
70
+ /**
71
+ * Map WebGL texture formats (GL constants) to WebGPU-style TextureFormat strings
72
+ export function convertGLToTextureFormat(format: GL | TextureFormat): TextureFormat {
73
+ if (typeof format === 'string') {
74
+ return format;
75
+ }
76
+ const entry = Object.entries(TEXTURE_FORMATS).find(([, entry]) => entry.gl === format);
77
+ if (!entry) {
78
+ throw new Error(`Unknown texture format ${format}`);
79
+ }
80
+ return entry[0] as TextureFormat;
81
+ }
82
+ */
77
83
  //# sourceMappingURL=texture-formats.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"texture-formats.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/texture-formats.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAEhE,OAAO,EAAC,EAAE,EAAE,YAAY,EAAC,MAAM,oBAAoB,CAAC;AA2CpD,eAAO,MAAM,gBAAgB,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC,CAwBrE,CAAC;AAEF,wGAAwG;AASxG,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAEhE;AAED,wFAAwF;AACxF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E,EAAE,sBAAsB,EAC1B,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,YAAY,GACvB,OAAO,CAGT;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,EAAE,GAAG,aAAa,GAAG,aAAa,CASlF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,aAAa,GAAG,EAAE,GAAG,SAAS,CAO9E;AAED,8CAA8C;AAC9C,wBAAgB,uBAAuB,CACrC,EAAE,EAAE,sBAAsB,EAC1B,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,YAAY,GACvB;IACD,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CA6BA;AAED,uGAAuG;AACvG,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,sBAAsB,EAC1B,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,YAAY,GACvB,OAAO,CAsBT;AAED,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,sBAAsB,EAC1B,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,YAAY,GACvB,OAAO,CAST;AAED,2GAA2G;AAC3G,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,aAAa;;;;;EAgB9D;AAED,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,aAAa,GACpB,EAAE,CAAC,gBAAgB,GAAG,EAAE,CAAC,kBAAkB,GAAG,EAAE,CAAC,wBAAwB,CAM3E;AAED,uEAAuE;AACvE,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAO3E"}
1
+ {"version":3,"file":"texture-formats.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/texture-formats.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,E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,GAAG,EAAE,CAAC,kBAAkB,GAAG,EAAE,CAAC,wBAAwB,CAM3E;AAED,uEAAuE;AACvE,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAO3E;AAID,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,OAAO,EACnB,MAAM,EAAE,EAAE,GACT,iBAAiB,CAanB;;AAcD;;;;;;;;;;;;GAYG"}
@@ -123,7 +123,6 @@ export const TEXTURE_FORMATS = {
123
123
  'bgra8unorm-srgb': { b: 4, c: 4 },
124
124
  'rg16uint': { gl: 33338, b: 4, c: 1, bpp: 4 },
125
125
  'rg16sint': { gl: 33337, b: 4, c: 2, bpp: 4 },
126
- // When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
127
126
  'rg16float': { gl: 33327, bpp: 4, b: 4, c: 2, render: float16_renderable, filter: float16_filterable, rb: true },
128
127
  'rg16unorm-webgl': { gl: 33324, b: 2, c: 2, render: norm16_renderable },
129
128
  'rg16snorm-webgl': { gl: 36761, b: 2, c: 2, render: snorm16_renderable },
@@ -380,31 +379,7 @@ export function isTextureFormatSupported(gl, format, extensions) {
380
379
  }
381
380
  export function isRenderbufferFormatSupported(gl, format, extensions) {
382
381
  // Note: Order is important since the function call initializes extensions.
383
- return isTextureFormatSupported(gl, format, extensions) && TEXTURE_FORMATS[format]?.rb;
384
- }
385
- /**
386
- * Map WebGL texture formats (GL constants) to WebGPU-style TextureFormat strings
387
- */
388
- export function convertGLToTextureFormat(format) {
389
- if (typeof format === 'string') {
390
- return format;
391
- }
392
- const entry = Object.entries(TEXTURE_FORMATS).find(([, entry]) => entry.gl === format);
393
- if (!entry) {
394
- throw new Error(`Unknown texture format ${format}`);
395
- }
396
- return entry[0];
397
- }
398
- /**
399
- * Map WebGPU style texture format strings to GL constants
400
- */
401
- export function convertTextureFormatToGL(format) {
402
- const formatInfo = TEXTURE_FORMATS[format];
403
- const webglFormat = formatInfo?.gl;
404
- if (webglFormat === undefined) {
405
- throw new Error(`Unsupported texture format ${format}`);
406
- }
407
- return webglFormat;
382
+ return isTextureFormatSupported(gl, format, extensions) && Boolean(TEXTURE_FORMATS[format]?.rb);
408
383
  }
409
384
  /** Checks if a texture format is supported */
410
385
  export function getTextureFormatSupport(gl, format, extensions) {
@@ -470,13 +445,13 @@ export function isTextureFormatRenderable(gl, format, extensions) {
470
445
  return true;
471
446
  }
472
447
  /** Get parameters necessary to work with format in WebGL: internalFormat, dataFormat, type, compressed, */
473
- export function getWebGLTextureParameters(format) {
448
+ export function getTextureFormatWebGL(format) {
474
449
  const formatData = TEXTURE_FORMATS[format];
475
450
  const webglFormat = convertTextureFormatToGL(format);
476
451
  const decoded = decodeTextureFormat(format);
477
452
  return {
478
- format: webglFormat,
479
- dataFormat: formatData?.dataFormat ||
453
+ internalFormat: webglFormat,
454
+ format: formatData?.dataFormat ||
480
455
  getWebGLPixelDataFormat(decoded.format, decoded.integer, decoded.normalized, webglFormat),
481
456
  // depth formats don't have a type
482
457
  type: decoded.dataType
@@ -496,14 +471,14 @@ export function getDepthStencilAttachmentWebGL(format) {
496
471
  /** TODO - VERY roundabout legacy way of calculating bytes per pixel */
497
472
  export function getTextureFormatBytesPerPixel(format) {
498
473
  // TODO remove webgl1 support
499
- const params = getWebGLTextureParameters(format);
474
+ const params = getTextureFormatWebGL(format);
500
475
  // NOTE(Tarek): Default to RGBA bytes
501
- const channels = DATA_FORMAT_CHANNELS[params.dataFormat] || 4;
476
+ const channels = DATA_FORMAT_CHANNELS[params.format] || 4;
502
477
  const channelSize = TYPE_SIZES[params.type] || 1;
503
478
  return channels * channelSize;
504
479
  }
505
480
  // DATA TYPE HELPERS
506
- function getWebGLPixelDataFormat(dataFormat, integer, normalized, format) {
481
+ export function getWebGLPixelDataFormat(dataFormat, integer, normalized, format) {
507
482
  // WebGL1 formats use same internalFormat
508
483
  if (format === 6408 || format === 6407) {
509
484
  return format;
@@ -517,3 +492,27 @@ function getWebGLPixelDataFormat(dataFormat, integer, normalized, format) {
517
492
  default: return 6408;
518
493
  }
519
494
  }
495
+ /**
496
+ * Map WebGPU style texture format strings to GL constants
497
+ */
498
+ function convertTextureFormatToGL(format) {
499
+ const formatInfo = TEXTURE_FORMATS[format];
500
+ const webglFormat = formatInfo?.gl;
501
+ if (webglFormat === undefined) {
502
+ throw new Error(`Unsupported texture format ${format}`);
503
+ }
504
+ return webglFormat;
505
+ }
506
+ /**
507
+ * Map WebGL texture formats (GL constants) to WebGPU-style TextureFormat strings
508
+ export function convertGLToTextureFormat(format: GL | TextureFormat): TextureFormat {
509
+ if (typeof format === 'string') {
510
+ return format;
511
+ }
512
+ const entry = Object.entries(TEXTURE_FORMATS).find(([, entry]) => entry.gl === format);
513
+ if (!entry) {
514
+ throw new Error(`Unknown texture format ${format}`);
515
+ }
516
+ return entry[0] as TextureFormat;
517
+ }
518
+ */
@@ -57,7 +57,7 @@ export class WebGLDeviceFeatures extends DeviceFeatures {
57
57
  return [];
58
58
  }
59
59
  has(feature) {
60
- if (this.disabledFeatures[feature]) {
60
+ if (this.disabledFeatures?.[feature]) {
61
61
  return false;
62
62
  }
63
63
  // We have already tested this feature
@@ -42,6 +42,6 @@ export class WebGLDeviceLimits extends DeviceLimits {
42
42
  if (this.limits[parameter] === undefined) {
43
43
  this.limits[parameter] = this.gl.getParameter(parameter);
44
44
  }
45
- return this.limits[parameter];
45
+ return this.limits[parameter] || 0;
46
46
  }
47
47
  }
@@ -0,0 +1,300 @@
1
+ import type { ExternalImage } from '@luma.gl/core';
2
+ import { GL, GLTextureTarget, GLTexelDataFormat, GLPixelType } from '@luma.gl/constants';
3
+ import { TypedArray } from '@math.gl/types';
4
+ export type WebGLSetTextureOptions = {
5
+ dimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';
6
+ height: number;
7
+ width: number;
8
+ depth?: number;
9
+ level?: number;
10
+ glTarget: GLTextureTarget;
11
+ glInternalFormat: GL;
12
+ glFormat: GLTexelDataFormat;
13
+ glType: GLPixelType;
14
+ compressed?: boolean;
15
+ byteOffset?: number;
16
+ byteLength?: number;
17
+ };
18
+ /**
19
+ * @param {*} pixels, data -
20
+ * null - create empty texture of specified format
21
+ * Typed array - init from image data in typed array
22
+ * Buffer|WebGLBuffer - (WEBGL2) init from image data in WebGLBuffer
23
+ * HTMLImageElement|Image - Inits with content of image. Auto width/height
24
+ * HTMLCanvasElement - Inits with contents of canvas. Auto width/height
25
+ * HTMLVideoElement - Creates video texture. Auto width/height
26
+ *
27
+ * @param x - xOffset from where texture to be updated
28
+ * @param y - yOffset from where texture to be updated
29
+ * @param width - width of the sub image to be updated
30
+ * @param height - height of the sub image to be updated
31
+ * @param level - mip level to be updated
32
+ * @param {GLenum} format - internal format of image data.
33
+ * @param {GLenum} type
34
+ * - format of array (autodetect from type) or
35
+ * - (WEBGL2) format of buffer or ArrayBufferView
36
+ * @param {GLenum} dataFormat - format of image data.
37
+ * @param {Number} offset - (WEBGL2) offset from start of buffer
38
+ * @parameters - temporary settings to be applied, can be used to supply pixel store settings.
39
+ */
40
+ export type WebGLCopyTextureOptions = {
41
+ dimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';
42
+ level?: number;
43
+ height: number;
44
+ width: number;
45
+ depth?: number;
46
+ x?: number;
47
+ y?: number;
48
+ z?: number;
49
+ glTarget: GLTextureTarget;
50
+ glInternalFormat: GL;
51
+ glFormat: GL;
52
+ glType: GL;
53
+ compressed?: boolean;
54
+ byteOffset?: number;
55
+ byteLength?: number;
56
+ };
57
+ /**
58
+ * Initializes a texture memory space
59
+ * Clear all the textures and mip levels of a two-dimensional or array texture at the same time.
60
+ * On some implementations faster than repeatedly setting levels
61
+ *
62
+ * @note From WebGL 2 spec section 3.7.6:
63
+ * @see https://registry.khronos.org/webgl/specs/latest/2.0/
64
+ * - The image contents are set as if a buffer of sufficient size initialized to 0 would be passed to each level's texImage2D/3D
65
+ * - texStorage2D should be considered a preferred alternative to texImage2D. It may have lower memory costs than texImage2D in some implementations.
66
+ * - Once texStorage*D has been called, the texture is immutable and can only be updated with texSubImage*(), not texImage()
67
+ */
68
+ export declare function initializeTextureStorage(gl: WebGL2RenderingContext, levels: number, options: WebGLSetTextureOptions): void;
69
+ /**
70
+ * Copy a region of compressed data from a GPU memory buffer into this texture.
71
+ */
72
+ export declare function copyCPUImageToMipLevel(gl: WebGL2RenderingContext, image: ExternalImage, options: WebGLCopyTextureOptions): void;
73
+ /**
74
+ * Copy a region of data from a CPU memory buffer into this texture.
75
+ */
76
+ export declare function copyCPUDataToMipLevel(gl: WebGL2RenderingContext, typedArray: TypedArray, options: WebGLCopyTextureOptions): void;
77
+ /**
78
+ * Copy a region of compressed data from a GPU memory buffer into this texture.
79
+ */
80
+ export declare function copyGPUBufferToMipLevel(gl: WebGL2RenderingContext, webglBuffer: WebGLBuffer, byteLength: number, options: WebGLCopyTextureOptions): void;
81
+ /** Convert a WebGPU style texture constant to a WebGL style texture constant */
82
+ export declare function getWebGLTextureTarget(dimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d'): GLTextureTarget;
83
+ /**
84
+ * Clear a texture mip level.
85
+ * Wrapper for the messy WebGL texture API
86
+ *
87
+ export function clearMipLevel(gl: WebGL2RenderingContext, options: WebGLSetTextureOptions): void {
88
+ const {dimension, width, height, depth = 0, level = 0} = options;
89
+ const {glInternalFormat, glFormat, glType, compressed} = options;
90
+ const glTarget = getCubeTargetWebGL(options.glTarget, dimension, depth);
91
+
92
+ switch (dimension) {
93
+ case '2d-array':
94
+ case '3d':
95
+ if (compressed) {
96
+ // prettier-ignore
97
+ gl.compressedTexImage3D(glTarget, level, glInternalFormat, width, height, depth, BORDER, null);
98
+ } else {
99
+ // prettier-ignore
100
+ gl.texImage3D( glTarget, level, glInternalFormat, width, height, depth, BORDER, glFormat, glType, null);
101
+ }
102
+ break;
103
+
104
+ case '2d':
105
+ case 'cube':
106
+ if (compressed) {
107
+ // prettier-ignore
108
+ gl.compressedTexImage2D(glTarget, level, glInternalFormat, width, height, BORDER, null);
109
+ } else {
110
+ // prettier-ignore
111
+ gl.texImage2D(glTarget, level, glInternalFormat, width, height, BORDER, glFormat, glType, null);
112
+ }
113
+ break;
114
+
115
+ default:
116
+ throw new Error(dimension);
117
+ }
118
+ }
119
+
120
+ /**
121
+ * Set a texture mip level to the contents of an external image.
122
+ * Wrapper for the messy WebGL texture API
123
+ * @note Corresponds to WebGPU device.queue.copyExternalImageToTexture()
124
+ *
125
+ export function setMipLevelFromExternalImage(
126
+ gl: WebGL2RenderingContext,
127
+ image: ExternalImage,
128
+ options: WebGLSetTextureOptions
129
+ ): void {
130
+ const {dimension, width, height, depth = 0, level = 0} = options;
131
+ const {glInternalFormat, glType} = options;
132
+
133
+ const glTarget = getCubeTargetWebGL(options.glTarget, dimension, depth);
134
+
135
+ // TODO - we can't change texture width (due to WebGPU limitations) -
136
+ // and the width/heigh of an external image is implicit, so why do we need to extract it?
137
+ // So what width height do we supply? The image size or the texture size?
138
+ // const {width, height} = Texture.getExternalImageSize(image);
139
+
140
+ switch (dimension) {
141
+ case '2d-array':
142
+ case '3d':
143
+ // prettier-ignore
144
+ gl.texImage3D(glTarget, level, glInternalFormat, width, height, depth, BORDER, glInternalFormat, glType, image);
145
+ break;
146
+
147
+ case '2d':
148
+ case 'cube':
149
+ // prettier-ignore
150
+ gl.texImage2D(glTarget, level, glInternalFormat, width, height, BORDER, glInternalFormat, glType, image);
151
+ break;
152
+
153
+ default:
154
+ throw new Error(dimension);
155
+ }
156
+ }
157
+
158
+ /**
159
+ * Set a texture mip level from CPU memory
160
+ * Wrapper for the messy WebGL texture API
161
+ * @note Not available (directly) in WebGPU
162
+ *
163
+ export function setMipLevelFromTypedArray(
164
+ gl: WebGL2RenderingContext,
165
+ data: TypedArray,
166
+ parameters: {},
167
+ options: {
168
+ dimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';
169
+ height: number;
170
+ width: number;
171
+ depth?: number;
172
+ level?: number;
173
+ offset?: number;
174
+ glTarget: GLTextureTarget;
175
+ glInternalFormat: GL;
176
+ glFormat: GL;
177
+ glType: GL;
178
+ compressed?: boolean;
179
+ }
180
+ ): void {
181
+ const {dimension, width, height, depth = 0, level = 0, offset = 0} = options;
182
+ const {glInternalFormat, glFormat, glType, compressed} = options;
183
+
184
+ const glTarget = getCubeTargetWebGL(options.glTarget, dimension, depth);
185
+
186
+ withGLParameters(gl, parameters, () => {
187
+ switch (dimension) {
188
+ case '2d-array':
189
+ case '3d':
190
+ if (compressed) {
191
+ // prettier-ignore
192
+ gl.compressedTexImage3D(glTarget, level, glInternalFormat, width, height, depth, BORDER, data);
193
+ } else {
194
+ // prettier-ignore
195
+ gl.texImage3D( glTarget, level, glInternalFormat, width, height, depth, BORDER, glFormat, glType, data);
196
+ }
197
+ break;
198
+
199
+ case '2d':
200
+ if (compressed) {
201
+ // prettier-ignore
202
+ gl.compressedTexImage2D(glTarget, level, glInternalFormat, width, height, BORDER, data);
203
+ } else {
204
+ // prettier-ignore
205
+ gl.texImage2D( glTarget, level, glInternalFormat, width, height, BORDER, glFormat, glType, data, offset);
206
+ }
207
+ break;
208
+
209
+ default:
210
+ throw new Error(dimension);
211
+ }
212
+ });
213
+ }
214
+
215
+ /**
216
+ * Set a texture level from CPU memory
217
+ * @note Not available (directly) in WebGPU
218
+ _setMipLevelFromTypedArray(
219
+ depth: number,
220
+ level: number,
221
+ data: TextureLevelData,
222
+ offset = 0,
223
+ parameters
224
+ ): void {
225
+ withGLParameters(this.gl, parameters, () => {
226
+ switch (this.props.dimension) {
227
+ case '2d-array':
228
+ case '3d':
229
+ if (this.compressed) {
230
+ // prettier-ignore
231
+ this.device.gl.compressedTexImage3D(this.glTarget, level, this.glInternalFormat, data.width, data.height, depth, BORDER, data.data);
232
+ } else {
233
+ // prettier-ignore
234
+ this.gl.texImage3D( this.glTarget, level, this.glInternalFormat, this.width, this.height, depth, BORDER, this.glFormat, this.glType, data.data);
235
+ }
236
+ break;
237
+
238
+ case '2d':
239
+ if (this.compressed) {
240
+ // prettier-ignore
241
+ this.device.gl.compressedTexImage2D(this.glTarget, level, this.glInternalFormat, data.width, data.height, BORDER, data.data);
242
+ } else {
243
+ // prettier-ignore
244
+ this.device.gl.texImage2D( this.glTarget, level, this.glInternalFormat, this.width, this.height, BORDER, this.glFormat, this.glType, data.data, offset);
245
+ }
246
+ break;
247
+
248
+ default:
249
+ throw new Error(this.props.dimension);
250
+ }
251
+ });
252
+ }
253
+
254
+ * Set a texture level from a GPU buffer
255
+ *
256
+ export function setMipLevelFromGPUBuffer(
257
+ gl: WebGL2RenderingContext,
258
+ buffer: Buffer,
259
+ options: WebGLSetTextureOptions
260
+ ): void {
261
+ const {dimension, width, height, depth = 0, level = 0, byteOffset = 0} = options;
262
+ const {glInternalFormat, glFormat, glType, compressed} = options;
263
+ const glTarget = getCubeTargetWebGL(options.glTarget, dimension, depth);
264
+
265
+ const webglBuffer = buffer as WEBGLBuffer;
266
+ const imageSize = buffer.byteLength;
267
+
268
+ // In WebGL the source buffer is not a parameter. Instead it needs to be bound to a special bind point
269
+ gl.bindBuffer(GL.PIXEL_UNPACK_BUFFER, webglBuffer.handle);
270
+
271
+ switch (dimension) {
272
+ case '2d-array':
273
+ case '3d':
274
+ if (compressed) {
275
+ // prettier-ignore
276
+ gl.compressedTexImage3D(glTarget, level, glInternalFormat, width, height, depth, BORDER, imageSize, byteOffset);
277
+ } else {
278
+ // prettier-ignore
279
+ gl.texImage3D(glTarget, level, glInternalFormat, width, height, depth, BORDER, glFormat, glType, byteOffset);
280
+ }
281
+ break;
282
+
283
+ case '2d':
284
+ if (compressed) {
285
+ // prettier-ignore
286
+ gl.compressedTexImage2D(glTarget, level, glInternalFormat, width, height, BORDER, imageSize, byteOffset);
287
+ } else {
288
+ // prettier-ignore
289
+ gl.texImage2D(glTarget, level, glInternalFormat, width, height, BORDER, glFormat, glType, byteOffset);
290
+ }
291
+ break;
292
+
293
+ default:
294
+ throw new Error(dimension);
295
+ }
296
+
297
+ gl.bindBuffer(GL.PIXEL_UNPACK_BUFFER, null);
298
+ }
299
+ */
300
+ //# sourceMappingURL=webgl-texture-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webgl-texture-utils.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/webgl-texture-utils.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;AAEjD,OAAO,EACL,EAAE,EACF,eAAe,EAEf,iBAAiB,EACjB,WAAW,EACZ,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAK1C,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,IAAI,GAAG,IAAI,GAAG,UAAU,GAAG,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,eAAe,CAAC;IAC1B,gBAAgB,EAAE,EAAE,CAAC;IACrB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,MAAM,EAAE,WAAW,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,SAAS,EAAE,IAAI,GAAG,IAAI,GAAG,UAAU,GAAG,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,CAAC,CAAC,EAAE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