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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (288) hide show
  1. package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
  2. package/dist/adapter/converters/device-parameters.js +297 -155
  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 +13 -19
  9. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  10. package/dist/adapter/converters/texture-formats.js +474 -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/device-features.d.ts +2 -5
  14. package/dist/adapter/device-helpers/device-features.d.ts.map +1 -1
  15. package/dist/adapter/device-helpers/device-features.js +56 -87
  16. package/dist/adapter/device-helpers/device-limits.d.ts +2 -4
  17. package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
  18. package/dist/adapter/device-helpers/device-limits.js +88 -83
  19. package/dist/adapter/device-helpers/get-device-info.d.ts +1 -1
  20. package/dist/adapter/device-helpers/get-device-info.d.ts.map +1 -1
  21. package/dist/adapter/device-helpers/get-device-info.js +79 -63
  22. package/dist/adapter/device-helpers/webgl-device-features.d.ts +19 -0
  23. package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -0
  24. package/dist/adapter/device-helpers/webgl-device-features.js +86 -0
  25. package/dist/adapter/device-helpers/webgl-device-info.d.ts +5 -0
  26. package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -0
  27. package/dist/adapter/device-helpers/webgl-device-info.js +90 -0
  28. package/dist/adapter/device-helpers/webgl-device-limits.d.ts +35 -0
  29. package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -0
  30. package/dist/adapter/device-helpers/webgl-device-limits.js +47 -0
  31. package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -1
  32. package/dist/adapter/helpers/decode-webgl-types.js +88 -76
  33. package/dist/adapter/helpers/get-shader-layout.d.ts +1 -1
  34. package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
  35. package/dist/adapter/helpers/get-shader-layout.js +261 -225
  36. package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
  37. package/dist/adapter/helpers/parse-shader-compiler-log.js +47 -37
  38. package/dist/adapter/helpers/set-uniform.d.ts +1 -1
  39. package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
  40. package/dist/adapter/helpers/set-uniform.js +68 -82
  41. package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
  42. package/dist/adapter/helpers/webgl-topology-utils.js +78 -93
  43. package/dist/adapter/objects/constants-to-keys.d.ts +1 -1
  44. package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
  45. package/dist/adapter/objects/constants-to-keys.js +19 -12
  46. package/dist/adapter/objects/webgl-renderbuffer.d.ts +2 -2
  47. package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
  48. package/dist/adapter/objects/webgl-renderbuffer.js +86 -77
  49. package/dist/adapter/objects/webgl-resource.d.ts +3 -25
  50. package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
  51. package/dist/adapter/objects/webgl-resource.js +102 -146
  52. package/dist/adapter/resources/webgl-buffer.d.ts +3 -4
  53. package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
  54. package/dist/adapter/resources/webgl-buffer.js +161 -119
  55. package/dist/adapter/resources/webgl-command-buffer.d.ts +1 -1
  56. package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
  57. package/dist/adapter/resources/webgl-command-buffer.js +266 -168
  58. package/dist/adapter/resources/webgl-command-encoder.d.ts +8 -3
  59. package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
  60. package/dist/adapter/resources/webgl-command-encoder.js +33 -39
  61. package/dist/adapter/resources/webgl-external-texture.js +93 -1
  62. package/dist/adapter/resources/webgl-framebuffer.d.ts +8 -10
  63. package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
  64. package/dist/adapter/resources/webgl-framebuffer.js +167 -137
  65. package/dist/adapter/resources/webgl-query-set.d.ts +44 -0
  66. package/dist/adapter/resources/webgl-query-set.d.ts.map +1 -0
  67. package/dist/adapter/resources/webgl-query-set.js +136 -0
  68. package/dist/adapter/resources/webgl-render-pass.d.ts +3 -1
  69. package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
  70. package/dist/adapter/resources/webgl-render-pass.js +124 -90
  71. package/dist/adapter/resources/webgl-render-pipeline.d.ts +15 -6
  72. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  73. package/dist/adapter/resources/webgl-render-pipeline.js +356 -221
  74. package/dist/adapter/resources/webgl-sampler.d.ts +1 -3
  75. package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
  76. package/dist/adapter/resources/webgl-sampler.js +43 -33
  77. package/dist/adapter/resources/webgl-shader.d.ts +12 -2
  78. package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
  79. package/dist/adapter/resources/webgl-shader.js +114 -47
  80. package/dist/adapter/resources/webgl-texture-view.d.ts +14 -0
  81. package/dist/adapter/resources/webgl-texture-view.d.ts.map +1 -0
  82. package/dist/adapter/resources/webgl-texture-view.js +18 -0
  83. package/dist/adapter/resources/webgl-texture.d.ts +6 -9
  84. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  85. package/dist/adapter/resources/webgl-texture.js +615 -695
  86. package/dist/adapter/resources/webgl-transform-feedback.d.ts +2 -2
  87. package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
  88. package/dist/adapter/resources/webgl-transform-feedback.js +141 -143
  89. package/dist/adapter/resources/webgl-vertex-array.d.ts +3 -3
  90. package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
  91. package/dist/adapter/resources/webgl-vertex-array.js +229 -157
  92. package/dist/adapter/webgl-canvas-context.d.ts +2 -2
  93. package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
  94. package/dist/adapter/webgl-canvas-context.js +58 -36
  95. package/dist/adapter/webgl-device.d.ts +34 -40
  96. package/dist/adapter/webgl-device.d.ts.map +1 -1
  97. package/dist/adapter/webgl-device.js +418 -363
  98. package/dist/classic/accessor.d.ts.map +1 -1
  99. package/dist/classic/accessor.js +132 -101
  100. package/dist/classic/clear.d.ts +2 -2
  101. package/dist/classic/clear.d.ts.map +1 -1
  102. package/dist/classic/clear.js +73 -72
  103. package/dist/classic/copy-and-blit.d.ts +1 -1
  104. package/dist/classic/copy-and-blit.d.ts.map +1 -1
  105. package/dist/classic/copy-and-blit.js +175 -175
  106. package/dist/classic/format-utils.d.ts +2 -2
  107. package/dist/classic/format-utils.d.ts.map +1 -1
  108. package/dist/classic/format-utils.js +39 -32
  109. package/dist/classic/typed-array-utils.d.ts.map +1 -1
  110. package/dist/classic/typed-array-utils.js +96 -81
  111. package/dist/context/context/context-data.d.ts +14 -0
  112. package/dist/context/context/context-data.d.ts.map +1 -0
  113. package/dist/context/context/context-data.js +33 -0
  114. package/dist/context/context/create-browser-context.d.ts +1 -6
  115. package/dist/context/context/create-browser-context.d.ts.map +1 -1
  116. package/dist/context/context/create-browser-context.js +62 -49
  117. package/dist/context/debug/spector.d.ts.map +1 -1
  118. package/dist/context/debug/spector.js +55 -50
  119. package/dist/context/debug/webgl-developer-tools.d.ts +1 -2
  120. package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
  121. package/dist/context/debug/webgl-developer-tools.js +104 -77
  122. package/dist/context/helpers/create-browser-context.d.ts +35 -0
  123. package/dist/context/helpers/create-browser-context.d.ts.map +1 -0
  124. package/dist/context/helpers/create-browser-context.js +67 -0
  125. package/dist/context/{polyfill/context-data.d.ts → helpers/webgl-context-data.d.ts} +2 -2
  126. package/dist/context/helpers/webgl-context-data.d.ts.map +1 -0
  127. package/dist/context/helpers/webgl-context-data.js +21 -0
  128. package/dist/context/helpers/webgl-extensions.d.ts +4 -0
  129. package/dist/context/helpers/webgl-extensions.d.ts.map +1 -0
  130. package/dist/context/helpers/webgl-extensions.js +10 -0
  131. package/dist/context/parameters/unified-parameter-api.d.ts +3 -3
  132. package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
  133. package/dist/context/parameters/unified-parameter-api.js +94 -44
  134. package/dist/context/parameters/webgl-parameter-tables.d.ts +120 -99
  135. package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
  136. package/dist/context/parameters/webgl-parameter-tables.js +469 -404
  137. package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
  138. package/dist/context/state-tracker/deep-array-equal.js +19 -14
  139. package/dist/context/state-tracker/track-context-state.d.ts +4 -4
  140. package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
  141. package/dist/context/state-tracker/track-context-state.js +188 -123
  142. package/dist/context/state-tracker/with-parameters.d.ts +2 -2
  143. package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
  144. package/dist/context/state-tracker/with-parameters.js +43 -26
  145. package/dist/dist.dev.js +3135 -4142
  146. package/dist/index.cjs +1766 -2717
  147. package/dist/index.cjs.map +7 -0
  148. package/dist/index.d.ts +25 -28
  149. package/dist/index.d.ts.map +1 -1
  150. package/dist/index.js +16 -5
  151. package/dist/types.d.ts.map +1 -1
  152. package/dist/types.js +3 -1
  153. package/dist.min.js +9 -42
  154. package/package.json +11 -15
  155. package/src/adapter/converters/device-parameters.ts +105 -17
  156. package/src/adapter/converters/sampler-parameters.ts +12 -20
  157. package/src/adapter/converters/shader-formats.ts +47 -22
  158. package/src/adapter/converters/texture-formats.ts +138 -185
  159. package/src/adapter/converters/vertex-formats.ts +3 -3
  160. package/src/adapter/device-helpers/webgl-device-features.ts +101 -0
  161. package/src/adapter/device-helpers/{get-device-info.ts → webgl-device-info.ts} +30 -22
  162. package/src/adapter/device-helpers/webgl-device-limits.ts +53 -0
  163. package/src/adapter/helpers/decode-webgl-types.ts +13 -7
  164. package/src/adapter/helpers/get-shader-layout.ts +21 -31
  165. package/src/adapter/helpers/parse-shader-compiler-log.ts +10 -6
  166. package/src/adapter/helpers/set-uniform.ts +3 -4
  167. package/src/adapter/helpers/webgl-topology-utils.ts +10 -3
  168. package/src/adapter/objects/constants-to-keys.ts +3 -2
  169. package/src/adapter/objects/webgl-renderbuffer.ts +38 -16
  170. package/src/adapter/objects/webgl-resource.ts +7 -140
  171. package/src/adapter/resources/webgl-buffer.ts +10 -14
  172. package/src/adapter/resources/webgl-command-buffer.ts +24 -34
  173. package/src/adapter/resources/webgl-command-encoder.ts +14 -11
  174. package/src/adapter/resources/webgl-external-texture.ts +5 -5
  175. package/src/adapter/resources/webgl-framebuffer.ts +38 -34
  176. package/src/adapter/resources/webgl-query-set.ts +171 -0
  177. package/src/adapter/resources/webgl-render-pass.ts +24 -15
  178. package/src/adapter/resources/webgl-render-pipeline.ts +138 -70
  179. package/src/adapter/resources/webgl-sampler.ts +7 -10
  180. package/src/adapter/resources/webgl-shader.ts +65 -11
  181. package/src/adapter/resources/webgl-texture-view.ts +28 -0
  182. package/src/adapter/resources/webgl-texture.ts +38 -105
  183. package/src/adapter/resources/webgl-transform-feedback.ts +16 -22
  184. package/src/adapter/resources/webgl-vertex-array.ts +20 -21
  185. package/src/adapter/webgl-canvas-context.ts +7 -11
  186. package/src/adapter/webgl-device.ts +106 -151
  187. package/src/classic/accessor.ts +5 -4
  188. package/src/classic/clear.ts +25 -20
  189. package/src/classic/copy-and-blit.ts +12 -6
  190. package/src/classic/format-utils.ts +2 -1
  191. package/src/classic/typed-array-utils.ts +3 -7
  192. package/src/context/debug/spector.ts +9 -6
  193. package/src/context/debug/webgl-developer-tools.ts +31 -20
  194. package/src/context/{context → helpers}/create-browser-context.ts +9 -33
  195. package/src/context/{polyfill/context-data.ts → helpers/webgl-context-data.ts} +3 -2
  196. package/src/context/helpers/webgl-extensions.ts +17 -0
  197. package/src/context/parameters/unified-parameter-api.ts +5 -4
  198. package/src/context/parameters/webgl-parameter-tables.ts +118 -90
  199. package/src/context/state-tracker/deep-array-equal.ts +2 -1
  200. package/src/context/state-tracker/track-context-state.ts +29 -23
  201. package/src/context/state-tracker/with-parameters.ts +7 -2
  202. package/src/index.ts +4 -18
  203. package/src/types.ts +2 -1
  204. package/dist/adapter/converters/device-parameters.js.map +0 -1
  205. package/dist/adapter/converters/sampler-parameters.js.map +0 -1
  206. package/dist/adapter/converters/shader-formats.js.map +0 -1
  207. package/dist/adapter/converters/texture-formats.js.map +0 -1
  208. package/dist/adapter/converters/vertex-formats.js.map +0 -1
  209. package/dist/adapter/device-helpers/device-features.js.map +0 -1
  210. package/dist/adapter/device-helpers/device-limits.js.map +0 -1
  211. package/dist/adapter/device-helpers/get-device-info.js.map +0 -1
  212. package/dist/adapter/device-helpers/is-old-ie.d.ts +0 -2
  213. package/dist/adapter/device-helpers/is-old-ie.d.ts.map +0 -1
  214. package/dist/adapter/device-helpers/is-old-ie.js +0 -9
  215. package/dist/adapter/device-helpers/is-old-ie.js.map +0 -1
  216. package/dist/adapter/helpers/decode-webgl-types.js.map +0 -1
  217. package/dist/adapter/helpers/get-shader-layout.js.map +0 -1
  218. package/dist/adapter/helpers/parse-shader-compiler-log.js.map +0 -1
  219. package/dist/adapter/helpers/set-uniform.js.map +0 -1
  220. package/dist/adapter/helpers/webgl-topology-utils.js.map +0 -1
  221. package/dist/adapter/objects/constants-to-keys.js.map +0 -1
  222. package/dist/adapter/objects/webgl-renderbuffer.js.map +0 -1
  223. package/dist/adapter/objects/webgl-resource.js.map +0 -1
  224. package/dist/adapter/resources/webgl-buffer.js.map +0 -1
  225. package/dist/adapter/resources/webgl-command-buffer.js.map +0 -1
  226. package/dist/adapter/resources/webgl-command-encoder.js.map +0 -1
  227. package/dist/adapter/resources/webgl-external-texture.js.map +0 -1
  228. package/dist/adapter/resources/webgl-framebuffer.js.map +0 -1
  229. package/dist/adapter/resources/webgl-render-pass.js.map +0 -1
  230. package/dist/adapter/resources/webgl-render-pipeline.js.map +0 -1
  231. package/dist/adapter/resources/webgl-sampler.js.map +0 -1
  232. package/dist/adapter/resources/webgl-shader.js.map +0 -1
  233. package/dist/adapter/resources/webgl-texture.js.map +0 -1
  234. package/dist/adapter/resources/webgl-transform-feedback.js.map +0 -1
  235. package/dist/adapter/resources/webgl-vertex-array.js.map +0 -1
  236. package/dist/adapter/webgl-canvas-context.js.map +0 -1
  237. package/dist/adapter/webgl-device.js.map +0 -1
  238. package/dist/classic/accessor.js.map +0 -1
  239. package/dist/classic/clear.js.map +0 -1
  240. package/dist/classic/copy-and-blit.js.map +0 -1
  241. package/dist/classic/format-utils.js.map +0 -1
  242. package/dist/classic/typed-array-utils.js.map +0 -1
  243. package/dist/context/context/create-browser-context.js.map +0 -1
  244. package/dist/context/context/create-headless-context.d.ts +0 -9
  245. package/dist/context/context/create-headless-context.d.ts.map +0 -1
  246. package/dist/context/context/create-headless-context.js +0 -42
  247. package/dist/context/context/create-headless-context.js.map +0 -1
  248. package/dist/context/context/webgl-checks.d.ts +0 -13
  249. package/dist/context/context/webgl-checks.d.ts.map +0 -1
  250. package/dist/context/context/webgl-checks.js +0 -31
  251. package/dist/context/context/webgl-checks.js.map +0 -1
  252. package/dist/context/debug/spector.js.map +0 -1
  253. package/dist/context/debug/webgl-developer-tools.js.map +0 -1
  254. package/dist/context/parameters/unified-parameter-api.js.map +0 -1
  255. package/dist/context/parameters/webgl-parameter-tables.js.map +0 -1
  256. package/dist/context/polyfill/context-data.d.ts.map +0 -1
  257. package/dist/context/polyfill/context-data.js +0 -12
  258. package/dist/context/polyfill/context-data.js.map +0 -1
  259. package/dist/context/polyfill/get-parameter-polyfill.d.ts +0 -2
  260. package/dist/context/polyfill/get-parameter-polyfill.d.ts.map +0 -1
  261. package/dist/context/polyfill/get-parameter-polyfill.js +0 -85
  262. package/dist/context/polyfill/get-parameter-polyfill.js.map +0 -1
  263. package/dist/context/polyfill/polyfill-context.d.ts +0 -5
  264. package/dist/context/polyfill/polyfill-context.d.ts.map +0 -1
  265. package/dist/context/polyfill/polyfill-context.js +0 -87
  266. package/dist/context/polyfill/polyfill-context.js.map +0 -1
  267. package/dist/context/polyfill/polyfill-table.d.ts +0 -48
  268. package/dist/context/polyfill/polyfill-table.d.ts.map +0 -1
  269. package/dist/context/polyfill/polyfill-table.js +0 -137
  270. package/dist/context/polyfill/polyfill-table.js.map +0 -1
  271. package/dist/context/polyfill/polyfill-vertex-array-object.d.ts +0 -2
  272. package/dist/context/polyfill/polyfill-vertex-array-object.d.ts.map +0 -1
  273. package/dist/context/polyfill/polyfill-vertex-array-object.js +0 -265
  274. package/dist/context/polyfill/polyfill-vertex-array-object.js.map +0 -1
  275. package/dist/context/state-tracker/deep-array-equal.js.map +0 -1
  276. package/dist/context/state-tracker/track-context-state.js.map +0 -1
  277. package/dist/context/state-tracker/with-parameters.js.map +0 -1
  278. package/dist/index.js.map +0 -1
  279. package/dist/types.js.map +0 -1
  280. package/src/adapter/device-helpers/device-features.ts +0 -161
  281. package/src/adapter/device-helpers/device-limits.ts +0 -155
  282. package/src/adapter/device-helpers/is-old-ie.ts +0 -14
  283. package/src/context/context/create-headless-context.ts +0 -51
  284. package/src/context/context/webgl-checks.ts +0 -51
  285. package/src/context/polyfill/get-parameter-polyfill.ts +0 -122
  286. package/src/context/polyfill/polyfill-context.ts +0 -104
  287. package/src/context/polyfill/polyfill-table.ts +0 -167
  288. package/src/context/polyfill/polyfill-vertex-array-object.ts +0 -365
@@ -1 +0,0 @@
1
- {"version":3,"file":"track-context-state.js","names":["assert","GL_PARAMETER_DEFAULTS","GL_HOOKED_SETTERS","NON_CACHE_PARAMETERS","setGLParameters","getGLParameters","deepArrayEqual","GLState","constructor","gl","copyState","log","arguments","length","undefined","program","stateStack","enable","cache","Object","assign","_updateCache","bind","seal","push","values","pop","oldValues","valueChanged","oldValue","key","value","cached","getContextState","state","trackContextState","options","installProgramSpy","setter","installSetterSpy","installGetterOverride","glState","pushContextState","popContextState","functionName","originalGetterFunc","get","pname","has","defineProperty","configurable","originalSetterFunc","set","_len","params","Array","_key","originalUseProgram","useProgram","useProgramLuma","handle"],"sources":["../../../src/context/state-tracker/track-context-state.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n// Support for listening to context state changes and intercepting state queries\n// NOTE: this system does not handle buffer bindings\nimport {assert} from '@luma.gl/core';\nimport {GL_PARAMETER_DEFAULTS, GL_HOOKED_SETTERS, NON_CACHE_PARAMETERS} from '../parameters/webgl-parameter-tables';\nimport {setGLParameters, getGLParameters} from '../parameters/unified-parameter-api';\nimport {deepArrayEqual} from './deep-array-equal';\n\n// HELPER CLASS - GLState\n\n/* eslint-disable no-shadow */\nclass GLState {\n gl: WebGLRenderingContext;\n program: unknown = null;\n stateStack: object[] = [];\n enable = true;\n cache: Record<string, any>;\n log;\n\n constructor(\n gl: WebGLRenderingContext,\n {\n copyState = false, // Copy cache from params (slow) or initialize from WebGL defaults (fast)\n log = () => {} // Logging function, called when gl parameter change calls are actually issued\n } = {}\n ) {\n this.gl = gl;\n this.cache = copyState ? getGLParameters(gl) : Object.assign({}, GL_PARAMETER_DEFAULTS);\n this.log = log;\n\n this._updateCache = this._updateCache.bind(this);\n Object.seal(this);\n }\n\n push(values = {}) {\n this.stateStack.push({});\n }\n\n pop() {\n assert(this.stateStack.length > 0);\n // Use the saved values in the state stack to restore parameters\n const oldValues = this.stateStack[this.stateStack.length - 1];\n setGLParameters(this.gl, oldValues);\n // Don't pop until we have reset parameters (to make sure other \"stack frames\" are not affected)\n this.stateStack.pop();\n }\n\n /**\n // interceptor for context set functions - update our cache and our stack\n // values (Object) - the key values for this setter\n * @param values\n * @returns\n */\n _updateCache(values: {[key: number | string]: any}) {\n let valueChanged = false;\n let oldValue; // = undefined\n\n const oldValues: {[key: number | string]: any} | null = this.stateStack.length > 0 ? this.stateStack[this.stateStack.length - 1] : null;\n\n for (const key in values) {\n assert(key !== undefined);\n const value = values[key];\n const cached = this.cache[key];\n // Check that value hasn't already been shadowed\n if (!deepArrayEqual(value, cached)) {\n valueChanged = true;\n oldValue = cached;\n\n // First, save current value being shadowed\n // If a state stack frame is active, save the current parameter values for pop\n // but first check that value hasn't already been shadowed and saved\n if (oldValues && !(key in oldValues)) {\n oldValues[key] = cached;\n }\n\n // Save current value being shadowed\n this.cache[key] = value;\n }\n }\n\n return {valueChanged, oldValue};\n }\n}\n\nfunction getContextState(gl: WebGLRenderingContext): GLState {\n // @ts-expect-error\n return gl.state as GLState;\n}\n\n// PUBLIC API\n\n/**\n * Initialize WebGL state caching on a context\n * can be called multiple times to enable/disable\n *\n * @note After calling this function, context state will be cached\n * gl.state.push() and gl.state.pop() will be available for saving,\n * temporarily modifying, and then restoring state.\n */\nexport function trackContextState(\n gl: WebGLRenderingContext,\n options?: {\n enable?: boolean;\n copyState?: boolean;\n log?: any;\n }\n): WebGLRenderingContext {\n const {enable = true, copyState} = options;\n assert(copyState !== undefined);\n // @ts-expect-error\n if (!gl.state) {\n // @ts-ignore\n // const {polyfillContext} = global_;\n // if (polyfillContext) {\n // polyfillContext(gl);\n // }\n\n // Create a state cache\n // @ts-expect-error\n gl.state = new GLState(gl, {copyState});\n\n installProgramSpy(gl);\n\n // intercept all setter functions in the table\n for (const key in GL_HOOKED_SETTERS) {\n const setter = GL_HOOKED_SETTERS[key];\n installSetterSpy(gl, key, setter);\n }\n\n // intercept all getter functions in the table\n installGetterOverride(gl, 'getParameter');\n installGetterOverride(gl, 'isEnabled');\n }\n\n const glState = getContextState(gl);\n glState.enable = enable;\n\n return gl;\n}\n\n/**\n * Saves current WebGL context state onto an internal per-context stack\n */\nexport function pushContextState(gl: WebGLRenderingContext): void {\n let glState = getContextState(gl);\n if (!glState) {\n trackContextState(gl, {copyState: false});\n glState = getContextState(gl);\n }\n glState.push();\n}\n\n\n/**\n * Restores previously saved WebGL context state\n */\nexport function popContextState(gl: WebGLRenderingContext): void {\n const glState = getContextState(gl);\n assert(glState);\n glState.pop();\n}\n\n// HELPER FUNCTIONS - INSTALL GET/SET INTERCEPTORS (SPYS) ON THE CONTEXT\n\n/**\n// Overrides a WebGLRenderingContext state \"getter\" function\n// to return values directly from cache\n * @param gl\n * @param functionName\n */\nfunction installGetterOverride(gl: WebGLRenderingContext, functionName: string) {\n // Get the original function from the WebGLRenderingContext\n const originalGetterFunc = gl[functionName].bind(gl);\n\n // Wrap it with a spy so that we can update our state cache when it gets called\n gl[functionName] = function get(pname) {\n if (pname === undefined || NON_CACHE_PARAMETERS.has(pname)) {\n // Invalid or blacklisted parameter, do not cache\n return originalGetterFunc(pname);\n }\n\n const glState = getContextState(gl);\n if (!(pname in glState.cache)) {\n // WebGL limits are not prepopulated in the cache, call the original getter when first queried.\n glState.cache[pname] = originalGetterFunc(pname);\n }\n\n // Optionally call the original function to do a \"hard\" query from the WebGLRenderingContext\n return glState.enable\n ? // Call the getter the params so that it can e.g. serve from a cache\n glState.cache[pname]\n : // Optionally call the original function to do a \"hard\" query from the WebGLRenderingContext\n originalGetterFunc(pname);\n };\n\n // Set the name of this anonymous function to help in debugging and profiling\n Object.defineProperty(gl[functionName], 'name', {\n value: `${functionName}-from-cache`,\n configurable: false\n });\n}\n\n/**\n// Overrides a WebGLRenderingContext state \"setter\" function\n// to call a setter spy before the actual setter. Allows us to keep a cache\n// updated with a copy of the WebGL context state.\n * @param gl\n * @param functionName\n * @param setter\n * @returns\n */\nfunction installSetterSpy(gl: WebGLRenderingContext, functionName: string, setter: Function) {\n // Get the original function from the WebGLRenderingContext\n if (!gl[functionName]) {\n // This could happen if we try to intercept WebGL2 method on a WebGL1 context\n return;\n }\n\n const originalSetterFunc = gl[functionName].bind(gl);\n\n // Wrap it with a spy so that we can update our state cache when it gets called\n gl[functionName] = function set(...params) {\n // Update the value\n // Call the setter with the state cache and the params so that it can store the parameters\n const glState = getContextState(gl);\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const {valueChanged, oldValue} = setter(glState._updateCache, ...params);\n\n // Call the original WebGLRenderingContext func to make sure the context actually gets updated\n if (valueChanged) {\n originalSetterFunc(...params);\n }\n\n // Note: if the original function fails to set the value, our state cache will be bad\n // No solution for this at the moment, but assuming that this is unlikely to be a real problem\n // We could call the setter after the originalSetterFunc. Concern is that this would\n // cause different behavior in debug mode, where originalSetterFunc can throw exceptions\n\n return oldValue;\n };\n\n // Set the name of this anonymous function to help in debugging and profiling\n Object.defineProperty(gl[functionName], 'name', {\n value: `${functionName}-to-cache`,\n configurable: false\n });\n}\n\nfunction installProgramSpy(gl: WebGLRenderingContext): void {\n const originalUseProgram = gl.useProgram.bind(gl);\n\n gl.useProgram = function useProgramLuma(handle) {\n const glState = getContextState(gl);\n if (glState.program !== handle) {\n originalUseProgram(handle);\n glState.program = handle;\n }\n };\n}\n"],"mappings":"AAKA,SAAQA,MAAM,QAAO,eAAe;AAAC,SAC7BC,qBAAqB,EAAEC,iBAAiB,EAAEC,oBAAoB;AAAA,SAC9DC,eAAe,EAAEC,eAAe;AAAA,SAChCC,cAAc;AAKtB,MAAMC,OAAO,CAAC;EAQZC,WAAWA,CACTC,EAAyB,EAKzB;IAAA,IAJA;MACEC,SAAS,GAAG,KAAK;MACjBC,GAAG,GAAGA,CAAA,KAAM,CAAC;IACf,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAA,KAZRH,EAAE;IAAA,KACFM,OAAO,GAAY,IAAI;IAAA,KACvBC,UAAU,GAAa,EAAE;IAAA,KACzBC,MAAM,GAAG,IAAI;IAAA,KACbC,KAAK;IAAA,KACLP,GAAG;IASD,IAAI,CAACF,EAAE,GAAGA,EAAE;IACZ,IAAI,CAACS,KAAK,GAAGR,SAAS,GAAGL,eAAe,CAACI,EAAE,CAAC,GAAGU,MAAM,CAACC,M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C9BH,kBAAkB,CAACG,MAAM,CAAC;MAC1BnB,OAAO,CAAC1B,OAAO,GAAG6C,MAAM;IAC1B;EACF,CAAC;AACH"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"with-parameters.js","names":["WebGLDevice","setGLParameters","pushContextState","popContextState","withGLParameters","device","parameters","func","webglDevice","attach","gl","isObjectEmpty","nocatch","value","object","key"],"sources":["../../../src/context/state-tracker/with-parameters.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {Device} from '@luma.gl/core';\nimport {WebGLDevice} from '../../adapter/webgl-device';\nimport {GLParameters, setGLParameters} from '../parameters/unified-parameter-api';\nimport {pushContextState, popContextState} from './track-context-state';\n\n/**\n * Execute a function with a set of temporary WebGL parameter overrides\n * - Saves current \"global\" WebGL context settings\n * - Sets the supplies WebGL context parameters,\n * - Executes supplied function\n * - Restores parameters\n * - Returns the return value of the supplied function\n */\nexport function withGLParameters(device: Device | WebGLRenderingContext, parameters: GLParameters & {nocatch?: boolean}, func: any): any {\n const webglDevice = WebGLDevice.attach(device);\n const gl = webglDevice.gl;\n\n if (isObjectEmpty(parameters)) {\n // Avoid setting state if no parameters provided. Just call and return\n return func(device);\n }\n\n const {nocatch = true} = parameters;\n\n pushContextState(gl);\n setGLParameters(gl, parameters);\n\n // Setup is done, call the function\n let value;\n\n if (nocatch) {\n // Avoid try catch to minimize stack size impact for safe execution paths\n value = func(gl);\n popContextState(gl);\n } else {\n // Wrap in a try-catch to ensure that parameters are restored on exceptions\n try {\n value = func(gl);\n } finally {\n popContextState(gl);\n }\n }\n\n return value;\n}\n\n// Helpers\n\n// Returns true if given object is empty, false otherwise.\nfunction isObjectEmpty(object) {\n // @ts-ignore - dummy key variable\n for (const key in object) {\n return false;\n }\n return true;\n}\n"],"mappings":"SAIQA,WAAW;AAAA,SACGC,eAAe;AAAA,SAC7BC,gBAAgB,EAAEC,eAAe;AAUzC,OAAO,SAASC,gBAAgBA,CAACC,MAAsC,EAAEC,UAA8C,EAAEC,IAAS,EAAO;EACvI,MAAMC,WAAW,GAAGR,WAAW,CAACS,MAAM,CAACJ,MAAM,CAAC;EAC9C,MAAMK,EAAE,GAAGF,WAAW,CAACE,EAAE;EAEzB,IAAIC,aAAa,CAACL,UAAU,CAAC,EAAE;IAE7B,OAAOC,IAAI,CAACF,MAAM,CAAC;EACrB;EAEA,MAAM;IAACO,OAAO,GAAG;EAAI,CAAC,GAAGN,UAAU;EAEnCJ,gBAAgB,CAACQ,EAAE,CAAC;EACpBT,eAAe,CAACS,EAAE,EAAEJ,UAAU,CAAC;EAG/B,IAAIO,KAAK;EAET,IAAID,OAAO,EAAE;IAEXC,KAAK,GAAGN,IAAI,CAACG,EAAE,CAAC;IAChBP,eAAe,CAACO,EAAE,CAAC;EACrB,CAAC,MAAM;IAEL,IAAI;MACFG,KAAK,GAAGN,IAAI,CAACG,EAAE,CAAC;IAClB,CAAC,SAAS;MACRP,eAAe,CAACO,EAAE,CAAC;IACrB;EACF;EAEA,OAAOG,KAAK;AACd;AAKA,SAASF,aAAaA,CAACG,MAAM,EAAE;EAE7B,KAAK,MAAMC,GAAG,IAAID,MAAM,EAAE;IACxB,OAAO,KAAK;EACd;EACA,OAAO,IAAI;AACb"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["registerHeadlessGL","WebGLDevice","WebGLCanvasContext","WebGLResource","WEBGLResource","WEBGLBuffer","WEBGLTexture","WEBGLShader","WEBGLSampler","WEBGLFramebuffer","WEBGLRenderPipeline","WEBGLCommandEncoder","WEBGLRenderPass","WEBGLVertexArray","WEBGLRenderbuffer","WEBGLTransformFeedback","Accessor","isWebGL","isWebGL2","getWebGL2Context","assertWebGLContext","assertWebGL2Context","setDeviceParameters","withDeviceParameters","getShaderLayout","convertGLToTextureFormat","_checkFloat32ColorAttachment","TEXTURE_FORMATS","_TEXTURE_FORMATS","trackContextState","pushContextState","popContextState","polyfillContext","resetGLParameters","setGLParameters","getGLParameters","withGLParameters"],"sources":["../src/index.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n// luma.gl Base WebGL wrapper library\n// Provides simple class/function wrappers around the low level webgl objects\n// These classes are intentionally close to the WebGL API\n// but make it easier to use.\n// Higher level abstractions can be built on these classes\n\n// Types\nexport type {WebGLLimits} from './adapter/device-helpers/device-limits';\n\nexport {registerHeadlessGL} from './context/context/create-headless-context';\n\n// WebGL adapter classes\nexport {WebGLDevice} from './adapter/webgl-device';\nexport {WebGLCanvasContext} from './adapter/webgl-canvas-context';\n\n// WebGL Resource classes\nexport {WebGLResource, WebGLResource as WEBGLResource} from './adapter/objects/webgl-resource';\nexport {WEBGLBuffer} from './adapter/resources/webgl-buffer';\nexport {WEBGLTexture} from './adapter/resources/webgl-texture';\n// export {WEBGLExternalTexture} from './adapter/resources/webgl-external-texture';\nexport {WEBGLShader} from './adapter/resources/webgl-shader';\nexport {WEBGLSampler} from './adapter/resources/webgl-sampler';\nexport {WEBGLFramebuffer} from './adapter/resources/webgl-framebuffer';\n\nexport {WEBGLRenderPipeline} from './adapter/resources/webgl-render-pipeline';\n// export {WEBGLComputePipeline} from './adapter/resources/webgl-compute-pipeline';\nexport {WEBGLCommandEncoder} from './adapter/resources/webgl-command-encoder';\nexport {WEBGLRenderPass} from './adapter/resources/webgl-render-pass';\n// export {WEBGLComputePass} from './adapter/resources/webgl-compute-pass';\nexport {WEBGLVertexArray} from './adapter/resources/webgl-vertex-array';\n\n// Internal WebGL classes\nexport type {RenderbufferProps} from './adapter/objects/webgl-renderbuffer';\nexport {WEBGLRenderbuffer} from './adapter/objects/webgl-renderbuffer';\n\n// WebGL adapter classes\nexport {WEBGLTransformFeedback} from './adapter/resources/webgl-transform-feedback';\n\n// WebGL adapter classes\nexport {Accessor} from './classic/accessor';\nexport type {AccessorObject} from './types';\n\nexport {\n isWebGL,\n isWebGL2,\n getWebGL2Context,\n assertWebGLContext,\n assertWebGL2Context\n} from './context/context/webgl-checks';\n\n// Unified parameter API\n\nexport {setDeviceParameters, withDeviceParameters} from './adapter/converters/device-parameters';\n\n// HELPERS - EXPERIMENTAL\nexport {getShaderLayout} from './adapter/helpers/get-shader-layout';\nexport {\n convertGLToTextureFormat,\n _checkFloat32ColorAttachment\n} from './adapter/converters/texture-formats';\n\n// TEST EXPORTS\nexport {TEXTURE_FORMATS as _TEXTURE_FORMATS} from './adapter/converters/texture-formats';\n\n// DEPRECATED TEST EXPORTS\n// State tracking\nexport {\n trackContextState,\n pushContextState,\n popContextState\n} from './context/state-tracker/track-context-state';\n// Polyfills (supports a subset of WebGL2 APIs on WebGL1 contexts)\nexport {polyfillContext} from './context/polyfill/polyfill-context';\n\nexport {\n resetGLParameters,\n setGLParameters,\n getGLParameters\n} from './context/parameters/unified-parameter-api';\n\nexport {withGLParameters} from './context/state-tracker/with-parameters';\n"],"mappings":"SAYQA,kBAAkB;AAAA,SAGlBC,WAAW;AAAA,SACXC,kBAAkB;AAAA,SAGlBC,aAAa,EAAEA,aAAa,IAAIC,aAAa;AAAA,SAC7CC,WAAW;AAAA,SACXC,YAAY;AAAA,SAEZC,WAAW;AAAA,SACXC,YAAY;AAAA,SACZC,gBAAgB;AAAA,SAEhBC,mBAAmB;AAAA,SAEnBC,mBAAmB;AAAA,SACnBC,eAAe;AAAA,SAEfC,gBAAgB;AAAA,SAIhBC,iBAAiB;AAAA,SAGjBC,sBAAsB;AAAA,SAGtBC,QAAQ;AAAA,SAIdC,OAAO,EACPC,QAAQ,EACRC,gBAAgB,EAChBC,kBAAkB,EAClBC,mBAAmB;AAAA,SAKbC,mBAAmB,EAAEC,oBAAoB;AAAA,SAGzCC,eAAe;AAAA,SAErBC,wBAAwB,EACxBC,4BAA4B;AAAA,SAItBC,eAAe,IAAIC,gBAAgB;AAAA,SAKzCC,iBAAiB,EACjBC,gBAAgB,EAChBC,eAAe;AAAA,SAGTC,eAAe;AAAA,SAGrBC,iBAAiB,EACjBC,eAAe,EACfC,eAAe;AAAA,SAGTC,gBAAgB"}
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nexport type AccessorObject = {\n size?: number;\n index?: number;\n type?: number;\n divisor?: number;\n offset?: number;\n stride?: number;\n normalized?: boolean;\n integer?: boolean;\n};\n"],"mappings":""}
@@ -1,161 +0,0 @@
1
- // luma.gl, MIT license
2
- // Copyright (c) vis.gl contributors
3
-
4
- // Feature detection for WebGL
5
- // Provides a function that enables simple checking of which WebGL features are
6
- // available in an WebGL1 or WebGL2 environment.
7
-
8
- import {DeviceFeature} from '@luma.gl/core';
9
- import {isWebGL2} from '../../context/context/webgl-checks';
10
- import {isOldIE} from './is-old-ie';
11
- import {getTextureFeatures, _checkFloat32ColorAttachment} from '../converters/texture-formats';
12
-
13
- /** Get WebGPU style feature strings */
14
- export function getDeviceFeatures(gl: WebGLRenderingContext): Set<DeviceFeature> {
15
- const features = getWebGLFeatures(gl);
16
-
17
- // texture features
18
- // features.add('texture-compression-bc');
19
- for (const textureFeature of getTextureFeatures(gl)) {
20
- features.add(textureFeature);
21
- }
22
-
23
- // TODO
24
- // features.add('depth-clip-control'); // GPUPrimitiveState.clampDepth
25
- // features.add('depth24unorm-stencil8'); // GPUTextureFormat 'depth24unorm-stencil8'.
26
- // features.add('depth32float-stencil8'); // GPUTextureFormat 'depth32float-stencil8'.
27
- // features.add('timestamp-query'); // GPUQueryType "timestamp-query"
28
- // "indirect-first-instance"
29
-
30
- return features;
31
- }
32
-
33
- /** Extract all WebGL features */
34
- export function getWebGLFeatures(gl: WebGLRenderingContext): Set<DeviceFeature> {
35
- // Enables EXT_float_blend first: https://developer.mozilla.org/en-US/docs/Web/API/EXT_float_blend
36
- gl.getExtension('EXT_color_buffer_float');
37
- gl.getExtension('WEBGL_color_buffer_float');
38
- gl.getExtension('EXT_float_blend');
39
-
40
- const features = new Set<DeviceFeature>();
41
- for (const feature of Object.keys(WEBGL_FEATURES)) {
42
- // @ts-expect-error
43
- if (isFeatureSupported(gl, feature)) {
44
- // @ts-expect-error
45
- features.add(feature);
46
- }
47
- }
48
- return features;
49
- }
50
-
51
- function isFeatureSupported(gl: WebGLRenderingContext, feature: DeviceFeature): boolean {
52
- const featureInfo = WEBGL_FEATURES[feature];
53
- if (!featureInfo) {
54
- return false;
55
- }
56
-
57
- const [webgl1Feature, webgl2Feature] = featureInfo || [];
58
-
59
- // Get extension name from table
60
- const featureDefinition = isWebGL2(gl) ? webgl2Feature : webgl1Feature;
61
-
62
- // Check if the value is dependent on checking one or more extensions
63
- if (typeof featureDefinition === 'boolean') {
64
- return featureDefinition;
65
- }
66
-
67
- switch (feature) {
68
- case 'texture-renderable-rgba32float-webgl':
69
- return isWebGL2(gl) ? Boolean(gl.getExtension(featureDefinition)) :
70
- _checkFloat32ColorAttachment(gl);
71
- case 'glsl-derivatives':
72
- return canCompileGLSLExtension(gl, featureDefinition); // TODO options
73
- case 'glsl-frag-data':
74
- return canCompileGLSLExtension(gl, featureDefinition, {behavior: 'require'}); // TODO options
75
- case 'glsl-frag-depth':
76
- return canCompileGLSLExtension(gl, featureDefinition); // TODO options
77
- default:
78
- return Boolean(gl.getExtension(featureDefinition));
79
- }
80
- }
81
-
82
- const compiledGLSLExtensions: Record<string, boolean> = {};
83
-
84
- /*
85
- * Enables feature detection in IE11 due to a bug where gl.getExtension may return true
86
- * but fail to compile when the extension is enabled in the shader. Specifically,
87
- * the OES_standard_derivatives and WEBGL_draw_buffers extensions fails to compile in IE11 even though its included
88
- * in the list of supported extensions.
89
- * opts allows user agent to be overridden for testing
90
- * Inputs :
91
- * gl : WebGL context
92
- * cap : Key of WEBGL_FEATURES object identifying the extension
93
- * opts :
94
- * behavior : behavior of extension to be tested, by defualt `enable` is used
95
- * Returns : true, if shader is compiled successfully, false otherwise
96
- */
97
- export function canCompileGLSLExtension(gl: WebGLRenderingContext, extensionName, opts: {behavior?} = {}) {
98
- if (!isOldIE(opts)) {
99
- return true;
100
- }
101
-
102
- if (extensionName in compiledGLSLExtensions) {
103
- return compiledGLSLExtensions[extensionName];
104
- }
105
-
106
- const behavior = opts.behavior || 'enable';
107
- const source = `#extension GL_${extensionName} : ${behavior}\nvoid main(void) {}`;
108
-
109
- const shader = gl.createShader(gl.VERTEX_SHADER);
110
- if (!shader) {
111
- throw new Error('shader');
112
- }
113
- gl.shaderSource(shader, source);
114
- gl.compileShader(shader);
115
- const canCompile = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
116
- gl.deleteShader(shader);
117
- compiledGLSLExtensions[extensionName] = canCompile;
118
- return canCompile;
119
- }
120
-
121
- /** Defines luma.gl "feature" names and semantics
122
- * Format: 'feature-name: [WebGL1 support, WebGL2 support] / [WebGL1 and WebGL2 support]', when support is 'string' it is the name of the extension
123
- */
124
- const WEBGL_FEATURES: Partial<Record<DeviceFeature, [boolean | string, boolean | string]>> = {
125
- 'webgl': [true, true],
126
- 'webgl2': [false, true],
127
-
128
- 'timer-query-webgl': ['EXT_disjoint_timer_query', 'EXT_disjoint_timer_query_webgl2'],
129
- 'transform-feedback-webgl2': [false, true],
130
-
131
- // WEBGL1 SUPPORT
132
- 'vertex-array-object-webgl1': ['OES_vertex_array_object', true],
133
- 'instanced-rendering-webgl1': ['ANGLE_instanced_arrays', true],
134
- 'multiple-render-targets-webgl1': ['WEBGL_draw_buffers', true],
135
- 'index-uint32-webgl1': ['OES_element_index_uint', true],
136
- 'blend-minmax-webgl1': ['EXT_blend_minmax', true],
137
- 'texture-blend-float-webgl1': ['EXT_float_blend', 'EXT_float_blend'],
138
-
139
- // TEXTURES, RENDERBUFFERS
140
- 'texture-formats-srgb-webgl1': ['EXT_sRGB', true],
141
-
142
- // TEXTURES
143
- 'texture-formats-depth-webgl1': ['WEBGL_depth_texture', true],
144
- 'texture-formats-float32-webgl1': ['OES_texture_float', true],
145
- 'texture-formats-float16-webgl1': ['OES_texture_half_float', true],
146
-
147
- 'texture-filter-linear-float32-webgl': ['OES_texture_float_linear', 'OES_texture_float_linear'],
148
- 'texture-filter-linear-float16-webgl': ['OES_texture_half_float_linear', 'OES_texture_half_float_linear'],
149
- 'texture-filter-anisotropic-webgl': ['EXT_texture_filter_anisotropic', 'EXT_texture_filter_anisotropic'],
150
-
151
- // FRAMEBUFFERS, TEXTURES AND RENDERBUFFERS
152
- 'texture-renderable-rgba32float-webgl': ['WEBGL_color_buffer_float', 'EXT_color_buffer_float'], // Note override check
153
- 'texture-renderable-float32-webgl': [false, 'EXT_color_buffer_float'],
154
- 'texture-renderable-float16-webgl': ['EXT_color_buffer_half_float', 'EXT_color_buffer_half_float'],
155
-
156
- // GLSL extensions
157
- 'glsl-frag-data': ['WEBGL_draw_buffers', true],
158
- 'glsl-frag-depth': ['EXT_frag_depth', true],
159
- 'glsl-derivatives': ['OES_standard_derivatives', true],
160
- 'glsl-texture-lod': ['EXT_shader_texture_lod', true]
161
- };
@@ -1,155 +0,0 @@
1
- // luma.gl, MIT license
2
- // Copyright (c) vis.gl contributors
3
-
4
- import type {DeviceLimits} from '@luma.gl/core';
5
- import {GL} from '@luma.gl/constants';
6
- import {getWebGL2Context} from '../../context/context/webgl-checks';
7
-
8
- /** Populate a WebGPU style device limits */
9
- export function getDeviceLimits(gl: WebGLRenderingContext): DeviceLimits {
10
- const gl2: WebGL2RenderingContext | null = getWebGL2Context(gl);
11
- return {
12
- maxTextureDimension1D: 0, // WebGL does not support 1D textures
13
- maxTextureDimension2D: gl.getParameter(GL.MAX_TEXTURE_SIZE),
14
- maxTextureDimension3D: gl2 ? gl2.getParameter(GL.MAX_3D_TEXTURE_SIZE) : 0,
15
- maxTextureArrayLayers: gl2 ? gl2.getParameter(GL.MAX_ARRAY_TEXTURE_LAYERS) : 0,
16
- maxBindGroups: 1, // TBD
17
- maxDynamicUniformBuffersPerPipelineLayout: 0, // TBD
18
- maxDynamicStorageBuffersPerPipelineLayout: 0, // TBD
19
- maxSampledTexturesPerShaderStage: gl.getParameter(GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS), // TBD
20
- maxSamplersPerShaderStage: gl.getParameter(GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS),
21
- maxStorageBuffersPerShaderStage: 0, // TBD
22
- maxStorageTexturesPerShaderStage: 0, // TBD
23
- maxUniformBuffersPerShaderStage: gl2 ? gl2.getParameter(GL.MAX_UNIFORM_BUFFER_BINDINGS) : 0,
24
- maxUniformBufferBindingSize: gl2 ? gl2.getParameter(GL.MAX_UNIFORM_BLOCK_SIZE) : 0,
25
- maxStorageBufferBindingSize: 0,
26
- minUniformBufferOffsetAlignment: gl2 ? gl2.getParameter(GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT) : 0,
27
- minStorageBufferOffsetAlignment: 0, // TBD
28
- maxVertexBuffers: 0,
29
- maxVertexAttributes: gl.getParameter(GL.MAX_VERTEX_ATTRIBS),
30
- maxVertexBufferArrayStride: 2048, // TBD, this is just the default value from WebGPU
31
- maxInterStageShaderComponents: gl2 ? gl2.getParameter(GL.MAX_VARYING_COMPONENTS) : 0,
32
- maxComputeWorkgroupStorageSize: 0, // WebGL does not support compute shaders
33
- maxComputeInvocationsPerWorkgroup: 0, // WebGL does not support compute shaders
34
- maxComputeWorkgroupSizeX: 0, // WebGL does not support compute shaders
35
- maxComputeWorkgroupSizeY: 0, // WebGL does not support compute shaders
36
- maxComputeWorkgroupSizeZ: 0, // WebGL does not support compute shaders
37
- maxComputeWorkgroupsPerDimension: 0, // WebGL does not support compute shaders
38
- }
39
- }
40
-
41
- /** WebGL context limits */
42
- export type WebGLLimits = {
43
- [GL.ALIASED_LINE_WIDTH_RANGE]: [number, number];
44
- [GL.ALIASED_POINT_SIZE_RANGE]: [number, number];
45
- [GL.MAX_TEXTURE_SIZE]: number;
46
- [GL.MAX_CUBE_MAP_TEXTURE_SIZE]: number;
47
- [GL.MAX_TEXTURE_IMAGE_UNITS]: number;
48
- [GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS]: number;
49
- [GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS]: number;
50
- [GL.MAX_RENDERBUFFER_SIZE]: number;
51
- [GL.MAX_VARYING_VECTORS]: number;
52
- [GL.MAX_VERTEX_ATTRIBS]: number;
53
- [GL.MAX_VERTEX_UNIFORM_VECTORS]: number;
54
- [GL.MAX_FRAGMENT_UNIFORM_VECTORS]: number;
55
- [GL.MAX_VIEWPORT_DIMS]: [number, number];
56
-
57
- // Extensions
58
- [GL.MAX_TEXTURE_MAX_ANISOTROPY_EXT]: number;
59
-
60
- // WebGL2 Limits
61
- [GL.MAX_3D_TEXTURE_SIZE]: number;
62
- [GL.MAX_ARRAY_TEXTURE_LAYERS]: number;
63
- [GL.MAX_CLIENT_WAIT_TIMEOUT_WEBGL]: number;
64
- [GL.MAX_COLOR_ATTACHMENTS]: number;
65
- [GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS]: number;
66
- [GL.MAX_COMBINED_UNIFORM_BLOCKS]: number;
67
- [GL.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS]: number;
68
- [GL.MAX_DRAW_BUFFERS]: number;
69
- [GL.MAX_ELEMENT_INDEX]: number;
70
- [GL.MAX_ELEMENTS_INDICES]: number;
71
- [GL.MAX_ELEMENTS_VERTICES]: number;
72
- [GL.MAX_FRAGMENT_INPUT_COMPONENTS]: number;
73
- [GL.MAX_FRAGMENT_UNIFORM_BLOCKS]: number;
74
- [GL.MAX_FRAGMENT_UNIFORM_COMPONENTS]: number;
75
- [GL.MAX_SAMPLES]: number;
76
- [GL.MAX_SERVER_WAIT_TIMEOUT]: number;
77
- [GL.MAX_TEXTURE_LOD_BIAS]: number;
78
- [GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS]: number;
79
- [GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS]: number;
80
- [GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS]: number;
81
- [GL.MAX_UNIFORM_BLOCK_SIZE]: number;
82
- [GL.MAX_UNIFORM_BUFFER_BINDINGS]: number;
83
- [GL.MAX_VARYING_COMPONENTS]: number;
84
- [GL.MAX_VERTEX_OUTPUT_COMPONENTS]: number;
85
- [GL.MAX_VERTEX_UNIFORM_BLOCKS]: number;
86
- [GL.MAX_VERTEX_UNIFORM_COMPONENTS]: number;
87
- [GL.MIN_PROGRAM_TEXEL_OFFSET]: number;
88
- [GL.MAX_PROGRAM_TEXEL_OFFSET]: number;
89
- [GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT]: number;
90
- };
91
-
92
-
93
- export function getWebGLLimits(gl: WebGLRenderingContext): WebGLLimits {
94
- const gl2 = getWebGL2Context(gl);
95
- function get<T = number>(pname: number): T {
96
- return gl.getParameter(pname) as T;
97
- }
98
- function get2(pname: number, defaultValue?: number): number;
99
- function get2<T>(pname: number, defaultValue: T): T;
100
- function get2<T>(pname: number, defaultValue: T): T {
101
- return gl2 ? gl2.getParameter(pname) as T : (defaultValue || 0) as T;
102
- }
103
- // function getMaxAnistropy() {
104
- // const extension = gl.getExtension('EXT_texture_filter_anisotropic');
105
- // }
106
- return {
107
- [GL.ALIASED_LINE_WIDTH_RANGE]: get(GL.ALIASED_LINE_WIDTH_RANGE),
108
- [GL.ALIASED_POINT_SIZE_RANGE]: get(GL.ALIASED_POINT_SIZE_RANGE),
109
- [GL.MAX_TEXTURE_SIZE]: get(GL.MAX_TEXTURE_SIZE),
110
- [GL.MAX_CUBE_MAP_TEXTURE_SIZE]: get(GL.MAX_CUBE_MAP_TEXTURE_SIZE), // GLint
111
- [GL.MAX_TEXTURE_IMAGE_UNITS]: get(GL.MAX_TEXTURE_IMAGE_UNITS), // GLint
112
- [GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS]: get(GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS), // GLint
113
- [GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS]: get(GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS), // GLint
114
- [GL.MAX_RENDERBUFFER_SIZE]: get(GL.MAX_RENDERBUFFER_SIZE), // GLint
115
- [GL.MAX_VARYING_VECTORS]: get(GL.MAX_VARYING_VECTORS), // GLint
116
- [GL.MAX_VERTEX_ATTRIBS]: get(GL.MAX_VERTEX_ATTRIBS), // GLint
117
- [GL.MAX_VERTEX_UNIFORM_VECTORS]: get(GL.MAX_VERTEX_UNIFORM_VECTORS), // GLint
118
- [GL.MAX_FRAGMENT_UNIFORM_VECTORS]: get(GL.MAX_FRAGMENT_UNIFORM_VECTORS), // GLint
119
- [GL.MAX_VIEWPORT_DIMS]: get(GL.MAX_VIEWPORT_DIMS),
120
-
121
- // Extensions
122
- [GL.MAX_TEXTURE_MAX_ANISOTROPY_EXT]: get(GL.MAX_TEXTURE_MAX_ANISOTROPY_EXT), // getMaxAnistropy(),
123
-
124
- // WebGL2 Limits
125
- [GL.MAX_3D_TEXTURE_SIZE]: get2(GL.MAX_3D_TEXTURE_SIZE), // GLint
126
- [GL.MAX_ARRAY_TEXTURE_LAYERS]: get2(GL.MAX_ARRAY_TEXTURE_LAYERS), // GLint
127
- [GL.MAX_CLIENT_WAIT_TIMEOUT_WEBGL]: get2(GL.MAX_CLIENT_WAIT_TIMEOUT_WEBGL), // GLint64
128
- [GL.MAX_COLOR_ATTACHMENTS]: get2(GL.MAX_COLOR_ATTACHMENTS), // GLint
129
- [GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS]: get2(GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS), // GLint64
130
- [GL.MAX_COMBINED_UNIFORM_BLOCKS]: get2(GL.MAX_COMBINED_UNIFORM_BLOCKS), // GLint
131
- [GL.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS]: get2(GL.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS), // GLint64
132
- [GL.MAX_DRAW_BUFFERS]: get2(GL.MAX_DRAW_BUFFERS), // GLint
133
- [GL.MAX_ELEMENT_INDEX]: get2(GL.MAX_ELEMENT_INDEX), // GLint64
134
- [GL.MAX_ELEMENTS_INDICES]: get2(GL.MAX_ELEMENTS_INDICES), // GLint
135
- [GL.MAX_ELEMENTS_VERTICES]: get2(GL.MAX_ELEMENTS_VERTICES), // GLint
136
- [GL.MAX_FRAGMENT_INPUT_COMPONENTS]: get2(GL.MAX_FRAGMENT_INPUT_COMPONENTS), // GLint
137
- [GL.MAX_FRAGMENT_UNIFORM_BLOCKS]: get2(GL.MAX_FRAGMENT_UNIFORM_BLOCKS), // GLint
138
- [GL.MAX_FRAGMENT_UNIFORM_COMPONENTS]: get2(GL.MAX_FRAGMENT_UNIFORM_COMPONENTS), // GLint
139
- [GL.MAX_SAMPLES]: get2(GL.MAX_SAMPLES), // GLint
140
- [GL.MAX_SERVER_WAIT_TIMEOUT]: get2(GL.MAX_SERVER_WAIT_TIMEOUT), // GLint64
141
- [GL.MAX_TEXTURE_LOD_BIAS]: get2(GL.MAX_TEXTURE_LOD_BIAS), // GLfloat
142
- [GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS]: get2(GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS), // GLint
143
- [GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS]: get2(GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS), // GLint
144
- [GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS]: get2(GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS), // GLint
145
- [GL.MAX_UNIFORM_BLOCK_SIZE]: get2(GL.MAX_UNIFORM_BLOCK_SIZE), // GLint64
146
- [GL.MAX_UNIFORM_BUFFER_BINDINGS]: get2(GL.MAX_UNIFORM_BUFFER_BINDINGS), // GLint
147
- [GL.MAX_VARYING_COMPONENTS]: get2(GL.MAX_VARYING_COMPONENTS), // GLint
148
- [GL.MAX_VERTEX_OUTPUT_COMPONENTS]: get2(GL.MAX_VERTEX_OUTPUT_COMPONENTS), // GLint
149
- [GL.MAX_VERTEX_UNIFORM_BLOCKS]: get2(GL.MAX_VERTEX_UNIFORM_BLOCKS), // GLint
150
- [GL.MAX_VERTEX_UNIFORM_COMPONENTS]: get2(GL.MAX_VERTEX_UNIFORM_COMPONENTS), // GLint
151
- [GL.MIN_PROGRAM_TEXEL_OFFSET]: get2(GL.MIN_PROGRAM_TEXEL_OFFSET), // GLint
152
- [GL.MAX_PROGRAM_TEXEL_OFFSET]: get2(GL.MAX_PROGRAM_TEXEL_OFFSET), // GLint
153
- [GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT]: get2(GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT) // GLint
154
- };
155
- }
@@ -1,14 +0,0 @@
1
- // luma.gl, MIT license
2
- // Copyright (c) vis.gl contributors
3
-
4
- // opts allows user agent to be overridden for testing
5
- export function isOldIE(opts = {}) {
6
- const navigator = typeof window !== 'undefined' ? window.navigator || {} : {};
7
- // @ts-expect-error
8
- const userAgent = opts.userAgent || navigator.userAgent || '';
9
- // We only care about older versions of IE (IE 11 and below). Newer versions of IE (Edge)
10
- // have much better web standards support.
11
- const isMSIE = userAgent.indexOf('MSIE ') !== -1;
12
- const isTrident = userAgent.indexOf('Trident/') !== -1;
13
- return isMSIE || isTrident;
14
- }
@@ -1,51 +0,0 @@
1
- // luma.gl, MIT license
2
- // Copyright (c) vis.gl contributors
3
-
4
- const ERR_HEADLESSGL_FAILED =
5
- 'Failed to create WebGL context in Node.js, headless gl returned null';
6
-
7
- const ERR_HEADLESSGL_LOAD = '\
8
- luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \
9
- contexts can not be created. This may not be an error. For example, this is a \
10
- typical configuration for isorender applications running on the server.';
11
-
12
- const CONTEXT_DEFAULTS = {
13
- width: 1,
14
- height: 1,
15
- debug: true,
16
- throwOnError: false
17
- };
18
-
19
- /** Duck typing for the main headless gl export, a function to create contexts */
20
- export type HeadlessGL = (width: number, height: number, options: Record<string, unknown>) => WebGLRenderingContext;
21
-
22
- let headlessGL: HeadlessGL | null = null;
23
-
24
- /** By importing `gl` and registering it with this function, contexts can be created under Node.js */
25
- export function registerHeadlessGL(headlessgl: HeadlessGL) {
26
- headlessGL = headlessgl;
27
- }
28
-
29
- /** @returns true if headless gl is registered */
30
- export function isHeadlessGLRegistered(): boolean {
31
- return headlessGL !== null;
32
- }
33
-
34
- /** Create headless gl context (for running under Node.js) */
35
- export function createHeadlessContext(options?: Record<string, any>): WebGLRenderingContext {
36
- options = {...CONTEXT_DEFAULTS, ...options};
37
-
38
- const {width, height, webgl1, webgl2} = options;
39
-
40
- if (webgl2 && !webgl1) {
41
- throw new Error('headless-gl does not support WebGL2');
42
- }
43
- if (!headlessGL) {
44
- throw new Error(ERR_HEADLESSGL_LOAD);
45
- }
46
- const gl = headlessGL(width, height, options);
47
- if (!gl) {
48
- throw new Error(ERR_HEADLESSGL_FAILED);
49
- }
50
- return gl;
51
- }
@@ -1,51 +0,0 @@
1
- // luma.gl, MIT license
2
- // Copyright (c) vis.gl contributors
3
-
4
- import {assert} from '@luma.gl/core';
5
-
6
- const ERR_CONTEXT = 'Invalid WebGLRenderingContext';
7
- export const ERR_WEBGL = ERR_CONTEXT;
8
- export const ERR_WEBGL2 = 'Requires WebGL2';
9
-
10
-
11
- /** Check if supplied parameter is a WebGLRenderingContext */
12
- export function isWebGL(gl: any): boolean {
13
- if (typeof WebGLRenderingContext !== 'undefined' && gl instanceof WebGLRenderingContext) {
14
- return true;
15
- }
16
- if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {
17
- return true;
18
- }
19
- // Look for debug contexts, headless gl etc
20
- return Boolean(gl && Number.isFinite(gl._version));
21
- }
22
-
23
-
24
- /** Check if supplied parameter is a WebGL2RenderingContext */
25
- export function isWebGL2(gl: any): boolean {
26
- if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {
27
- return true;
28
- }
29
- // Look for debug contexts, headless gl etc
30
- return Boolean(gl && gl._version === 2);
31
- }
32
-
33
-
34
- /** Returns a properly typed WebGL2RenderingContext from a WebGL1 context, or null */
35
- export function getWebGL2Context(gl: WebGLRenderingContext): WebGL2RenderingContext | null {
36
- // @ts-expect-error
37
- return isWebGL2(gl) ? gl : null;
38
- }
39
-
40
-
41
- /** Throw if supplied parameter is not a WebGLRenderingContext, otherwise return properly typed value */
42
- export function assertWebGLContext(gl: any): WebGLRenderingContext {
43
- assert(isWebGL(gl), ERR_CONTEXT);
44
- return gl;
45
- }
46
-
47
- /** Throw if supplied parameter is not a WebGL2RenderingContext, otherwise return properly typed value */
48
- export function assertWebGL2Context(gl: any): WebGL2RenderingContext {
49
- assert(isWebGL2(gl), ERR_WEBGL2);
50
- return gl;
51
- }
@@ -1,122 +0,0 @@
1
- // luma.gl, MIT license
2
- // Copyright (c) vis.gl contributors
3
-
4
- /* eslint-disable no-inline-comments, max-len, camelcase */
5
- import {GL} from '@luma.gl/constants';
6
- import {isWebGL2} from '../context/webgl-checks';
7
-
8
- const OES_element_index = 'OES_element_index';
9
- const WEBGL_draw_buffers = 'WEBGL_draw_buffers';
10
- const EXT_disjoint_timer_query = 'EXT_disjoint_timer_query';
11
- const EXT_disjoint_timer_query_webgl2 = 'EXT_disjoint_timer_query_webgl2';
12
- const EXT_texture_filter_anisotropic = 'EXT_texture_filter_anisotropic';
13
- const WEBGL_debug_renderer_info = 'WEBGL_debug_renderer_info';
14
-
15
- const GL_FRAGMENT_SHADER_DERIVATIVE_HINT = 0x8b8b;
16
- const GL_DONT_CARE = 0x1100;
17
- const GL_GPU_DISJOINT_EXT = 0x8fbb;
18
- const GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84ff;
19
- const GL_UNMASKED_VENDOR_WEBGL = 0x9245; // vendor string of the graphics driver.
20
- const GL_UNMASKED_RENDERER_WEBGL = 0x9246; // renderer string of the graphics driver.
21
-
22
- const getWebGL2ValueOrZero = (gl) => (!isWebGL2(gl) ? 0 : undefined);
23
-
24
- // if a function returns undefined in this table,
25
- // the original getParameter will be called, defeating the override
26
- const WEBGL_PARAMETERS = {
27
- [GL.READ_BUFFER]: (gl) => (!isWebGL2(gl) ? GL.COLOR_ATTACHMENT0 : undefined),
28
-
29
- // WebGL2 context parameters
30
- [GL_FRAGMENT_SHADER_DERIVATIVE_HINT]: (gl) => (!isWebGL2(gl) ? GL_DONT_CARE : undefined),
31
-
32
- [GL.RASTERIZER_DISCARD]: getWebGL2ValueOrZero,
33
-
34
- [GL.SAMPLES]: getWebGL2ValueOrZero,
35
-
36
- // WebGL2 extension context parameters
37
- [GL_GPU_DISJOINT_EXT]: (gl: WebGLRenderingContext, getParameter) => {
38
- const ext = isWebGL2(gl)
39
- ? gl.getExtension(EXT_disjoint_timer_query_webgl2)
40
- : gl.getExtension(EXT_disjoint_timer_query);
41
- return ext && ext.GPU_DISJOINT_EXT ? getParameter(ext.GPU_DISJOINT_EXT) : 0;
42
- },
43
-
44
- // Extension fixed values
45
- [GL_UNMASKED_VENDOR_WEBGL]: (gl: WebGLRenderingContext, getParameter) => {
46
- const ext = gl.getExtension(WEBGL_debug_renderer_info);
47
- return getParameter((ext && ext.UNMASKED_VENDOR_WEBGL) || GL.VENDOR);
48
- },
49
-
50
- [GL_UNMASKED_RENDERER_WEBGL]: (gl: WebGLRenderingContext, getParameter) => {
51
- const ext = gl.getExtension(WEBGL_debug_renderer_info);
52
- return getParameter((ext && ext.UNMASKED_RENDERER_WEBGL) || GL.RENDERER);
53
- },
54
-
55
- // Extension LIMITS
56
- [GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT]: (gl: WebGLRenderingContext, getParameter) => {
57
- // @ts-ignore TODO - store these on the device instance instead...
58
- const ext = gl.luma?.extensions?.[EXT_texture_filter_anisotropic] ||
59
- gl.getExtension('EXT_texture_filter_anisotropic');
60
- return ext ? getParameter(ext.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 1.0;
61
- },
62
-
63
- // WebGL2 Limits
64
- [GL.MAX_3D_TEXTURE_SIZE]: getWebGL2ValueOrZero,
65
- [GL.MAX_ARRAY_TEXTURE_LAYERS]: getWebGL2ValueOrZero,
66
- [GL.MAX_CLIENT_WAIT_TIMEOUT_WEBGL]: getWebGL2ValueOrZero,
67
- [GL.MAX_COLOR_ATTACHMENTS]: (gl: WebGLRenderingContext, getParameter) => {
68
- if (!isWebGL2(gl)) {
69
- const ext = gl.getExtension(WEBGL_draw_buffers);
70
- return ext ? getParameter(ext.MAX_COLOR_ATTACHMENTS_WEBGL) : 0;
71
- }
72
- return undefined;
73
- },
74
- [GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS]: getWebGL2ValueOrZero,
75
- [GL.MAX_COMBINED_UNIFORM_BLOCKS]: getWebGL2ValueOrZero,
76
- [GL.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS]: getWebGL2ValueOrZero,
77
- [GL.MAX_DRAW_BUFFERS]: (gl) => {
78
- if (!isWebGL2(gl)) {
79
- const ext = gl.getExtension(WEBGL_draw_buffers);
80
- return ext ? ext.MAX_DRAW_BUFFERS_WEBGL : 0;
81
- }
82
- return undefined;
83
- },
84
- [GL.MAX_ELEMENT_INDEX]:
85
- // Guess: per webglstats.com 99.6% of webgl2 supports 2147483647
86
- (gl) => (gl.getExtension(OES_element_index) ? 2147483647 : 65535),
87
- [GL.MAX_ELEMENTS_INDICES]:
88
- // Guess: "Reasonably safe" per webglstats.com - could be higher/lower (on some mobile devices)
89
- (gl) => (gl.getExtension(OES_element_index) ? 16777216 : 65535),
90
- [GL.MAX_ELEMENTS_VERTICES]:
91
- // Guess: "Reasonably safe" per webglstats.com - could be higher/lower (on some mobile devices)
92
- (gl) => 16777216,
93
- [GL.MAX_FRAGMENT_INPUT_COMPONENTS]: getWebGL2ValueOrZero,
94
- [GL.MAX_FRAGMENT_UNIFORM_BLOCKS]: getWebGL2ValueOrZero,
95
- [GL.MAX_FRAGMENT_UNIFORM_COMPONENTS]: getWebGL2ValueOrZero,
96
- [GL.MAX_SAMPLES]: getWebGL2ValueOrZero,
97
- [GL.MAX_SERVER_WAIT_TIMEOUT]: getWebGL2ValueOrZero,
98
- [GL.MAX_TEXTURE_LOD_BIAS]: getWebGL2ValueOrZero,
99
- [GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS]: getWebGL2ValueOrZero,
100
- [GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS]: getWebGL2ValueOrZero,
101
- [GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS]: getWebGL2ValueOrZero,
102
- [GL.MAX_UNIFORM_BLOCK_SIZE]: getWebGL2ValueOrZero,
103
- [GL.MAX_UNIFORM_BUFFER_BINDINGS]: getWebGL2ValueOrZero,
104
- [GL.MAX_VARYING_COMPONENTS]: getWebGL2ValueOrZero,
105
- [GL.MAX_VERTEX_OUTPUT_COMPONENTS]: getWebGL2ValueOrZero,
106
- [GL.MAX_VERTEX_UNIFORM_BLOCKS]: getWebGL2ValueOrZero,
107
- [GL.MAX_VERTEX_UNIFORM_COMPONENTS]: getWebGL2ValueOrZero,
108
- [GL.MIN_PROGRAM_TEXEL_OFFSET]: getWebGL2ValueOrZero,
109
- [GL.MAX_PROGRAM_TEXEL_OFFSET]: getWebGL2ValueOrZero,
110
- [GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT]: getWebGL2ValueOrZero
111
- };
112
-
113
- // A "replacement" gl.getParameter that accepts "enums" from extensions and WebGL2
114
- // and returns reasonably safe defaults
115
- export function getParameterPolyfill(gl: WebGLRenderingContext, originalGetParameter, pname) {
116
- // Return mock limits (usually 0) for WebGL2 constants to ensure these
117
- // can be queries without error
118
- const limit = WEBGL_PARAMETERS[pname];
119
- const value = typeof limit === 'function' ? limit(gl, originalGetParameter, pname) : limit;
120
- const result = value !== undefined ? value : originalGetParameter(pname);
121
- return result;
122
- }