@luma.gl/webgl 9.0.0-beta.1 → 9.0.0-beta.10

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 (285) hide show
  1. package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
  2. package/dist/adapter/converters/device-parameters.js +295 -156
  3. package/dist/adapter/converters/sampler-parameters.d.ts +0 -4
  4. package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
  5. package/dist/adapter/converters/sampler-parameters.js +73 -67
  6. package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
  7. package/dist/adapter/converters/shader-formats.js +53 -46
  8. package/dist/adapter/converters/texture-formats.d.ts +17 -21
  9. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  10. package/dist/adapter/converters/texture-formats.js +481 -879
  11. package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
  12. package/dist/adapter/converters/vertex-formats.js +53 -61
  13. package/dist/adapter/device-helpers/webgl-device-features.d.ts +20 -0
  14. package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -0
  15. package/dist/adapter/device-helpers/webgl-device-features.js +98 -0
  16. package/dist/adapter/device-helpers/webgl-device-info.d.ts +5 -0
  17. package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -0
  18. package/dist/adapter/device-helpers/webgl-device-info.js +90 -0
  19. package/dist/adapter/device-helpers/webgl-device-limits.d.ts +35 -0
  20. package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -0
  21. package/dist/adapter/device-helpers/webgl-device-limits.js +47 -0
  22. package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -1
  23. package/dist/adapter/helpers/decode-webgl-types.js +88 -76
  24. package/dist/adapter/helpers/get-shader-layout.d.ts +1 -1
  25. package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
  26. package/dist/adapter/helpers/get-shader-layout.js +261 -225
  27. package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
  28. package/dist/adapter/helpers/parse-shader-compiler-log.js +47 -37
  29. package/dist/adapter/helpers/set-uniform.d.ts +1 -1
  30. package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
  31. package/dist/adapter/helpers/set-uniform.js +68 -82
  32. package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
  33. package/dist/adapter/helpers/webgl-topology-utils.js +78 -93
  34. package/dist/adapter/objects/constants-to-keys.d.ts +1 -1
  35. package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
  36. package/dist/adapter/objects/constants-to-keys.js +19 -12
  37. package/dist/adapter/objects/webgl-renderbuffer.d.ts +2 -2
  38. package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
  39. package/dist/adapter/objects/webgl-renderbuffer.js +86 -77
  40. package/dist/adapter/objects/webgl-resource.d.ts +3 -25
  41. package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
  42. package/dist/adapter/objects/webgl-resource.js +102 -147
  43. package/dist/adapter/resources/webgl-buffer.d.ts +3 -4
  44. package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
  45. package/dist/adapter/resources/webgl-buffer.js +159 -117
  46. package/dist/adapter/resources/webgl-command-buffer.d.ts +1 -1
  47. package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
  48. package/dist/adapter/resources/webgl-command-buffer.js +266 -168
  49. package/dist/adapter/resources/webgl-command-encoder.d.ts +8 -3
  50. package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
  51. package/dist/adapter/resources/webgl-command-encoder.js +33 -39
  52. package/dist/adapter/resources/webgl-external-texture.js +93 -1
  53. package/dist/adapter/resources/webgl-framebuffer.d.ts +8 -12
  54. package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
  55. package/dist/adapter/resources/webgl-framebuffer.js +174 -139
  56. package/dist/adapter/resources/webgl-query-set.d.ts +44 -0
  57. package/dist/adapter/resources/webgl-query-set.d.ts.map +1 -0
  58. package/dist/adapter/resources/webgl-query-set.js +136 -0
  59. package/dist/adapter/resources/webgl-render-pass.d.ts +3 -1
  60. package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
  61. package/dist/adapter/resources/webgl-render-pass.js +124 -90
  62. package/dist/adapter/resources/webgl-render-pipeline.d.ts +15 -6
  63. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  64. package/dist/adapter/resources/webgl-render-pipeline.js +362 -221
  65. package/dist/adapter/resources/webgl-sampler.d.ts +1 -3
  66. package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
  67. package/dist/adapter/resources/webgl-sampler.js +43 -33
  68. package/dist/adapter/resources/webgl-shader.d.ts +12 -2
  69. package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
  70. package/dist/adapter/resources/webgl-shader.js +114 -47
  71. package/dist/adapter/resources/webgl-texture-view.d.ts +14 -0
  72. package/dist/adapter/resources/webgl-texture-view.d.ts.map +1 -0
  73. package/dist/adapter/resources/webgl-texture-view.js +18 -0
  74. package/dist/adapter/resources/webgl-texture.d.ts +8 -10
  75. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  76. package/dist/adapter/resources/webgl-texture.js +616 -694
  77. package/dist/adapter/resources/webgl-transform-feedback.d.ts +2 -2
  78. package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
  79. package/dist/adapter/resources/webgl-transform-feedback.js +141 -143
  80. package/dist/adapter/resources/webgl-vertex-array.d.ts +3 -3
  81. package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
  82. package/dist/adapter/resources/webgl-vertex-array.js +229 -157
  83. package/dist/adapter/webgl-canvas-context.d.ts +2 -2
  84. package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
  85. package/dist/adapter/webgl-canvas-context.js +58 -36
  86. package/dist/adapter/webgl-device.d.ts +50 -44
  87. package/dist/adapter/webgl-device.d.ts.map +1 -1
  88. package/dist/adapter/webgl-device.js +427 -352
  89. package/dist/classic/accessor.d.ts.map +1 -1
  90. package/dist/classic/accessor.js +132 -101
  91. package/dist/classic/clear.d.ts +2 -2
  92. package/dist/classic/clear.d.ts.map +1 -1
  93. package/dist/classic/clear.js +73 -72
  94. package/dist/classic/copy-and-blit.d.ts +1 -1
  95. package/dist/classic/copy-and-blit.d.ts.map +1 -1
  96. package/dist/classic/copy-and-blit.js +174 -175
  97. package/dist/classic/format-utils.d.ts +2 -2
  98. package/dist/classic/format-utils.d.ts.map +1 -1
  99. package/dist/classic/format-utils.js +39 -32
  100. package/dist/classic/typed-array-utils.d.ts.map +1 -1
  101. package/dist/classic/typed-array-utils.js +96 -81
  102. package/dist/context/debug/spector.d.ts.map +1 -1
  103. package/dist/context/debug/spector.js +55 -50
  104. package/dist/context/debug/webgl-developer-tools.d.ts +1 -2
  105. package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
  106. package/dist/context/debug/webgl-developer-tools.js +104 -77
  107. package/dist/context/{context → helpers}/create-browser-context.d.ts +1 -6
  108. package/dist/context/helpers/create-browser-context.d.ts.map +1 -0
  109. package/dist/context/helpers/create-browser-context.js +67 -0
  110. package/dist/context/{polyfill/context-data.d.ts → helpers/webgl-context-data.d.ts} +2 -2
  111. package/dist/context/helpers/webgl-context-data.d.ts.map +1 -0
  112. package/dist/context/helpers/webgl-context-data.js +21 -0
  113. package/dist/context/helpers/webgl-extensions.d.ts +4 -0
  114. package/dist/context/helpers/webgl-extensions.d.ts.map +1 -0
  115. package/dist/context/helpers/webgl-extensions.js +10 -0
  116. package/dist/context/parameters/unified-parameter-api.d.ts +3 -4
  117. package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
  118. package/dist/context/parameters/unified-parameter-api.js +92 -47
  119. package/dist/context/parameters/webgl-parameter-tables.d.ts +109 -99
  120. package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
  121. package/dist/context/parameters/webgl-parameter-tables.js +463 -404
  122. package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
  123. package/dist/context/state-tracker/deep-array-equal.js +19 -14
  124. package/dist/context/state-tracker/track-context-state.d.ts +4 -4
  125. package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
  126. package/dist/context/state-tracker/track-context-state.js +188 -123
  127. package/dist/context/state-tracker/with-parameters.d.ts +2 -3
  128. package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
  129. package/dist/context/state-tracker/with-parameters.js +42 -28
  130. package/dist/dist.dev.js +4465 -7235
  131. package/dist/dist.min.js +10 -0
  132. package/dist/index.cjs +2146 -3116
  133. package/dist/index.cjs.map +7 -0
  134. package/dist/index.d.ts +25 -31
  135. package/dist/index.d.ts.map +1 -1
  136. package/dist/index.js +19 -10
  137. package/dist/types.d.ts.map +1 -1
  138. package/dist/types.js +3 -1
  139. package/dist.min.js +9 -42
  140. package/package.json +10 -15
  141. package/src/adapter/converters/device-parameters.ts +114 -28
  142. package/src/adapter/converters/sampler-parameters.ts +12 -20
  143. package/src/adapter/converters/shader-formats.ts +47 -22
  144. package/src/adapter/converters/texture-formats.ts +183 -227
  145. package/src/adapter/converters/vertex-formats.ts +3 -3
  146. package/src/adapter/device-helpers/webgl-device-features.ts +121 -0
  147. package/src/adapter/device-helpers/{get-device-info.ts → webgl-device-info.ts} +30 -22
  148. package/src/adapter/device-helpers/webgl-device-limits.ts +53 -0
  149. package/src/adapter/helpers/decode-webgl-types.ts +13 -7
  150. package/src/adapter/helpers/get-shader-layout.ts +21 -31
  151. package/src/adapter/helpers/parse-shader-compiler-log.ts +10 -6
  152. package/src/adapter/helpers/set-uniform.ts +3 -4
  153. package/src/adapter/helpers/webgl-topology-utils.ts +10 -3
  154. package/src/adapter/objects/constants-to-keys.ts +3 -2
  155. package/src/adapter/objects/webgl-renderbuffer.ts +38 -16
  156. package/src/adapter/objects/webgl-resource.ts +8 -141
  157. package/src/adapter/resources/webgl-buffer.ts +10 -14
  158. package/src/adapter/resources/webgl-command-buffer.ts +24 -34
  159. package/src/adapter/resources/webgl-command-encoder.ts +14 -11
  160. package/src/adapter/resources/webgl-external-texture.ts +7 -7
  161. package/src/adapter/resources/webgl-framebuffer.ts +65 -58
  162. package/src/adapter/resources/webgl-query-set.ts +171 -0
  163. package/src/adapter/resources/webgl-render-pass.ts +27 -18
  164. package/src/adapter/resources/webgl-render-pipeline.ts +148 -73
  165. package/src/adapter/resources/webgl-sampler.ts +7 -10
  166. package/src/adapter/resources/webgl-shader.ts +65 -11
  167. package/src/adapter/resources/webgl-texture-view.ts +28 -0
  168. package/src/adapter/resources/webgl-texture.ts +43 -106
  169. package/src/adapter/resources/webgl-transform-feedback.ts +16 -22
  170. package/src/adapter/resources/webgl-vertex-array.ts +20 -21
  171. package/src/adapter/webgl-canvas-context.ts +7 -11
  172. package/src/adapter/webgl-device.ts +142 -162
  173. package/src/classic/accessor.ts +5 -4
  174. package/src/classic/clear.ts +25 -20
  175. package/src/classic/copy-and-blit.ts +12 -6
  176. package/src/classic/format-utils.ts +2 -1
  177. package/src/classic/typed-array-utils.ts +3 -7
  178. package/src/context/debug/spector.ts +9 -6
  179. package/src/context/debug/webgl-developer-tools.ts +31 -20
  180. package/src/context/{context → helpers}/create-browser-context.ts +9 -33
  181. package/src/context/{polyfill/context-data.ts → helpers/webgl-context-data.ts} +3 -2
  182. package/src/context/helpers/webgl-extensions.ts +17 -0
  183. package/src/context/parameters/unified-parameter-api.ts +6 -17
  184. package/src/context/parameters/webgl-parameter-tables.ts +118 -90
  185. package/src/context/state-tracker/deep-array-equal.ts +2 -1
  186. package/src/context/state-tracker/track-context-state.ts +29 -23
  187. package/src/context/state-tracker/with-parameters.ts +8 -8
  188. package/src/index.ts +16 -56
  189. package/src/types.ts +2 -1
  190. package/dist/adapter/converters/device-parameters.js.map +0 -1
  191. package/dist/adapter/converters/sampler-parameters.js.map +0 -1
  192. package/dist/adapter/converters/shader-formats.js.map +0 -1
  193. package/dist/adapter/converters/texture-formats.js.map +0 -1
  194. package/dist/adapter/converters/vertex-formats.js.map +0 -1
  195. package/dist/adapter/device-helpers/device-features.d.ts +0 -9
  196. package/dist/adapter/device-helpers/device-features.d.ts.map +0 -1
  197. package/dist/adapter/device-helpers/device-features.js +0 -96
  198. package/dist/adapter/device-helpers/device-features.js.map +0 -1
  199. package/dist/adapter/device-helpers/device-limits.d.ts +0 -52
  200. package/dist/adapter/device-helpers/device-limits.d.ts.map +0 -1
  201. package/dist/adapter/device-helpers/device-limits.js +0 -87
  202. package/dist/adapter/device-helpers/device-limits.js.map +0 -1
  203. package/dist/adapter/device-helpers/get-device-info.d.ts +0 -4
  204. package/dist/adapter/device-helpers/get-device-info.d.ts.map +0 -1
  205. package/dist/adapter/device-helpers/get-device-info.js +0 -71
  206. package/dist/adapter/device-helpers/get-device-info.js.map +0 -1
  207. package/dist/adapter/device-helpers/is-old-ie.d.ts +0 -2
  208. package/dist/adapter/device-helpers/is-old-ie.d.ts.map +0 -1
  209. package/dist/adapter/device-helpers/is-old-ie.js +0 -9
  210. package/dist/adapter/device-helpers/is-old-ie.js.map +0 -1
  211. package/dist/adapter/helpers/decode-webgl-types.js.map +0 -1
  212. package/dist/adapter/helpers/get-shader-layout.js.map +0 -1
  213. package/dist/adapter/helpers/parse-shader-compiler-log.js.map +0 -1
  214. package/dist/adapter/helpers/set-uniform.js.map +0 -1
  215. package/dist/adapter/helpers/webgl-topology-utils.js.map +0 -1
  216. package/dist/adapter/objects/constants-to-keys.js.map +0 -1
  217. package/dist/adapter/objects/webgl-renderbuffer.js.map +0 -1
  218. package/dist/adapter/objects/webgl-resource.js.map +0 -1
  219. package/dist/adapter/resources/webgl-buffer.js.map +0 -1
  220. package/dist/adapter/resources/webgl-command-buffer.js.map +0 -1
  221. package/dist/adapter/resources/webgl-command-encoder.js.map +0 -1
  222. package/dist/adapter/resources/webgl-external-texture.js.map +0 -1
  223. package/dist/adapter/resources/webgl-framebuffer.js.map +0 -1
  224. package/dist/adapter/resources/webgl-render-pass.js.map +0 -1
  225. package/dist/adapter/resources/webgl-render-pipeline.js.map +0 -1
  226. package/dist/adapter/resources/webgl-sampler.js.map +0 -1
  227. package/dist/adapter/resources/webgl-shader.js.map +0 -1
  228. package/dist/adapter/resources/webgl-texture.js.map +0 -1
  229. package/dist/adapter/resources/webgl-transform-feedback.js.map +0 -1
  230. package/dist/adapter/resources/webgl-vertex-array.js.map +0 -1
  231. package/dist/adapter/webgl-canvas-context.js.map +0 -1
  232. package/dist/adapter/webgl-device.js.map +0 -1
  233. package/dist/classic/accessor.js.map +0 -1
  234. package/dist/classic/clear.js.map +0 -1
  235. package/dist/classic/copy-and-blit.js.map +0 -1
  236. package/dist/classic/format-utils.js.map +0 -1
  237. package/dist/classic/typed-array-utils.js.map +0 -1
  238. package/dist/context/context/create-browser-context.d.ts.map +0 -1
  239. package/dist/context/context/create-browser-context.js +0 -53
  240. package/dist/context/context/create-browser-context.js.map +0 -1
  241. package/dist/context/context/create-headless-context.d.ts +0 -9
  242. package/dist/context/context/create-headless-context.d.ts.map +0 -1
  243. package/dist/context/context/create-headless-context.js +0 -42
  244. package/dist/context/context/create-headless-context.js.map +0 -1
  245. package/dist/context/context/webgl-checks.d.ts +0 -13
  246. package/dist/context/context/webgl-checks.d.ts.map +0 -1
  247. package/dist/context/context/webgl-checks.js +0 -31
  248. package/dist/context/context/webgl-checks.js.map +0 -1
  249. package/dist/context/debug/spector.js.map +0 -1
  250. package/dist/context/debug/webgl-developer-tools.js.map +0 -1
  251. package/dist/context/parameters/unified-parameter-api.js.map +0 -1
  252. package/dist/context/parameters/webgl-parameter-tables.js.map +0 -1
  253. package/dist/context/polyfill/context-data.d.ts.map +0 -1
  254. package/dist/context/polyfill/context-data.js +0 -12
  255. package/dist/context/polyfill/context-data.js.map +0 -1
  256. package/dist/context/polyfill/get-parameter-polyfill.d.ts +0 -2
  257. package/dist/context/polyfill/get-parameter-polyfill.d.ts.map +0 -1
  258. package/dist/context/polyfill/get-parameter-polyfill.js +0 -85
  259. package/dist/context/polyfill/get-parameter-polyfill.js.map +0 -1
  260. package/dist/context/polyfill/polyfill-context.d.ts +0 -5
  261. package/dist/context/polyfill/polyfill-context.d.ts.map +0 -1
  262. package/dist/context/polyfill/polyfill-context.js +0 -87
  263. package/dist/context/polyfill/polyfill-context.js.map +0 -1
  264. package/dist/context/polyfill/polyfill-table.d.ts +0 -48
  265. package/dist/context/polyfill/polyfill-table.d.ts.map +0 -1
  266. package/dist/context/polyfill/polyfill-table.js +0 -137
  267. package/dist/context/polyfill/polyfill-table.js.map +0 -1
  268. package/dist/context/polyfill/polyfill-vertex-array-object.d.ts +0 -2
  269. package/dist/context/polyfill/polyfill-vertex-array-object.d.ts.map +0 -1
  270. package/dist/context/polyfill/polyfill-vertex-array-object.js +0 -265
  271. package/dist/context/polyfill/polyfill-vertex-array-object.js.map +0 -1
  272. package/dist/context/state-tracker/deep-array-equal.js.map +0 -1
  273. package/dist/context/state-tracker/track-context-state.js.map +0 -1
  274. package/dist/context/state-tracker/with-parameters.js.map +0 -1
  275. package/dist/index.js.map +0 -1
  276. package/dist/types.js.map +0 -1
  277. package/src/adapter/device-helpers/device-features.ts +0 -161
  278. package/src/adapter/device-helpers/device-limits.ts +0 -155
  279. package/src/adapter/device-helpers/is-old-ie.ts +0 -14
  280. package/src/context/context/create-headless-context.ts +0 -51
  281. package/src/context/context/webgl-checks.ts +0 -51
  282. package/src/context/polyfill/get-parameter-polyfill.ts +0 -122
  283. package/src/context/polyfill/polyfill-context.ts +0 -104
  284. package/src/context/polyfill/polyfill-table.ts +0 -167
  285. package/src/context/polyfill/polyfill-vertex-array-object.ts +0 -365
@@ -1,10 +1,11 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import {GL} from '@luma.gl/constants';
5
6
  import {VertexFormat, VertexType} from '@luma.gl/core';
6
7
 
7
- type GLDataType =
8
+ type GLDataType =
8
9
  | GL.UNSIGNED_BYTE
9
10
  | GL.BYTE
10
11
  | GL.UNSIGNED_SHORT
@@ -14,7 +15,6 @@ type GLDataType =
14
15
  | GL.HALF_FLOAT
15
16
  | GL.FLOAT;
16
17
 
17
-
18
18
  /** Get vertex format from GL constants */
19
19
  export function getVertexFormatFromGL(type: GLDataType, components: 1 | 2 | 3 | 4): VertexFormat {
20
20
  const base = getVertexTypeFromGL(type);
@@ -0,0 +1,121 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ // Feature detection for WebGL
6
+ // Provides a function that enables simple checking of which WebGL features are
7
+
8
+ import {DeviceFeature, DeviceFeatures} from '@luma.gl/core';
9
+ import {GLExtensions} from '@luma.gl/constants';
10
+ import {getWebGLExtension} from '../../context/helpers/webgl-extensions';
11
+ import {isTextureFeature, checkTextureFeature} from '../converters/texture-formats';
12
+ import {TEXTURE_FEATURES} from '../converters/texture-formats';
13
+
14
+ /**
15
+ * Defines luma.gl "feature" names and semantics
16
+ * when value is 'string' it is the name of the extension that enables this feature
17
+ */
18
+ const WEBGL_FEATURES: Partial<Record<DeviceFeature, boolean | string>> = {
19
+ // optional WebGPU features
20
+ 'depth-clip-control': 'EXT_depth_clamp', // TODO these seem subtly different
21
+ // 'timestamp-query' // GPUQueryType "timestamp-query"
22
+ // "indirect-first-instance"
23
+ // Textures are handled by getTextureFeatures()
24
+ // 'depth24unorm-stencil8' // GPUTextureFormat 'depth24unorm-stencil8'
25
+ // 'depth32float-stencil8' // GPUTextureFormat 'depth32float-stencil8'
26
+
27
+ // optional WebGL features
28
+ 'timer-query-webgl': 'EXT_disjoint_timer_query_webgl2',
29
+ 'compilation-status-async-webgl': 'KHR_parallel_shader_compile',
30
+ 'polygon-mode-webgl': 'WEBGL_polygon_mode',
31
+ 'provoking-vertex-webgl': 'WEBGL_provoking_vertex',
32
+ 'shader-clip-cull-distance-webgl': 'WEBGL_clip_cull_distance',
33
+ 'shader-noperspective-interpolation-webgl': 'NV_shader_noperspective_interpolation',
34
+ 'shader-conservative-depth-webgl': 'EXT_conservative_depth'
35
+
36
+ // Textures are handled by getTextureFeatures()
37
+ };
38
+
39
+ /**
40
+ * WebGL extensions exposed as luma.gl features
41
+ * To minimize GL log noise and improve performance, this class ensures that
42
+ * - WebGL extensions are not queried until the corresponding feature is checked.
43
+ * - WebGL extensions are only queried once.
44
+ */
45
+ export class WebGLDeviceFeatures extends DeviceFeatures {
46
+ protected gl: WebGL2RenderingContext;
47
+ protected extensions: GLExtensions;
48
+ protected testedFeatures = new Set<DeviceFeature>();
49
+
50
+ constructor(
51
+ gl: WebGL2RenderingContext,
52
+ extensions: GLExtensions,
53
+ disabledFeatures: Partial<Record<DeviceFeature, boolean>>
54
+ ) {
55
+ super([], disabledFeatures);
56
+ this.gl = gl;
57
+ this.extensions = extensions;
58
+ // TODO - is this really needed?
59
+ // Enable EXT_float_blend first: https://developer.mozilla.org/en-US/docs/Web/API/EXT_float_blend
60
+ getWebGLExtension(gl, 'EXT_color_buffer_float', extensions);
61
+ }
62
+
63
+ *[Symbol.iterator](): IterableIterator<DeviceFeature> {
64
+ for (const feature of Object.keys(WEBGL_FEATURES) as DeviceFeature[]) {
65
+ if (this.has(feature)) {
66
+ yield feature;
67
+ }
68
+ }
69
+ for (const feature of Object.keys(TEXTURE_FEATURES) as DeviceFeature[]) {
70
+ if (this.has(feature)) {
71
+ yield feature;
72
+ }
73
+ }
74
+ return [];
75
+ }
76
+
77
+ override has(feature: DeviceFeature): boolean {
78
+ if (this.disabledFeatures[feature]) {
79
+ return false;
80
+ }
81
+
82
+ // We have already tested this feature
83
+ if (!this.testedFeatures.has(feature)) {
84
+ this.testedFeatures.add(feature);
85
+
86
+ // Check the feature once
87
+ if (isTextureFeature(feature) && checkTextureFeature(this.gl, feature, this.extensions)) {
88
+ this.features.add(feature);
89
+ }
90
+
91
+ if (this.getWebGLFeature(feature)) {
92
+ this.features.add(feature);
93
+ }
94
+ }
95
+ return this.features.has(feature);
96
+ }
97
+
98
+ // FOR DEVICE
99
+
100
+ initializeFeatures() {
101
+ // @ts-expect-error
102
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
103
+ for (const feature of this) {
104
+ // WebGL extensions are initialized by requesting them
105
+ }
106
+ }
107
+
108
+ // IMPLEMENTATION
109
+
110
+ /** Extract all WebGL features */
111
+ protected getWebGLFeature(feature: DeviceFeature): boolean {
112
+ const featureInfo = WEBGL_FEATURES[feature];
113
+ // string value requires checking the corresponding WebGL extension
114
+ const isSupported =
115
+ typeof featureInfo === 'string'
116
+ ? Boolean(getWebGLExtension(this.gl, featureInfo, this.extensions))
117
+ : Boolean(featureInfo);
118
+
119
+ return isSupported;
120
+ }
121
+ }
@@ -1,19 +1,21 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import {DeviceInfo} from '@luma.gl/core';
5
- import {GL} from '@luma.gl/constants';
6
- import {isWebGL2} from '../../context/context/webgl-checks';
6
+ import {GL, GLExtensions} from '@luma.gl/constants';
7
+ import {getWebGLExtension} from '../../context/helpers/webgl-extensions';
7
8
 
8
9
  /** @returns strings identifying the GPU vendor and driver. */
9
- export function getDeviceInfo(gl: WebGLRenderingContext): DeviceInfo {
10
+ export function getDeviceInfo(gl: WebGL2RenderingContext, extensions: GLExtensions): DeviceInfo {
10
11
  // "Masked" info is always available, but don't contain much useful information
11
12
  const vendorMasked = gl.getParameter(GL.VENDOR);
12
13
  const rendererMasked = gl.getParameter(GL.RENDERER);
13
14
 
14
15
  // If we are lucky, unmasked info is available
15
16
  // https://www.khronos.org/registry/webgl/extensions/WEBGL_debug_renderer_info/
16
- const ext = gl.getExtension('WEBGL_debug_renderer_info');
17
+ getWebGLExtension(gl, 'WEBGL_debug_renderer_info', extensions);
18
+ const ext = extensions.WEBGL_debug_renderer_info;
17
19
  const vendorUnmasked = gl.getParameter(ext ? ext.UNMASKED_VENDOR_WEBGL : GL.VENDOR);
18
20
  const rendererUnmasked = gl.getParameter(ext ? ext.UNMASKED_RENDERER_WEBGL : GL.RENDERER);
19
21
  const vendor = vendorUnmasked || vendorMasked;
@@ -32,10 +34,10 @@ export function getDeviceInfo(gl: WebGLRenderingContext): DeviceInfo {
32
34
  // const version = gl.getParameter(GL.SHADING_LANGUAGE_VERSION) as string;
33
35
  // const shadingLanguageVersion = parseGLSLVersion(version);
34
36
  const shadingLanguage = 'glsl';
35
- const shadingLanguageVersion = isWebGL2(gl) ? 300 : 100
37
+ const shadingLanguageVersion = 300;
36
38
 
37
39
  return {
38
- type: isWebGL2(gl) ? 'webgl2' : 'webgl',
40
+ type: 'webgl',
39
41
  gpu,
40
42
  gpuType,
41
43
  gpuBackend,
@@ -48,44 +50,50 @@ export function getDeviceInfo(gl: WebGLRenderingContext): DeviceInfo {
48
50
  }
49
51
 
50
52
  /** "Sniff" the GPU type from the info. This works best if unmasked info is available. */
51
- function identifyGPUVendor(vendor: string, renderer: string): 'nvidia' | 'intel' | 'apple' | 'amd' | 'software' | 'unknown' {
52
- if ((/NVIDIA/i.exec(vendor)) || (/NVIDIA/i.exec(renderer))) {
53
+ function identifyGPUVendor(
54
+ vendor: string,
55
+ renderer: string
56
+ ): 'nvidia' | 'intel' | 'apple' | 'amd' | 'software' | 'unknown' {
57
+ if (/NVIDIA/i.exec(vendor) || /NVIDIA/i.exec(renderer)) {
53
58
  return 'nvidia';
54
59
  }
55
- if ((/INTEL/i.exec(vendor)) || (/INTEL/i.exec(renderer))) {
60
+ if (/INTEL/i.exec(vendor) || /INTEL/i.exec(renderer)) {
56
61
  return 'intel';
57
62
  }
58
- if ((/Apple/i.exec(vendor)) || (/Apple/i.exec(renderer))) {
63
+ if (/Apple/i.exec(vendor) || /Apple/i.exec(renderer)) {
59
64
  return 'apple';
60
65
  }
61
66
  if (
62
- (/AMD/i.exec(vendor)) ||
63
- (/AMD/i.exec(renderer)) ||
64
- (/ATI/i.exec(vendor)) ||
65
- (/ATI/i.exec(renderer))
67
+ /AMD/i.exec(vendor) ||
68
+ /AMD/i.exec(renderer) ||
69
+ /ATI/i.exec(vendor) ||
70
+ /ATI/i.exec(renderer)
66
71
  ) {
67
72
  return 'amd';
68
73
  }
69
- if ((/SwiftShader/i.exec(vendor)) || (/SwiftShader/i.exec(renderer))) {
74
+ if (/SwiftShader/i.exec(vendor) || /SwiftShader/i.exec(renderer)) {
70
75
  return 'software';
71
76
  }
72
-
77
+
73
78
  return 'unknown';
74
79
  }
75
80
 
76
81
  /** "Sniff" the GPU backend from the info. This works best if unmasked info is available. */
77
82
  function identifyGPUBackend(vendor: string, renderer: string): 'opengl' | 'metal' | 'unknown' {
78
- if ((/Metal/i.exec(vendor)) || (/Metal/i.exec(renderer))) {
83
+ if (/Metal/i.exec(vendor) || /Metal/i.exec(renderer)) {
79
84
  return 'metal';
80
85
  }
81
- if ((/ANGLE/i.exec(vendor)) || (/ANGLE/i.exec(renderer))) {
86
+ if (/ANGLE/i.exec(vendor) || /ANGLE/i.exec(renderer)) {
82
87
  return 'opengl';
83
- }
88
+ }
84
89
  return 'unknown';
85
90
  }
86
91
 
87
- function identifyGPUType(vendor: string, renderer: string): 'discrete' | 'integrated' | 'cpu' | 'unknown' {
88
- if ((/SwiftShader/i.exec(vendor)) || (/SwiftShader/i.exec(renderer))) {
92
+ function identifyGPUType(
93
+ vendor: string,
94
+ renderer: string
95
+ ): 'discrete' | 'integrated' | 'cpu' | 'unknown' {
96
+ if (/SwiftShader/i.exec(vendor) || /SwiftShader/i.exec(renderer)) {
89
97
  return 'cpu';
90
98
  }
91
99
 
@@ -0,0 +1,53 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {DeviceLimits} from '@luma.gl/core';
6
+ import {GL} from '@luma.gl/constants';
7
+
8
+ // prettier-ignore
9
+ export class WebGLDeviceLimits extends DeviceLimits {
10
+ get maxTextureDimension1D() { return 0; } // WebGL does not support 1D textures
11
+ get maxTextureDimension2D() { return this.getParameter(GL.MAX_TEXTURE_SIZE); }
12
+ get maxTextureDimension3D() { return this.getParameter(GL.MAX_3D_TEXTURE_SIZE); }
13
+ get maxTextureArrayLayers() { return this.getParameter(GL.MAX_ARRAY_TEXTURE_LAYERS); }
14
+ get maxBindGroups() { return 0; }
15
+ get maxDynamicUniformBuffersPerPipelineLayout() { return 0; } // TBD
16
+ get maxDynamicStorageBuffersPerPipelineLayout() { return 0; } // TBD
17
+ get maxSampledTexturesPerShaderStage() { return this.getParameter(GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS); } // ) TBD
18
+ get maxSamplersPerShaderStage() { return this.getParameter(GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS); }
19
+ get maxStorageBuffersPerShaderStage() { return 0; } // TBD
20
+ get maxStorageTexturesPerShaderStage() { return 0; } // TBD
21
+ get maxUniformBuffersPerShaderStage() { return this.getParameter(GL.MAX_UNIFORM_BUFFER_BINDINGS); }
22
+ get maxUniformBufferBindingSize() { return this.getParameter(GL.MAX_UNIFORM_BLOCK_SIZE); }
23
+ get maxStorageBufferBindingSize() { return 0; }
24
+ get minUniformBufferOffsetAlignment() { return this.getParameter(GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT); }
25
+ get minStorageBufferOffsetAlignment() { return 0; }
26
+ get maxVertexBuffers() { return 16; } // WebGL 2 supports 16 buffers, see https://github.com/gpuweb/gpuweb/issues/4284
27
+ get maxVertexAttributes() { return this.getParameter(GL.MAX_VERTEX_ATTRIBS); }
28
+ get maxVertexBufferArrayStride() { return 2048; } // TBD, this is just the default value from WebGPU
29
+ get maxInterStageShaderComponents() { return this.getParameter(GL.MAX_VARYING_COMPONENTS); }
30
+ get maxComputeWorkgroupStorageSize() { return 0; } // WebGL does not support compute shaders
31
+ get maxComputeInvocationsPerWorkgroup() { return 0; } // WebGL does not support compute shaders
32
+ get maxComputeWorkgroupSizeX() { return 0; } // WebGL does not support compute shaders
33
+ get maxComputeWorkgroupSizeY() { return 0; } // WebGL does not support compute shaders
34
+ get maxComputeWorkgroupSizeZ() { return 0; } // WebGL does not support compute shaders
35
+ get maxComputeWorkgroupsPerDimension() { return 0;} // WebGL does not support compute shaders
36
+
37
+ // PRIVATE
38
+
39
+ protected gl: WebGL2RenderingContext;
40
+ protected limits: Partial<Record<GL, number>> = {};
41
+
42
+ constructor(gl: WebGL2RenderingContext) {
43
+ super();
44
+ this.gl = gl;
45
+ }
46
+
47
+ protected getParameter(parameter: GL): number {
48
+ if (this.limits[parameter] === undefined) {
49
+ this.limits[parameter] = this.gl.getParameter(parameter);
50
+ }
51
+ return this.limits[parameter];
52
+ }
53
+ }
@@ -1,4 +1,5 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import {ShaderUniformType, ShaderAttributeType, VertexFormat} from '@luma.gl/core';
@@ -67,9 +68,11 @@ const COMPOSITE_GL_TYPES: Record<
67
68
  };
68
69
 
69
70
  /** Decomposes a composite type (GL.VEC3) into a basic type (GL.FLOAT) and components (3) */
70
- export function decodeGLUniformType(
71
- glUniformType: GL
72
- ): {format: ShaderUniformType; components: number; glType: GLDataType} {
71
+ export function decodeGLUniformType(glUniformType: GL): {
72
+ format: ShaderUniformType;
73
+ components: number;
74
+ glType: GLDataType;
75
+ } {
73
76
  const typeAndSize = COMPOSITE_GL_TYPES[glUniformType];
74
77
  if (!typeAndSize) {
75
78
  throw new Error('uniform');
@@ -87,11 +90,11 @@ export function decodeGLAttributeType(glAttributeType: GL): {
87
90
  } {
88
91
  const typeAndSize = COMPOSITE_GL_TYPES[glAttributeType];
89
92
  if (!typeAndSize) {
90
- throw new Error('attribute')
93
+ throw new Error('attribute');
91
94
  }
92
95
  const [, components, , shaderType, vertexFormat] = typeAndSize;
93
96
  // TODO sanity - if (shaderType.startsWith('mat' ...))
94
- const attributeType = shaderType as unknown as ShaderAttributeType
97
+ const attributeType = shaderType as unknown as ShaderAttributeType;
95
98
  return {attributeType, vertexFormat, components}; // , glType};
96
99
  }
97
100
 
@@ -107,7 +110,10 @@ export function decomposeCompositeGLDataType(
107
110
  return {type, components};
108
111
  }
109
112
 
110
- export function getCompositeGLDataType(type: GL, components): {glType: GLDataType; name: string} | null {
113
+ export function getCompositeGLDataType(
114
+ type: GL,
115
+ components
116
+ ): {glType: GLDataType; name: string} | null {
111
117
  switch (type) {
112
118
  case GL.BYTE:
113
119
  case GL.UNSIGNED_BYTE:
@@ -1,4 +1,5 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import type {
@@ -10,7 +11,6 @@ import type {
10
11
  } from '@luma.gl/core';
11
12
 
12
13
  import {GL} from '@luma.gl/constants';
13
- import {isWebGL2} from '../../context/context/webgl-checks';
14
14
  import {Accessor} from '../../classic/accessor'; // TODO - should NOT depend on classic API
15
15
  import {decodeGLUniformType, decodeGLAttributeType, isSamplerUniform} from './decode-webgl-types';
16
16
 
@@ -19,7 +19,7 @@ import {decodeGLUniformType, decodeGLAttributeType, isSamplerUniform} from './de
19
19
  * Note: `linkProgram()` needs to have been called
20
20
  * (although linking does not need to have been successful).
21
21
  */
22
- export function getShaderLayout(gl: WebGLRenderingContext, program: WebGLProgram): ShaderLayout {
22
+ export function getShaderLayout(gl: WebGL2RenderingContext, program: WebGLProgram): ShaderLayout {
23
23
  const shaderLayout: ShaderLayout = {
24
24
  attributes: [],
25
25
  bindings: []
@@ -88,7 +88,7 @@ export function getShaderLayout(gl: WebGLRenderingContext, program: WebGLProgram
88
88
  * linkProgram needs to have been called, although linking does not need to have been successful
89
89
  */
90
90
  function readAttributeDeclarations(
91
- gl: WebGLRenderingContext,
91
+ gl: WebGL2RenderingContext,
92
92
  program: WebGLProgram
93
93
  ): AttributeDeclaration[] {
94
94
  const attributes: AttributeDeclaration[] = [];
@@ -106,7 +106,7 @@ function readAttributeDeclarations(
106
106
  if (location >= 0) {
107
107
  const {attributeType} = decodeGLAttributeType(compositeType);
108
108
 
109
- // Whether an attribute is instanced is essentially fixed by the structure of the shader code,
109
+ // Whether an attribute is instanced is essentially fixed by the structure of the shader code,
110
110
  // so it is arguably a static property of the shader.
111
111
  // There is no hint in the shader declarations
112
112
  // Heuristic: Any attribute name containing the word "instance" will be assumed to be instanced
@@ -116,7 +116,7 @@ function readAttributeDeclarations(
116
116
  name,
117
117
  location,
118
118
  stepMode,
119
- type: attributeType,
119
+ type: attributeType
120
120
  // size - for arrays, size is the number of elements in the array
121
121
  });
122
122
  }
@@ -132,17 +132,12 @@ function readAttributeDeclarations(
132
132
  *
133
133
  * linkProgram needs to have been called, although linking does not need to have been successful
134
134
  */
135
- function readVaryings(gl: WebGLRenderingContext, program: WebGLProgram): VaryingBinding[] {
136
- if (!isWebGL2(gl)) {
137
- return [];
138
- }
139
- const gl2 = gl as WebGL2RenderingContext;
140
-
135
+ function readVaryings(gl: WebGL2RenderingContext, program: WebGLProgram): VaryingBinding[] {
141
136
  const varyings: VaryingBinding[] = [];
142
137
 
143
138
  const count = gl.getProgramParameter(program, GL.TRANSFORM_FEEDBACK_VARYINGS);
144
139
  for (let location = 0; location < count; location++) {
145
- const activeInfo = gl2.getTransformFeedbackVarying(program, location);
140
+ const activeInfo = gl.getTransformFeedbackVarying(program, location);
146
141
  if (!activeInfo) {
147
142
  throw new Error('activeInfo');
148
143
  }
@@ -162,7 +157,7 @@ function readVaryings(gl: WebGLRenderingContext, program: WebGLProgram): Varying
162
157
  *
163
158
  * Query uniform locations and build name to setter map.
164
159
  */
165
- function readUniformBindings(gl: WebGLRenderingContext, program: WebGLProgram): UniformBinding[] {
160
+ function readUniformBindings(gl: WebGL2RenderingContext, program: WebGLProgram): UniformBinding[] {
166
161
  const uniforms: UniformBinding[] = [];
167
162
 
168
163
  const uniformCount = gl.getProgramParameter(program, GL.ACTIVE_UNIFORMS);
@@ -209,23 +204,18 @@ function readUniformBindings(gl: WebGLRenderingContext, program: WebGLProgram):
209
204
  * @note In WebGL, "active" just means that unused (inactive) blocks may have been optimized away during linking)
210
205
  */
211
206
  function readUniformBlocks(
212
- gl: WebGLRenderingContext,
207
+ gl: WebGL2RenderingContext,
213
208
  program: WebGLProgram
214
209
  ): UniformBlockBinding[] {
215
- if (!isWebGL2(gl)) {
216
- return [];
217
- }
218
- const gl2 = gl as WebGL2RenderingContext;
219
-
220
210
  const getBlockParameter = (blockIndex: number, pname: GL): any =>
221
- gl2.getActiveUniformBlockParameter(program, blockIndex, pname);
211
+ gl.getActiveUniformBlockParameter(program, blockIndex, pname);
222
212
 
223
213
  const uniformBlocks: UniformBlockBinding[] = [];
224
214
 
225
- const blockCount = gl2.getProgramParameter(program, GL.ACTIVE_UNIFORM_BLOCKS);
215
+ const blockCount = gl.getProgramParameter(program, GL.ACTIVE_UNIFORM_BLOCKS);
226
216
  for (let blockIndex = 0; blockIndex < blockCount; blockIndex++) {
227
217
  const blockInfo: UniformBlockBinding = {
228
- name: gl2.getActiveUniformBlockName(program, blockIndex) || '',
218
+ name: gl.getActiveUniformBlockName(program, blockIndex) || '',
229
219
  location: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_BINDING),
230
220
  byteLength: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_DATA_SIZE),
231
221
  vertex: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),
@@ -237,23 +227,23 @@ function readUniformBlocks(
237
227
  const uniformIndices =
238
228
  (getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES) as number[]) || [];
239
229
 
240
- const uniformType = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_TYPE); // Array of GLenum indicating the types of the uniforms.
241
- const uniformArrayLength = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_SIZE); // Array of GLuint indicating the sizes of the uniforms.
242
- // const uniformBlockIndex = gl2.getActiveUniforms(
230
+ const uniformType = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_TYPE); // Array of GLenum indicating the types of the uniforms.
231
+ const uniformArrayLength = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_SIZE); // Array of GLuint indicating the sizes of the uniforms.
232
+ // const uniformBlockIndex = gl.getActiveUniforms(
243
233
  // program,
244
234
  // uniformIndices,
245
235
  // GL.UNIFORM_BLOCK_INDEX
246
236
  // ); // Array of GLint indicating the block indices of the uniforms.
247
- const uniformOffset = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_OFFSET); // Array of GLint indicating the uniform buffer offsets.
248
- const uniformStride = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_ARRAY_STRIDE); // Array of GLint indicating the strides between the elements.
249
- // const uniformMatrixStride = gl2.getActiveUniforms(
237
+ const uniformOffset = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_OFFSET); // Array of GLint indicating the uniform buffer offsets.
238
+ const uniformStride = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_ARRAY_STRIDE); // Array of GLint indicating the strides between the elements.
239
+ // const uniformMatrixStride = gl.getActiveUniforms(
250
240
  // program,
251
241
  // uniformIndices,
252
242
  // GL.UNIFORM_MATRIX_STRIDE
253
243
  // ); // Array of GLint indicating the strides between columns of a column-major matrix or a row-major matrix.
254
- // const uniformRowMajor = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_IS_ROW_MAJOR);
244
+ // const uniformRowMajor = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_IS_ROW_MAJOR);
255
245
  for (let i = 0; i < blockInfo.uniformCount; ++i) {
256
- const activeInfo = gl2.getActiveUniform(program, uniformIndices[i]);
246
+ const activeInfo = gl.getActiveUniform(program, uniformIndices[i]);
257
247
  if (!activeInfo) {
258
248
  throw new Error('activeInfo');
259
249
  }
@@ -1,4 +1,5 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import type {CompilerMessage} from '@luma.gl/core';
@@ -8,7 +9,7 @@ import type {CompilerMessage} from '@luma.gl/core';
8
9
  * This follows documented WebGL conventions for compilation logs.
9
10
  * Based on https://github.com/wwwtyro/gl-format-compiler-error (public domain)
10
11
  */
11
- export function parseShaderCompilerLog(errLog: string) : readonly CompilerMessage[] {
12
+ export function parseShaderCompilerLog(errLog: string): readonly CompilerMessage[] {
12
13
  // Parse the error - note: browser and driver dependent
13
14
  const lines = errLog.split(/\r?\n/);
14
15
 
@@ -30,7 +31,7 @@ export function parseShaderCompilerLog(errLog: string) : readonly CompilerMessag
30
31
  lineNum: 0,
31
32
  linePos: 0
32
33
  });
33
- continue; // eslint-disable-line no-continue
34
+ continue; // eslint-disable-line no-continue
34
35
  }
35
36
 
36
37
  const [messageType, linePosition, lineNumber, ...rest] = segments;
@@ -50,15 +51,18 @@ export function parseShaderCompilerLog(errLog: string) : readonly CompilerMessag
50
51
  type: getMessageType(messageType),
51
52
  lineNum,
52
53
  linePos // TODO
53
- })
54
+ });
54
55
  }
55
56
 
56
57
  return messages;
57
58
  }
58
59
 
59
60
  /** Ensure supported type */
60
- function getMessageType(messageType: string): 'warning' | 'error' | 'info' {
61
+ function getMessageType(messageType: string): 'warning' | 'error' | 'info' {
61
62
  const MESSAGE_TYPES = ['warning', 'error', 'info'];
62
63
  const lowerCaseType = messageType.toLowerCase();
63
- return (MESSAGE_TYPES.includes(lowerCaseType) ? lowerCaseType : 'info') as 'warning' | 'error' | 'info';
64
+ return (MESSAGE_TYPES.includes(lowerCaseType) ? lowerCaseType : 'info') as
65
+ | 'warning'
66
+ | 'error'
67
+ | 'info';
64
68
  }
@@ -1,4 +1,5 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  /* eslint-disable */
@@ -10,7 +11,7 @@ import {GL, GLCompositeType, GLSamplerType} from '@luma.gl/constants';
10
11
  /** Set a raw uniform (without type conversion and caching) */
11
12
  /* eslint-disable max-len */
12
13
  export function setUniform(
13
- gl: WebGLRenderingContext,
14
+ gl: WebGL2RenderingContext,
14
15
  location: WebGLUniformLocation,
15
16
  type: GLCompositeType | GLSamplerType,
16
17
  value: UniformValue
@@ -29,10 +30,8 @@ export function setUniform(
29
30
 
30
31
  // prettier-ignore
31
32
  switch (type) {
32
- // WebGL1 samplers
33
33
  case GL.SAMPLER_2D:
34
34
  case GL.SAMPLER_CUBE:
35
- // WebGL2 samplers
36
35
  case GL.SAMPLER_3D:
37
36
  case GL.SAMPLER_2D_SHADOW:
38
37
  case GL.SAMPLER_2D_ARRAY:
@@ -1,4 +1,5 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import {GL, GLPrimitiveTopology, GLPrimitive} from '@luma.gl/constants';
@@ -27,7 +28,10 @@ export function getPrimitiveDrawMode(drawMode: GLPrimitiveTopology): GLPrimitive
27
28
  }
28
29
 
29
30
  // Counts the number of complete "primitives" given a number of vertices and a drawMode
30
- export function getPrimitiveCount(options: {drawMode: GLPrimitiveTopology, vertexCount: number}): number {
31
+ export function getPrimitiveCount(options: {
32
+ drawMode: GLPrimitiveTopology;
33
+ vertexCount: number;
34
+ }): number {
31
35
  const {drawMode, vertexCount} = options;
32
36
  switch (drawMode) {
33
37
  case GL.POINTS:
@@ -48,7 +52,10 @@ export function getPrimitiveCount(options: {drawMode: GLPrimitiveTopology, verte
48
52
  }
49
53
 
50
54
  // Counts the number of vertices after splitting the vertex stream into separate "primitives"
51
- export function getVertexCount(options: {drawMode: GLPrimitiveTopology, vertexCount: number}): number {
55
+ export function getVertexCount(options: {
56
+ drawMode: GLPrimitiveTopology;
57
+ vertexCount: number;
58
+ }): number {
52
59
  const {drawMode, vertexCount} = options;
53
60
  const primitiveCount = getPrimitiveCount({drawMode, vertexCount});
54
61
  switch (getPrimitiveDrawMode(drawMode)) {
@@ -1,11 +1,12 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import {assert} from '@luma.gl/core';
5
6
  import {GL} from '@luma.gl/constants';
6
7
 
7
8
  // Resolve a WebGL enumeration name (returns itself if already a number)
8
- export function getKeyValue(gl: WebGLRenderingContext, name: string | GL): GL {
9
+ export function getKeyValue(gl: WebGL2RenderingContext, name: string | GL): GL {
9
10
  // If not a string, return (assume number)
10
11
  if (typeof name !== 'string') {
11
12
  return name;