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

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 (192) hide show
  1. package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
  2. package/dist/adapter/converters/device-parameters.js +128 -71
  3. package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
  4. package/dist/adapter/converters/sampler-parameters.js +20 -19
  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 +16 -11
  8. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  9. package/dist/adapter/converters/texture-formats.js +224 -205
  10. package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
  11. package/dist/adapter/converters/vertex-formats.js +22 -21
  12. package/dist/adapter/device-helpers/webgl-device-features.d.ts +19 -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 +89 -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 +22 -19
  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 +47 -46
  23. package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
  24. package/dist/adapter/helpers/get-shader-layout.js +35 -34
  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 +42 -41
  29. package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
  30. package/dist/adapter/helpers/webgl-topology-utils.js +40 -39
  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 +30 -17
  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 -101
  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 +16 -15
  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 +32 -31
  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 +6 -5
  49. package/dist/adapter/resources/webgl-framebuffer.d.ts +6 -10
  50. package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
  51. package/dist/adapter/resources/webgl-framebuffer.js +60 -53
  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 +20 -12
  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 +52 -61
  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 +5 -4
  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 +15 -9
  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 +6 -4
  71. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  72. package/dist/adapter/resources/webgl-texture.js +39 -32
  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 +10 -10
  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 +10 -9
  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 +35 -30
  83. package/dist/adapter/webgl-device.d.ts.map +1 -1
  84. package/dist/adapter/webgl-device.js +110 -109
  85. package/dist/classic/accessor.d.ts.map +1 -1
  86. package/dist/classic/accessor.js +8 -7
  87. package/dist/classic/clear.d.ts.map +1 -1
  88. package/dist/classic/clear.js +5 -4
  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 +19 -19
  92. package/dist/classic/format-utils.d.ts.map +1 -1
  93. package/dist/classic/format-utils.js +16 -15
  94. package/dist/classic/typed-array-utils.d.ts.map +1 -1
  95. package/dist/classic/typed-array-utils.js +20 -19
  96. package/dist/context/debug/spector.d.ts.map +1 -1
  97. package/dist/context/debug/spector.js +2 -1
  98. package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
  99. package/dist/context/debug/webgl-developer-tools.js +7 -6
  100. package/dist/context/{context → helpers}/create-browser-context.d.ts.map +1 -1
  101. package/dist/context/{context → helpers}/create-browser-context.js +2 -1
  102. package/dist/context/{context/context-data.d.ts → helpers/webgl-context-data.d.ts} +2 -3
  103. package/dist/context/helpers/webgl-context-data.d.ts.map +1 -0
  104. package/dist/context/helpers/webgl-context-data.js +21 -0
  105. package/dist/context/helpers/webgl-extensions.d.ts +4 -0
  106. package/dist/context/helpers/webgl-extensions.d.ts.map +1 -0
  107. package/dist/context/helpers/webgl-extensions.js +10 -0
  108. package/dist/context/parameters/unified-parameter-api.d.ts +3 -4
  109. package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
  110. package/dist/context/parameters/unified-parameter-api.js +7 -11
  111. package/dist/context/parameters/webgl-parameter-tables.d.ts +12 -13
  112. package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
  113. package/dist/context/parameters/webgl-parameter-tables.js +302 -295
  114. package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
  115. package/dist/context/state-tracker/deep-array-equal.js +2 -1
  116. package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
  117. package/dist/context/state-tracker/track-context-state.js +5 -4
  118. package/dist/context/state-tracker/with-parameters.d.ts +2 -3
  119. package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
  120. package/dist/context/state-tracker/with-parameters.js +6 -8
  121. package/dist/dist.dev.js +1635 -1387
  122. package/dist/index.cjs +1766 -1534
  123. package/dist/index.cjs.map +4 -4
  124. package/dist/index.d.ts +25 -25
  125. package/dist/index.d.ts.map +1 -1
  126. package/dist/index.js +24 -23
  127. package/dist/types.d.ts.map +1 -1
  128. package/dist/types.js +2 -1
  129. package/dist.min.js +6 -6
  130. package/package.json +4 -4
  131. package/src/adapter/converters/device-parameters.ts +114 -27
  132. package/src/adapter/converters/sampler-parameters.ts +12 -3
  133. package/src/adapter/converters/shader-formats.ts +47 -22
  134. package/src/adapter/converters/texture-formats.ts +138 -114
  135. package/src/adapter/converters/vertex-formats.ts +3 -3
  136. package/src/adapter/device-helpers/webgl-device-features.ts +102 -50
  137. package/src/adapter/device-helpers/webgl-device-info.ts +28 -19
  138. package/src/adapter/device-helpers/webgl-device-limits.ts +46 -150
  139. package/src/adapter/helpers/decode-webgl-types.ts +13 -7
  140. package/src/adapter/helpers/get-shader-layout.ts +4 -3
  141. package/src/adapter/helpers/parse-shader-compiler-log.ts +10 -6
  142. package/src/adapter/helpers/set-uniform.ts +2 -1
  143. package/src/adapter/helpers/webgl-topology-utils.ts +10 -3
  144. package/src/adapter/objects/constants-to-keys.ts +2 -1
  145. package/src/adapter/objects/webgl-renderbuffer.ts +36 -14
  146. package/src/adapter/objects/webgl-resource.ts +7 -125
  147. package/src/adapter/resources/webgl-buffer.ts +4 -3
  148. package/src/adapter/resources/webgl-command-buffer.ts +5 -5
  149. package/src/adapter/resources/webgl-command-encoder.ts +14 -11
  150. package/src/adapter/resources/webgl-external-texture.ts +6 -5
  151. package/src/adapter/resources/webgl-framebuffer.ts +61 -53
  152. package/src/adapter/resources/webgl-query-set.ts +171 -0
  153. package/src/adapter/resources/webgl-render-pass.ts +20 -11
  154. package/src/adapter/resources/webgl-render-pipeline.ts +54 -54
  155. package/src/adapter/resources/webgl-sampler.ts +2 -1
  156. package/src/adapter/resources/webgl-shader.ts +12 -5
  157. package/src/adapter/resources/webgl-texture-view.ts +28 -0
  158. package/src/adapter/resources/webgl-texture.ts +14 -3
  159. package/src/adapter/resources/webgl-transform-feedback.ts +2 -7
  160. package/src/adapter/resources/webgl-vertex-array.ts +4 -3
  161. package/src/adapter/webgl-canvas-context.ts +6 -4
  162. package/src/adapter/webgl-device.ts +116 -107
  163. package/src/classic/accessor.ts +5 -4
  164. package/src/classic/clear.ts +14 -8
  165. package/src/classic/copy-and-blit.ts +11 -4
  166. package/src/classic/format-utils.ts +2 -1
  167. package/src/classic/typed-array-utils.ts +3 -7
  168. package/src/context/debug/spector.ts +9 -6
  169. package/src/context/debug/webgl-developer-tools.ts +27 -14
  170. package/src/context/{context → helpers}/create-browser-context.ts +3 -2
  171. package/src/context/helpers/webgl-context-data.ts +31 -0
  172. package/src/context/helpers/webgl-extensions.ts +17 -0
  173. package/src/context/parameters/unified-parameter-api.ts +6 -17
  174. package/src/context/parameters/webgl-parameter-tables.ts +69 -32
  175. package/src/context/state-tracker/deep-array-equal.ts +2 -1
  176. package/src/context/state-tracker/track-context-state.ts +11 -6
  177. package/src/context/state-tracker/with-parameters.ts +8 -8
  178. package/src/index.ts +7 -6
  179. package/src/types.ts +2 -1
  180. package/dist/adapter/device-helpers/device-features.d.ts +0 -6
  181. package/dist/adapter/device-helpers/device-features.d.ts.map +0 -1
  182. package/dist/adapter/device-helpers/device-features.js +0 -65
  183. package/dist/adapter/device-helpers/device-limits.d.ts +0 -50
  184. package/dist/adapter/device-helpers/device-limits.d.ts.map +0 -1
  185. package/dist/adapter/device-helpers/device-limits.js +0 -92
  186. package/dist/adapter/device-helpers/get-device-info.d.ts +0 -4
  187. package/dist/adapter/device-helpers/get-device-info.d.ts.map +0 -1
  188. package/dist/adapter/device-helpers/get-device-info.js +0 -87
  189. package/dist/context/context/context-data.d.ts.map +0 -1
  190. package/dist/context/context/context-data.js +0 -33
  191. package/src/context/context/context-data.ts +0 -44
  192. /package/dist/context/{context → helpers}/create-browser-context.d.ts +0 -0
@@ -1,8 +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 { decodeTextureFormat } from '@luma.gl/core';
4
5
  import { GL } from '@luma.gl/constants';
5
- import { getGLFromVertexType } from './vertex-formats';
6
+ import { getWebGLExtension } from "../../context/helpers/webgl-extensions.js";
7
+ import { getGLFromVertexType } from "./vertex-formats.js";
6
8
  /* eslint-disable camelcase */
7
9
  // TEXTURE FEATURES
8
10
  // Define local device feature strings to optimize minification
@@ -12,8 +14,14 @@ const texture_compression_etc2 = 'texture-compression-etc2';
12
14
  const texture_compression_etc1_webgl = 'texture-compression-etc1-webgl';
13
15
  const texture_compression_pvrtc_webgl = 'texture-compression-pvrtc-webgl';
14
16
  const texture_compression_atc_webgl = 'texture-compression-atc-webgl';
15
- // const float32_renderable_webgl: DeviceFeature = 'float32-renderable-webgl';
16
- // const float16_renderable_webgl: DeviceFeature = 'float16-renderable-webgl';
17
+ const float32_renderable = 'float32-renderable-webgl';
18
+ const float16_renderable = 'float16-renderable-webgl';
19
+ const rgb9e5ufloat_renderable = 'rgb9e5ufloat_renderable-webgl';
20
+ const snorm8_renderable = 'snorm8-renderable-webgl';
21
+ const norm16_renderable = 'norm16-renderable-webgl';
22
+ const snorm16_renderable = 'snorm16-renderable-webgl';
23
+ const float32_filterable = 'float32-filterable';
24
+ const float16_filterable = 'float16-filterable-webgl';
17
25
  // Define local webgl extension strings to optimize minification
18
26
  const X_S3TC = 'WEBGL_compressed_texture_s3tc'; // BC1, BC2, BC3
19
27
  const X_S3TC_SRGB = 'WEBGL_compressed_texture_s3tc_srgb'; // BC1, BC2, BC3
@@ -25,19 +33,19 @@ const X_ETC1 = 'WEBGL_compressed_texture_etc1';
25
33
  const X_PVRTC = 'WEBGL_compressed_texture_pvrtc';
26
34
  const X_ATC = 'WEBGL_compressed_texture_atc';
27
35
  // Define local webgl extension strings to optimize minification
28
- const EXT_TEXTURE_NORM16 = 'EXT_texture_norm16';
29
- const EXT_FLOAT_RENDER_WEBGL2 = 'EXT_color_buffer_float';
30
- // const EXT_HALF_FLOAT_WEBGL1 = 'EXT_color_buffer_half_float';
31
- // const DEPTH = 'WEBGL_depth_texture';
32
- // WebGL1-only extensions
33
- // const EXT_SRGB = 'EXT_sRGB'; // https://developer.mozilla.org/en-US/docs/Web/API/EXT_sRGB
36
+ const EXT_texture_norm16 = 'EXT_texture_norm16';
37
+ const EXT_render_snorm = 'EXT_render_snorm';
38
+ const EXT_color_buffer_float = 'EXT_color_buffer_float';
34
39
  // prettier-ignore
35
- const TEXTURE_FEATURE_CHECKS = {
36
- 'float32-renderable-webgl': ['EXT_color_buffer_float'], // [false, 'EXT_color_buffer_float'],
40
+ export const TEXTURE_FEATURES = {
41
+ 'float32-renderable-webgl': ['EXT_color_buffer_float'],
37
42
  'float16-renderable-webgl': ['EXT_color_buffer_half_float'],
38
- 'norm16-renderable-webgl': [EXT_TEXTURE_NORM16],
39
- 'float32-filterable-linear-webgl': ['OES_texture_float_linear'],
40
- 'float16-filterable-linear-webgl': ['OES_texture_half_float_linear'],
43
+ 'rgb9e5ufloat_renderable-webgl': ['WEBGL_render_shared_exponent'],
44
+ 'snorm8-renderable-webgl': [EXT_render_snorm],
45
+ 'norm16-renderable-webgl': [EXT_texture_norm16],
46
+ 'snorm16-renderable-webgl': [EXT_texture_norm16, EXT_render_snorm],
47
+ 'float32-filterable': ['OES_texture_float_linear'],
48
+ 'float16-filterable-webgl': ['OES_texture_half_float_linear'],
41
49
  'texture-filterable-anisotropic-webgl': ['EXT_texture_filter_anisotropic'],
42
50
  'texture-blend-float-webgl': ['EXT_float_blend'],
43
51
  'texture-compression-bc': [X_S3TC, X_S3TC_SRGB, X_RGTC, X_BPTC],
@@ -51,17 +59,21 @@ const TEXTURE_FEATURE_CHECKS = {
51
59
  'texture-compression-pvrtc-webgl': [X_PVRTC],
52
60
  'texture-compression-atc-webgl': [X_ATC]
53
61
  };
54
- function checkTextureFeature(gl, feature) {
55
- const extensions = TEXTURE_FEATURE_CHECKS[feature] || [];
56
- return extensions.every(extension => gl.getExtension(extension));
57
- }
58
- function checkTextureFeatures(gl, features) {
59
- return features.every(feature => checkTextureFeature(gl, feature));
60
- }
61
62
  /** Return a list of texture feature strings (for Device.features). Mainly compressed texture support */
62
- export function getTextureFeatures(gl) {
63
- const textureFeatures = Object.keys(TEXTURE_FEATURE_CHECKS);
64
- return textureFeatures.filter(feature => checkTextureFeature(gl, feature));
63
+ // export function getTextureFeatures(
64
+ // gl: WebGL2RenderingContext,
65
+ // extensions: GLExtensions
66
+ // ): DeviceFeature[] {
67
+ // const textureFeatures = Object.keys(TEXTURE_FEATURES) as DeviceFeature[];
68
+ // return textureFeatures.filter(feature => checkTextureFeature(gl, feature, extensions));
69
+ // }
70
+ export function isTextureFeature(feature) {
71
+ return feature in TEXTURE_FEATURES;
72
+ }
73
+ /** Checks a texture feature (for Device.features). Mainly compressed texture support */
74
+ export function checkTextureFeature(gl, feature, extensions) {
75
+ const textureExtensions = TEXTURE_FEATURES[feature] || [];
76
+ return textureExtensions.every(extension => getWebGLExtension(gl, extension, extensions));
65
77
  }
66
78
  // TABLES
67
79
  /**
@@ -70,159 +82,164 @@ export function getTextureFeatures(gl) {
70
82
  */
71
83
  // prettier-ignore
72
84
  export const TEXTURE_FORMATS = {
73
- // Unsized formats that leave the precision up to the driver.
74
- // TODO - Fix bpp constants
85
+ // Unsized formats that leave the precision up to the driver. TODO - Fix bpp constants
86
+ 'rgb8unorm-unsized': { gl: 6407, b: 4, c: 2, bpp: 4,
87
+ dataFormat: 6407, types: [5121, 33635] },
88
+ 'rgba8unorm-unsized': { gl: 6408, b: 4, c: 2, bpp: 4,
89
+ dataFormat: 6408, types: [5121, 32819, 32820] },
75
90
  // 'r8unorm-unsized': {gl: GL.LUMINANCE, b: 4, c: 2, bpp: 4},
76
- 'rgb8unorm-unsized': { gl: GL.RGB, b: 4, c: 2, bpp: 4,
77
- dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_6_5] },
78
- 'rgba8unorm-unsized': { gl: GL.RGBA, b: 4, c: 2, bpp: 4,
79
- dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_4_4_4_4, GL.UNSIGNED_SHORT_5_5_5_1] },
80
91
  // 'rgb8unorm-srgb-unsized': {gl: GL.SRGB_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
81
92
  // 'rgba8unorm-srgb-unsized': {gl: GL.SRGB_ALPHA_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
82
93
  // 8-bit formats
83
- 'r8unorm': { gl: GL.R8, b: 1, c: 1, renderbuffer: true },
84
- 'r8snorm': { gl: GL.R8_SNORM, b: 1, c: 1 },
85
- 'r8uint': { gl: GL.R8UI, b: 1, c: 1, renderbuffer: true },
86
- 'r8sint': { gl: GL.R8I, b: 1, c: 1, renderbuffer: true },
94
+ 'r8unorm': { gl: 33321, b: 1, c: 1, rb: true },
95
+ 'r8snorm': { gl: 36756, b: 1, c: 1, render: snorm8_renderable },
96
+ 'r8uint': { gl: 33330, b: 1, c: 1, rb: true },
97
+ 'r8sint': { gl: 33329, b: 1, c: 1, rb: true },
87
98
  // 16-bit formats
88
- 'rg8unorm': { gl: GL.RG8, b: 2, c: 2, renderbuffer: true },
89
- 'rg8snorm': { gl: GL.RG8_SNORM, b: 2, c: 2 },
90
- 'rg8uint': { gl: GL.RG8UI, b: 2, c: 2, renderbuffer: true },
91
- 'rg8sint': { gl: GL.RG8I, b: 2, c: 2, renderbuffer: true },
92
- 'r16uint': { gl: GL.R16UI, b: 2, c: 1, renderbuffer: true },
93
- 'r16sint': { gl: GL.R16I, b: 2, c: 1, renderbuffer: true },
94
- 'r16float': { gl: GL.R16F, b: 2, c: 1, render: 'float16-renderable-webgl', filter: 'float16-filterable-linear-webgl', renderbuffer: true },
95
- 'r16unorm-webgl': { gl: GL.R16_EXT, b: 2, c: 1, f: 'norm16-renderable-webgl', renderbuffer: true, x: EXT_TEXTURE_NORM16 },
96
- 'r16snorm-webgl': { gl: GL.R16_SNORM_EXT, b: 2, c: 1, f: 'norm16-renderable-webgl', x: EXT_TEXTURE_NORM16 },
99
+ 'rg8unorm': { gl: 33323, b: 2, c: 2, rb: true },
100
+ 'rg8snorm': { gl: 36757, b: 2, c: 2, render: snorm8_renderable },
101
+ 'rg8uint': { gl: 33336, b: 2, c: 2, rb: true },
102
+ 'rg8sint': { gl: 33335, b: 2, c: 2, rb: true },
103
+ 'r16uint': { gl: 33332, b: 2, c: 1, rb: true },
104
+ 'r16sint': { gl: 33331, b: 2, c: 1, rb: true },
105
+ 'r16float': { gl: 33325, b: 2, c: 1, render: float16_renderable, filter: 'float16-filterable-webgl', rb: true },
106
+ 'r16unorm-webgl': { gl: 33322, b: 2, c: 1, f: norm16_renderable, rb: true },
107
+ 'r16snorm-webgl': { gl: 36760, b: 2, c: 1, f: snorm16_renderable },
97
108
  // Packed 16-bit formats
98
- 'rgba4unorm-webgl': { gl: GL.RGBA4, b: 2, c: 4, wgpu: false, renderbuffer: true },
99
- 'rgb565unorm-webgl': { gl: GL.RGB565, b: 2, c: 4, wgpu: false, renderbuffer: true },
100
- 'rgb5a1unorm-webgl': { gl: GL.RGB5_A1, b: 2, c: 4, wgpu: false, renderbuffer: true },
109
+ 'rgba4unorm-webgl': { gl: 32854, b: 2, c: 4, wgpu: false, rb: true },
110
+ 'rgb565unorm-webgl': { gl: 36194, b: 2, c: 4, wgpu: false, rb: true },
111
+ 'rgb5a1unorm-webgl': { gl: 32855, b: 2, c: 4, wgpu: false, rb: true },
101
112
  // 24-bit formats
102
- 'rgb8unorm-webgl': { gl: GL.RGB8, b: 3, c: 3, wgpu: false },
103
- 'rgb8snorm-webgl': { gl: GL.RGB8_SNORM, b: 3, c: 3, wgpu: false },
113
+ 'rgb8unorm-webgl': { gl: 32849, b: 3, c: 3, wgpu: false },
114
+ 'rgb8snorm-webgl': { gl: 36758, b: 3, c: 3, wgpu: false },
104
115
  // 32-bit formats
105
- 'rgba8unorm': { gl: GL.RGBA8, b: 4, c: 2, bpp: 4 },
106
- 'rgba8unorm-srgb': { gl: GL.SRGB8_ALPHA8, b: 4, c: 4, bpp: 4 },
107
- 'rgba8snorm': { gl: GL.RGBA8_SNORM, b: 4, c: 4 },
108
- 'rgba8uint': { gl: GL.RGBA8UI, b: 4, c: 4, bpp: 4 },
109
- 'rgba8sint': { gl: GL.RGBA8I, b: 4, c: 4, bpp: 4 },
116
+ 'rgba8unorm': { gl: 32856, b: 4, c: 2, bpp: 4 },
117
+ 'rgba8unorm-srgb': { gl: 35907, b: 4, c: 4, bpp: 4 },
118
+ 'rgba8snorm': { gl: 36759, b: 4, c: 4, render: snorm8_renderable },
119
+ 'rgba8uint': { gl: 36220, b: 4, c: 4, bpp: 4 },
120
+ 'rgba8sint': { gl: 36238, b: 4, c: 4, bpp: 4 },
110
121
  // reverse colors, webgpu only
111
122
  'bgra8unorm': { b: 4, c: 4 },
112
123
  'bgra8unorm-srgb': { b: 4, c: 4 },
113
- 'rg16uint': { gl: GL.RG16UI, b: 4, c: 1, bpp: 4 },
114
- 'rg16sint': { gl: GL.RG16I, b: 4, c: 2, bpp: 4 },
124
+ 'rg16uint': { gl: 33338, b: 4, c: 1, bpp: 4 },
125
+ 'rg16sint': { gl: 33337, b: 4, c: 2, bpp: 4 },
115
126
  // When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
116
- 'rg16float': { gl: GL.RG16F, bpp: 4, b: 4, c: 2, render: 'float16-renderable-webgl', filter: 'float16-filterable-linear-webgl', renderbuffer: true },
117
- 'rg16unorm-webgl': { gl: GL.RG16_EXT, b: 2, c: 2, f: 'norm16-renderable-webgl', x: EXT_TEXTURE_NORM16 },
118
- 'rg16snorm-webgl': { gl: GL.RG16_SNORM_EXT, b: 2, c: 2, f: 'norm16-renderable-webgl', x: EXT_TEXTURE_NORM16 },
119
- 'r32uint': { gl: GL.R32UI, b: 4, c: 1, bpp: 4, renderbuffer: true },
120
- 'r32sint': { gl: GL.R32I, b: 4, c: 1, bpp: 4, renderbuffer: true },
121
- 'r32float': { gl: GL.R32F, bpp: 4, b: 4, c: 1, render: 'float32-renderable-webgl', filter: 'float32-filterable-linear-webgl' },
127
+ 'rg16float': { gl: 33327, bpp: 4, b: 4, c: 2, render: float16_renderable, filter: float16_filterable, rb: true },
128
+ 'rg16unorm-webgl': { gl: 33324, b: 2, c: 2, render: norm16_renderable },
129
+ 'rg16snorm-webgl': { gl: 36761, b: 2, c: 2, render: snorm16_renderable },
130
+ 'r32uint': { gl: 33334, b: 4, c: 1, bpp: 4, rb: true },
131
+ 'r32sint': { gl: 33333, b: 4, c: 1, bpp: 4, rb: true },
132
+ 'r32float': { gl: 33326, bpp: 4, b: 4, c: 1, render: float32_renderable, filter: float32_filterable },
122
133
  // Packed 32-bit formats
123
- 'rgb9e5ufloat': { gl: GL.RGB9_E5, b: 4, c: 3, p: 1, render: 'float16-renderable-webgl', filter: 'float16-filterable-linear-webgl' },
124
- 'rg11b10ufloat': { gl: GL.R11F_G11F_B10F, b: 4, c: 3, p: 1, render: 'float32-renderable-webgl', renderbuffer: true },
125
- 'rgb10a2unorm': { gl: GL.RGB10_A2, b: 4, c: 4, p: 1, renderbuffer: true },
126
- 'rgb10a2unorm-webgl': { b: 4, c: 4, gl: GL.RGB10_A2UI, p: 1, wgpu: false, bpp: 4, renderbuffer: true },
134
+ 'rgb9e5ufloat': { gl: 35901, b: 4, c: 3, p: 1, render: rgb9e5ufloat_renderable }, // , filter: true},
135
+ 'rg11b10ufloat': { gl: 35898, b: 4, c: 3, p: 1, render: float32_renderable, rb: true },
136
+ 'rgb10a2unorm': { gl: 32857, b: 4, c: 4, p: 1, rb: true },
137
+ 'rgb10a2uint-webgl': { b: 4, c: 4, gl: 36975, p: 1, wgpu: false, bpp: 4, rb: true },
127
138
  // 48-bit formats
128
- 'rgb16unorm-webgl': { gl: GL.RGB16_EXT, b: 2, c: 3, f: 'norm16-renderable-webgl', x: EXT_TEXTURE_NORM16 },
129
- 'rgb16snorm-webgl': { gl: GL.RGB16_SNORM_EXT, b: 2, c: 3, f: 'norm16-renderable-webgl', x: EXT_TEXTURE_NORM16 },
139
+ 'rgb16unorm-webgl': { gl: 32852, b: 2, c: 3, f: norm16_renderable }, // rgb not renderable
140
+ 'rgb16snorm-webgl': { gl: 36762, b: 2, c: 3, f: norm16_renderable }, // rgb not renderable
130
141
  // 64-bit formats
131
- 'rg32uint': { gl: GL.RG32UI, b: 8, c: 2, renderbuffer: true },
132
- 'rg32sint': { gl: GL.RG32I, b: 8, c: 2, renderbuffer: true },
133
- 'rg32float': { gl: GL.RG32F, b: 8, c: 2, render: 'float32-renderable-webgl', filter: 'float32-filterable-linear-webgl', renderbuffer: true },
134
- 'rgba16uint': { gl: GL.RGBA16UI, b: 8, c: 4, renderbuffer: true },
135
- 'rgba16sint': { gl: GL.RGBA16I, b: 8, c: 4, renderbuffer: true },
136
- 'rgba16float': { gl: GL.RGBA16F, b: 8, c: 4, render: 'float16-renderable-webgl', filter: 'float16-filterable-linear-webgl' },
137
- 'rgba16unorm-webgl': { gl: GL.RGBA16_EXT, b: 2, c: 4, f: 'norm16-renderable-webgl', renderbuffer: true, x: EXT_TEXTURE_NORM16 },
138
- 'rgba16snorm-webgl': { gl: GL.RGBA16_SNORM_EXT, b: 2, c: 4, f: 'norm16-renderable-webgl', x: EXT_TEXTURE_NORM16 },
142
+ 'rg32uint': { gl: 33340, b: 8, c: 2, rb: true },
143
+ 'rg32sint': { gl: 33339, b: 8, c: 2, rb: true },
144
+ 'rg32float': { gl: 33328, b: 8, c: 2, render: float32_renderable, filter: float32_filterable, rb: true },
145
+ 'rgba16uint': { gl: 36214, b: 8, c: 4, rb: true },
146
+ 'rgba16sint': { gl: 36232, b: 8, c: 4, rb: true },
147
+ 'rgba16float': { gl: 34842, b: 8, c: 4, render: float16_renderable, filter: float16_filterable },
148
+ 'rgba16unorm-webgl': { gl: 32859, b: 2, c: 4, render: norm16_renderable, rb: true },
149
+ 'rgba16snorm-webgl': { gl: 36763, b: 2, c: 4, render: snorm16_renderable },
139
150
  // 96-bit formats (deprecated!)
140
- 'rgb32float-webgl': { gl: GL.RGB32F, render: 'float32-renderable-webgl', filter: 'float32-filterable-linear-webgl',
141
- gl2ext: EXT_FLOAT_RENDER_WEBGL2, dataFormat: GL.RGB, types: [GL.FLOAT] },
151
+ 'rgb32float-webgl': { gl: 34837, render: float32_renderable, filter: float32_filterable,
152
+ gl2ext: EXT_color_buffer_float, dataFormat: 6407, types: [5126] },
142
153
  // 128-bit formats
143
- 'rgba32uint': { gl: GL.RGBA32UI, b: 16, c: 4, renderbuffer: true },
144
- 'rgba32sint': { gl: GL.RGBA32I, b: 16, c: 4, renderbuffer: true },
145
- 'rgba32float': { gl: GL.RGBA32F, b: 16, c: 4, render: 'float32-renderable-webgl', filter: 'float32-filterable-linear-webgl', renderbuffer: true },
154
+ 'rgba32uint': { gl: 36208, b: 16, c: 4, rb: true },
155
+ 'rgba32sint': { gl: 36226, b: 16, c: 4, rb: true },
156
+ 'rgba32float': { gl: 34836, b: 16, c: 4, render: float32_renderable, filter: float32_filterable, rb: true },
146
157
  // Depth and stencil formats
147
- 'stencil8': { gl: GL.STENCIL_INDEX8, b: 1, c: 1, attachment: GL.STENCIL_ATTACHMENT, renderbuffer: true }, // 8 stencil bits
148
- 'depth16unorm': { gl: GL.DEPTH_COMPONENT16, b: 2, c: 1, attachment: GL.DEPTH_ATTACHMENT, renderbuffer: true }, // 16 depth bits
149
- 'depth24plus': { gl: GL.DEPTH_COMPONENT24, b: 3, c: 1, attachment: GL.DEPTH_ATTACHMENT },
150
- 'depth32float': { gl: GL.DEPTH_COMPONENT32F, b: 4, c: 1, attachment: GL.DEPTH_ATTACHMENT, renderbuffer: true },
158
+ 'stencil8': { gl: 36168, b: 1, c: 1, attachment: 36128, rb: true }, // 8 stencil bits
159
+ 'depth16unorm': { gl: 33189, b: 2, c: 1, attachment: 36096,
160
+ dataFormat: 6402, types: [5123], rb: true }, // 16 depth bits
161
+ 'depth24plus': { gl: 33190, b: 3, c: 1, attachment: 36096,
162
+ dataFormat: 6402, types: [5125] },
163
+ 'depth32float': { gl: 36012, b: 4, c: 1, attachment: 36096,
164
+ dataFormat: 6402, types: [5126], rb: true },
151
165
  // The depth component of the "depth24plus" and "depth24plus-stencil8" formats may be implemented as either a 24-bit depth value or a "depth32float" value.
152
- 'depth24plus-stencil8': { gl: GL.DEPTH_STENCIL, b: 4, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT, renderbuffer: true, depthTexture: true },
166
+ 'depth24plus-stencil8': { gl: 35056, b: 4, c: 2, p: 1, attachment: 33306, rb: true, depthTexture: true,
167
+ dataFormat: 34041, types: [34042] },
153
168
  // "depth24unorm-stencil8" feature
154
- 'depth24unorm-stencil8': { gl: GL.DEPTH24_STENCIL8, b: 4, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT, renderbuffer: true },
155
- // "depth32float-stencil8" feature
156
- 'depth32float-stencil8': { gl: GL.DEPTH32F_STENCIL8, b: 5, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT, renderbuffer: true },
169
+ 'depth24unorm-stencil8': { gl: 35056, b: 4, c: 2, p: 1, attachment: 33306,
170
+ dataFormat: 34041, types: [34042], rb: true },
171
+ // "depth32float-stencil8" feature - TODO below is render buffer only?
172
+ 'depth32float-stencil8': { gl: 36013, b: 5, c: 2, p: 1, attachment: 33306,
173
+ dataFormat: 34041, types: [36269], rb: true },
157
174
  // BC compressed formats: check device.features.has("texture-compression-bc");
158
- 'bc1-rgb-unorm-webgl': { gl: GL.COMPRESSED_RGB_S3TC_DXT1_EXT, x: X_S3TC, f: texture_compression_bc },
159
- 'bc1-rgb-unorm-srgb-webgl': { gl: GL.COMPRESSED_SRGB_S3TC_DXT1_EXT, x: X_S3TC_SRGB, f: texture_compression_bc },
160
- 'bc1-rgba-unorm': { gl: GL.COMPRESSED_RGBA_S3TC_DXT1_EXT, x: X_S3TC, f: texture_compression_bc },
161
- 'bc1-rgba-unorm-srgb': { gl: GL.COMPRESSED_SRGB_S3TC_DXT1_EXT, x: X_S3TC_SRGB, f: texture_compression_bc },
162
- 'bc2-rgba-unorm': { gl: GL.COMPRESSED_RGBA_S3TC_DXT3_EXT, x: X_S3TC, f: texture_compression_bc },
163
- 'bc2-rgba-unorm-srgb': { gl: GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, x: X_S3TC_SRGB, f: texture_compression_bc },
164
- 'bc3-rgba-unorm': { gl: GL.COMPRESSED_RGBA_S3TC_DXT5_EXT, x: X_S3TC, f: texture_compression_bc },
165
- 'bc3-rgba-unorm-srgb': { gl: GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, x: X_S3TC_SRGB, f: texture_compression_bc },
166
- 'bc4-r-unorm': { gl: GL.COMPRESSED_RED_RGTC1_EXT, x: X_RGTC, f: texture_compression_bc },
167
- 'bc4-r-snorm': { gl: GL.COMPRESSED_SIGNED_RED_RGTC1_EXT, x: X_RGTC, f: texture_compression_bc },
168
- 'bc5-rg-unorm': { gl: GL.COMPRESSED_RED_GREEN_RGTC2_EXT, x: X_RGTC, f: texture_compression_bc },
169
- 'bc5-rg-snorm': { gl: GL.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT, x: X_RGTC, f: texture_compression_bc },
170
- 'bc6h-rgb-ufloat': { gl: GL.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT, x: X_BPTC, f: texture_compression_bc },
171
- 'bc6h-rgb-float': { gl: GL.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, x: X_BPTC, f: texture_compression_bc },
172
- 'bc7-rgba-unorm': { gl: GL.COMPRESSED_RGBA_BPTC_UNORM_EXT, x: X_BPTC, f: texture_compression_bc },
173
- 'bc7-rgba-unorm-srgb': { gl: GL.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT, x: X_BPTC, f: texture_compression_bc },
175
+ 'bc1-rgb-unorm-webgl': { gl: 33776, x: X_S3TC, f: texture_compression_bc },
176
+ 'bc1-rgb-unorm-srgb-webgl': { gl: 35916, x: X_S3TC_SRGB, f: texture_compression_bc },
177
+ 'bc1-rgba-unorm': { gl: 33777, x: X_S3TC, f: texture_compression_bc },
178
+ 'bc1-rgba-unorm-srgb': { gl: 35916, x: X_S3TC_SRGB, f: texture_compression_bc },
179
+ 'bc2-rgba-unorm': { gl: 33778, x: X_S3TC, f: texture_compression_bc },
180
+ 'bc2-rgba-unorm-srgb': { gl: 35918, x: X_S3TC_SRGB, f: texture_compression_bc },
181
+ 'bc3-rgba-unorm': { gl: 33779, x: X_S3TC, f: texture_compression_bc },
182
+ 'bc3-rgba-unorm-srgb': { gl: 35919, x: X_S3TC_SRGB, f: texture_compression_bc },
183
+ 'bc4-r-unorm': { gl: 36283, x: X_RGTC, f: texture_compression_bc },
184
+ 'bc4-r-snorm': { gl: 36284, x: X_RGTC, f: texture_compression_bc },
185
+ 'bc5-rg-unorm': { gl: 36285, x: X_RGTC, f: texture_compression_bc },
186
+ 'bc5-rg-snorm': { gl: 36286, x: X_RGTC, f: texture_compression_bc },
187
+ 'bc6h-rgb-ufloat': { gl: 36495, x: X_BPTC, f: texture_compression_bc },
188
+ 'bc6h-rgb-float': { gl: 36494, x: X_BPTC, f: texture_compression_bc },
189
+ 'bc7-rgba-unorm': { gl: 36492, x: X_BPTC, f: texture_compression_bc },
190
+ 'bc7-rgba-unorm-srgb': { gl: 36493, x: X_BPTC, f: texture_compression_bc },
174
191
  // WEBGL_compressed_texture_etc: device.features.has("texture-compression-etc2")
175
192
  // Note: Supposedly guaranteed availability compressed formats in WebGL2, but through CPU decompression
176
- 'etc2-rgb8unorm': { gl: GL.COMPRESSED_RGB8_ETC2, f: texture_compression_etc2 },
177
- 'etc2-rgb8unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ETC2, f: texture_compression_etc2 },
178
- 'etc2-rgb8a1unorm': { gl: GL.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, f: texture_compression_etc2 },
179
- 'etc2-rgb8a1unorm-srgb': { gl: GL.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, f: texture_compression_etc2 },
180
- 'etc2-rgba8unorm': { gl: GL.COMPRESSED_RGBA8_ETC2_EAC, f: texture_compression_etc2 },
181
- 'etc2-rgba8unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, f: texture_compression_etc2 },
182
- 'eac-r11unorm': { gl: GL.COMPRESSED_R11_EAC, f: texture_compression_etc2 },
183
- 'eac-r11snorm': { gl: GL.COMPRESSED_SIGNED_R11_EAC, f: texture_compression_etc2 },
184
- 'eac-rg11unorm': { gl: GL.COMPRESSED_RG11_EAC, f: texture_compression_etc2 },
185
- 'eac-rg11snorm': { gl: GL.COMPRESSED_SIGNED_RG11_EAC, f: texture_compression_etc2 },
193
+ 'etc2-rgb8unorm': { gl: 37492, f: texture_compression_etc2 },
194
+ 'etc2-rgb8unorm-srgb': { gl: 37494, f: texture_compression_etc2 },
195
+ 'etc2-rgb8a1unorm': { gl: 37496, f: texture_compression_etc2 },
196
+ 'etc2-rgb8a1unorm-srgb': { gl: 37497, f: texture_compression_etc2 },
197
+ 'etc2-rgba8unorm': { gl: 37493, f: texture_compression_etc2 },
198
+ 'etc2-rgba8unorm-srgb': { gl: 37495, f: texture_compression_etc2 },
199
+ 'eac-r11unorm': { gl: 37488, f: texture_compression_etc2 },
200
+ 'eac-r11snorm': { gl: 37489, f: texture_compression_etc2 },
201
+ 'eac-rg11unorm': { gl: 37490, f: texture_compression_etc2 },
202
+ 'eac-rg11snorm': { gl: 37491, f: texture_compression_etc2 },
186
203
  // X_ASTC compressed formats: device.features.has("texture-compression-astc")
187
- 'astc-4x4-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_4x4_KHR, f: texture_compression_astc },
188
- 'astc-4x4-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, f: texture_compression_astc },
189
- 'astc-5x4-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_5x4_KHR, f: texture_compression_astc },
190
- 'astc-5x4-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, f: texture_compression_astc },
191
- 'astc-5x5-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_5x5_KHR, f: texture_compression_astc },
192
- 'astc-5x5-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, f: texture_compression_astc },
193
- 'astc-6x5-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_6x5_KHR, f: texture_compression_astc },
194
- 'astc-6x5-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, f: texture_compression_astc },
195
- 'astc-6x6-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_6x6_KHR, f: texture_compression_astc },
196
- 'astc-6x6-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, f: texture_compression_astc },
197
- 'astc-8x5-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_8x5_KHR, f: texture_compression_astc },
198
- 'astc-8x5-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, f: texture_compression_astc },
199
- 'astc-8x6-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_8x6_KHR, f: texture_compression_astc },
200
- 'astc-8x6-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, f: texture_compression_astc },
201
- 'astc-8x8-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_8x8_KHR, f: texture_compression_astc },
202
- 'astc-8x8-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, f: texture_compression_astc },
203
- 'astc-10x5-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_10x10_KHR, f: texture_compression_astc },
204
- 'astc-10x5-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, f: texture_compression_astc },
205
- 'astc-10x6-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_10x6_KHR, f: texture_compression_astc },
206
- 'astc-10x6-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, f: texture_compression_astc },
207
- 'astc-10x8-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_10x8_KHR, f: texture_compression_astc },
208
- 'astc-10x8-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, f: texture_compression_astc },
209
- 'astc-10x10-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_10x10_KHR, f: texture_compression_astc },
210
- 'astc-10x10-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, f: texture_compression_astc },
211
- 'astc-12x10-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_12x10_KHR, f: texture_compression_astc },
212
- 'astc-12x10-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, f: texture_compression_astc },
213
- 'astc-12x12-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_12x12_KHR, f: texture_compression_astc },
214
- 'astc-12x12-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, f: texture_compression_astc },
204
+ 'astc-4x4-unorm': { gl: 37808, f: texture_compression_astc },
205
+ 'astc-4x4-unorm-srgb': { gl: 37840, f: texture_compression_astc },
206
+ 'astc-5x4-unorm': { gl: 37809, f: texture_compression_astc },
207
+ 'astc-5x4-unorm-srgb': { gl: 37841, f: texture_compression_astc },
208
+ 'astc-5x5-unorm': { gl: 37810, f: texture_compression_astc },
209
+ 'astc-5x5-unorm-srgb': { gl: 37842, f: texture_compression_astc },
210
+ 'astc-6x5-unorm': { gl: 37811, f: texture_compression_astc },
211
+ 'astc-6x5-unorm-srgb': { gl: 37843, f: texture_compression_astc },
212
+ 'astc-6x6-unorm': { gl: 37812, f: texture_compression_astc },
213
+ 'astc-6x6-unorm-srgb': { gl: 37844, f: texture_compression_astc },
214
+ 'astc-8x5-unorm': { gl: 37813, f: texture_compression_astc },
215
+ 'astc-8x5-unorm-srgb': { gl: 37845, f: texture_compression_astc },
216
+ 'astc-8x6-unorm': { gl: 37814, f: texture_compression_astc },
217
+ 'astc-8x6-unorm-srgb': { gl: 37846, f: texture_compression_astc },
218
+ 'astc-8x8-unorm': { gl: 37815, f: texture_compression_astc },
219
+ 'astc-8x8-unorm-srgb': { gl: 37847, f: texture_compression_astc },
220
+ 'astc-10x5-unorm': { gl: 37819, f: texture_compression_astc },
221
+ 'astc-10x5-unorm-srgb': { gl: 37851, f: texture_compression_astc },
222
+ 'astc-10x6-unorm': { gl: 37817, f: texture_compression_astc },
223
+ 'astc-10x6-unorm-srgb': { gl: 37849, f: texture_compression_astc },
224
+ 'astc-10x8-unorm': { gl: 37818, f: texture_compression_astc },
225
+ 'astc-10x8-unorm-srgb': { gl: 37850, f: texture_compression_astc },
226
+ 'astc-10x10-unorm': { gl: 37819, f: texture_compression_astc },
227
+ 'astc-10x10-unorm-srgb': { gl: 37851, f: texture_compression_astc },
228
+ 'astc-12x10-unorm': { gl: 37820, f: texture_compression_astc },
229
+ 'astc-12x10-unorm-srgb': { gl: 37852, f: texture_compression_astc },
230
+ 'astc-12x12-unorm': { gl: 37821, f: texture_compression_astc },
231
+ 'astc-12x12-unorm-srgb': { gl: 37853, f: texture_compression_astc },
215
232
  // WEBGL_compressed_texture_pvrtc
216
- 'pvrtc-rgb4unorm-webgl': { gl: GL.COMPRESSED_RGB_PVRTC_4BPPV1_IMG, f: texture_compression_pvrtc_webgl },
217
- 'pvrtc-rgba4unorm-webgl': { gl: GL.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, f: texture_compression_pvrtc_webgl },
218
- 'pvrtc-rbg2unorm-webgl': { gl: GL.COMPRESSED_RGB_PVRTC_2BPPV1_IMG, f: texture_compression_pvrtc_webgl },
219
- 'pvrtc-rgba2unorm-webgl': { gl: GL.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, f: texture_compression_pvrtc_webgl },
233
+ 'pvrtc-rgb4unorm-webgl': { gl: 35840, f: texture_compression_pvrtc_webgl },
234
+ 'pvrtc-rgba4unorm-webgl': { gl: 35842, f: texture_compression_pvrtc_webgl },
235
+ 'pvrtc-rbg2unorm-webgl': { gl: 35841, f: texture_compression_pvrtc_webgl },
236
+ 'pvrtc-rgba2unorm-webgl': { gl: 35843, f: texture_compression_pvrtc_webgl },
220
237
  // WEBGL_compressed_texture_etc1
221
- 'etc1-rbg-unorm-webgl': { gl: GL.COMPRESSED_RGB_ETC1_WEBGL, f: texture_compression_etc1_webgl },
238
+ 'etc1-rbg-unorm-webgl': { gl: 36196, f: texture_compression_etc1_webgl },
222
239
  // WEBGL_compressed_texture_atc
223
- 'atc-rgb-unorm-webgl': { gl: GL.COMPRESSED_RGB_ATC_WEBGL, f: texture_compression_atc_webgl },
224
- 'atc-rgba-unorm-webgl': { gl: GL.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL, f: texture_compression_atc_webgl },
225
- 'atc-rgbai-unorm-webgl': { gl: GL.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL, f: texture_compression_atc_webgl }
240
+ 'atc-rgb-unorm-webgl': { gl: 35986, f: texture_compression_atc_webgl },
241
+ 'atc-rgba-unorm-webgl': { gl: 35986, f: texture_compression_atc_webgl },
242
+ 'atc-rgbai-unorm-webgl': { gl: 34798, f: texture_compression_atc_webgl }
226
243
  };
227
244
  /** Legal combinations for internalFormat, format and type *
228
245
  // [GL.DEPTH_COMPONENT]: {types: [GL.UNSIGNED_SHORT, GL.UNSIGNED_INT, GL.UNSIGNED_INT_24_8]},
@@ -312,41 +329,40 @@ export const RENDERBUFFER_FORMATS: Record<string, RenderbufferFormat> = {
312
329
  [GL.RG32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 8},
313
330
  // TODO - can't get WEBGL_color_buffer_float to work on renderbuffers
314
331
  [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 16},
315
- // [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2, gl1: EXT_FLOAT_WEBGL1},
332
+ // [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2},
316
333
  [GL.R11F_G11F_B10F]: {ext: EXT_FLOAT_WEBGL2, bpp: 4}
317
334
  };
318
335
  */
319
336
  /** @deprecated should be removed */
320
337
  const DATA_FORMAT_CHANNELS = {
321
- [GL.RED]: 1,
322
- [GL.RED_INTEGER]: 1,
323
- [GL.RG]: 2,
324
- [GL.RG_INTEGER]: 2,
325
- [GL.RGB]: 3,
326
- [GL.RGB_INTEGER]: 3,
327
- [GL.RGBA]: 4,
328
- [GL.RGBA_INTEGER]: 4,
329
- [GL.DEPTH_COMPONENT]: 1,
330
- [GL.DEPTH_STENCIL]: 1,
331
- [GL.ALPHA]: 1,
332
- [GL.LUMINANCE]: 1,
333
- [GL.LUMINANCE_ALPHA]: 2
338
+ [6403]: 1,
339
+ [36244]: 1,
340
+ [33319]: 2,
341
+ [33320]: 2,
342
+ [6407]: 3,
343
+ [36248]: 3,
344
+ [6408]: 4,
345
+ [36249]: 4,
346
+ [6402]: 1,
347
+ [34041]: 1,
348
+ [6406]: 1,
349
+ [6409]: 1,
350
+ [6410]: 2
334
351
  };
335
352
  /** @deprecated should be removed */
336
353
  const TYPE_SIZES = {
337
- [GL.FLOAT]: 4,
338
- [GL.UNSIGNED_INT]: 4,
339
- [GL.INT]: 4,
340
- [GL.UNSIGNED_SHORT]: 2,
341
- [GL.SHORT]: 2,
342
- [GL.HALF_FLOAT]: 2,
343
- [GL.BYTE]: 1,
344
- [GL.UNSIGNED_BYTE]: 1
354
+ [5126]: 4,
355
+ [5125]: 4,
356
+ [5124]: 4,
357
+ [5123]: 2,
358
+ [5122]: 2,
359
+ [5131]: 2,
360
+ [5120]: 1,
361
+ [5121]: 1
345
362
  };
346
363
  // FUNCTIONS
347
364
  /** Checks if a texture format is supported */
348
- export function isTextureFormatSupported(gl, formatOrGL) {
349
- const format = convertGLToTextureFormat(formatOrGL);
365
+ export function isTextureFormatSupported(gl, format, extensions) {
350
366
  const info = TEXTURE_FORMATS[format];
351
367
  if (!info) {
352
368
  return false;
@@ -358,13 +374,13 @@ export function isTextureFormatSupported(gl, formatOrGL) {
358
374
  // Check extensions
359
375
  const extension = info.x || info.gl2ext;
360
376
  if (extension) {
361
- return Boolean(gl.getExtension(extension));
377
+ return Boolean(getWebGLExtension(gl, extension, extensions));
362
378
  }
363
379
  return true;
364
380
  }
365
- export function isRenderbufferFormatSupported(gl, format) {
381
+ export function isRenderbufferFormatSupported(gl, format, extensions) {
366
382
  // Note: Order is important since the function call initializes extensions.
367
- return isTextureFormatSupported(gl, format) && TEXTURE_FORMATS[format]?.renderbuffer;
383
+ return isTextureFormatSupported(gl, format, extensions) && TEXTURE_FORMATS[format]?.rb;
368
384
  }
369
385
  /**
370
386
  * Map WebGL texture formats (GL constants) to WebGPU-style TextureFormat strings
@@ -391,8 +407,7 @@ export function convertTextureFormatToGL(format) {
391
407
  return webglFormat;
392
408
  }
393
409
  /** Checks if a texture format is supported */
394
- export function getTextureFormatSupport(gl, formatOrGL) {
395
- const format = convertGLToTextureFormat(formatOrGL);
410
+ export function getTextureFormatSupport(gl, format, extensions) {
396
411
  const info = TEXTURE_FORMATS[format];
397
412
  if (!info) {
398
413
  return { supported: false };
@@ -403,26 +418,28 @@ export function getTextureFormatSupport(gl, formatOrGL) {
403
418
  // } catch {}
404
419
  // Support Check that we have a GL constant
405
420
  let supported = info.gl === undefined;
406
- supported = supported && checkTextureFeatures(gl, [info.f]);
421
+ supported = supported && checkTextureFeature(gl, info.f, extensions);
407
422
  // Filtering
408
423
  // const filterable = info.filter
409
- // ? checkTextureFeatures(gl, [info.filter])
424
+ // ? checkTextureFeature(gl, infofilter])
410
425
  // : decoded && !decoded.signed;
411
426
  // const renderable = info.filter
412
- // ? checkTextureFeatures(gl, [info.render])
427
+ // ? checkTextureFeature(gl, inforender])
413
428
  // : decoded && !decoded.signed;
414
429
  return {
415
430
  supported,
416
- renderable: supported && checkTextureFeatures(gl, [info.render]),
417
- filterable: supported && checkTextureFeatures(gl, [info.filter]),
431
+ renderable: supported && checkTextureFeature(gl, info.render, extensions),
432
+ filterable: supported && checkTextureFeature(gl, info.filter, extensions),
418
433
  blendable: false, // tod,
419
434
  storable: false
420
435
  };
421
436
  }
422
437
  /** Checks whether linear filtering (interpolated sampling) is available for floating point textures */
423
- export function isTextureFormatFilterable(gl, formatOrGL) {
424
- const format = convertGLToTextureFormat(formatOrGL);
425
- if (!isTextureFormatSupported(gl, format)) {
438
+ export function isTextureFormatFilterable(gl, format, extensions) {
439
+ if (!isTextureFormatSupported(gl, format, extensions)) {
440
+ return false;
441
+ }
442
+ if (format.startsWith('depth') || format.startsWith('stencil')) {
426
443
  return false;
427
444
  }
428
445
  try {
@@ -435,16 +452,15 @@ export function isTextureFormatFilterable(gl, formatOrGL) {
435
452
  return false;
436
453
  }
437
454
  if (format.endsWith('32float')) {
438
- return Boolean(gl.getExtension('OES_texture_float_linear'));
455
+ return Boolean(getWebGLExtension(gl, 'OES_texture_float_linear, extensions', extensions));
439
456
  }
440
457
  if (format.endsWith('16float')) {
441
- return Boolean(gl.getExtension('OES_texture_half_float_linear'));
458
+ return Boolean(getWebGLExtension(gl, 'OES_texture_half_float_linear, extensions', extensions));
442
459
  }
443
460
  return true;
444
461
  }
445
- export function isTextureFormatRenderable(gl, formatOrGL) {
446
- const format = convertGLToTextureFormat(formatOrGL);
447
- if (!isTextureFormatSupported(gl, format)) {
462
+ export function isTextureFormatRenderable(gl, format, extensions) {
463
+ if (!isTextureFormatSupported(gl, format, extensions)) {
448
464
  return false;
449
465
  }
450
466
  if (typeof format === 'number') {
@@ -453,15 +469,19 @@ export function isTextureFormatRenderable(gl, formatOrGL) {
453
469
  // TODO depends on device...
454
470
  return true;
455
471
  }
456
- export function getWebGLTextureParameters(formatOrGL) {
457
- const format = convertGLToTextureFormat(formatOrGL);
472
+ /** Get parameters necessary to work with format in WebGL: internalFormat, dataFormat, type, compressed, */
473
+ export function getWebGLTextureParameters(format) {
474
+ const formatData = TEXTURE_FORMATS[format];
458
475
  const webglFormat = convertTextureFormatToGL(format);
459
476
  const decoded = decodeTextureFormat(format);
460
477
  return {
461
478
  format: webglFormat,
462
- dataFormat: getWebGLPixelDataFormat(decoded.format, decoded.integer, decoded.normalized, webglFormat),
479
+ dataFormat: formatData?.dataFormat ||
480
+ getWebGLPixelDataFormat(decoded.format, decoded.integer, decoded.normalized, webglFormat),
463
481
  // depth formats don't have a type
464
- type: decoded.dataType ? getGLFromVertexType(decoded.dataType) : GL.UNSIGNED_BYTE,
482
+ type: decoded.dataType
483
+ ? getGLFromVertexType(decoded.dataType)
484
+ : formatData?.types?.[0] || 5121,
465
485
  // @ts-expect-error
466
486
  compressed: decoded.compressed
467
487
  };
@@ -474,9 +494,8 @@ export function getDepthStencilAttachmentWebGL(format) {
474
494
  return info.attachment;
475
495
  }
476
496
  /** TODO - VERY roundabout legacy way of calculating bytes per pixel */
477
- export function getTextureFormatBytesPerPixel(formatOrGL) {
497
+ export function getTextureFormatBytesPerPixel(format) {
478
498
  // TODO remove webgl1 support
479
- const format = convertGLToTextureFormat(formatOrGL);
480
499
  const params = getWebGLTextureParameters(format);
481
500
  // NOTE(Tarek): Default to RGBA bytes
482
501
  const channels = DATA_FORMAT_CHANNELS[params.dataFormat] || 4;
@@ -486,15 +505,15 @@ export function getTextureFormatBytesPerPixel(formatOrGL) {
486
505
  // DATA TYPE HELPERS
487
506
  function getWebGLPixelDataFormat(dataFormat, integer, normalized, format) {
488
507
  // WebGL1 formats use same internalFormat
489
- if (format === GL.RGBA || format === GL.RGB) {
508
+ if (format === 6408 || format === 6407) {
490
509
  return format;
491
510
  }
492
511
  // prettier-ignore
493
512
  switch (dataFormat) {
494
- case 'r': return integer && !normalized ? GL.RED_INTEGER : GL.RED;
495
- case 'rg': return integer && !normalized ? GL.RG_INTEGER : GL.RG;
496
- case 'rgb': return integer && !normalized ? GL.RGB_INTEGER : GL.RGB;
497
- case 'rgba': return integer && !normalized ? GL.RGBA_INTEGER : GL.RGBA;
498
- default: return GL.RGBA;
513
+ case 'r': return integer && !normalized ? 36244 : 6403;
514
+ case 'rg': return integer && !normalized ? 33320 : 33319;
515
+ case 'rgb': return integer && !normalized ? 36248 : 6407;
516
+ case 'rgba': return integer && !normalized ? 36249 : 6408;
517
+ default: return 6408;
499
518
  }
500
519
  }
@@ -1 +1 @@
1
- {"version":3,"file":"vertex-formats.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/vertex-formats.ts"],"names":[],"mappings":"AAGA,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;AAGb,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
+ {"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"}