@luma.gl/webgl 9.0.0-alpha.14 → 9.0.0-alpha.16

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 (367) hide show
  1. package/dist/adapter/converters/device-parameters.js +199 -136
  2. package/dist/adapter/converters/renderbuffer-formats.d.ts +1 -1
  3. package/dist/adapter/converters/renderbuffer-formats.d.ts.map +1 -1
  4. package/dist/adapter/converters/renderbuffer-formats.js +62 -176
  5. package/dist/adapter/converters/sampler-parameters.js +149 -206
  6. package/dist/adapter/converters/texture-formats.d.ts +2 -2
  7. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  8. package/dist/adapter/converters/texture-formats.js +437 -890
  9. package/dist/adapter/converters/vertex-formats.js +15 -33
  10. package/dist/adapter/device-helpers/device-features.js +119 -100
  11. package/dist/adapter/device-helpers/device-limits.d.ts +1 -1
  12. package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
  13. package/dist/adapter/device-helpers/device-limits.js +88 -86
  14. package/dist/adapter/device-helpers/get-device-info.js +42 -43
  15. package/dist/adapter/device-helpers/is-old-ie.js +9 -6
  16. package/dist/adapter/helpers/attribute-utils.js +50 -74
  17. package/dist/adapter/helpers/get-shader-info.d.ts +9 -0
  18. package/dist/adapter/helpers/get-shader-info.d.ts.map +1 -0
  19. package/dist/adapter/helpers/get-shader-info.js +27 -0
  20. package/dist/adapter/helpers/get-shader-layout.js +307 -296
  21. package/dist/adapter/helpers/parse-shader-compiler-log.d.ts +1 -1
  22. package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
  23. package/dist/adapter/helpers/parse-shader-compiler-log.js +32 -33
  24. package/dist/adapter/helpers/set-uniform.js +67 -110
  25. package/dist/adapter/helpers/uniforms.js +80 -85
  26. package/dist/adapter/objects/constants-to-keys.js +33 -33
  27. package/dist/adapter/objects/webgl-renderbuffer.d.ts +1 -1
  28. package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
  29. package/dist/adapter/objects/webgl-renderbuffer.js +67 -86
  30. package/dist/adapter/objects/webgl-resource.js +213 -205
  31. package/dist/adapter/objects/webgl-vertex-array-object.d.ts +1 -1
  32. package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +1 -1
  33. package/dist/adapter/objects/webgl-vertex-array-object.js +74 -76
  34. package/dist/adapter/resources/webgl-buffer.js +150 -147
  35. package/dist/adapter/resources/webgl-command-buffer.d.ts +5 -5
  36. package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
  37. package/dist/adapter/resources/webgl-command-buffer.js +39 -55
  38. package/dist/adapter/resources/webgl-command-encoder.js +25 -49
  39. package/dist/adapter/resources/webgl-external-texture.js +91 -1
  40. package/dist/adapter/resources/webgl-framebuffer.d.ts +2 -2
  41. package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
  42. package/dist/adapter/resources/webgl-framebuffer.js +231 -258
  43. package/dist/adapter/resources/webgl-render-pass.d.ts +1 -1
  44. package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
  45. package/dist/adapter/resources/webgl-render-pass.js +8 -18
  46. package/dist/adapter/resources/webgl-render-pipeline.js +316 -378
  47. package/dist/adapter/resources/webgl-sampler.js +42 -47
  48. package/dist/adapter/resources/webgl-shader.d.ts +1 -2
  49. package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
  50. package/dist/adapter/resources/webgl-shader.js +58 -68
  51. package/dist/adapter/resources/webgl-texture.d.ts +5 -5
  52. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  53. package/dist/adapter/resources/webgl-texture.js +661 -815
  54. package/dist/adapter/webgl-canvas-context.js +55 -49
  55. package/dist/adapter/webgl-device.js +288 -338
  56. package/dist/bundle.js +1 -2
  57. package/dist/classic/accessor.js +120 -127
  58. package/dist/classic/buffer.d.ts +1 -1
  59. package/dist/classic/buffer.d.ts.map +1 -1
  60. package/dist/classic/buffer.js +325 -356
  61. package/dist/classic/typed-array-utils.d.ts +1 -1
  62. package/dist/classic/typed-array-utils.d.ts.map +1 -1
  63. package/dist/classic/typed-array-utils.js +91 -101
  64. package/dist/context/context/create-browser-context.d.ts +1 -2
  65. package/dist/context/context/create-browser-context.d.ts.map +1 -1
  66. package/dist/context/context/create-browser-context.js +61 -52
  67. package/dist/context/context/create-headless-context.d.ts +1 -1
  68. package/dist/context/context/create-headless-context.d.ts.map +1 -1
  69. package/dist/context/context/create-headless-context.js +26 -33
  70. package/dist/context/context/webgl-checks.js +25 -20
  71. package/dist/context/debug/spector.d.ts +1 -2
  72. package/dist/context/debug/spector.d.ts.map +1 -1
  73. package/dist/context/debug/spector.js +53 -62
  74. package/dist/context/debug/webgl-developer-tools.d.ts +1 -1
  75. package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
  76. package/dist/context/debug/webgl-developer-tools.js +106 -93
  77. package/dist/context/parameters/unified-parameter-api.js +91 -55
  78. package/dist/context/parameters/webgl-parameter-tables.d.ts +1 -1
  79. package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
  80. package/dist/context/parameters/webgl-parameter-tables.js +462 -423
  81. package/dist/context/polyfill/context-data.js +16 -12
  82. package/dist/context/polyfill/get-parameter-polyfill.js +91 -76
  83. package/dist/context/polyfill/polyfill-context.js +75 -80
  84. package/dist/context/polyfill/polyfill-table.js +133 -139
  85. package/dist/context/polyfill/polyfill-vertex-array-object.js +255 -297
  86. package/dist/context/state-tracker/deep-array-equal.js +16 -18
  87. package/dist/context/state-tracker/track-context-state.js +183 -161
  88. package/dist/context/state-tracker/with-parameters.js +43 -35
  89. package/dist/dist.min.js +1 -0
  90. package/dist/es5/adapter/converters/device-parameters.js +3 -38
  91. package/dist/es5/adapter/converters/device-parameters.js.map +1 -1
  92. package/dist/es5/adapter/converters/renderbuffer-formats.js +2 -14
  93. package/dist/es5/adapter/converters/renderbuffer-formats.js.map +1 -1
  94. package/dist/es5/adapter/converters/sampler-parameters.js +2 -65
  95. package/dist/es5/adapter/converters/sampler-parameters.js.map +1 -1
  96. package/dist/es5/adapter/converters/texture-formats.js +9 -81
  97. package/dist/es5/adapter/converters/texture-formats.js.map +1 -1
  98. package/dist/es5/adapter/converters/vertex-formats.js +0 -12
  99. package/dist/es5/adapter/converters/vertex-formats.js.map +1 -1
  100. package/dist/es5/adapter/device-helpers/device-features.js +6 -40
  101. package/dist/es5/adapter/device-helpers/device-features.js.map +1 -1
  102. package/dist/es5/adapter/device-helpers/device-limits.js +0 -10
  103. package/dist/es5/adapter/device-helpers/device-limits.js.map +1 -1
  104. package/dist/es5/adapter/device-helpers/get-device-info.js +0 -10
  105. package/dist/es5/adapter/device-helpers/get-device-info.js.map +1 -1
  106. package/dist/es5/adapter/device-helpers/is-old-ie.js +0 -1
  107. package/dist/es5/adapter/device-helpers/is-old-ie.js.map +1 -1
  108. package/dist/es5/adapter/helpers/attribute-utils.js +3 -25
  109. package/dist/es5/adapter/helpers/attribute-utils.js.map +1 -1
  110. package/dist/es5/adapter/helpers/get-shader-info.js +31 -0
  111. package/dist/es5/adapter/helpers/get-shader-info.js.map +1 -0
  112. package/dist/es5/adapter/helpers/get-shader-layout.js +23 -101
  113. package/dist/es5/adapter/helpers/get-shader-layout.js.map +1 -1
  114. package/dist/es5/adapter/helpers/parse-shader-compiler-log.js +6 -24
  115. package/dist/es5/adapter/helpers/parse-shader-compiler-log.js.map +1 -1
  116. package/dist/es5/adapter/helpers/set-uniform.js +0 -33
  117. package/dist/es5/adapter/helpers/set-uniform.js.map +1 -1
  118. package/dist/es5/adapter/helpers/uniforms.js +13 -37
  119. package/dist/es5/adapter/helpers/uniforms.js.map +1 -1
  120. package/dist/es5/adapter/objects/constants-to-keys.js +1 -12
  121. package/dist/es5/adapter/objects/constants-to-keys.js.map +1 -1
  122. package/dist/es5/adapter/objects/webgl-renderbuffer.js +5 -33
  123. package/dist/es5/adapter/objects/webgl-renderbuffer.js.map +1 -1
  124. package/dist/es5/adapter/objects/webgl-resource.js +6 -60
  125. package/dist/es5/adapter/objects/webgl-resource.js.map +1 -1
  126. package/dist/es5/adapter/objects/webgl-vertex-array-object.js +7 -35
  127. package/dist/es5/adapter/objects/webgl-vertex-array-object.js.map +1 -1
  128. package/dist/es5/adapter/resources/webgl-buffer.js +20 -66
  129. package/dist/es5/adapter/resources/webgl-buffer.js.map +1 -1
  130. package/dist/es5/adapter/resources/webgl-command-buffer.js +6 -32
  131. package/dist/es5/adapter/resources/webgl-command-buffer.js.map +1 -1
  132. package/dist/es5/adapter/resources/webgl-command-encoder.js +0 -18
  133. package/dist/es5/adapter/resources/webgl-command-encoder.js.map +1 -1
  134. package/dist/es5/adapter/resources/webgl-external-texture.js.map +1 -1
  135. package/dist/es5/adapter/resources/webgl-framebuffer.js +10 -82
  136. package/dist/es5/adapter/resources/webgl-framebuffer.js.map +1 -1
  137. package/dist/es5/adapter/resources/webgl-render-pass.js +2 -19
  138. package/dist/es5/adapter/resources/webgl-render-pass.js.map +1 -1
  139. package/dist/es5/adapter/resources/webgl-render-pipeline.js +24 -133
  140. package/dist/es5/adapter/resources/webgl-render-pipeline.js.map +1 -1
  141. package/dist/es5/adapter/resources/webgl-sampler.js +2 -28
  142. package/dist/es5/adapter/resources/webgl-sampler.js.map +1 -1
  143. package/dist/es5/adapter/resources/webgl-shader.js +13 -52
  144. package/dist/es5/adapter/resources/webgl-shader.js.map +1 -1
  145. package/dist/es5/adapter/resources/webgl-texture.js +137 -291
  146. package/dist/es5/adapter/resources/webgl-texture.js.map +1 -1
  147. package/dist/es5/adapter/webgl-canvas-context.js +0 -24
  148. package/dist/es5/adapter/webgl-canvas-context.js.map +1 -1
  149. package/dist/es5/adapter/webgl-device.js +40 -127
  150. package/dist/es5/adapter/webgl-device.js.map +1 -1
  151. package/dist/es5/bundle.js +0 -1
  152. package/dist/es5/bundle.js.map +1 -1
  153. package/dist/es5/classic/accessor.js +1 -31
  154. package/dist/es5/classic/accessor.js.map +1 -1
  155. package/dist/es5/classic/buffer.js +32 -102
  156. package/dist/es5/classic/buffer.js.map +1 -1
  157. package/dist/es5/classic/typed-array-utils.js +10 -37
  158. package/dist/es5/classic/typed-array-utils.js.map +1 -1
  159. package/dist/es5/context/context/create-browser-context.js +4 -21
  160. package/dist/es5/context/context/create-browser-context.js.map +1 -1
  161. package/dist/es5/context/context/create-headless-context.js +8 -21
  162. package/dist/es5/context/context/create-headless-context.js.map +1 -1
  163. package/dist/es5/context/context/webgl-checks.js +4 -14
  164. package/dist/es5/context/context/webgl-checks.js.map +1 -1
  165. package/dist/es5/context/debug/spector.js +20 -54
  166. package/dist/es5/context/debug/spector.js.map +1 -1
  167. package/dist/es5/context/debug/webgl-developer-tools.js +19 -65
  168. package/dist/es5/context/debug/webgl-developer-tools.js.map +1 -1
  169. package/dist/es5/context/parameters/unified-parameter-api.js +3 -28
  170. package/dist/es5/context/parameters/unified-parameter-api.js.map +1 -1
  171. package/dist/es5/context/parameters/webgl-parameter-tables.js +18 -65
  172. package/dist/es5/context/parameters/webgl-parameter-tables.js.map +1 -1
  173. package/dist/es5/context/polyfill/context-data.js +0 -3
  174. package/dist/es5/context/polyfill/context-data.js.map +1 -1
  175. package/dist/es5/context/polyfill/get-parameter-polyfill.js +0 -12
  176. package/dist/es5/context/polyfill/get-parameter-polyfill.js.map +1 -1
  177. package/dist/es5/context/polyfill/polyfill-context.js +8 -33
  178. package/dist/es5/context/polyfill/polyfill-context.js.map +1 -1
  179. package/dist/es5/context/polyfill/polyfill-table.js +3 -27
  180. package/dist/es5/context/polyfill/polyfill-table.js.map +1 -1
  181. package/dist/es5/context/polyfill/polyfill-vertex-array-object.js +0 -70
  182. package/dist/es5/context/polyfill/polyfill-vertex-array-object.js.map +1 -1
  183. package/dist/es5/context/state-tracker/deep-array-equal.js +0 -5
  184. package/dist/es5/context/state-tracker/deep-array-equal.js.map +1 -1
  185. package/dist/es5/context/state-tracker/track-context-state.js +10 -53
  186. package/dist/es5/context/state-tracker/track-context-state.js.map +1 -1
  187. package/dist/es5/context/state-tracker/with-parameters.js +1 -13
  188. package/dist/es5/context/state-tracker/with-parameters.js.map +1 -1
  189. package/dist/es5/index.js +72 -99
  190. package/dist/es5/index.js.map +1 -1
  191. package/dist/es5/init.js +0 -3
  192. package/dist/es5/init.js.map +1 -1
  193. package/dist/es5/types/webgl.js +0 -1
  194. package/dist/es5/types/webgl.js.map +1 -1
  195. package/dist/es5/types.js.map +1 -1
  196. package/dist/esm/adapter/converters/device-parameters.js +0 -20
  197. package/dist/esm/adapter/converters/device-parameters.js.map +1 -1
  198. package/dist/esm/adapter/converters/renderbuffer-formats.js +0 -4
  199. package/dist/esm/adapter/converters/renderbuffer-formats.js.map +1 -1
  200. package/dist/esm/adapter/converters/sampler-parameters.js +2 -57
  201. package/dist/esm/adapter/converters/sampler-parameters.js.map +1 -1
  202. package/dist/esm/adapter/converters/texture-formats.js +8 -52
  203. package/dist/esm/adapter/converters/texture-formats.js.map +1 -1
  204. package/dist/esm/adapter/converters/vertex-formats.js +0 -9
  205. package/dist/esm/adapter/converters/vertex-formats.js.map +1 -1
  206. package/dist/esm/adapter/device-helpers/device-features.js +2 -19
  207. package/dist/esm/adapter/device-helpers/device-features.js.map +1 -1
  208. package/dist/esm/adapter/device-helpers/device-limits.js +0 -3
  209. package/dist/esm/adapter/device-helpers/device-limits.js.map +1 -1
  210. package/dist/esm/adapter/device-helpers/get-device-info.js +0 -6
  211. package/dist/esm/adapter/device-helpers/get-device-info.js.map +1 -1
  212. package/dist/esm/adapter/device-helpers/is-old-ie.js +2 -1
  213. package/dist/esm/adapter/device-helpers/is-old-ie.js.map +1 -1
  214. package/dist/esm/adapter/helpers/attribute-utils.js +0 -17
  215. package/dist/esm/adapter/helpers/attribute-utils.js.map +1 -1
  216. package/dist/esm/adapter/helpers/get-shader-info.js +25 -0
  217. package/dist/esm/adapter/helpers/get-shader-info.js.map +1 -0
  218. package/dist/esm/adapter/helpers/get-shader-layout.js +2 -48
  219. package/dist/esm/adapter/helpers/get-shader-layout.js.map +1 -1
  220. package/dist/esm/adapter/helpers/parse-shader-compiler-log.js +0 -7
  221. package/dist/esm/adapter/helpers/parse-shader-compiler-log.js.map +1 -1
  222. package/dist/esm/adapter/helpers/set-uniform.js +0 -30
  223. package/dist/esm/adapter/helpers/set-uniform.js.map +1 -1
  224. package/dist/esm/adapter/helpers/uniforms.js +0 -10
  225. package/dist/esm/adapter/helpers/uniforms.js.map +1 -1
  226. package/dist/esm/adapter/objects/constants-to-keys.js +0 -7
  227. package/dist/esm/adapter/objects/constants-to-keys.js.map +1 -1
  228. package/dist/esm/adapter/objects/webgl-renderbuffer.js +2 -18
  229. package/dist/esm/adapter/objects/webgl-renderbuffer.js.map +1 -1
  230. package/dist/esm/adapter/objects/webgl-resource.js +10 -57
  231. package/dist/esm/adapter/objects/webgl-resource.js.map +1 -1
  232. package/dist/esm/adapter/objects/webgl-vertex-array-object.js +5 -15
  233. package/dist/esm/adapter/objects/webgl-vertex-array-object.js.map +1 -1
  234. package/dist/esm/adapter/resources/webgl-buffer.js +12 -40
  235. package/dist/esm/adapter/resources/webgl-buffer.js.map +1 -1
  236. package/dist/esm/adapter/resources/webgl-command-buffer.js +2 -17
  237. package/dist/esm/adapter/resources/webgl-command-buffer.js.map +1 -1
  238. package/dist/esm/adapter/resources/webgl-command-encoder.js +0 -12
  239. package/dist/esm/adapter/resources/webgl-command-encoder.js.map +1 -1
  240. package/dist/esm/adapter/resources/webgl-external-texture.js.map +1 -1
  241. package/dist/esm/adapter/resources/webgl-framebuffer.js +0 -60
  242. package/dist/esm/adapter/resources/webgl-framebuffer.js.map +1 -1
  243. package/dist/esm/adapter/resources/webgl-render-pass.js +1 -8
  244. package/dist/esm/adapter/resources/webgl-render-pass.js.map +1 -1
  245. package/dist/esm/adapter/resources/webgl-render-pipeline.js +0 -89
  246. package/dist/esm/adapter/resources/webgl-render-pipeline.js.map +1 -1
  247. package/dist/esm/adapter/resources/webgl-sampler.js +0 -12
  248. package/dist/esm/adapter/resources/webgl-sampler.js.map +1 -1
  249. package/dist/esm/adapter/resources/webgl-shader.js +2 -16
  250. package/dist/esm/adapter/resources/webgl-shader.js.map +1 -1
  251. package/dist/esm/adapter/resources/webgl-texture.js +36 -154
  252. package/dist/esm/adapter/resources/webgl-texture.js.map +1 -1
  253. package/dist/esm/adapter/webgl-canvas-context.js +0 -14
  254. package/dist/esm/adapter/webgl-canvas-context.js.map +1 -1
  255. package/dist/esm/adapter/webgl-device.js +19 -89
  256. package/dist/esm/adapter/webgl-device.js.map +1 -1
  257. package/dist/esm/bundle.js +0 -1
  258. package/dist/esm/bundle.js.map +1 -1
  259. package/dist/esm/classic/accessor.js +10 -34
  260. package/dist/esm/classic/accessor.js.map +1 -1
  261. package/dist/esm/classic/buffer.js +15 -71
  262. package/dist/esm/classic/buffer.js.map +1 -1
  263. package/dist/esm/classic/typed-array-utils.js +0 -20
  264. package/dist/esm/classic/typed-array-utils.js.map +1 -1
  265. package/dist/esm/context/context/create-browser-context.js +6 -14
  266. package/dist/esm/context/context/create-browser-context.js.map +1 -1
  267. package/dist/esm/context/context/create-headless-context.js +2 -6
  268. package/dist/esm/context/context/create-headless-context.js.map +1 -1
  269. package/dist/esm/context/context/webgl-checks.js +0 -3
  270. package/dist/esm/context/context/webgl-checks.js.map +1 -1
  271. package/dist/esm/context/debug/spector.js +2 -14
  272. package/dist/esm/context/debug/spector.js.map +1 -1
  273. package/dist/esm/context/debug/webgl-developer-tools.js +4 -22
  274. package/dist/esm/context/debug/webgl-developer-tools.js.map +1 -1
  275. package/dist/esm/context/parameters/unified-parameter-api.js +2 -13
  276. package/dist/esm/context/parameters/unified-parameter-api.js.map +1 -1
  277. package/dist/esm/context/parameters/webgl-parameter-tables.js +0 -19
  278. package/dist/esm/context/parameters/webgl-parameter-tables.js.map +1 -1
  279. package/dist/esm/context/polyfill/context-data.js +0 -2
  280. package/dist/esm/context/polyfill/context-data.js.map +1 -1
  281. package/dist/esm/context/polyfill/get-parameter-polyfill.js +0 -5
  282. package/dist/esm/context/polyfill/get-parameter-polyfill.js.map +1 -1
  283. package/dist/esm/context/polyfill/polyfill-context.js +14 -21
  284. package/dist/esm/context/polyfill/polyfill-context.js.map +1 -1
  285. package/dist/esm/context/polyfill/polyfill-table.js +0 -23
  286. package/dist/esm/context/polyfill/polyfill-table.js.map +1 -1
  287. package/dist/esm/context/polyfill/polyfill-vertex-array-object.js +0 -70
  288. package/dist/esm/context/polyfill/polyfill-vertex-array-object.js.map +1 -1
  289. package/dist/esm/context/state-tracker/deep-array-equal.js +0 -4
  290. package/dist/esm/context/state-tracker/deep-array-equal.js.map +1 -1
  291. package/dist/esm/context/state-tracker/track-context-state.js +11 -45
  292. package/dist/esm/context/state-tracker/track-context-state.js.map +1 -1
  293. package/dist/esm/context/state-tracker/with-parameters.js +0 -6
  294. package/dist/esm/context/state-tracker/with-parameters.js.map +1 -1
  295. package/dist/esm/index.js.map +1 -1
  296. package/dist/esm/init.js.map +1 -1
  297. package/dist/esm/types/webgl.js.map +1 -1
  298. package/dist/esm/types.js.map +1 -1
  299. package/dist/index.js +39 -25
  300. package/dist/init.js +1 -2
  301. package/dist/types/webgl.d.ts +20 -20
  302. package/dist/types/webgl.d.ts.map +1 -1
  303. package/dist/types/webgl.js +0 -1
  304. package/dist/types.d.ts +1 -1
  305. package/dist/types.d.ts.map +1 -1
  306. package/dist/types.js +0 -1
  307. package/package.json +8 -8
  308. package/src/adapter/helpers/get-shader-info.ts +37 -0
  309. package/src/adapter/helpers/parse-shader-compiler-log.ts +1 -1
  310. package/src/adapter/resources/webgl-render-pass.ts +1 -1
  311. package/src/adapter/resources/webgl-shader.ts +2 -2
  312. package/src/adapter/webgl-device.ts +1 -1
  313. package/src/context/debug/webgl-developer-tools.ts +0 -1
  314. package/src/types/webgl.ts +4 -4
  315. package/dist/adapter/converters/device-parameters.js.map +0 -1
  316. package/dist/adapter/converters/renderbuffer-formats.js.map +0 -1
  317. package/dist/adapter/converters/sampler-parameters.js.map +0 -1
  318. package/dist/adapter/converters/texture-formats.js.map +0 -1
  319. package/dist/adapter/converters/vertex-formats.js.map +0 -1
  320. package/dist/adapter/device-helpers/device-features.js.map +0 -1
  321. package/dist/adapter/device-helpers/device-limits.js.map +0 -1
  322. package/dist/adapter/device-helpers/get-device-info.js.map +0 -1
  323. package/dist/adapter/device-helpers/is-old-ie.js.map +0 -1
  324. package/dist/adapter/helpers/attribute-utils.js.map +0 -1
  325. package/dist/adapter/helpers/get-shader-layout.js.map +0 -1
  326. package/dist/adapter/helpers/parse-shader-compiler-log.js.map +0 -1
  327. package/dist/adapter/helpers/set-uniform.js.map +0 -1
  328. package/dist/adapter/helpers/uniforms.js.map +0 -1
  329. package/dist/adapter/objects/constants-to-keys.js.map +0 -1
  330. package/dist/adapter/objects/webgl-renderbuffer.js.map +0 -1
  331. package/dist/adapter/objects/webgl-resource.js.map +0 -1
  332. package/dist/adapter/objects/webgl-vertex-array-object.js.map +0 -1
  333. package/dist/adapter/resources/webgl-buffer.js.map +0 -1
  334. package/dist/adapter/resources/webgl-command-buffer.js.map +0 -1
  335. package/dist/adapter/resources/webgl-command-encoder.js.map +0 -1
  336. package/dist/adapter/resources/webgl-external-texture.js.map +0 -1
  337. package/dist/adapter/resources/webgl-framebuffer.js.map +0 -1
  338. package/dist/adapter/resources/webgl-render-pass.js.map +0 -1
  339. package/dist/adapter/resources/webgl-render-pipeline.js.map +0 -1
  340. package/dist/adapter/resources/webgl-sampler.js.map +0 -1
  341. package/dist/adapter/resources/webgl-shader.js.map +0 -1
  342. package/dist/adapter/resources/webgl-texture.js.map +0 -1
  343. package/dist/adapter/webgl-canvas-context.js.map +0 -1
  344. package/dist/adapter/webgl-device.js.map +0 -1
  345. package/dist/bundle.js.map +0 -1
  346. package/dist/classic/accessor.js.map +0 -1
  347. package/dist/classic/buffer.js.map +0 -1
  348. package/dist/classic/typed-array-utils.js.map +0 -1
  349. package/dist/context/context/create-browser-context.js.map +0 -1
  350. package/dist/context/context/create-headless-context.js.map +0 -1
  351. package/dist/context/context/webgl-checks.js.map +0 -1
  352. package/dist/context/debug/spector.js.map +0 -1
  353. package/dist/context/debug/webgl-developer-tools.js.map +0 -1
  354. package/dist/context/parameters/unified-parameter-api.js.map +0 -1
  355. package/dist/context/parameters/webgl-parameter-tables.js.map +0 -1
  356. package/dist/context/polyfill/context-data.js.map +0 -1
  357. package/dist/context/polyfill/get-parameter-polyfill.js.map +0 -1
  358. package/dist/context/polyfill/polyfill-context.js.map +0 -1
  359. package/dist/context/polyfill/polyfill-table.js.map +0 -1
  360. package/dist/context/polyfill/polyfill-vertex-array-object.js.map +0 -1
  361. package/dist/context/state-tracker/deep-array-equal.js.map +0 -1
  362. package/dist/context/state-tracker/track-context-state.js.map +0 -1
  363. package/dist/context/state-tracker/with-parameters.js.map +0 -1
  364. package/dist/index.js.map +0 -1
  365. package/dist/init.js.map +0 -1
  366. package/dist/types/webgl.js.map +0 -1
  367. package/dist/types.js.map +0 -1
@@ -3,51 +3,41 @@ import { Buffer, assert } from '@luma.gl/api';
3
3
  import GL from '@luma.gl/constants';
4
4
  const DEBUG_DATA_LENGTH = 10;
5
5
  export default class WEBGLBuffer extends Buffer {
6
- constructor(device, props = {}) {
6
+ constructor(device) {
7
+ let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7
8
  super(device, props);
8
-
9
9
  _defineProperty(this, "device", void 0);
10
-
11
10
  _defineProperty(this, "gl", void 0);
12
-
13
11
  _defineProperty(this, "gl2", void 0);
14
-
15
12
  _defineProperty(this, "handle", void 0);
16
-
17
13
  _defineProperty(this, "target", void 0);
18
-
19
14
  _defineProperty(this, "byteLength", void 0);
20
-
21
15
  _defineProperty(this, "bytesUsed", void 0);
22
-
23
16
  _defineProperty(this, "debugData", null);
24
-
25
17
  _defineProperty(this, "webglUsage", void 0);
26
-
27
18
  this.device = device;
28
19
  this.gl = this.device.gl;
29
20
  this.gl2 = this.device.gl2;
30
21
  const handle = typeof props === 'object' ? props.handle : undefined;
31
22
  this.handle = handle || this.gl.createBuffer();
32
- this.handle.__SPECTOR_Metadata = { ...this.props,
23
+ this.handle.__SPECTOR_Metadata = {
24
+ ...this.props,
33
25
  data: typeof this.props.data
34
26
  };
35
27
  this.target = this.props.target || getWebGLTarget(this.props.usage);
36
28
  this.webglUsage = this.props.webglUsage || getWebGLUsage(this.props.usage);
37
29
  this.debugData = null;
38
-
39
30
  if (props.data) {
40
31
  this._initWithData(props.data, props.byteOffset, props.byteLength);
41
32
  } else {
42
33
  this._initWithByteLength(props.byteLength || 0);
43
34
  }
44
35
  }
45
-
46
- _initWithData(data, byteOffset = 0, byteLength = data.byteLength + byteOffset) {
36
+ _initWithData(data) {
37
+ let byteOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
38
+ let byteLength = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : data.byteLength + byteOffset;
47
39
  assert(ArrayBuffer.isView(data));
48
-
49
40
  const target = this._getWriteTarget();
50
-
51
41
  this.gl.bindBuffer(target, this.handle);
52
42
  this.gl.bufferData(target, byteLength, this.webglUsage);
53
43
  this.gl.bufferSubData(target, byteOffset, data);
@@ -58,17 +48,13 @@ export default class WEBGLBuffer extends Buffer {
58
48
  this.trackAllocatedMemory(byteLength);
59
49
  return this;
60
50
  }
61
-
62
51
  _initWithByteLength(byteLength) {
63
52
  assert(byteLength >= 0);
64
53
  let data = byteLength;
65
-
66
54
  if (byteLength === 0) {
67
55
  data = new Float32Array(0);
68
56
  }
69
-
70
57
  const target = this._getWriteTarget();
71
-
72
58
  this.gl.bindBuffer(target, this.handle);
73
59
  this.gl.bufferData(target, data, this.webglUsage);
74
60
  this.gl.bindBuffer(target, null);
@@ -77,7 +63,6 @@ export default class WEBGLBuffer extends Buffer {
77
63
  this.byteLength = byteLength;
78
64
  return this;
79
65
  }
80
-
81
66
  destroy() {
82
67
  if (!this.destroyed && this.handle) {
83
68
  this.removeStats();
@@ -86,24 +71,23 @@ export default class WEBGLBuffer extends Buffer {
86
71
  this.destroyed = true;
87
72
  }
88
73
  }
89
-
90
- write(data, byteOffset = 0) {
74
+ write(data) {
75
+ let byteOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
91
76
  const srcOffset = 0;
92
77
  const byteLength = data.byteLength;
93
78
  const target = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.target;
94
79
  this.gl.bindBuffer(target, this.handle);
95
-
96
80
  if (srcOffset !== 0 || byteLength !== undefined) {
97
81
  this.device.assertWebGL2();
98
82
  this.gl.bufferSubData(this.target, offset, data, srcOffset, byteLength);
99
83
  } else {
100
84
  this.gl.bufferSubData(target, byteOffset, data);
101
85
  }
102
-
103
86
  this.gl.bindBuffer(target, null);
104
87
  }
105
-
106
- async readAsync(byteOffset = 0, byteLength) {
88
+ async readAsync() {
89
+ let byteOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
90
+ let byteLength = arguments.length > 1 ? arguments[1] : undefined;
107
91
  this.device.assertWebGL2();
108
92
  const data = new Uint8Array(byteLength);
109
93
  const dstOffset = 0;
@@ -112,51 +96,39 @@ export default class WEBGLBuffer extends Buffer {
112
96
  this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);
113
97
  return data;
114
98
  }
115
-
116
99
  _invalidateDebugData() {
117
100
  this.debugData = null;
118
101
  }
119
-
120
102
  _getWriteTarget() {
121
103
  return this.target;
122
104
  }
123
-
124
105
  _getReadTarget() {
125
106
  return this.target;
126
107
  return this.device.isWebGL2 ? GL.COPY_READ_BUFFER : this.target;
127
108
  }
128
-
129
109
  }
130
-
131
110
  function getWebGLTarget(usage) {
132
111
  if (usage & Buffer.INDEX) {
133
112
  return GL.ELEMENT_ARRAY_BUFFER;
134
113
  }
135
-
136
114
  if (usage & Buffer.VERTEX) {
137
115
  return GL.ARRAY_BUFFER;
138
116
  }
139
-
140
117
  if (usage & Buffer.UNIFORM) {
141
118
  return GL.UNIFORM_BUFFER;
142
119
  }
143
-
144
120
  return GL.ARRAY_BUFFER;
145
121
  }
146
-
147
122
  function getWebGLUsage(usage) {
148
123
  if (usage & Buffer.INDEX) {
149
124
  return GL.STATIC_DRAW;
150
125
  }
151
-
152
126
  if (usage & Buffer.VERTEX) {
153
127
  return GL.STATIC_DRAW;
154
128
  }
155
-
156
129
  if (usage & Buffer.UNIFORM) {
157
130
  return GL.DYNAMIC_DRAW;
158
131
  }
159
-
160
132
  return GL.DYNAMIC_DRAW;
161
133
  }
162
134
  //# sourceMappingURL=webgl-buffer.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/adapter/resources/webgl-buffer.ts"],"names":["Buffer","assert","GL","DEBUG_DATA_LENGTH","WEBGLBuffer","constructor","device","props","gl","gl2","handle","undefined","createBuffer","__SPECTOR_Metadata","data","target","getWebGLTarget","usage","webglUsage","getWebGLUsage","debugData","_initWithData","byteOffset","byteLength","_initWithByteLength","ArrayBuffer","isView","_getWriteTarget","bindBuffer","bufferData","bufferSubData","slice","bytesUsed","trackAllocatedMemory","Float32Array","destroy","destroyed","removeStats","trackDeallocatedMemory","deleteBuffer","write","srcOffset","isWebGL2","COPY_WRITE_BUFFER","assertWebGL2","offset","readAsync","Uint8Array","dstOffset","COPY_READ_BUFFER","getBufferSubData","_invalidateDebugData","_getReadTarget","INDEX","ELEMENT_ARRAY_BUFFER","VERTEX","ARRAY_BUFFER","UNIFORM","UNIFORM_BUFFER","STATIC_DRAW","DYNAMIC_DRAW"],"mappings":";AACA,SAAQA,MAAR,EAAgBC,MAAhB,QAA6B,cAA7B;AACA,OAAOC,EAAP,MAAe,oBAAf;AAGA,MAAMC,iBAAiB,GAAG,EAA1B;AAGA,eAAe,MAAMC,WAAN,SAA0BJ,MAA1B,CAAiC;AAe9CK,EAAAA,WAAW,CAACC,MAAD,EAAsBC,KAAkB,GAAG,EAA3C,EAA+C;AACxD,UAAMD,MAAN,EAAcC,KAAd;;AADwD;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,uCAN1B,IAM0B;;AAAA;;AAGxD,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,EAAL,GAAU,KAAKF,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EAAwC,IAAxC;AAKA,WAAOnC,IAAP;AACD;;AAIDqC,EAAAA,oBAAoB,GAAG;AACrB,SAAK/B,SAAL,GAAiB,IAAjB;AACD;;AAEDO,EAAAA,eAAe,GAAG;AAChB,WAAO,KAAKZ,MAAZ;AAED;;AAEDqC,EAAAA,cAAc,GAAG;AACf,WAAO,KAAKrC,MAAZ;AACA,WAAO,KAAKT,MAAL,CAAYoC,QAAZ,GAAuBxC,EAAE,CAAC+C,gBAA1B,GAA6C,KAAKlC,MAAzD;AACD;;AAnK6C;;AAiLhD,SAASC,cAAT,CAAwBC,KAAxB,EAA2C;AACzC,MAAIA,KAAK,GAAGjB,MAAM,CAACqD,KAAnB,EAA0B;AACxB,WAAOnD,EAAE,CAACoD,oBAAV;AACD;;AACD,MAAIrC,KAAK,GAAGjB,MAAM,CAACuD,MAAnB,EAA2B;AACzB,WAAOrD,EAAE,CAACsD,YAAV;AACD;;AACD,MAAIvC,KAAK,GAAGjB,MAAM,CAACyD,OAAnB,EAA4B;AAC1B,WAAOvD,EAAE,CAACwD,cAAV;AACD;;AAUD,SAAOxD,EAAE,CAACsD,YAAV;AACD;;AAED,SAASrC,aAAT,CAAuBF,KAAvB,EAA0C;AACxC,MAAIA,KAAK,GAAGjB,MAAM,CAACqD,KAAnB,EAA0B;AACxB,WAAOnD,EAAE,CAACyD,WAAV;AACD;;AACD,MAAI1C,KAAK,GAAGjB,MAAM,CAACuD,MAAnB,EAA2B;AACzB,WAAOrD,EAAE,CAACyD,WAAV;AACD;;AACD,MAAI1C,KAAK,GAAGjB,MAAM,CAACyD,OAAnB,EAA4B;AAC1B,WAAOvD,EAAE,CAAC0D,YAAV;AACD;;AACD,SAAO1D,EAAE,CAAC0D,YAAV;AACD","sourcesContent":["import type {BufferProps} from '@luma.gl/api';\nimport {Buffer, assert} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport WebGLDevice from '../webgl-device';\n\nconst DEBUG_DATA_LENGTH = 10;\n\n/** WebGL Buffer interface */\nexport default class WEBGLBuffer extends Buffer {\n readonly device: WebGLDevice;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext | null;\n readonly handle: WebGLBuffer;\n readonly target: number;\n\n byteLength: number;\n bytesUsed: number;\n debugData: ArrayBuffer | null = null;\n\n webglUsage: number;\n\n // accessor: {};\n\n constructor(device: WebGLDevice, props: BufferProps = {}) {\n super(device, props);\n\n this.device = device;\n this.gl = this.device.gl;\n this.gl2 = this.device.gl2;\n\n const handle = typeof props === 'object' ? (props as BufferProps).handle : undefined;\n this.handle = handle || this.gl.createBuffer();\n // @ts-expect-error Add metadata for spector\n this.handle.__SPECTOR_Metadata = {...this.props, data: typeof this.props.data}; // {name: this.props.id};\n\n // In WebGL1, need to make sure we use GL.ELEMENT_ARRAY_BUFFER when initializing element buffers\n // otherwise buffer type will lock to generic (non-element) buffer\n // In WebGL2, we can use GL.COPY_READ_BUFFER which avoids locking the type here\n // @ts-expect-error Hack - Checking for subclass prop\n this.target = this.props.target || getWebGLTarget(this.props.usage);\n // @ts-expect-error Hack - Checking for subclass prop\n this.webglUsage = this.props.webglUsage || getWebGLUsage(this.props.usage);\n this.debugData = null;\n\n // Set data: (re)initializes the buffer\n if (props.data) {\n this._initWithData(props.data, props.byteOffset, props.byteLength);\n } else {\n this._initWithByteLength(props.byteLength || 0);\n }\n\n // Deprecated: Merge main props and accessor\n // this.accessor = {...props.accessor};\n\n // Object.seal(this);\n }\n\n // PRIVATE METHODS\n\n // Allocate a new buffer and initialize to contents of typed array\n _initWithData(data, byteOffset: number = 0, byteLength: number = data.byteLength + byteOffset): this {\n assert(ArrayBuffer.isView(data));\n\n const target = this._getWriteTarget();\n\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, byteLength, this.webglUsage);\n this.gl.bufferSubData(target, byteOffset, data);\n this.gl.bindBuffer(target, null);\n\n this.debugData = data.slice(0, DEBUG_DATA_LENGTH);\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n this.trackAllocatedMemory(byteLength);\n\n return this;\n }\n\n // Allocate a GPU buffer of specified size.\n _initWithByteLength(byteLength: number): this {\n assert(byteLength >= 0);\n\n // Workaround needed for Safari (#291):\n // gl.bufferData with size equal to 0 crashes. Instead create zero sized array.\n let data = byteLength;\n if (byteLength === 0) {\n // @ts-expect-error\n data = new Float32Array(0);\n }\n\n const target = this._getWriteTarget();\n\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, data, this.webglUsage);\n this.gl.bindBuffer(target, null);\n\n this.debugData = null;\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n return this;\n }\n\n override destroy(): void {\n if (!this.destroyed && this.handle) {\n this.removeStats();\n this.trackDeallocatedMemory();\n this.gl.deleteBuffer(this.handle);\n this.destroyed = true;\n // this.handle = null;\n }\n }\n\n override write(data: ArrayBufferView, byteOffset: number = 0): void {\n const srcOffset = 0;\n const byteLength = data.byteLength;\n\n // Create the buffer - binding it here for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n const target = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.target;\n this.gl.bindBuffer(target, this.handle);\n // WebGL2: subData supports additional srcOffset and length parameters\n if (srcOffset !== 0 || byteLength !== undefined) {\n this.device.assertWebGL2();\n\n // @ts-expect-error\n this.gl.bufferSubData(this.target, offset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(target, byteOffset, data);\n }\n this.gl.bindBuffer(target, null);\n\n // TODO - update local `data` if offsets are right\n // this.debugData = data.slice(byteOffset, 40);\n }\n\n /** Read data from the buffer */\n override async readAsync(\n byteOffset: number = 0,\n byteLength?: number\n ): Promise<ArrayBuffer> {\n this.device.assertWebGL2();\n\n const data = new Uint8Array(byteLength);\n const dstOffset = 0;\n\n // Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, this.handle);\n this.gl2.getBufferSubData(GL.COPY_READ_BUFFER, byteOffset, data, dstOffset, byteLength);\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n // this.debugData = null;\n\n return data;\n }\n\n // PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)\n\n _invalidateDebugData() {\n this.debugData = null;\n }\n\n _getWriteTarget() {\n return this.target;\n // return this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.target;\n }\n\n _getReadTarget() {\n return this.target;\n return this.device.isWebGL2 ? GL.COPY_READ_BUFFER : this.target;\n }\n}\n\n// static MAP_READ = 0x01;\n// static MAP_WRITE = 0x02;\n// static COPY_SRC = 0x0004;\n// static COPY_DST = 0x0008;\n// static INDEX = 0x0010;\n// static VERTEX = 0x0020;\n// static UNIFORM = 0x0040;\n// static STORAGE = 0x0080;\n// static INDIRECT = 0x0100;\n// static QUERY_RESOLVE = 0x0200;\n\nfunction getWebGLTarget(usage: number): GL {\n if (usage & Buffer.INDEX) {\n return GL.ELEMENT_ARRAY_BUFFER;\n }\n if (usage & Buffer.VERTEX) {\n return GL.ARRAY_BUFFER;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.UNIFORM_BUFFER;\n }\n\n // gl.COPY_READ_BUFFER: Buffer for copying from one buffer object to another.\n // gl.COPY_WRITE_BUFFER: Buffer for copying from one buffer object to another.\n // gl.TRANSFORM_FEEDBACK_BUFFER: Buffer for transform feedback operations.\n // gl.PIXEL_PACK_BUFFER: Buffer used for pixel transfer operations.\n // gl.PIXEL_UNPACK_BUFFER: Buffer used for pixel transfer operations.\n\n // Binding a buffer for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n return GL.ARRAY_BUFFER;\n}\n\nfunction getWebGLUsage(usage: number): GL {\n if (usage & Buffer.INDEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.VERTEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.DYNAMIC_DRAW;\n }\n return GL.DYNAMIC_DRAW;\n}\n"],"file":"webgl-buffer.js"}
1
+ {"version":3,"file":"webgl-buffer.js","names":["Buffer","assert","GL","DEBUG_DATA_LENGTH","WEBGLBuffer","constructor","device","props","arguments","length","undefined","_defineProperty","gl","gl2","handle","createBuffer","__SPECTOR_Metadata","data","target","getWebGLTarget","usage","webglUsage","getWebGLUsage","debugData","_initWithData","byteOffset","byteLength","_initWithByteLength","ArrayBuffer","isView","_getWriteTarget","bindBuffer","bufferData","bufferSubData","slice","bytesUsed","trackAllocatedMemory","Float32Array","destroy","destroyed","removeStats","trackDeallocatedMemory","deleteBuffer","write","srcOffset","isWebGL2","COPY_WRITE_BUFFER","assertWebGL2","offset","readAsync","Uint8Array","dstOffset","COPY_READ_BUFFER","getBufferSubData","_invalidateDebugData","_getReadTarget","INDEX","ELEMENT_ARRAY_BUFFER","VERTEX","ARRAY_BUFFER","UNIFORM","UNIFORM_BUFFER","STATIC_DRAW","DYNAMIC_DRAW"],"sources":["../../../../src/adapter/resources/webgl-buffer.ts"],"sourcesContent":["import type {BufferProps} from '@luma.gl/api';\nimport {Buffer, assert} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport WebGLDevice from '../webgl-device';\n\nconst DEBUG_DATA_LENGTH = 10;\n\n/** WebGL Buffer interface */\nexport default class WEBGLBuffer extends Buffer {\n readonly device: WebGLDevice;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext | null;\n readonly handle: WebGLBuffer;\n readonly target: number;\n\n byteLength: number;\n bytesUsed: number;\n debugData: ArrayBuffer | null = null;\n\n webglUsage: number;\n\n // accessor: {};\n\n constructor(device: WebGLDevice, props: BufferProps = {}) {\n super(device, props);\n\n this.device = device;\n this.gl = this.device.gl;\n this.gl2 = this.device.gl2;\n\n const handle = typeof props === 'object' ? (props as BufferProps).handle : undefined;\n this.handle = handle || this.gl.createBuffer();\n // @ts-expect-error Add metadata for spector\n this.handle.__SPECTOR_Metadata = {...this.props, data: typeof this.props.data}; // {name: this.props.id};\n\n // In WebGL1, need to make sure we use GL.ELEMENT_ARRAY_BUFFER when initializing element buffers\n // otherwise buffer type will lock to generic (non-element) buffer\n // In WebGL2, we can use GL.COPY_READ_BUFFER which avoids locking the type here\n // @ts-expect-error Hack - Checking for subclass prop\n this.target = this.props.target || getWebGLTarget(this.props.usage);\n // @ts-expect-error Hack - Checking for subclass prop\n this.webglUsage = this.props.webglUsage || getWebGLUsage(this.props.usage);\n this.debugData = null;\n\n // Set data: (re)initializes the buffer\n if (props.data) {\n this._initWithData(props.data, props.byteOffset, props.byteLength);\n } else {\n this._initWithByteLength(props.byteLength || 0);\n }\n\n // Deprecated: Merge main props and accessor\n // this.accessor = {...props.accessor};\n\n // Object.seal(this);\n }\n\n // PRIVATE METHODS\n\n // Allocate a new buffer and initialize to contents of typed array\n _initWithData(data, byteOffset: number = 0, byteLength: number = data.byteLength + byteOffset): this {\n assert(ArrayBuffer.isView(data));\n\n const target = this._getWriteTarget();\n\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, byteLength, this.webglUsage);\n this.gl.bufferSubData(target, byteOffset, data);\n this.gl.bindBuffer(target, null);\n\n this.debugData = data.slice(0, DEBUG_DATA_LENGTH);\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n this.trackAllocatedMemory(byteLength);\n\n return this;\n }\n\n // Allocate a GPU buffer of specified size.\n _initWithByteLength(byteLength: number): this {\n assert(byteLength >= 0);\n\n // Workaround needed for Safari (#291):\n // gl.bufferData with size equal to 0 crashes. Instead create zero sized array.\n let data = byteLength;\n if (byteLength === 0) {\n // @ts-expect-error\n data = new Float32Array(0);\n }\n\n const target = this._getWriteTarget();\n\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, data, this.webglUsage);\n this.gl.bindBuffer(target, null);\n\n this.debugData = null;\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n return this;\n }\n\n override destroy(): void {\n if (!this.destroyed && this.handle) {\n this.removeStats();\n this.trackDeallocatedMemory();\n this.gl.deleteBuffer(this.handle);\n this.destroyed = true;\n // this.handle = null;\n }\n }\n\n override write(data: ArrayBufferView, byteOffset: number = 0): void {\n const srcOffset = 0;\n const byteLength = data.byteLength;\n\n // Create the buffer - binding it here for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n const target = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.target;\n this.gl.bindBuffer(target, this.handle);\n // WebGL2: subData supports additional srcOffset and length parameters\n if (srcOffset !== 0 || byteLength !== undefined) {\n this.device.assertWebGL2();\n\n // @ts-expect-error\n this.gl.bufferSubData(this.target, offset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(target, byteOffset, data);\n }\n this.gl.bindBuffer(target, null);\n\n // TODO - update local `data` if offsets are right\n // this.debugData = data.slice(byteOffset, 40);\n }\n\n /** Read data from the buffer */\n override async readAsync(\n byteOffset: number = 0,\n byteLength?: number\n ): Promise<ArrayBuffer> {\n this.device.assertWebGL2();\n\n const data = new Uint8Array(byteLength);\n const dstOffset = 0;\n\n // Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, this.handle);\n this.gl2.getBufferSubData(GL.COPY_READ_BUFFER, byteOffset, data, dstOffset, byteLength);\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n // this.debugData = null;\n\n return data;\n }\n\n // PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)\n\n _invalidateDebugData() {\n this.debugData = null;\n }\n\n _getWriteTarget() {\n return this.target;\n // return this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.target;\n }\n\n _getReadTarget() {\n return this.target;\n return this.device.isWebGL2 ? GL.COPY_READ_BUFFER : this.target;\n }\n}\n\n// static MAP_READ = 0x01;\n// static MAP_WRITE = 0x02;\n// static COPY_SRC = 0x0004;\n// static COPY_DST = 0x0008;\n// static INDEX = 0x0010;\n// static VERTEX = 0x0020;\n// static UNIFORM = 0x0040;\n// static STORAGE = 0x0080;\n// static INDIRECT = 0x0100;\n// static QUERY_RESOLVE = 0x0200;\n\nfunction getWebGLTarget(usage: number): GL {\n if (usage & Buffer.INDEX) {\n return GL.ELEMENT_ARRAY_BUFFER;\n }\n if (usage & Buffer.VERTEX) {\n return GL.ARRAY_BUFFER;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.UNIFORM_BUFFER;\n }\n\n // gl.COPY_READ_BUFFER: Buffer for copying from one buffer object to another.\n // gl.COPY_WRITE_BUFFER: Buffer for copying from one buffer object to another.\n // gl.TRANSFORM_FEEDBACK_BUFFER: Buffer for transform feedback operations.\n // gl.PIXEL_PACK_BUFFER: Buffer used for pixel transfer operations.\n // gl.PIXEL_UNPACK_BUFFER: Buffer used for pixel transfer operations.\n\n // Binding a buffer for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n return GL.ARRAY_BUFFER;\n}\n\nfunction getWebGLUsage(usage: number): GL {\n if (usage & Buffer.INDEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.VERTEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.DYNAMIC_DRAW;\n }\n return GL.DYNAMIC_DRAW;\n}\n"],"mappings":";AACA,SAAQA,MAAM,EAAEC,MAAM,QAAO,cAAc;AAC3C,OAAOC,EAAE,MAAM,oBAAoB;AAGnC,MAAMC,iBAAiB,GAAG,EAAE;AAG5B,eAAe,MAAMC,WAAW,SAASJ,MAAM,CAAC;EAe9CK,WAAWA,CAACC,MAAmB,EAA2B;IAAA,IAAzBC,KAAkB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IACtD,KAAK,CAACF,MAAM,EAAEC,KAAK,CAAC;IAACI,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;I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AM,CAAC0D,MAAM,EAAE;IACzB,OAAOxD,EAAE,CAACyD,YAAY;EACxB;EACA,IAAIvC,KAAK,GAAGpB,MAAM,CAAC4D,OAAO,EAAE;IAC1B,OAAO1D,EAAE,CAAC2D,cAAc;EAC1B;EAUA,OAAO3D,EAAE,CAACyD,YAAY;AACxB;AAEA,SAASrC,aAAaA,CAACF,KAAa,EAAM;EACxC,IAAIA,KAAK,GAAGpB,MAAM,CAACwD,KAAK,EAAE;IACxB,OAAOtD,EAAE,CAAC4D,WAAW;EACvB;EACA,IAAI1C,KAAK,GAAGpB,MAAM,CAAC0D,MAAM,EAAE;IACzB,OAAOxD,EAAE,CAAC4D,WAAW;EACvB;EACA,IAAI1C,KAAK,GAAGpB,MAAM,CAAC4D,OAAO,EAAE;IAC1B,OAAO1D,EAAE,CAAC6D,YAAY;EACxB;EACA,OAAO7D,EAAE,CAAC6D,YAAY;AACxB"}
@@ -1,52 +1,40 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import GL from '@luma.gl/constants';
3
-
4
3
  function cast(value) {
5
4
  return value;
6
5
  }
7
-
8
6
  export default class CommandBuffer {
9
7
  constructor() {
10
8
  _defineProperty(this, "commands", []);
11
9
  }
12
-
13
10
  }
14
- export function submitCommands(device, commands = []) {
11
+ export function submitCommands(device) {
12
+ let commands = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
15
13
  for (const command of commands) {
16
14
  switch (command.name) {
17
15
  case 'copy-buffer-to-buffer':
18
16
  _copyBufferToBuffer(device, command.options);
19
-
20
17
  break;
21
-
22
18
  case 'copy-buffer-to-texture':
23
19
  _copyBufferToTexture(device, command.options);
24
-
25
20
  break;
26
-
27
21
  case 'copy-texture-to-buffer':
28
22
  _copyTextureToBuffer(device, command.options);
29
-
30
23
  break;
31
-
32
24
  case 'copy-texture-to-texture':
33
25
  _copyTextureToTexture(device, command.options);
34
-
35
26
  break;
36
27
  }
37
28
  }
38
29
  }
39
-
40
30
  function _copyBufferToBuffer(device, options) {
41
31
  const source = cast(options.source);
42
32
  const destination = cast(options.destination);
43
33
  const {
44
34
  gl2
45
35
  } = device;
46
-
47
36
  if (gl2) {
48
37
  var _options$sourceOffset, _options$destinationO;
49
-
50
38
  gl2.bindBuffer(GL.COPY_READ_BUFFER, source.handle);
51
39
  gl2.bindBuffer(GL.COPY_WRITE_BUFFER, destination.handle);
52
40
  gl2.copyBufferSubData(GL.COPY_READ_BUFFER, GL.COPY_WRITE_BUFFER, (_options$sourceOffset = options.sourceOffset) !== null && _options$sourceOffset !== void 0 ? _options$sourceOffset : 0, (_options$destinationO = options.destinationOffset) !== null && _options$destinationO !== void 0 ? _options$destinationO : 0, options.size);
@@ -56,10 +44,7 @@ function _copyBufferToBuffer(device, options) {
56
44
  throw new Error('copyBufferToBuffer not implemented in WebGL1');
57
45
  }
58
46
  }
59
-
60
47
  function _copyBufferToTexture(device, options) {}
61
-
62
48
  function _copyTextureToBuffer(device, options) {}
63
-
64
49
  function _copyTextureToTexture(device, options) {}
65
50
  //# sourceMappingURL=webgl-command-buffer.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/adapter/resources/webgl-command-buffer.ts"],"names":["GL","cast","value","CommandBuffer","submitCommands","device","commands","command","name","_copyBufferToBuffer","options","_copyBufferToTexture","_copyTextureToBuffer","_copyTextureToTexture","source","destination","gl2","bindBuffer","COPY_READ_BUFFER","handle","COPY_WRITE_BUFFER","copyBufferSubData","sourceOffset","destinationOffset","size","Error"],"mappings":";AAMA,OAAOA,EAAP,MAAe,oBAAf;;AAIA,SAASC,IAAT,CAAiBC,KAAjB,EAAoC;AAClC,SAAOA,KAAP;AACD;;AA4BD,eAAe,MAAMC,aAAN,CAAoB;AAAA;AAAA,sCACX,EADW;AAAA;;AAAA;AAInC,OAAO,SAASC,cAAT,CAAwBC,MAAxB,EAA6CC,QAAmB,GAAG,EAAnE,EAAuE;AAC5E,OAAK,MAAMC,OAAX,IAAsBD,QAAtB,EAAgC;AA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,UAAM,IAAIK,KAAJ,CAAU,8CAAV,CAAN;AACD;AACF;;AAED,SAASd,oBAAT,CAA8BN,MAA9B,EAAmDK,OAAnD,EAA8F,CAAE;;AAEhG,SAASE,oBAAT,CAA8BP,MAA9B,EAAmDK,OAAnD,EAA8F,CAAE;;AAEhG,SAASG,qBAAT,CAA+BR,MAA/B,EAAoDK,OAApD,EAAgG,CAAE","sourcesContent":["import type {\n CopyBufferToBufferOptions,\n CopyBufferToTextureOptions,\n CopyTextureToBufferOptions,\n CopyTextureToTextureOptions\n} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport WebGLDevice from '../webgl-device';\nimport WEBGLBuffer from './webgl-buffer';\n\nfunction cast<T>(value: unknown): T {\n return value as T;\n}\n\ntype CopyBufferToBufferCommand = {\n name: 'copy-buffer-to-buffer';\n options: CopyBufferToBufferOptions;\n};\n\ntype CopyBufferToTextureCommand = {\n name: 'copy-buffer-to-texture';\n options: CopyBufferToTextureOptions;\n};\n\ntype CopyTextureToBufferCommand = {\n name: 'copy-texture-to-buffer';\n options: CopyTextureToBufferOptions;\n};\n\ntype CopyTextureToTextureCommand = {\n name: 'copy-texture-to-texture';\n options: CopyTextureToTextureOptions;\n};\n\ntype Command =\n | CopyBufferToBufferCommand\n | CopyBufferToTextureCommand\n | CopyTextureToBufferCommand\n | CopyTextureToTextureCommand;\n\nexport default class CommandBuffer {\n commands: Command[] = [];\n}\n\nexport function submitCommands(device: WebGLDevice, commands: Command[] = []) {\n for (const command of commands) {\n switch (command.name) {\n case 'copy-buffer-to-buffer':\n _copyBufferToBuffer(device, command.options);\n break;\n case 'copy-buffer-to-texture':\n _copyBufferToTexture(device, command.options);\n break;\n case 'copy-texture-to-buffer':\n _copyTextureToBuffer(device, command.options);\n break;\n case 'copy-texture-to-texture':\n _copyTextureToTexture(device, command.options);\n break;\n }\n }\n}\n\nfunction _copyBufferToBuffer(device: WebGLDevice, options: CopyBufferToBufferOptions): void {\n const source = cast<WEBGLBuffer>(options.source);\n const destination = cast<WEBGLBuffer>(options.destination);\n\n const {gl2} = device;\n if (gl2) {\n // In WebGL2 we can perform the copy on the GPU\n // Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type\n gl2.bindBuffer(GL.COPY_READ_BUFFER, source.handle);\n gl2.bindBuffer(GL.COPY_WRITE_BUFFER, destination.handle);\n gl2.copyBufferSubData(\n GL.COPY_READ_BUFFER,\n GL.COPY_WRITE_BUFFER,\n options.sourceOffset ?? 0,\n options.destinationOffset ?? 0,\n options.size\n );\n gl2.bindBuffer(GL.COPY_READ_BUFFER, null);\n gl2.bindBuffer(GL.COPY_WRITE_BUFFER, null);\n } else {\n // TODO - in WebGL1 we would have to read back to CPU\n // read / write buffer from / to CPU\n throw new Error('copyBufferToBuffer not implemented in WebGL1');\n }\n}\n\nfunction _copyBufferToTexture(device: WebGLDevice, options: CopyBufferToTextureOptions): void {}\n\nfunction _copyTextureToBuffer(device: WebGLDevice, options: CopyTextureToBufferOptions): void {}\n\nfunction _copyTextureToTexture(device: WebGLDevice, options: CopyTextureToTextureOptions): void {}\n"],"file":"webgl-command-buffer.js"}
1
+ {"version":3,"file":"webgl-command-buffer.js","names":["GL","cast","value","CommandBuffer","constructor","_defineProperty","submitCommands","device","commands","arguments","length","undefined","command","name","_copyBufferToBuffer","options","_copyBufferToTexture","_copyTextureToBuffer","_copyTextureToTexture","source","destination","gl2","_options$sourceOffset","_options$destinationO","bindBuffer","COPY_READ_BUFFER","handle","COPY_WRITE_BUFFER","copyBufferSubData","sourceOffset","destinationOffset","size","Error"],"sources":["../../../../src/adapter/resources/webgl-command-buffer.ts"],"sourcesContent":["import type {\n CopyBufferToBufferOptions,\n CopyBufferToTextureOptions,\n CopyTextureToBufferOptions,\n CopyTextureToTextureOptions\n} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport WebGLDevice from '../webgl-device';\nimport WEBGLBuffer from './webgl-buffer';\n\nfunction cast<T>(value: unknown): T {\n return value as T;\n}\n\ntype CopyBufferToBufferCommand = {\n name: 'copy-buffer-to-buffer';\n options: CopyBufferToBufferOptions;\n};\n\ntype CopyBufferToTextureCommand = {\n name: 'copy-buffer-to-texture';\n options: CopyBufferToTextureOptions;\n};\n\ntype CopyTextureToBufferCommand = {\n name: 'copy-texture-to-buffer';\n options: CopyTextureToBufferOptions;\n};\n\ntype CopyTextureToTextureCommand = {\n name: 'copy-texture-to-texture';\n options: CopyTextureToTextureOptions;\n};\n\ntype Command =\n | CopyBufferToBufferCommand\n | CopyBufferToTextureCommand\n | CopyTextureToBufferCommand\n | CopyTextureToTextureCommand;\n\nexport default class CommandBuffer {\n commands: Command[] = [];\n}\n\nexport function submitCommands(device: WebGLDevice, commands: Command[] = []) {\n for (const command of commands) {\n switch (command.name) {\n case 'copy-buffer-to-buffer':\n _copyBufferToBuffer(device, command.options);\n break;\n case 'copy-buffer-to-texture':\n _copyBufferToTexture(device, command.options);\n break;\n case 'copy-texture-to-buffer':\n _copyTextureToBuffer(device, command.options);\n break;\n case 'copy-texture-to-texture':\n _copyTextureToTexture(device, command.options);\n break;\n }\n }\n}\n\nfunction _copyBufferToBuffer(device: WebGLDevice, options: CopyBufferToBufferOptions): void {\n const source = cast<WEBGLBuffer>(options.source);\n const destination = cast<WEBGLBuffer>(options.destination);\n\n const {gl2} = device;\n if (gl2) {\n // In WebGL2 we can perform the copy on the GPU\n // Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type\n gl2.bindBuffer(GL.COPY_READ_BUFFER, source.handle);\n gl2.bindBuffer(GL.COPY_WRITE_BUFFER, destination.handle);\n gl2.copyBufferSubData(\n GL.COPY_READ_BUFFER,\n GL.COPY_WRITE_BUFFER,\n options.sourceOffset ?? 0,\n options.destinationOffset ?? 0,\n options.size\n );\n gl2.bindBuffer(GL.COPY_READ_BUFFER, null);\n gl2.bindBuffer(GL.COPY_WRITE_BUFFER, null);\n } else {\n // TODO - in WebGL1 we would have to read back to CPU\n // read / write buffer from / to CPU\n throw new Error('copyBufferToBuffer not implemented in WebGL1');\n }\n}\n\nfunction _copyBufferToTexture(device: WebGLDevice, options: CopyBufferToTextureOptions): void {}\n\nfunction _copyTextureToBuffer(device: WebGLDevice, options: CopyTextureToBufferOptions): void {}\n\nfunction _copyTextureToTexture(device: WebGLDevice, options: CopyTextureToTextureOptions): void {}\n"],"mappings":";AAMA,OAAOA,EAAE,MAAM,oBAAoB;AAInC,SAASC,IAAIA,CAAIC,KAAc,EAAK;EAClC,OAAOA,KAAK;AACd;AA4BA,eAAe,MAAMC,aAAa,CAAC;EAAAC,YAAA;IAAAC,eAAA,mBACX,EAAE;EAAA;AAC1B;AAEA,OAAO,SAASC,cAAcA,CAACC,MAAmB,EAA4B;EAAA,IAA1BC,QAAmB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EAC1E,KAAK,MAAMG,OAAO,IAAIJ,QAAQ,EAAE;IAC9B,QAAQI,OAAO,CAACC,IAAI;MAClB,KAAK,uBAAuB;QAC1BC,mBAAmB,CAACP,MAAM,EAAEK,OAAO,CAACG,OAAO,CAAC;QAC5C;MACF,KAAK,wBAAwB;QAC3BC,oBAAoB,CAACT,MAAM,EAAEK,OAAO,CAACG,OAAO,CAAC;QAC7C;MACF,KAAK,wBAAwB;QAC3BE,oBAAoB,CAACV,MAAM,EAAEK,OAAO,CAACG,OAAO,CAAC;QAC7C;MACF,KAAK,yBAAyB;QAC5BG,qBAAqB,CAACX,MAAM,EAAEK,OAAO,CAACG,OAAO,CAAC;QAC9C;IAAM;EAEZ;AACF;AAEA,SAASD,mBAAmBA,CAACP,MAAmB,EAAEQ,OAAkC,EAAQ;EAC1F,MAAMI,MAAM,GAAGlB,IAAI,CAAcc,OAAO,CAACI,MAAM,CAAC;EAChD,MAAMC,WAAW,GAAGnB,IAAI,CAAcc,OAAO,CAACK,WAAW,CAAC;EAE1D,MAAM;IAACC;EAAG,CAAC,GAAGd,MAAM;EACpB,IAAIc,GAAG,EAAE;IAAA,IAAAC,qBAAA,EAAAC,qBAAA;IAGPF,GAAG,CAACG,UAAU,CAACxB,EAAE,CAACyB,gBAAgB,EAAEN,MAAM,CAACO,MAAM,CAAC;IAClDL,GAAG,CAACG,UAAU,CAACxB,EAAE,CAAC2B,iBAAiB,EAAEP,WAAW,CAACM,MAAM,CAAC;IACxDL,GAAG,CAACO,iBAAiB,CACnB5B,EAAE,CAACyB,gBAAgB,EACnBzB,EAAE,CAAC2B,iBAAiB,GAAAL,qBAAA,GACpBP,OAAO,CAACc,YAAY,cAAAP,qBAAA,cAAAA,qBAAA,GAAI,CAAC,GAAAC,qBAAA,GACzBR,OAAO,CAACe,iBAAiB,cAAAP,qBAAA,cAAAA,qBAAA,GAAI,CAAC,EAC9BR,OAAO,CAACgB,IAAI,CACb;IACDV,GAAG,CAACG,UAAU,CAACxB,EAAE,CAACyB,gBAAgB,EAAE,IAAI,CAAC;IACzCJ,GAAG,CAACG,UAAU,CAACxB,EAAE,CAAC2B,iBAAiB,EAAE,IAAI,CAAC;EAC5C,CAAC,MAAM;IAGL,MAAM,IAAIK,KAAK,CAAC,8CAA8C,CAAC;EACjE;AACF;AAEA,SAAShB,oBAAoBA,CAACT,MAAmB,EAAEQ,OAAmC,EAAQ,CAAC;AAE/F,SAASE,oBAAoBA,CAACV,MAAmB,EAAEQ,OAAmC,EAAQ,CAAC;AAE/F,SAASG,qBAAqBA,CAACX,MAAmB,EAAEQ,OAAoC,EAAQ,CAAC"}
@@ -4,50 +4,38 @@ import CommandBuffer from './webgl-command-buffer';
4
4
  export default class WEBGLCommandEncoder extends CommandEncoder {
5
5
  constructor(device, props) {
6
6
  super(props);
7
-
8
7
  _defineProperty(this, "device", void 0);
9
-
10
8
  _defineProperty(this, "commandBuffer", new CommandBuffer());
11
-
12
9
  this.device = device;
13
10
  }
14
-
15
11
  destroy() {}
16
-
17
12
  copyBufferToBuffer(options) {
18
13
  this.commandBuffer.commands.push({
19
14
  name: 'copy-buffer-to-buffer',
20
15
  options
21
16
  });
22
17
  }
23
-
24
18
  copyBufferToTexture(options) {
25
19
  this.commandBuffer.commands.push({
26
20
  name: 'copy-buffer-to-texture',
27
21
  options
28
22
  });
29
23
  }
30
-
31
24
  copyTextureToBuffer(options) {
32
25
  this.commandBuffer.commands.push({
33
26
  name: 'copy-texture-to-buffer',
34
27
  options
35
28
  });
36
29
  }
37
-
38
30
  copyTextureToTexture(options) {
39
31
  this.commandBuffer.commands.push({
40
32
  name: 'copy-texture-to-texture',
41
33
  options
42
34
  });
43
35
  }
44
-
45
36
  pushDebugGroup(groupLabel) {}
46
-
47
37
  popDebugGroup() {}
48
-
49
38
  insertDebugMarker(markerLabel) {}
50
-
51
39
  }
52
40
  ;
53
41
  //# sourceMappingURL=webgl-command-encoder.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/adapter/resources/webgl-command-encoder.ts"],"names":["CommandEncoder","CommandBuffer","WEBGLCommandEncoder","constructor","device","props","destroy","copyBufferToBuffer","options","commandBuffer","commands","push","name","copyBufferToTexture","copyTextureToBuffer","copyTextureToTexture","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"mappings":";AAAA,SAAQA,cAAR,QAAkD,cAAlD;AAQA,OAAOC,aAAP,MAA0B,wBAA1B;AAGA,eAAe,MAAMC,mBAAN,SAAkCF,cAAlC,CAAiD;AAK9DG,EAAAA,WAAW,CAACC,MAAD,EAAsBC,KAAtB,EAAkD;AAC3D,UAAMA,KAAN;;AAD2D;;AAAA,2CAFpC,IAAIJ,aAAJ,EAEoC;;AAE3D,SAAKG,MAAL,GAAcA,MAAd;AACD;;AAEQE,EAAAA,OAAO,GAAS,CAAE;;AAM3BC,EAAAA,kBAAkB,CAACC,OAAD,EAA2C;AAC3D,SAAKC,aAAL,CAAmBC,QAAnB,CAA4BC,IAA5B,CAAiC;AAACC,MAAAA,IAAI,EAAE,uBAAP;AAAgCJ,MAAAA;AAAhC,KAAjC;AACD;;AAEDK,EAAAA,mBAAmB,CAACL,OAAD,EAAsC;AACvD,SAAKC,aAAL,CAAmBC,QAAnB,CAA4BC,IAA5B,CAAiC;AAACC,MAAAA,IAAI,EAAE,wBAAP;AAAiCJ,MAAAA;AAAjC,KAAjC;AACD;;AAEDM,EAAAA,mBAAmB,CAACN,OAAD,EAA4C;AAC7D,SAAKC,aAAL,CAAmBC,QAAnB,CAA4BC,IAA5B,CAAiC;AAACC,MAAAA,IAAI,EAAE,wBAAP;AAAiCJ,MAAAA;AAAjC,KAAjC;AACD;;AAEDO,EAAAA,oBAAoB,CAACP,OAAD,EAA6C;AAC/D,SAAKC,aAAL,CAAmBC,QAAnB,CAA4BC,IAA5B,CAAiC;AAACC,MAAAA,IAAI,EAAE,yBAAP;AAAkCJ,MAAAA;AAAlC,KAAjC;AACD;;AAEQQ,EAAAA,cAAc,CAACC,UAAD,EAA2B,CAAE;;AAC3CC,EAAAA,aAAa,GAAG,CAAE;;AAElBC,EAAAA,iBAAiB,CAACC,WAAD,EAA4B,CAAE;;AAnCM;AA8C/D","sourcesContent":["import {CommandEncoder, CommandEncoderProps} from '@luma.gl/api';\nimport type {\n CopyBufferToBufferOptions,\n CopyBufferToTextureOptions,\n CopyTextureToBufferOptions,\n CopyTextureToTextureOptions\n} from '@luma.gl/api';\n\nimport CommandBuffer from './webgl-command-buffer';\nimport WebGLDevice from '../webgl-device';\n\nexport default class WEBGLCommandEncoder extends CommandEncoder {\n readonly device: WebGLDevice;\n\n readonly commandBuffer = new CommandBuffer();\n\n constructor(device: WebGLDevice, props: CommandEncoderProps) {\n super(props);\n this.device = device;\n }\n\n override destroy(): void {}\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n // finish(options?: {id?: string}): GPUCommandBuffer;\n\n copyBufferToBuffer(options: CopyBufferToBufferOptions): void {\n this.commandBuffer.commands.push({name: 'copy-buffer-to-buffer', options});\n }\n\n copyBufferToTexture(options: CopyBufferToTextureOptions) {\n this.commandBuffer.commands.push({name: 'copy-buffer-to-texture', options});\n }\n\n copyTextureToBuffer(options: CopyTextureToBufferOptions): void {\n this.commandBuffer.commands.push({name: 'copy-texture-to-buffer', options});\n }\n\n copyTextureToTexture(options: CopyTextureToTextureOptions): void {\n this.commandBuffer.commands.push({name: 'copy-texture-to-texture', options});\n }\n\n override pushDebugGroup(groupLabel: string): void {}\n override popDebugGroup() {}\n\n override insertDebugMarker(markerLabel: string): void {}\n\n // writeTimestamp(querySet: Query, queryIndex: number): void {}\n\n // resolveQuerySet(options: {\n // querySet: GPUQuerySet,\n // firstQuery: number,\n // queryCount: number,\n // destination: Buffer,\n // destinationOffset?: number;\n // }): void;\n};\n"],"file":"webgl-command-encoder.js"}
1
+ {"version":3,"file":"webgl-command-encoder.js","names":["CommandEncoder","CommandBuffer","WEBGLCommandEncoder","constructor","device","props","_defineProperty","destroy","copyBufferToBuffer","options","commandBuffer","commands","push","name","copyBufferToTexture","copyTextureToBuffer","copyTextureToTexture","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../../src/adapter/resources/webgl-command-encoder.ts"],"sourcesContent":["import {CommandEncoder, CommandEncoderProps} from '@luma.gl/api';\nimport type {\n CopyBufferToBufferOptions,\n CopyBufferToTextureOptions,\n CopyTextureToBufferOptions,\n CopyTextureToTextureOptions\n} from '@luma.gl/api';\n\nimport CommandBuffer from './webgl-command-buffer';\nimport WebGLDevice from '../webgl-device';\n\nexport default class WEBGLCommandEncoder extends CommandEncoder {\n readonly device: WebGLDevice;\n\n readonly commandBuffer = new CommandBuffer();\n\n constructor(device: WebGLDevice, props: CommandEncoderProps) {\n super(props);\n this.device = device;\n }\n\n override destroy(): void {}\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n // finish(options?: {id?: string}): GPUCommandBuffer;\n\n copyBufferToBuffer(options: CopyBufferToBufferOptions): void {\n this.commandBuffer.commands.push({name: 'copy-buffer-to-buffer', options});\n }\n\n copyBufferToTexture(options: CopyBufferToTextureOptions) {\n this.commandBuffer.commands.push({name: 'copy-buffer-to-texture', options});\n }\n\n copyTextureToBuffer(options: CopyTextureToBufferOptions): void {\n this.commandBuffer.commands.push({name: 'copy-texture-to-buffer', options});\n }\n\n copyTextureToTexture(options: CopyTextureToTextureOptions): void {\n this.commandBuffer.commands.push({name: 'copy-texture-to-texture', options});\n }\n\n override pushDebugGroup(groupLabel: string): void {}\n override popDebugGroup() {}\n\n override insertDebugMarker(markerLabel: string): void {}\n\n // writeTimestamp(querySet: Query, queryIndex: number): void {}\n\n // resolveQuerySet(options: {\n // querySet: GPUQuerySet,\n // firstQuery: number,\n // queryCount: number,\n // destination: Buffer,\n // destinationOffset?: number;\n // }): void;\n};\n"],"mappings":";AAAA,SAAQA,cAAc,QAA4B,cAAc;AAQhE,OAAOC,aAAa,MAAM,wBAAwB;AAGlD,eAAe,MAAMC,mBAAmB,SAASF,cAAc,CAAC;EAK9DG,WAAWA,CAACC,MAAmB,EAAEC,KAA0B,EAAE;IAC3D,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA,wBAHU,IAAIL,aAAa,EAAE;IAI1C,IAAI,CAACG,MAAM,GAAGA,MAAM;EACtB;EAESG,OAAOA,CAAA,EAAS,CAAC;EAM1BC,kBAAkBA,CAACC,OAAkC,EAAQ;IAC3D,IAAI,CAACC,aAAa,CAACC,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,uBAAuB;MAAEJ;IAAO,CAAC,CAAC;EAC5E;EAEAK,mBAAmBA,CAACL,OAAmC,EAAE;IACvD,IAAI,CAACC,aAAa,CAACC,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,wBAAwB;MAAEJ;IAAO,CAAC,CAAC;EAC7E;EAEAM,mBAAmBA,CAACN,OAAmC,EAAQ;IAC7D,IAAI,CAACC,aAAa,CAACC,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,wBAAwB;MAAEJ;IAAO,CAAC,CAAC;EAC7E;EAEAO,oBAAoBA,CAACP,OAAoC,EAAQ;IAC/D,IAAI,CAACC,aAAa,CAACC,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,yBAAyB;MAAEJ;IAAO,CAAC,CAAC;EAC9E;EAESQ,cAAcA,CAACC,UAAkB,EAAQ,CAAC;EAC1CC,aAAaA,CAAA,EAAG,CAAC;EAEjBC,iBAAiBA,CAACC,WAAmB,EAAQ,CAAC;AAWzD;AAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"webgl-external-texture.js"}
1
+ {"version":3,"file":"webgl-external-texture.js","names":[],"sources":["../../../../src/adapter/resources/webgl-external-texture.ts"],"sourcesContent":["/*\nexport default class WEBGLExternalTexture extends WEBGLTexture {\n readonly device: WebGLDevice;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext | null;\n readonly handle: WebGLTexture;\n\n data;\n\n width: number = undefined;\n height: number = undefined;\n depth: number = undefined;\n\n format = undefined;\n type = undefined;\n dataFormat = undefined;\n border = undefined;\n mipmaps: boolean = undefined;\n\n textureUnit: number = undefined;\n\n sampler: WEBGLSampler;\n\n // Program.draw() checks the loaded flag of all textures to avoid\n // Textures that are still loading from promises\n // Set to true as soon as texture has been initialized with valid data\n loaded = false;\n _video;\n\n readonly target: GL;\n // target cannot be modified by bind:\n // textures are special because when you first bind them to a target,\n // they get special information. When you first bind a texture as a\n // GL_TEXTURE_2D, you are actually setting special state in the texture.\n // You are saying that this texture is a 2D texture.\n // And it will always be a 2D texture; this state cannot be changed ever.\n // If you have a texture that was first bound as a GL_TEXTURE_2D,\n // you must always bind it as a GL_TEXTURE_2D;\n // attempting to bind it as GL_TEXTURE_3D will give rise to an error\n // (while run-time).\n\n static isSupported(device: WebGLDevice, options?: TextureSupportOptions): boolean {\n const {format, linearFiltering} = options;\n let supported = true;\n if (format) {\n supported = supported && isFormatSupported(device.gl, format);\n supported = supported && (!linearFiltering || isTextureFormatFilterable(device.gl, format));\n }\n return supported;\n }\n\n // eslint-disable-next-line max-statements\n constructor(device: Device | WebGLRenderingContext, props: TextureProps) {\n super(WebGLDevice.attach(device), {id: uid('texture'), ...props});\n\n this.target = getWebGLTextureTarget(props);\n\n this.device = WebGLDevice.attach(device);\n this.gl = this.device.gl;\n this.gl2 = this.device.gl2;\n this.handle = this.props.handle || this.gl.createTexture();\n\n let data = props.data;\n\n const isVideo = typeof HTMLVideoElement !== 'undefined' && data instanceof HTMLVideoElement;\n // @ts-expect-error\n if (isVideo && data.readyState < HTMLVideoElement.HAVE_METADATA) {\n this._video = null; // Declare member before the object is sealed\n data.addEventListener('loadeddata', () => this.initialize(props));\n return this;\n }\n\n update(): this {\n if (this._video) {\n const {video, parameters, lastTime} = this._video;\n // @ts-expect-error\n if (lastTime === video.currentTime || video.readyState < HTMLVideoElement.HAVE_CURRENT_DATA) {\n return;\n }\n this.setSubImageData({\n data: video,\n parameters\n });\n if (this.mipmaps) {\n this.generateMipmap();\n }\n this._video.lastTime = video.currentTime;\n }\n }\n\n\n*/"],"mappings":""}
@@ -8,68 +8,50 @@ export default class WEBGLFramebuffer extends Framebuffer {
8
8
  get texture() {
9
9
  return this.colorAttachments[0];
10
10
  }
11
-
12
11
  constructor(device, props) {
13
12
  super(device, props);
14
-
15
13
  _defineProperty(this, "device", void 0);
16
-
17
14
  _defineProperty(this, "gl", void 0);
18
-
19
15
  _defineProperty(this, "handle", void 0);
20
-
21
16
  _defineProperty(this, "colorAttachments", []);
22
-
23
17
  _defineProperty(this, "depthStencilAttachment", null);
24
-
25
18
  _defineProperty(this, "_ownResources", []);
26
-
27
19
  this.device = device;
28
20
  this.gl = device.gl;
29
21
  this.handle = this.props.handle !== undefined ? this.props.handle : this.gl.createFramebuffer();
30
-
31
22
  if (this.handle) {
32
23
  this.handle.__SPECTOR_Metadata = {
33
24
  id: this.props.id,
34
25
  props: this.props
35
26
  };
36
27
  }
37
-
38
28
  this.colorAttachments = this._createColorAttachments();
39
29
  this.depthStencilAttachment = this._createDepthStencilAttachment();
40
30
  const prevHandle = this.gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle);
41
-
42
31
  for (let i = 0; i < this.colorAttachments.length; ++i) {
43
32
  const attachment = this.colorAttachments[i];
44
33
  const attachmentPoint = GL.COLOR_ATTACHMENT0 + i;
45
-
46
34
  if (attachment) {
47
35
  this._attachOne(attachmentPoint, attachment);
48
36
  }
49
37
  }
50
-
51
38
  if (this.props.depthStencilAttachment) {
52
39
  this._attachOne(getWebGLDepthStencilAttachment(this.depthStencilAttachment.format), this.depthStencilAttachment);
53
40
  }
54
-
55
41
  this.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);
56
-
57
42
  if (props.check !== false) {
58
43
  this._checkStatus();
59
44
  }
60
45
  }
61
-
62
46
  destroy() {
63
47
  if (this.handle !== null) {
64
48
  for (const resource of this._ownResources) {
65
49
  resource.destroy();
66
50
  }
67
-
68
51
  this.gl.deleteFramebuffer(this.handle);
69
52
  this.destroyed = true;
70
53
  }
71
54
  }
72
-
73
55
  _checkStatus() {
74
56
  const {
75
57
  gl
@@ -77,26 +59,21 @@ export default class WEBGLFramebuffer extends Framebuffer {
77
59
  const prevHandle = gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle);
78
60
  const status = gl.checkFramebufferStatus(GL.FRAMEBUFFER);
79
61
  gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);
80
-
81
62
  if (status !== gl.FRAMEBUFFER_COMPLETE) {
82
63
  throw new Error("Framebuffer ".concat(_getFrameBufferStatus(status)));
83
64
  }
84
65
  }
85
-
86
66
  _createColorAttachments() {
87
67
  return this.props.colorAttachments.map(colorAttachment => {
88
68
  if (!colorAttachment) {
89
69
  return undefined;
90
70
  }
91
-
92
71
  if (colorAttachment instanceof WebGLTexture) {
93
72
  return colorAttachment;
94
73
  }
95
-
96
74
  return this._createColorAttachment(colorAttachment, this.width, this.height);
97
75
  });
98
76
  }
99
-
100
77
  _createColorAttachment(format, width, height) {
101
78
  const texture = this.device._createTexture({
102
79
  id: "".concat(this.id, "-color"),
@@ -112,25 +89,19 @@ export default class WEBGLFramebuffer extends Framebuffer {
112
89
  addressModeV: 'clamp-to-edge'
113
90
  }
114
91
  });
115
-
116
92
  this._ownResources.push(texture);
117
-
118
93
  return texture;
119
94
  }
120
-
121
95
  _createDepthStencilAttachment() {
122
96
  if (!this.props.depthStencilAttachment) {
123
97
  return undefined;
124
98
  }
125
-
126
99
  if (this.props.depthStencilAttachment instanceof Renderbuffer) {
127
100
  return this.props.depthStencilAttachment;
128
101
  }
129
-
130
102
  if (this.props.depthStencilAttachment instanceof Texture) {
131
103
  return this.props.depthStencilAttachment;
132
104
  }
133
-
134
105
  const format = this.props.depthStencilAttachment;
135
106
  const webglFormat = getWebGLTextureFormat(this.gl, format);
136
107
  const texture = new Renderbuffer(this.device, {
@@ -139,127 +110,96 @@ export default class WEBGLFramebuffer extends Framebuffer {
139
110
  width: this.width,
140
111
  height: this.height
141
112
  });
142
-
143
113
  this._ownResources.push(texture);
144
-
145
114
  return texture;
146
115
  }
147
-
148
116
  _resizeAttachments(width, height) {
149
117
  var _this$depthStencilAtt;
150
-
151
118
  if (this.handle === null) {
152
119
  this.width = this.gl.drawingBufferWidth;
153
120
  this.height = this.gl.drawingBufferHeight;
154
121
  return this;
155
122
  }
156
-
157
123
  if (width === undefined) {
158
124
  width = this.gl.drawingBufferWidth;
159
125
  }
160
-
161
126
  if (height === undefined) {
162
127
  height = this.gl.drawingBufferHeight;
163
128
  }
164
-
165
129
  if (width !== this.width && height !== this.height) {
166
130
  log.log(2, "Resizing framebuffer ".concat(this.id, " to ").concat(width, "x").concat(height))();
167
131
  }
168
-
169
132
  for (const colorAttachment of this.colorAttachments) {
170
133
  colorAttachment.resize({
171
134
  width,
172
135
  height
173
136
  });
174
137
  }
175
-
176
138
  (_this$depthStencilAtt = this.depthStencilAttachment) === null || _this$depthStencilAtt === void 0 ? void 0 : _this$depthStencilAtt.resize({
177
139
  width,
178
140
  height
179
141
  });
180
142
  return this;
181
143
  }
182
-
183
144
  _attachOne(attachmentPoint, attachment) {
184
145
  if (attachment instanceof Renderbuffer) {
185
146
  this._attachRenderbuffer(attachmentPoint, attachment);
186
-
187
147
  return attachment;
188
148
  } else if (Array.isArray(attachment)) {
189
149
  const [texture, layer = 0, level = 0] = attachment;
190
-
191
150
  this._attachTexture(attachmentPoint, texture, layer, level);
192
-
193
151
  return texture;
194
152
  } else if (attachment instanceof WebGLTexture) {
195
153
  this._attachTexture(attachmentPoint, attachment, 0, 0);
196
-
197
154
  return attachment;
198
155
  }
199
-
200
156
  throw new Error('attach');
201
157
  }
202
-
203
158
  _attachRenderbuffer(attachment, renderbuffer) {
204
159
  this.gl.framebufferRenderbuffer(GL.FRAMEBUFFER, attachment, GL.RENDERBUFFER, renderbuffer.handle);
205
160
  }
206
-
207
161
  _attachTexture(attachment, texture, layer, level) {
208
162
  const {
209
163
  gl,
210
164
  gl2
211
165
  } = this.device;
212
166
  gl.bindTexture(texture.target, texture.handle);
213
-
214
167
  switch (texture.target) {
215
168
  case GL.TEXTURE_2D_ARRAY:
216
169
  case GL.TEXTURE_3D:
217
170
  this.device.assertWebGL2();
218
171
  gl2 === null || gl2 === void 0 ? void 0 : gl2.framebufferTextureLayer(GL.FRAMEBUFFER, attachment, texture.target, level, layer);
219
172
  break;
220
-
221
173
  case GL.TEXTURE_CUBE_MAP:
222
174
  const face = mapIndexToCubeMapFace(layer);
223
175
  gl.framebufferTexture2D(GL.FRAMEBUFFER, attachment, face, texture.handle, level);
224
176
  break;
225
-
226
177
  case GL.TEXTURE_2D:
227
178
  gl.framebufferTexture2D(GL.FRAMEBUFFER, attachment, GL.TEXTURE_2D, texture.handle, level);
228
179
  break;
229
-
230
180
  default:
231
181
  assert(false, 'Illegal texture type');
232
182
  }
233
-
234
183
  gl.bindTexture(texture.target, null);
235
184
  }
236
-
237
185
  }
238
-
239
186
  function mapIndexToCubeMapFace(layer) {
240
187
  return layer < GL.TEXTURE_CUBE_MAP_POSITIVE_X ? layer + GL.TEXTURE_CUBE_MAP_POSITIVE_X : layer;
241
188
  }
242
-
243
189
  function _getFrameBufferStatus(status) {
244
190
  switch (status) {
245
191
  case GL.FRAMEBUFFER_COMPLETE:
246
192
  return 'success';
247
-
248
193
  case GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
249
194
  return 'Mismatched attachments';
250
-
251
195
  case GL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
252
196
  return 'No attachments';
253
-
254
197
  case GL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
255
198
  return 'Height/width mismatch';
256
-
257
199
  case GL.FRAMEBUFFER_UNSUPPORTED:
258
200
  return 'Unsupported or split attachments';
259
-
260
201
  case GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
261
202
  return 'Samples mismatch';
262
-
263
203
  default:
264
204
  return "".concat(status);
265
205
  }