@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,192 +1,290 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  import { CommandBuffer, Texture } from '@luma.gl/core';
5
+ import { GL } from '@luma.gl/constants';
2
6
  import { WEBGLTexture } from "./webgl-texture.js";
3
7
  import { getWebGLTextureParameters } from "../converters/texture-formats.js";
4
8
  function cast(value) {
5
- return value;
9
+ return value;
6
10
  }
7
11
  export class WEBGLCommandBuffer extends CommandBuffer {
8
- constructor(device) {
9
- super(device, {});
10
- this.device = void 0;
11
- this.commands = [];
12
- this.device = device;
13
- }
14
- submitCommands() {
15
- let commands = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.commands;
16
- for (const command of commands) {
17
- switch (command.name) {
18
- case 'copy-buffer-to-buffer':
19
- _copyBufferToBuffer(this.device, command.options);
20
- break;
21
- case 'copy-buffer-to-texture':
22
- _copyBufferToTexture(this.device, command.options);
23
- break;
24
- case 'copy-texture-to-buffer':
25
- _copyTextureToBuffer(this.device, command.options);
26
- break;
27
- case 'copy-texture-to-texture':
28
- _copyTextureToTexture(this.device, command.options);
29
- break;
30
- }
12
+ device;
13
+ commands = [];
14
+ constructor(device) {
15
+ super(device, {});
16
+ this.device = device;
17
+ }
18
+ submitCommands(commands = this.commands) {
19
+ for (const command of commands) {
20
+ switch (command.name) {
21
+ case 'copy-buffer-to-buffer':
22
+ _copyBufferToBuffer(this.device, command.options);
23
+ break;
24
+ case 'copy-buffer-to-texture':
25
+ _copyBufferToTexture(this.device, command.options);
26
+ break;
27
+ case 'copy-texture-to-buffer':
28
+ _copyTextureToBuffer(this.device, command.options);
29
+ break;
30
+ case 'copy-texture-to-texture':
31
+ _copyTextureToTexture(this.device, command.options);
32
+ break;
33
+ }
34
+ }
31
35
  }
32
- }
33
36
  }
34
37
  function _copyBufferToBuffer(device, options) {
35
- const source = cast(options.source);
36
- const destination = cast(options.destination);
37
- const gl2 = device.assertWebGL2();
38
- if (gl2) {
39
- var _options$sourceOffset, _options$destinationO;
40
- gl2.bindBuffer(36662, source.handle);
41
- gl2.bindBuffer(36663, destination.handle);
42
- gl2.copyBufferSubData(36662, 36663, (_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);
43
- gl2.bindBuffer(36662, null);
44
- gl2.bindBuffer(36663, null);
45
- } else {
46
- throw new Error('copyBufferToBuffer not implemented in WebGL1');
47
- }
38
+ const source = cast(options.source);
39
+ const destination = cast(options.destination);
40
+ // {In WebGL2 we can p}erform the copy on the GPU
41
+ // Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type
42
+ device.gl.bindBuffer(GL.COPY_READ_BUFFER, source.handle);
43
+ device.gl.bindBuffer(GL.COPY_WRITE_BUFFER, destination.handle);
44
+ device.gl.copyBufferSubData(GL.COPY_READ_BUFFER, GL.COPY_WRITE_BUFFER, options.sourceOffset ?? 0, options.destinationOffset ?? 0, options.size);
45
+ device.gl.bindBuffer(GL.COPY_READ_BUFFER, null);
46
+ device.gl.bindBuffer(GL.COPY_WRITE_BUFFER, null);
48
47
  }
48
+ /**
49
+ * Copies data from a Buffer object into a Texture object
50
+ * NOTE: doesn't wait for copy to be complete
51
+ */
49
52
  function _copyBufferToTexture(device, options) {
50
- throw new Error('Not implemented');
53
+ throw new Error('Not implemented');
51
54
  }
55
+ /**
56
+ * Copies data from a Texture object into a Buffer object.
57
+ * NOTE: doesn't wait for copy to be complete
58
+ */
52
59
  function _copyTextureToBuffer(device, options) {
53
- const {
54
- source,
55
- mipLevel = 0,
56
- aspect = 'all',
57
- width = options.source.width,
58
- height = options.source.height,
59
- depthOrArrayLayers = 0,
60
- origin = [0, 0],
61
- destination,
62
- byteOffset = 0,
63
- bytesPerRow,
64
- rowsPerImage
65
- } = options;
66
- if (aspect !== 'all') {
67
- throw new Error('not supported');
68
- }
69
- if (mipLevel !== 0 || depthOrArrayLayers !== 0 || bytesPerRow || rowsPerImage) {
70
- throw new Error('not implemented');
71
- }
72
- const gl2 = device.assertWebGL2();
73
- const {
74
- framebuffer,
75
- destroyFramebuffer
76
- } = getFramebuffer(source);
77
- try {
78
- const webglBuffer = destination;
79
- const sourceWidth = width || framebuffer.width;
80
- const sourceHeight = height || framebuffer.height;
81
- const sourceParams = getWebGLTextureParameters(framebuffer.texture.format, true);
82
- const sourceFormat = sourceParams.dataFormat;
83
- const sourceType = sourceParams.type;
84
- gl2.bindBuffer(35051, webglBuffer.handle);
85
- gl2.bindFramebuffer(36160, framebuffer.handle);
86
- gl2.readPixels(origin[0], origin[1], sourceWidth, sourceHeight, sourceFormat, sourceType, byteOffset);
87
- } finally {
88
- gl2.bindBuffer(35051, null);
89
- gl2.bindFramebuffer(36160, null);
90
- if (destroyFramebuffer) {
91
- framebuffer.destroy();
60
+ const {
61
+ /** Texture to copy to/from. */
62
+ source,
63
+ /** Mip-map level of the texture to copy to/from. (Default 0) */
64
+ mipLevel = 0,
65
+ /** Defines which aspects of the texture to copy to/from. */
66
+ aspect = 'all',
67
+ /** Width to copy */
68
+ width = options.source.width,
69
+ /** Height to copy */
70
+ height = options.source.height, depthOrArrayLayers = 0,
71
+ /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */
72
+ origin = [0, 0],
73
+ /** Destination buffer */
74
+ destination,
75
+ /** Offset, in bytes, from the beginning of the buffer to the start of the image data (default 0) */
76
+ byteOffset = 0,
77
+ /**
78
+ * The stride, in bytes, between the beginning of each block row and the subsequent block row.
79
+ * Required if there are multiple block rows (i.e. the copy height or depth is more than one block).
80
+ */
81
+ bytesPerRow,
82
+ /**
83
+ * Number of block rows per single image of the texture.
84
+ * rowsPerImage × bytesPerRow is the stride, in bytes, between the beginning of each image of data and the subsequent image.
85
+ * Required if there are multiple images (i.e. the copy depth is more than one).
86
+ */
87
+ rowsPerImage } = options;
88
+ // TODO - Not possible to read just stencil or depth part in WebGL?
89
+ if (aspect !== 'all') {
90
+ throw new Error('not supported');
91
+ }
92
+ // TODO - mipLevels are set when attaching texture to framebuffer
93
+ if (mipLevel !== 0 || depthOrArrayLayers !== 0 || bytesPerRow || rowsPerImage) {
94
+ throw new Error('not implemented');
95
+ }
96
+ // Asynchronous read (PIXEL_PACK_BUFFER) is WebGL2 only feature
97
+ const { framebuffer, destroyFramebuffer } = getFramebuffer(source);
98
+ try {
99
+ const webglBuffer = destination;
100
+ const sourceWidth = width || framebuffer.width;
101
+ const sourceHeight = height || framebuffer.height;
102
+ const sourceParams = getWebGLTextureParameters(framebuffer.texture.props.format);
103
+ const sourceFormat = sourceParams.dataFormat;
104
+ const sourceType = sourceParams.type;
105
+ // if (!target) {
106
+ // // Create new buffer with enough size
107
+ // const components = glFormatToComponents(sourceFormat);
108
+ // const byteCount = glTypeToBytes(sourceType);
109
+ // const byteLength = byteOffset + sourceWidth * sourceHeight * components * byteCount;
110
+ // target = device.createBuffer({byteLength});
111
+ // }
112
+ device.gl.bindBuffer(GL.PIXEL_PACK_BUFFER, webglBuffer.handle);
113
+ device.gl.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle);
114
+ device.gl.readPixels(origin[0], origin[1], sourceWidth, sourceHeight, sourceFormat, sourceType, byteOffset);
115
+ }
116
+ finally {
117
+ device.gl.bindBuffer(GL.PIXEL_PACK_BUFFER, null);
118
+ device.gl.bindFramebuffer(GL.FRAMEBUFFER, null);
119
+ if (destroyFramebuffer) {
120
+ framebuffer.destroy();
121
+ }
92
122
  }
93
- }
94
123
  }
124
+ /**
125
+ * Copies data from a Framebuffer or a Texture object into a Buffer object.
126
+ * NOTE: doesn't wait for copy to be complete, it programs GPU to perform a DMA transfer.
127
+ export function readPixelsToBuffer(
128
+ source: Framebuffer | Texture,
129
+ options?: {
130
+ sourceX?: number;
131
+ sourceY?: number;
132
+ sourceFormat?: number;
133
+ target?: Buffer; // A new Buffer object is created when not provided.
134
+ targetByteOffset?: number; // byte offset in buffer object
135
+ // following parameters are auto deduced if not provided
136
+ sourceWidth?: number;
137
+ sourceHeight?: number;
138
+ sourceType?: number;
139
+ }
140
+ ): Buffer
141
+ */
142
+ /**
143
+ * Copy a rectangle from a Framebuffer or Texture object into a texture (at an offset)
144
+ */
145
+ // eslint-disable-next-line complexity, max-statements
95
146
  function _copyTextureToTexture(device, options) {
96
- const {
97
- source,
98
- origin = [0, 0],
147
+ const {
148
+ /** Texture to copy to/from. */
149
+ source,
150
+ /** Mip-map level of the texture to copy to/from. (Default 0) */
151
+ // mipLevel = 0,
152
+ /** Defines which aspects of the texture to copy to/from. */
153
+ // aspect = 'all',
154
+ /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */
155
+ origin = [0, 0],
156
+ /** Texture to copy to/from. */
99
157
  destination
100
- } = options;
101
- let {
102
- width = options.destination.width,
103
- height = options.destination.width
104
- } = options;
105
- const destinationMipmaplevel = 0;
106
- const destinationInternalFormat = 6408;
107
- const {
108
- framebuffer,
109
- destroyFramebuffer
110
- } = getFramebuffer(source);
111
- const [sourceX, sourceY] = origin;
112
- const isSubCopy = false;
113
- device.gl.bindFramebuffer(36160, framebuffer.handle);
114
- let texture = null;
115
- let textureTarget;
116
- if (destination instanceof WEBGLTexture) {
117
- texture = destination;
118
- width = Number.isFinite(width) ? width : texture.width;
119
- height = Number.isFinite(height) ? height : texture.height;
120
- texture.bind(0);
121
- textureTarget = texture.destination;
122
- } else {
123
- throw new Error('whoops');
124
- }
125
- if (!isSubCopy) {
126
- device.gl.copyTexImage2D(textureTarget, destinationMipmaplevel, destinationInternalFormat, sourceX, sourceY, width, height, 0);
127
- } else {}
128
- if (texture) {
129
- texture.unbind();
130
- }
131
- if (destroyFramebuffer) {
132
- framebuffer.destroy();
133
- }
134
- return texture;
158
+ /** Mip-map level of the texture to copy to/from. (Default 0) */
159
+ // destinationMipLevel = options.mipLevel,
160
+ /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */
161
+ // destinationOrigin = [0, 0],
162
+ /** Defines which aspects of the texture to copy to/from. */
163
+ // destinationAspect = options.aspect,
164
+ } = options;
165
+ let { width = options.destination.width, height = options.destination.width
166
+ // depthOrArrayLayers = 0
167
+ } = options;
168
+ const destinationMipmaplevel = 0;
169
+ const destinationInternalFormat = GL.RGBA;
170
+ const { framebuffer, destroyFramebuffer } = getFramebuffer(source);
171
+ const [sourceX, sourceY] = origin;
172
+ const isSubCopy = false;
173
+ // typeof destinationX !== 'undefined' ||
174
+ // typeof destinationY !== 'undefined' ||
175
+ // typeof destinationZ !== 'undefined';
176
+ // destinationX = destinationX || 0;
177
+ // destinationY = destinationY || 0;
178
+ // destinationZ = destinationZ || 0;
179
+ device.gl.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle);
180
+ // TODO - support gl.readBuffer (WebGL2 only)
181
+ // const prevBuffer = gl.readBuffer(attachment);
182
+ let texture = null;
183
+ let textureTarget;
184
+ if (destination instanceof WEBGLTexture) {
185
+ texture = destination;
186
+ width = Number.isFinite(width) ? width : texture.width;
187
+ height = Number.isFinite(height) ? height : texture.height;
188
+ texture.bind(0);
189
+ textureTarget = texture.destination;
190
+ }
191
+ else {
192
+ throw new Error('whoops');
193
+ // textureTarget = destination;
194
+ }
195
+ if (!isSubCopy) {
196
+ device.gl.copyTexImage2D(textureTarget, destinationMipmaplevel, destinationInternalFormat, sourceX, sourceY, width, height, 0 /* border must be 0 */);
197
+ }
198
+ else {
199
+ // switch (textureTarget) {
200
+ // case GL.TEXTURE_2D:
201
+ // case GL.TEXTURE_CUBE_MAP:
202
+ // device.gl.copyTexSubImage2D(
203
+ // textureTarget,
204
+ // destinationMipmaplevel,
205
+ // destinationX,
206
+ // destinationY,
207
+ // sourceX,
208
+ // sourceY,
209
+ // width,
210
+ // height
211
+ // );
212
+ // break;
213
+ // case GL.TEXTURE_2D_ARRAY:
214
+ // case GL.TEXTURE_3D:
215
+ // device.gl.copyTexSubImage3D(
216
+ // textureTarget,
217
+ // destinationMipmaplevel,
218
+ // destinationX,
219
+ // destinationY,
220
+ // destinationZ,
221
+ // sourceX,
222
+ // sourceY,
223
+ // width,
224
+ // height
225
+ // );
226
+ // break;
227
+ // default:
228
+ // }
229
+ }
230
+ if (texture) {
231
+ texture.unbind();
232
+ }
233
+ // ts-expect-error
234
+ // device.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);
235
+ if (destroyFramebuffer) {
236
+ framebuffer.destroy();
237
+ }
238
+ return texture;
135
239
  }
240
+ // Returns number of components in a specific readPixels WebGL format
136
241
  export function glFormatToComponents(format) {
137
- switch (format) {
138
- case 6406:
139
- case 33326:
140
- case 6403:
141
- return 1;
142
- case 33328:
143
- case 33319:
144
- return 2;
145
- case 6407:
146
- case 34837:
147
- return 3;
148
- case 6408:
149
- case 34836:
150
- return 4;
151
- default:
152
- throw new Error('GLFormat');
153
- }
242
+ switch (format) {
243
+ case GL.ALPHA:
244
+ case GL.R32F:
245
+ case GL.RED:
246
+ return 1;
247
+ case GL.RG32F:
248
+ case GL.RG:
249
+ return 2;
250
+ case GL.RGB:
251
+ case GL.RGB32F:
252
+ return 3;
253
+ case GL.RGBA:
254
+ case GL.RGBA32F:
255
+ return 4;
256
+ // TODO: Add support for additional WebGL2 formats
257
+ default:
258
+ throw new Error('GLFormat');
259
+ }
154
260
  }
261
+ // Return byte count for given readPixels WebGL type
155
262
  export function glTypeToBytes(type) {
156
- switch (type) {
157
- case 5121:
158
- return 1;
159
- case 33635:
160
- case 32819:
161
- case 32820:
162
- return 2;
163
- case 5126:
164
- return 4;
165
- default:
166
- throw new Error('GLType');
167
- }
263
+ switch (type) {
264
+ case GL.UNSIGNED_BYTE:
265
+ return 1;
266
+ case GL.UNSIGNED_SHORT_5_6_5:
267
+ case GL.UNSIGNED_SHORT_4_4_4_4:
268
+ case GL.UNSIGNED_SHORT_5_5_5_1:
269
+ return 2;
270
+ case GL.FLOAT:
271
+ return 4;
272
+ // TODO: Add support for additional WebGL2 types
273
+ default:
274
+ throw new Error('GLType');
275
+ }
168
276
  }
277
+ // Helper methods
169
278
  function getFramebuffer(source) {
170
- if (source instanceof Texture) {
171
- const {
172
- width,
173
- height,
174
- id
175
- } = source;
176
- const framebuffer = source.device.createFramebuffer({
177
- id: `framebuffer-for-${id}`,
178
- width,
179
- height,
180
- colorAttachments: [source]
181
- });
182
- return {
183
- framebuffer,
184
- destroyFramebuffer: true
185
- };
186
- }
187
- return {
188
- framebuffer: source,
189
- destroyFramebuffer: false
190
- };
279
+ if (source instanceof Texture) {
280
+ const { width, height, id } = source;
281
+ const framebuffer = source.device.createFramebuffer({
282
+ id: `framebuffer-for-${id}`,
283
+ width,
284
+ height,
285
+ colorAttachments: [source]
286
+ });
287
+ return { framebuffer, destroyFramebuffer: true };
288
+ }
289
+ return { framebuffer: source, destroyFramebuffer: false };
191
290
  }
192
- //# sourceMappingURL=webgl-command-buffer.js.map
@@ -1,7 +1,7 @@
1
1
  import { CommandEncoder, CommandEncoderProps } from '@luma.gl/core';
2
- import type { CopyBufferToBufferOptions, CopyBufferToTextureOptions, CopyTextureToBufferOptions, CopyTextureToTextureOptions } from '@luma.gl/core';
3
- import { WEBGLCommandBuffer } from './webgl-command-buffer';
4
- import { WebGLDevice } from '../webgl-device';
2
+ import type { CopyBufferToBufferOptions, CopyBufferToTextureOptions, CopyTextureToBufferOptions, CopyTextureToTextureOptions, QuerySet, Buffer } from '@luma.gl/core';
3
+ import { WEBGLCommandBuffer } from "./webgl-command-buffer.js";
4
+ import { WebGLDevice } from "../webgl-device.js";
5
5
  export declare class WEBGLCommandEncoder extends CommandEncoder {
6
6
  readonly device: WebGLDevice;
7
7
  readonly commandBuffer: WEBGLCommandBuffer;
@@ -15,5 +15,10 @@ export declare class WEBGLCommandEncoder extends CommandEncoder {
15
15
  pushDebugGroup(groupLabel: string): void;
16
16
  popDebugGroup(): void;
17
17
  insertDebugMarker(markerLabel: string): void;
18
+ resolveQuerySet(querySet: QuerySet, destination: Buffer, options?: {
19
+ firstQuery?: number;
20
+ queryCount?: number;
21
+ destinationOffset?: number;
22
+ }): void;
18
23
  }
19
24
  //# sourceMappingURL=webgl-command-encoder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webgl-command-encoder.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-command-encoder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAE5C,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAE7B,QAAQ,CAAC,aAAa,EAAE,kBAAkB,CAAC;gBAE/B,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,mBAAmB;IAMlD,OAAO,IAAI,IAAI;IAEf,MAAM,IAAI,IAAI;IAQvB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,IAAI;IAI5D,mBAAmB,CAAC,OAAO,EAAE,0BAA0B;IAIvD,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,IAAI;IAI9D,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,IAAI;IAIvD,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IACxC,aAAa;IAEb,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CAWtD"}
1
+ {"version":3,"file":"webgl-command-encoder.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-command-encoder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,EAC3B,QAAQ,EACR,MAAM,EACP,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAC,kBAAkB,EAAC,kCAA+B;AAC1D,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAE5C,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAE7B,QAAQ,CAAC,aAAa,EAAE,kBAAkB,CAAC;gBAE/B,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,mBAAmB;IAMlD,OAAO,IAAI,IAAI;IAEf,MAAM,IAAI,IAAI;IAQvB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,IAAI;IAI5D,mBAAmB,CAAC,OAAO,EAAE,0BAA0B;IAIvD,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,IAAI;IAI9D,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,IAAI;IAIvD,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IACxC,aAAa;IAEb,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAE5C,eAAe,CACtB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B,GACA,IAAI;CACR"}
@@ -1,43 +1,37 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  import { CommandEncoder } from '@luma.gl/core';
2
5
  import { WEBGLCommandBuffer } from "./webgl-command-buffer.js";
3
6
  export class WEBGLCommandEncoder extends CommandEncoder {
4
- constructor(device, props) {
5
- super(device, props);
6
- this.device = void 0;
7
- this.commandBuffer = void 0;
8
- this.device = device;
9
- this.commandBuffer = new WEBGLCommandBuffer(device);
10
- }
11
- destroy() {}
12
- finish() {
13
- this.commandBuffer.submitCommands();
14
- }
15
- copyBufferToBuffer(options) {
16
- this.commandBuffer.commands.push({
17
- name: 'copy-buffer-to-buffer',
18
- options
19
- });
20
- }
21
- copyBufferToTexture(options) {
22
- this.commandBuffer.commands.push({
23
- name: 'copy-buffer-to-texture',
24
- options
25
- });
26
- }
27
- copyTextureToBuffer(options) {
28
- this.commandBuffer.commands.push({
29
- name: 'copy-texture-to-buffer',
30
- options
31
- });
32
- }
33
- copyTextureToTexture(options) {
34
- this.commandBuffer.commands.push({
35
- name: 'copy-texture-to-texture',
36
- options
37
- });
38
- }
39
- pushDebugGroup(groupLabel) {}
40
- popDebugGroup() {}
41
- insertDebugMarker(markerLabel) {}
7
+ device;
8
+ commandBuffer;
9
+ constructor(device, props) {
10
+ super(device, props);
11
+ this.device = device;
12
+ this.commandBuffer = new WEBGLCommandBuffer(device);
13
+ }
14
+ destroy() { }
15
+ finish() {
16
+ this.commandBuffer.submitCommands();
17
+ }
18
+ // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;
19
+ // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;
20
+ // finish(options?: {id?: string}): GPUCommandBuffer;
21
+ copyBufferToBuffer(options) {
22
+ this.commandBuffer.commands.push({ name: 'copy-buffer-to-buffer', options });
23
+ }
24
+ copyBufferToTexture(options) {
25
+ this.commandBuffer.commands.push({ name: 'copy-buffer-to-texture', options });
26
+ }
27
+ copyTextureToBuffer(options) {
28
+ this.commandBuffer.commands.push({ name: 'copy-texture-to-buffer', options });
29
+ }
30
+ copyTextureToTexture(options) {
31
+ this.commandBuffer.commands.push({ name: 'copy-texture-to-texture', options });
32
+ }
33
+ pushDebugGroup(groupLabel) { }
34
+ popDebugGroup() { }
35
+ insertDebugMarker(markerLabel) { }
36
+ resolveQuerySet(querySet, destination, options) { }
42
37
  }
43
- //# sourceMappingURL=webgl-command-encoder.js.map
@@ -1,2 +1,94 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ /*
5
+ export class WEBGLExternalTexture extends WEBGLTexture {
6
+ readonly device: WebGLDevice;
7
+ readonly gl: WebGL2RenderingContext;
8
+ readonly handle: WebGLTexture;
1
9
 
2
- //# sourceMappingURL=webgl-external-texture.js.map
10
+ data;
11
+
12
+ width: number = undefined;
13
+ height: number = undefined;
14
+ depth: number = undefined;
15
+
16
+ format = undefined;
17
+ type = undefined;
18
+ dataFormat = undefined;
19
+ border = undefined;
20
+ mipmaps: boolean = undefined;
21
+
22
+ textureUnit: number = undefined;
23
+
24
+ sampler: WEBGLSampler;
25
+
26
+ // Program.draw() checks the loaded flag of all textures to avoid
27
+ // Textures that are still loading from promises
28
+ // Set to true as soon as texture has been initialized with valid data
29
+ loaded = false;
30
+ _video;
31
+
32
+ readonly target: GL;
33
+ // target cannot be modified by bind:
34
+ // textures are special because when you first bind them to a target,
35
+ // they get special information. When you first bind a texture as a
36
+ // GL_TEXTURE_2D, you are actually setting special state in the texture.
37
+ // You are saying that this texture is a 2D texture.
38
+ // And it will always be a 2D texture; this state cannot be changed ever.
39
+ // If you have a texture that was first bound as a GL_TEXTURE_2D,
40
+ // you must always bind it as a GL_TEXTURE_2D;
41
+ // attempting to bind it as GL_TEXTURE_3D will give rise to an error
42
+ // (while run-time).
43
+
44
+ static isSupported(device: WebGLDevice, options?: TextureSupportOptions): boolean {
45
+ const {format, linearFiltering} = options;
46
+ let supported = true;
47
+ if (format) {
48
+ supported = supported && isFormatSupported(device.gl, format);
49
+ supported = supported && (!linearFiltering || isTextureFormatFilterable(device.gl, format));
50
+ }
51
+ return supported;
52
+ }
53
+
54
+ // eslint-disable-next-line max-statements
55
+ constructor(device: Device | WebGL2RenderingContext, props: TextureProps) {
56
+ super(WebGLDevice.attach(device), {id: uid('texture'), ...props});
57
+
58
+ this.glTarget = getWebGLTextureTarget(props);
59
+
60
+ this.device = WebGLDevice.attach(device);
61
+ this.gl = this.device.gl;
62
+ this.gl2 = this.device.gl2;
63
+ this.handle = this.props.handle || this.gl.createTexture();
64
+
65
+ let data = props.data;
66
+
67
+ const isVideo = typeof HTMLVideoElement !== 'undefined' && data instanceof HTMLVideoElement;
68
+ // @ts-expect-error
69
+ if (isVideo && data.readyState < HTMLVideoElement.HAVE_METADATA) {
70
+ this._video = null; // Declare member before the object is sealed
71
+ data.addEventListener('loadeddata', () => this.initialize(props));
72
+ return this;
73
+ }
74
+
75
+ update(): this {
76
+ if (this._video) {
77
+ const {video, parameters, lastTime} = this._video;
78
+ // @ts-expect-error
79
+ if (lastTime === video.currentTime || video.readyState < HTMLVideoElement.HAVE_CURRENT_DATA) {
80
+ return;
81
+ }
82
+ this.setSubImageData({
83
+ data: video,
84
+ parameters
85
+ });
86
+ if (this.mipmaps) {
87
+ this.generateMipmap();
88
+ }
89
+ this._video.lastTime = video.currentTime;
90
+ }
91
+ }
92
+
93
+
94
+ */