@luma.gl/core 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 (291) hide show
  1. package/dist/adapter/attribute-utils/get-attribute-from-layouts.d.ts +4 -4
  2. package/dist/adapter/attribute-utils/get-attribute-from-layouts.d.ts.map +1 -1
  3. package/dist/adapter/attribute-utils/get-attribute-from-layouts.js +138 -106
  4. package/dist/adapter/canvas-context.d.ts +2 -2
  5. package/dist/adapter/canvas-context.d.ts.map +1 -1
  6. package/dist/adapter/canvas-context.js +306 -232
  7. package/dist/adapter/device.d.ts +112 -69
  8. package/dist/adapter/device.d.ts.map +1 -1
  9. package/dist/adapter/device.js +145 -94
  10. package/dist/adapter/resources/buffer.d.ts +3 -3
  11. package/dist/adapter/resources/buffer.d.ts.map +1 -1
  12. package/dist/adapter/resources/buffer.js +70 -56
  13. package/dist/adapter/resources/command-buffer.d.ts +2 -2
  14. package/dist/adapter/resources/command-buffer.d.ts.map +1 -1
  15. package/dist/adapter/resources/command-buffer.js +15 -12
  16. package/dist/adapter/resources/command-encoder.d.ts +22 -7
  17. package/dist/adapter/resources/command-encoder.d.ts.map +1 -1
  18. package/dist/adapter/resources/command-encoder.js +16 -16
  19. package/dist/adapter/resources/compute-pass.d.ts +16 -5
  20. package/dist/adapter/resources/compute-pass.d.ts.map +1 -1
  21. package/dist/adapter/resources/compute-pass.js +15 -12
  22. package/dist/adapter/resources/compute-pipeline.d.ts +4 -4
  23. package/dist/adapter/resources/compute-pipeline.d.ts.map +1 -1
  24. package/dist/adapter/resources/compute-pipeline.js +20 -17
  25. package/dist/adapter/resources/external-texture.d.ts +2 -2
  26. package/dist/adapter/resources/external-texture.d.ts.map +1 -1
  27. package/dist/adapter/resources/external-texture.js +14 -14
  28. package/dist/adapter/resources/framebuffer.d.ts +9 -8
  29. package/dist/adapter/resources/framebuffer.d.ts.map +1 -1
  30. package/dist/adapter/resources/framebuffer.js +191 -91
  31. package/dist/adapter/resources/query-set.d.ts +26 -0
  32. package/dist/adapter/resources/query-set.d.ts.map +1 -0
  33. package/dist/adapter/resources/query-set.js +18 -0
  34. package/dist/adapter/resources/render-pass.d.ts +22 -9
  35. package/dist/adapter/resources/render-pass.d.ts.map +1 -1
  36. package/dist/adapter/resources/render-pass.js +34 -20
  37. package/dist/adapter/resources/render-pipeline.d.ts +22 -18
  38. package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
  39. package/dist/adapter/resources/render-pipeline.js +50 -33
  40. package/dist/adapter/resources/resource.d.ts +1 -1
  41. package/dist/adapter/resources/resource.d.ts.map +1 -1
  42. package/dist/adapter/resources/resource.js +133 -92
  43. package/dist/adapter/resources/sampler.d.ts +3 -3
  44. package/dist/adapter/resources/sampler.d.ts.map +1 -1
  45. package/dist/adapter/resources/sampler.js +24 -23
  46. package/dist/adapter/resources/shader.d.ts +8 -6
  47. package/dist/adapter/resources/shader.d.ts.map +1 -1
  48. package/dist/adapter/resources/shader.js +98 -74
  49. package/dist/adapter/resources/texture-view.d.ts +32 -0
  50. package/dist/adapter/resources/texture-view.d.ts.map +1 -0
  51. package/dist/adapter/resources/texture-view.js +24 -0
  52. package/dist/adapter/resources/texture.d.ts +10 -15
  53. package/dist/adapter/resources/texture.d.ts.map +1 -1
  54. package/dist/adapter/resources/texture.js +54 -42
  55. package/dist/adapter/resources/transform-feedback.d.ts +7 -7
  56. package/dist/adapter/resources/transform-feedback.d.ts.map +1 -1
  57. package/dist/adapter/resources/transform-feedback.js +15 -14
  58. package/dist/adapter/resources/vertex-array.d.ts +9 -9
  59. package/dist/adapter/resources/vertex-array.d.ts.map +1 -1
  60. package/dist/adapter/resources/vertex-array.js +36 -20
  61. package/dist/adapter/type-utils/decode-attribute-type.d.ts +2 -2
  62. package/dist/adapter/type-utils/decode-attribute-type.d.ts.map +1 -1
  63. package/dist/adapter/type-utils/decode-attribute-type.js +59 -52
  64. package/dist/adapter/type-utils/decode-data-type.d.ts +1 -1
  65. package/dist/adapter/type-utils/decode-data-type.d.ts.map +1 -1
  66. package/dist/adapter/type-utils/decode-data-type.js +39 -35
  67. package/dist/adapter/type-utils/decode-shader-types.d.ts +1 -1
  68. package/dist/adapter/type-utils/decode-shader-types.d.ts.map +1 -1
  69. package/dist/adapter/type-utils/decode-shader-types.js +36 -96
  70. package/dist/adapter/type-utils/decode-texture-format.d.ts +6 -2
  71. package/dist/adapter/type-utils/decode-texture-format.d.ts.map +1 -1
  72. package/dist/adapter/type-utils/decode-texture-format.js +172 -92
  73. package/dist/adapter/type-utils/decode-vertex-format.d.ts +1 -1
  74. package/dist/adapter/type-utils/decode-vertex-format.d.ts.map +1 -1
  75. package/dist/adapter/type-utils/decode-vertex-format.js +30 -22
  76. package/dist/adapter/type-utils/vertex-format-from-attribute.d.ts +2 -2
  77. package/dist/adapter/type-utils/vertex-format-from-attribute.d.ts.map +1 -1
  78. package/dist/adapter/type-utils/vertex-format-from-attribute.js +72 -65
  79. package/dist/adapter/type-utils/wgsl-utils.d.ts +1 -1
  80. package/dist/adapter/type-utils/wgsl-utils.d.ts.map +1 -1
  81. package/dist/adapter/type-utils/wgsl-utils.js +17 -13
  82. package/dist/adapter/types/accessor.d.ts +1 -1
  83. package/dist/adapter/types/accessor.d.ts.map +1 -1
  84. package/dist/adapter/types/accessor.js +3 -1
  85. package/dist/adapter/types/buffer-layout.d.ts +1 -1
  86. package/dist/adapter/types/buffer-layout.d.ts.map +1 -1
  87. package/dist/adapter/types/buffer-layout.js +3 -1
  88. package/dist/adapter/types/parameters.d.ts +28 -6
  89. package/dist/adapter/types/parameters.d.ts.map +1 -1
  90. package/dist/adapter/types/parameters.js +46 -26
  91. package/dist/adapter/types/shader-layout.d.ts +8 -7
  92. package/dist/adapter/types/shader-layout.d.ts.map +1 -1
  93. package/dist/adapter/types/shader-layout.js +3 -1
  94. package/dist/adapter/types/shader-types.d.ts.map +1 -1
  95. package/dist/adapter/types/shader-types.js +3 -1
  96. package/dist/adapter/types/texture-formats.d.ts +2 -2
  97. package/dist/adapter/types/texture-formats.d.ts.map +1 -1
  98. package/dist/adapter/types/texture-formats.js +3 -1
  99. package/dist/adapter/types/types.d.ts +4 -4
  100. package/dist/adapter/types/types.d.ts.map +1 -1
  101. package/dist/adapter/types/types.js +3 -1
  102. package/dist/adapter/types/vertex-formats.d.ts.map +1 -1
  103. package/dist/adapter/types/vertex-formats.js +3 -1
  104. package/dist/dist.dev.js +614 -406
  105. package/dist/index.cjs +344 -369
  106. package/dist/index.cjs.map +7 -0
  107. package/dist/index.d.ts +80 -76
  108. package/dist/index.d.ts.map +1 -1
  109. package/dist/index.js +19 -5
  110. package/dist/init.d.ts.map +1 -1
  111. package/dist/init.js +30 -17
  112. package/dist/lib/compiler-log/compiler-message.d.ts.map +1 -1
  113. package/dist/lib/compiler-log/compiler-message.js +3 -1
  114. package/dist/lib/compiler-log/format-compiler-log.d.ts +1 -1
  115. package/dist/lib/compiler-log/format-compiler-log.d.ts.map +1 -1
  116. package/dist/lib/compiler-log/format-compiler-log.js +69 -48
  117. package/dist/lib/compiler-log/get-shader-info.d.ts.map +1 -1
  118. package/dist/lib/compiler-log/get-shader-info.js +23 -19
  119. package/dist/lib/luma.d.ts +3 -3
  120. package/dist/lib/luma.d.ts.map +1 -1
  121. package/dist/lib/luma.js +60 -51
  122. package/dist/lib/uniforms/uniform-block.d.ts +3 -4
  123. package/dist/lib/uniforms/uniform-block.d.ts.map +1 -1
  124. package/dist/lib/uniforms/uniform-block.js +52 -42
  125. package/dist/lib/uniforms/uniform-buffer-layout.d.ts +2 -2
  126. package/dist/lib/uniforms/uniform-buffer-layout.d.ts.map +1 -1
  127. package/dist/lib/uniforms/uniform-buffer-layout.js +86 -66
  128. package/dist/lib/uniforms/uniform-store.d.ts +6 -6
  129. package/dist/lib/uniforms/uniform-store.d.ts.map +1 -1
  130. package/dist/lib/uniforms/uniform-store.js +111 -75
  131. package/dist/lib/uniforms/uniform.d.ts +2 -2
  132. package/dist/lib/uniforms/uniform.d.ts.map +1 -1
  133. package/dist/lib/uniforms/uniform.js +15 -15
  134. package/dist/types.d.ts.map +1 -1
  135. package/dist/types.js +4 -3
  136. package/dist/utils/array-equal.d.ts.map +1 -1
  137. package/dist/utils/array-equal.js +25 -22
  138. package/dist/utils/array-utils-flat.d.ts +1 -1
  139. package/dist/utils/array-utils-flat.d.ts.map +1 -1
  140. package/dist/utils/array-utils-flat.js +29 -28
  141. package/dist/utils/assert.d.ts.map +1 -1
  142. package/dist/utils/assert.js +8 -4
  143. package/dist/utils/cast.d.ts.map +1 -1
  144. package/dist/utils/cast.js +5 -2
  145. package/dist/utils/check-props.d.ts.map +1 -1
  146. package/dist/utils/check-props.js +30 -26
  147. package/dist/utils/deep-equal.d.ts.map +1 -1
  148. package/dist/utils/deep-equal.js +42 -32
  149. package/dist/utils/format-value.d.ts +1 -1
  150. package/dist/utils/format-value.d.ts.map +1 -1
  151. package/dist/utils/format-value.js +36 -39
  152. package/dist/utils/is-array.d.ts +1 -1
  153. package/dist/utils/is-array.d.ts.map +1 -1
  154. package/dist/utils/is-array.js +20 -6
  155. package/dist/utils/load-file.d.ts.map +1 -1
  156. package/dist/utils/load-file.js +63 -37
  157. package/dist/utils/log.d.ts.map +1 -1
  158. package/dist/utils/log.js +5 -4
  159. package/dist/utils/random.d.ts.map +1 -1
  160. package/dist/utils/random.js +13 -9
  161. package/dist/utils/request-animation-frame.d.ts.map +1 -1
  162. package/dist/utils/request-animation-frame.js +12 -3
  163. package/dist/utils/stats-manager.d.ts.map +1 -1
  164. package/dist/utils/stats-manager.js +16 -14
  165. package/dist/utils/stub-methods.d.ts.map +1 -1
  166. package/dist/utils/stub-methods.js +15 -12
  167. package/dist/utils/utils.d.ts +0 -6
  168. package/dist/utils/utils.d.ts.map +1 -1
  169. package/dist/utils/utils.js +21 -15
  170. package/dist.min.js +8 -23
  171. package/package.json +6 -6
  172. package/src/adapter/attribute-utils/get-attribute-from-layouts.ts +6 -5
  173. package/src/adapter/canvas-context.ts +8 -5
  174. package/src/adapter/device.ts +181 -127
  175. package/src/adapter/resources/buffer.ts +19 -6
  176. package/src/adapter/resources/command-buffer.ts +7 -5
  177. package/src/adapter/resources/command-encoder.ts +40 -29
  178. package/src/adapter/resources/compute-pass.ts +23 -9
  179. package/src/adapter/resources/compute-pipeline.ts +5 -2
  180. package/src/adapter/resources/external-texture.ts +8 -2
  181. package/src/adapter/resources/framebuffer.ts +115 -102
  182. package/src/adapter/resources/query-set.ts +41 -0
  183. package/src/adapter/resources/render-pass.ts +48 -54
  184. package/src/adapter/resources/render-pipeline.ts +22 -9
  185. package/src/adapter/resources/resource.ts +13 -10
  186. package/src/adapter/resources/sampler.ts +4 -3
  187. package/src/adapter/resources/shader.ts +19 -7
  188. package/src/adapter/resources/texture-view.ts +51 -0
  189. package/src/adapter/resources/texture.ts +28 -26
  190. package/src/adapter/resources/transform-feedback.ts +6 -3
  191. package/src/adapter/resources/vertex-array.ts +11 -3
  192. package/src/adapter/type-utils/decode-attribute-type.ts +24 -10
  193. package/src/adapter/type-utils/decode-data-type.ts +5 -1
  194. package/src/adapter/type-utils/decode-shader-types.ts +12 -9
  195. package/src/adapter/type-utils/decode-texture-format.ts +28 -12
  196. package/src/adapter/type-utils/decode-vertex-format.ts +4 -0
  197. package/src/adapter/type-utils/vertex-format-from-attribute.ts +4 -1
  198. package/src/adapter/type-utils/wgsl-utils.ts +6 -2
  199. package/src/adapter/types/accessor.ts +5 -2
  200. package/src/adapter/types/buffer-layout.ts +11 -8
  201. package/src/adapter/types/parameters.ts +98 -93
  202. package/src/adapter/types/shader-layout.ts +11 -2
  203. package/src/adapter/types/shader-types.ts +2 -1
  204. package/src/adapter/types/texture-formats.ts +130 -129
  205. package/src/adapter/types/types.ts +12 -6
  206. package/src/adapter/types/vertex-formats.ts +4 -5
  207. package/src/index.ts +30 -15
  208. package/src/init.ts +10 -4
  209. package/src/lib/compiler-log/compiler-message.ts +3 -2
  210. package/src/lib/compiler-log/format-compiler-log.ts +8 -3
  211. package/src/lib/compiler-log/get-shader-info.ts +2 -1
  212. package/src/lib/luma.ts +13 -8
  213. package/src/lib/uniforms/uniform-block.ts +7 -3
  214. package/src/lib/uniforms/uniform-buffer-layout.ts +16 -10
  215. package/src/lib/uniforms/uniform-store.ts +4 -1
  216. package/src/lib/uniforms/uniform.ts +12 -6
  217. package/src/types.ts +7 -3
  218. package/src/utils/array-equal.ts +2 -1
  219. package/src/utils/array-utils-flat.ts +9 -3
  220. package/src/utils/assert.ts +4 -0
  221. package/src/utils/cast.ts +4 -0
  222. package/src/utils/check-props.ts +9 -1
  223. package/src/utils/deep-equal.ts +4 -0
  224. package/src/utils/format-value.ts +9 -2
  225. package/src/utils/is-array.ts +4 -0
  226. package/src/utils/load-file.ts +5 -3
  227. package/src/utils/log.ts +4 -0
  228. package/src/utils/random.ts +4 -0
  229. package/src/utils/request-animation-frame.ts +4 -0
  230. package/src/utils/stats-manager.ts +6 -2
  231. package/src/utils/stub-methods.ts +10 -1
  232. package/src/utils/utils.ts +2 -10
  233. package/dist/adapter/attribute-utils/get-attribute-from-layouts.js.map +0 -1
  234. package/dist/adapter/canvas-context.js.map +0 -1
  235. package/dist/adapter/device.js.map +0 -1
  236. package/dist/adapter/resources/buffer.js.map +0 -1
  237. package/dist/adapter/resources/command-buffer.js.map +0 -1
  238. package/dist/adapter/resources/command-encoder.js.map +0 -1
  239. package/dist/adapter/resources/compute-pass.js.map +0 -1
  240. package/dist/adapter/resources/compute-pipeline.js.map +0 -1
  241. package/dist/adapter/resources/external-texture.js.map +0 -1
  242. package/dist/adapter/resources/framebuffer.js.map +0 -1
  243. package/dist/adapter/resources/render-pass.js.map +0 -1
  244. package/dist/adapter/resources/render-pipeline.js.map +0 -1
  245. package/dist/adapter/resources/resource.js.map +0 -1
  246. package/dist/adapter/resources/sampler.js.map +0 -1
  247. package/dist/adapter/resources/shader.js.map +0 -1
  248. package/dist/adapter/resources/texture.js.map +0 -1
  249. package/dist/adapter/resources/transform-feedback.js.map +0 -1
  250. package/dist/adapter/resources/vertex-array.js.map +0 -1
  251. package/dist/adapter/type-utils/decode-attribute-type.js.map +0 -1
  252. package/dist/adapter/type-utils/decode-data-type.js.map +0 -1
  253. package/dist/adapter/type-utils/decode-shader-types.js.map +0 -1
  254. package/dist/adapter/type-utils/decode-texture-format.js.map +0 -1
  255. package/dist/adapter/type-utils/decode-vertex-format.js.map +0 -1
  256. package/dist/adapter/type-utils/vertex-format-from-attribute.js.map +0 -1
  257. package/dist/adapter/type-utils/wgsl-utils.js.map +0 -1
  258. package/dist/adapter/types/accessor.js.map +0 -1
  259. package/dist/adapter/types/buffer-layout.js.map +0 -1
  260. package/dist/adapter/types/parameters.js.map +0 -1
  261. package/dist/adapter/types/shader-layout.js.map +0 -1
  262. package/dist/adapter/types/shader-types.js.map +0 -1
  263. package/dist/adapter/types/texture-formats.js.map +0 -1
  264. package/dist/adapter/types/types.js.map +0 -1
  265. package/dist/adapter/types/vertex-formats.js.map +0 -1
  266. package/dist/index.js.map +0 -1
  267. package/dist/init.js.map +0 -1
  268. package/dist/lib/compiler-log/compiler-message.js.map +0 -1
  269. package/dist/lib/compiler-log/format-compiler-log.js.map +0 -1
  270. package/dist/lib/compiler-log/get-shader-info.js.map +0 -1
  271. package/dist/lib/luma.js.map +0 -1
  272. package/dist/lib/uniforms/uniform-block.js.map +0 -1
  273. package/dist/lib/uniforms/uniform-buffer-layout.js.map +0 -1
  274. package/dist/lib/uniforms/uniform-store.js.map +0 -1
  275. package/dist/lib/uniforms/uniform.js.map +0 -1
  276. package/dist/types.js.map +0 -1
  277. package/dist/utils/array-equal.js.map +0 -1
  278. package/dist/utils/array-utils-flat.js.map +0 -1
  279. package/dist/utils/assert.js.map +0 -1
  280. package/dist/utils/cast.js.map +0 -1
  281. package/dist/utils/check-props.js.map +0 -1
  282. package/dist/utils/deep-equal.js.map +0 -1
  283. package/dist/utils/format-value.js.map +0 -1
  284. package/dist/utils/is-array.js.map +0 -1
  285. package/dist/utils/load-file.js.map +0 -1
  286. package/dist/utils/log.js.map +0 -1
  287. package/dist/utils/random.js.map +0 -1
  288. package/dist/utils/request-animation-frame.js.map +0 -1
  289. package/dist/utils/stats-manager.js.map +0 -1
  290. package/dist/utils/stub-methods.js.map +0 -1
  291. package/dist/utils/utils.js.map +0 -1
package/dist/dist.dev.js CHANGED
@@ -39,8 +39,11 @@ var __exports__ = (() => {
39
39
  ComputePass: () => ComputePass,
40
40
  ComputePipeline: () => ComputePipeline,
41
41
  Device: () => Device,
42
+ DeviceFeatures: () => DeviceFeatures,
43
+ DeviceLimits: () => DeviceLimits,
42
44
  ExternalTexture: () => ExternalTexture,
43
45
  Framebuffer: () => Framebuffer,
46
+ QuerySet: () => QuerySet,
44
47
  RenderPass: () => RenderPass,
45
48
  RenderPipeline: () => RenderPipeline,
46
49
  Resource: () => Resource,
@@ -48,6 +51,7 @@ var __exports__ = (() => {
48
51
  Shader: () => Shader,
49
52
  StatsManager: () => StatsManager,
50
53
  Texture: () => Texture,
54
+ TextureView: () => TextureView,
51
55
  TransformFeedback: () => TransformFeedback,
52
56
  UniformBlock: () => UniformBlock,
53
57
  UniformBufferLayout: () => UniformBufferLayout,
@@ -75,7 +79,6 @@ var __exports__ = (() => {
75
79
  glsl: () => glsl,
76
80
  isNumberArray: () => isNumberArray,
77
81
  isObjectEmpty: () => isObjectEmpty,
78
- isPowerOfTwo: () => isPowerOfTwo,
79
82
  isTypedArray: () => isTypedArray,
80
83
  isUniformValue: () => isUniformValue,
81
84
  loadFile: () => loadFile,
@@ -176,20 +179,20 @@ var __exports__ = (() => {
176
179
  function formatTime(ms) {
177
180
  let formatted;
178
181
  if (ms < 10) {
179
- formatted = "".concat(ms.toFixed(2), "ms");
182
+ formatted = `${ms.toFixed(2)}ms`;
180
183
  } else if (ms < 100) {
181
- formatted = "".concat(ms.toFixed(1), "ms");
184
+ formatted = `${ms.toFixed(1)}ms`;
182
185
  } else if (ms < 1e3) {
183
- formatted = "".concat(ms.toFixed(0), "ms");
186
+ formatted = `${ms.toFixed(0)}ms`;
184
187
  } else {
185
- formatted = "".concat((ms / 1e3).toFixed(2), "s");
188
+ formatted = `${(ms / 1e3).toFixed(2)}s`;
186
189
  }
187
190
  return formatted;
188
191
  }
189
192
  function leftPad(string) {
190
193
  let length = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8;
191
194
  const padLength = Math.max(length - string.length, 0);
192
- return "".concat(" ".repeat(padLength)).concat(string);
195
+ return `${" ".repeat(padLength)}${string}`;
193
196
  }
194
197
  function formatImage(image, message, scale) {
195
198
  let maxWidth = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 600;
@@ -199,8 +202,8 @@ var __exports__ = (() => {
199
202
  }
200
203
  const width = image.width * scale;
201
204
  const height = image.height * scale;
202
- const style = ["font-size:1px;", "padding:".concat(Math.floor(height / 2), "px ").concat(Math.floor(width / 2), "px;"), "line-height:".concat(height, "px;"), "background:url(".concat(imageUrl, ");"), "background-size:".concat(width, "px ").concat(height, "px;"), "color:transparent;"].join("");
203
- return ["".concat(message, " %c+"), style];
205
+ const style = ["font-size:1px;", `padding:${Math.floor(height / 2)}px ${Math.floor(width / 2)}px;`, `line-height:${height}px;`, `background:url(${imageUrl});`, `background-size:${width}px ${height}px;`, "color:transparent;"].join("");
206
+ return [`${message} %c+`, style];
204
207
  }
205
208
 
206
209
  // ../../node_modules/@probe.gl/log/dist/utils/color.js
@@ -235,11 +238,11 @@ var __exports__ = (() => {
235
238
  if (!isBrowser && typeof string === "string") {
236
239
  if (color) {
237
240
  const colorCode = getColor(color);
238
- string = "\x1B[".concat(colorCode, "m").concat(string, "\x1B[39m");
241
+ string = `\x1B[${colorCode}m${string}\x1B[39m`;
239
242
  }
240
243
  if (background) {
241
244
  const colorCode = getColor(background);
242
- string = "\x1B[".concat(colorCode + BACKGROUND_INCREMENT, "m").concat(string, "\x1B[49m");
245
+ string = `\x1B[${colorCode + BACKGROUND_INCREMENT}m${string}\x1B[49m`;
243
246
  }
244
247
  }
245
248
  return string;
@@ -318,8 +321,8 @@ var __exports__ = (() => {
318
321
  this.LOG_THROTTLE_TIMEOUT = 0;
319
322
  this.id = id;
320
323
  this.userData = {};
321
- this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_LOG_CONFIGURATION);
322
- this.timeStamp("".concat(this.id, " started"));
324
+ this._storage = new LocalStorage(`__probe-${this.id}__`, DEFAULT_LOG_CONFIGURATION);
325
+ this.timeStamp(`${this.id} started`);
323
326
  autobind(this);
324
327
  Object.seal(this);
325
328
  }
@@ -388,10 +391,10 @@ var __exports__ = (() => {
388
391
  return this._getLogFunction(0, message, originalConsole.error, arguments);
389
392
  }
390
393
  deprecated(oldUsage, newUsage) {
391
- return this.warn("`".concat(oldUsage, "` is deprecated and will be removed in a later version. Use `").concat(newUsage, "` instead"));
394
+ return this.warn(`\`${oldUsage}\` is deprecated and will be removed in a later version. Use \`${newUsage}\` instead`);
392
395
  }
393
396
  removed(oldUsage, newUsage) {
394
- return this.error("`".concat(oldUsage, "` has been removed. Use `").concat(newUsage, "` instead"));
397
+ return this.error(`\`${oldUsage}\` has been removed. Use \`${newUsage}\` instead`);
395
398
  }
396
399
  probe(logLevel, message) {
397
400
  return this._getLogFunction(logLevel, message, originalConsole.log, arguments, {
@@ -566,7 +569,7 @@ var __exports__ = (() => {
566
569
  function decorateMessage(id, message, opts) {
567
570
  if (typeof message === "string") {
568
571
  const time = opts.time ? leftPad(formatTime(opts.total)) : "";
569
- message = opts.time ? "".concat(id, ": ").concat(time, " ").concat(message) : "".concat(id, ": ").concat(message);
572
+ message = opts.time ? `${id}: ${time} ${message}` : `${id}: ${message}`;
570
573
  message = addColor(message, opts.color, opts.background);
571
574
  }
572
575
  return message;
@@ -617,15 +620,16 @@ var __exports__ = (() => {
617
620
  return "empty";
618
621
  }
619
622
 
623
+ // ../../node_modules/@probe.gl/log/dist/init.js
624
+ globalThis.probe = {};
625
+
620
626
  // ../../node_modules/@probe.gl/log/dist/index.js
621
627
  var dist_default = new Log({
622
628
  id: "@probe.gl/log"
623
629
  });
624
630
 
625
631
  // src/utils/log.ts
626
- var log = new Log({
627
- id: "luma.gl"
628
- });
632
+ var log = new Log({ id: "luma.gl" });
629
633
 
630
634
  // ../../node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js
631
635
  function getHiResTimestamp2() {
@@ -826,9 +830,7 @@ var __exports__ = (() => {
826
830
  }
827
831
  get(name2) {
828
832
  if (!this.stats.has(name2)) {
829
- this.stats.set(name2, new Stats({
830
- id: name2
831
- }));
833
+ this.stats.set(name2, new Stats({ id: name2 }));
832
834
  }
833
835
  return this.stats.get(name2);
834
836
  }
@@ -840,7 +842,9 @@ var __exports__ = (() => {
840
842
  const VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "running from source";
841
843
  const STARTUP_MESSAGE = "set luma.log.level=1 (or higher) to trace rendering";
842
844
  if (globalThis.luma && globalThis.luma.VERSION !== VERSION3) {
843
- throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${VERSION3}`);
845
+ throw new Error(
846
+ `luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${VERSION3}`
847
+ );
844
848
  }
845
849
  if (!globalThis.luma) {
846
850
  if (isBrowser()) {
@@ -850,6 +854,8 @@ var __exports__ = (() => {
850
854
  VERSION: VERSION3,
851
855
  version: VERSION3,
852
856
  log,
857
+ // A global stats object that various components can add information to
858
+ // E.g. see webgl/resource.js
853
859
  stats: lumaStats
854
860
  };
855
861
  }
@@ -875,9 +881,6 @@ var __exports__ = (() => {
875
881
  const count = uidCounters[id]++;
876
882
  return `${id}-${count}`;
877
883
  }
878
- function isPowerOfTwo(n) {
879
- return n > 0 && (n & n - 1) === 0;
880
- }
881
884
  function isObjectEmpty(obj) {
882
885
  let isEmpty = true;
883
886
  for (const key in obj) {
@@ -889,10 +892,20 @@ var __exports__ = (() => {
889
892
 
890
893
  // src/adapter/resources/resource.ts
891
894
  var Resource = class {
895
+ /** props.id, for debugging. */
896
+ id;
897
+ props;
892
898
  userData = {};
899
+ _device;
900
+ /** Whether this resource has been destroyed */
893
901
  destroyed = false;
902
+ /** For resources that allocate GPU memory */
894
903
  allocatedBytes = 0;
904
+ /** Attached resources will be destroyed when this resource is destroyed. Tracks auto-created "sub" resources. */
895
905
  _attachedResources = /* @__PURE__ */ new Set();
906
+ /**
907
+ * Create a new Resource. Called from Subclass
908
+ */
896
909
  constructor(device, props, defaultProps) {
897
910
  if (!device) {
898
911
  throw new Error("no device");
@@ -905,9 +918,13 @@ var __exports__ = (() => {
905
918
  this.userData = this.props.userData || {};
906
919
  this.addStats();
907
920
  }
921
+ /**
922
+ * destroy can be called on any resource to release it before it is garbage collected.
923
+ */
908
924
  destroy() {
909
925
  this.destroyResource();
910
926
  }
927
+ /** @deprecated Use destroy() */
911
928
  delete() {
912
929
  this.destroy();
913
930
  return this;
@@ -915,48 +932,70 @@ var __exports__ = (() => {
915
932
  toString() {
916
933
  return `${this[Symbol.toStringTag] || this.constructor.name}(${this.id})`;
917
934
  }
935
+ /**
936
+ * Combines a map of user props and default props, only including props from defaultProps
937
+ * @returns returns a map of overridden default props
938
+ */
918
939
  getProps() {
919
940
  return this.props;
920
941
  }
942
+ // ATTACHED RESOURCES
943
+ /**
944
+ * Attaches a resource. Attached resources are auto destroyed when this resource is destroyed
945
+ * Called automatically when sub resources are auto created but can be called by application
946
+ */
921
947
  attachResource(resource) {
922
948
  this._attachedResources.add(resource);
923
949
  }
950
+ /**
951
+ * Detach an attached resource. The resource will no longer be auto-destroyed when this resource is destroyed.
952
+ */
924
953
  detachResource(resource) {
925
954
  this._attachedResources.delete(resource);
926
955
  }
956
+ /**
957
+ * Destroys a resource (only if owned), and removes from the owned (auto-destroy) list for this resource.
958
+ */
927
959
  destroyAttachedResource(resource) {
928
960
  if (this._attachedResources.delete(resource)) {
929
961
  resource.destroy();
930
962
  }
931
963
  }
964
+ /** Destroy all owned resources. Make sure the resources are no longer needed before calling. */
932
965
  destroyAttachedResources() {
933
966
  for (const resource of Object.values(this._attachedResources)) {
934
967
  resource.destroy();
935
968
  }
936
969
  this._attachedResources = /* @__PURE__ */ new Set();
937
970
  }
971
+ // PROTECTED METHODS
972
+ /** Perform all destroy steps. Can be called by derived resources when overriding destroy() */
938
973
  destroyResource() {
939
974
  this.destroyAttachedResources();
940
975
  this.removeStats();
941
976
  this.destroyed = true;
942
977
  }
978
+ /** Called by .destroy() to track object destruction. Subclass must call if overriding destroy() */
943
979
  removeStats() {
944
980
  const stats = this._device.statsManager.getStats("Resource Counts");
945
981
  const name2 = this[Symbol.toStringTag];
946
982
  stats.get(`${name2}s Active`).decrementCount();
947
983
  }
984
+ /** Called by subclass to track memory allocations */
948
985
  trackAllocatedMemory(bytes, name2 = this[Symbol.toStringTag]) {
949
986
  const stats = this._device.statsManager.getStats("Resource Counts");
950
987
  stats.get("GPU Memory").addCount(bytes);
951
988
  stats.get(`${name2} Memory`).addCount(bytes);
952
989
  this.allocatedBytes = bytes;
953
990
  }
991
+ /** Called by subclass to track memory deallocations */
954
992
  trackDeallocatedMemory(name2 = this[Symbol.toStringTag]) {
955
993
  const stats = this._device.statsManager.getStats("Resource Counts");
956
994
  stats.get("GPU Memory").subtractCount(this.allocatedBytes);
957
995
  stats.get(`${name2} Memory`).subtractCount(this.allocatedBytes);
958
996
  this.allocatedBytes = 0;
959
997
  }
998
+ /** Called by resource constructor to track object creation */
960
999
  addStats() {
961
1000
  const stats = this._device.statsManager.getStats("Resource Counts");
962
1001
  const name2 = this[Symbol.toStringTag];
@@ -965,15 +1004,14 @@ var __exports__ = (() => {
965
1004
  stats.get(`${name2}s Active`).incrementCount();
966
1005
  }
967
1006
  };
1007
+ /** Default properties for resource */
968
1008
  __publicField(Resource, "defaultProps", {
969
1009
  id: "undefined",
970
1010
  handle: void 0,
971
1011
  userData: void 0
972
1012
  });
973
1013
  function selectivelyMerge(props, defaultProps) {
974
- const mergedProps = {
975
- ...defaultProps
976
- };
1014
+ const mergedProps = { ...defaultProps };
977
1015
  for (const key in props) {
978
1016
  if (props[key] !== void 0) {
979
1017
  mergedProps[key] = props[key];
@@ -987,10 +1025,12 @@ var __exports__ = (() => {
987
1025
  get [Symbol.toStringTag]() {
988
1026
  return "Buffer";
989
1027
  }
1028
+ /** The usage with which this buffer was created */
1029
+ usage;
1030
+ /** For index buffers, whether indices are 16 or 32 bit */
1031
+ indexType;
990
1032
  constructor(device, props) {
991
- const deducedProps = {
992
- ...props
993
- };
1033
+ const deducedProps = { ...props };
994
1034
  if ((props.usage || 0) & _Buffer.INDEX && !props.indexType) {
995
1035
  if (props.data instanceof Uint32Array) {
996
1036
  deducedProps.indexType = "uint32";
@@ -1002,13 +1042,19 @@ var __exports__ = (() => {
1002
1042
  this.usage = props.usage || 0;
1003
1043
  this.indexType = deducedProps.indexType;
1004
1044
  }
1005
- readSyncWebGL2(byteOffset, byteLength) {
1045
+ /** Read data synchronously. @note WebGL2 only */
1046
+ readSyncWebGL(byteOffset, byteLength) {
1006
1047
  throw new Error("not implemented");
1007
1048
  }
1049
+ /** A partial CPU-side copy of the data in this buffer, for debugging purposes */
1008
1050
  debugData = new ArrayBuffer(0);
1051
+ /** This doesn't handle partial non-zero offset updates correctly */
1009
1052
  _setDebugData(data, byteOffset, byteLength) {
1010
1053
  const buffer = ArrayBuffer.isView(data) ? data.buffer : data;
1011
- const debugDataLength = Math.min(data ? data.byteLength : byteLength, _Buffer.DEBUG_DATA_MAX_LENGTH);
1054
+ const debugDataLength = Math.min(
1055
+ data ? data.byteLength : byteLength,
1056
+ _Buffer.DEBUG_DATA_MAX_LENGTH
1057
+ );
1012
1058
  if (data === null) {
1013
1059
  this.debugData = new ArrayBuffer(debugDataLength);
1014
1060
  } else if (byteOffset === 0 && byteLength === data.byteLength) {
@@ -1022,42 +1068,197 @@ var __exports__ = (() => {
1022
1068
  __publicField(Buffer2, "defaultProps", {
1023
1069
  ...Resource.defaultProps,
1024
1070
  usage: 0,
1071
+ // Buffer.COPY_DST | Buffer.COPY_SRC
1025
1072
  byteLength: 0,
1026
1073
  byteOffset: 0,
1027
1074
  data: null,
1028
1075
  indexType: "uint16",
1029
1076
  mappedAtCreation: false
1030
1077
  });
1078
+ // Usage Flags
1031
1079
  __publicField(Buffer2, "MAP_READ", 1);
1032
1080
  __publicField(Buffer2, "MAP_WRITE", 2);
1033
1081
  __publicField(Buffer2, "COPY_SRC", 4);
1034
1082
  __publicField(Buffer2, "COPY_DST", 8);
1083
+ /** Index buffer */
1035
1084
  __publicField(Buffer2, "INDEX", 16);
1085
+ /** Vertex buffer */
1036
1086
  __publicField(Buffer2, "VERTEX", 32);
1087
+ /** Uniform buffer */
1037
1088
  __publicField(Buffer2, "UNIFORM", 64);
1089
+ /** Storage buffer */
1038
1090
  __publicField(Buffer2, "STORAGE", 128);
1039
1091
  __publicField(Buffer2, "INDIRECT", 256);
1040
1092
  __publicField(Buffer2, "QUERY_RESOLVE", 512);
1093
+ // PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)
1094
+ /** Max amount of debug data saved. Two vec4's */
1041
1095
  __publicField(Buffer2, "DEBUG_DATA_MAX_LENGTH", 32);
1042
1096
 
1097
+ // src/adapter/type-utils/decode-data-type.ts
1098
+ function decodeVertexType(type) {
1099
+ const dataType = TYPE_MAP[type];
1100
+ const bytes = getDataTypeBytes(dataType);
1101
+ const normalized = type.includes("norm");
1102
+ const integer = !normalized && !type.startsWith("float");
1103
+ const signed = type.startsWith("s");
1104
+ return {
1105
+ dataType: TYPE_MAP[type],
1106
+ byteLength: bytes,
1107
+ integer,
1108
+ signed,
1109
+ normalized
1110
+ };
1111
+ }
1112
+ function getDataTypeBytes(type) {
1113
+ const bytes = TYPE_SIZES[type];
1114
+ return bytes;
1115
+ }
1116
+ var TYPE_MAP = {
1117
+ uint8: "uint8",
1118
+ sint8: "sint8",
1119
+ unorm8: "uint8",
1120
+ snorm8: "sint8",
1121
+ uint16: "uint16",
1122
+ sint16: "sint16",
1123
+ unorm16: "uint16",
1124
+ snorm16: "sint16",
1125
+ float16: "float16",
1126
+ float32: "float32",
1127
+ uint32: "uint32",
1128
+ sint32: "sint32"
1129
+ };
1130
+ var TYPE_SIZES = {
1131
+ uint8: 1,
1132
+ sint8: 1,
1133
+ uint16: 2,
1134
+ sint16: 2,
1135
+ float16: 2,
1136
+ float32: 4,
1137
+ uint32: 4,
1138
+ sint32: 4
1139
+ };
1140
+
1141
+ // src/adapter/type-utils/decode-texture-format.ts
1142
+ var COMPRESSED_TEXTURE_FORMAT_PREFIXES = [
1143
+ "bc1",
1144
+ "bc2",
1145
+ "bc3",
1146
+ "bc4",
1147
+ "bc5",
1148
+ "bc6",
1149
+ "bc7",
1150
+ "etc1",
1151
+ "etc2",
1152
+ "eac",
1153
+ "atc",
1154
+ "astc",
1155
+ "pvrtc"
1156
+ ];
1157
+ var REGEX = /^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;
1158
+ function isTextureFormatCompressed(textureFormat) {
1159
+ return COMPRESSED_TEXTURE_FORMAT_PREFIXES.some((prefix) => textureFormat.startsWith(prefix));
1160
+ }
1161
+ function decodeTextureFormat(format) {
1162
+ const matches = REGEX.exec(format);
1163
+ if (matches) {
1164
+ const [, format2, length, type, srgb, suffix] = matches;
1165
+ if (format2) {
1166
+ const dataType = `${type}${length}`;
1167
+ const decodedType = decodeVertexType(dataType);
1168
+ return {
1169
+ format: format2,
1170
+ components: format2.length,
1171
+ // dataType - overwritten by decodedType
1172
+ srgb: srgb === "-srgb",
1173
+ unsized: suffix === "-unsized",
1174
+ webgl: suffix === "-webgl",
1175
+ ...decodedType
1176
+ };
1177
+ }
1178
+ }
1179
+ return decodeNonStandardFormat(format);
1180
+ }
1181
+ var EXCEPTIONS = {
1182
+ // Packed 16 bit formats
1183
+ "rgba4unorm-webgl": { format: "rgba", bpp: 2 },
1184
+ "rgb565unorm-webgl": { format: "rgb", bpp: 2 },
1185
+ "rgb5a1unorm-webgl": { format: "rgba", bbp: 2 },
1186
+ // Packed 32 bit formats
1187
+ rgb9e5ufloat: { format: "rgb", bbp: 4 },
1188
+ rg11b10ufloat: { format: "rgb", bbp: 4 },
1189
+ rgb10a2unorm: { format: "rgba", bbp: 4 },
1190
+ "rgb10a2uint-webgl": { format: "rgba", bbp: 4 },
1191
+ // Depth/stencil
1192
+ stencil8: { components: 1, bpp: 1, a: "stencil" },
1193
+ depth16unorm: { components: 1, bpp: 2, a: "depth" },
1194
+ depth24plus: { components: 1, bpp: 3, a: "depth" },
1195
+ depth32float: { components: 1, bpp: 4, a: "depth" },
1196
+ "depth24plus-stencil8": { components: 2, bpp: 4, a: "depth-stencil" },
1197
+ // "depth24unorm-stencil8" feature
1198
+ "depth24unorm-stencil8": { components: 2, bpp: 4, a: "depth-stencil" },
1199
+ // "depth32float-stencil8" feature
1200
+ "depth32float-stencil8": { components: 2, bpp: 4, a: "depth-stencil" }
1201
+ };
1202
+ function decodeNonStandardFormat(format) {
1203
+ const data = EXCEPTIONS[format];
1204
+ if (!data) {
1205
+ throw new Error(`Unknown format ${format}`);
1206
+ }
1207
+ return {
1208
+ format: data.format || "",
1209
+ components: data.components || data.format?.length || 1,
1210
+ byteLength: data.bpp || 1,
1211
+ srgb: false,
1212
+ unsized: false
1213
+ };
1214
+ }
1215
+
1043
1216
  // src/adapter/device.ts
1217
+ var DeviceLimits = class {
1218
+ };
1219
+ var DeviceFeatures = class {
1220
+ features;
1221
+ constructor(features = []) {
1222
+ this.features = new Set(features);
1223
+ }
1224
+ *[Symbol.iterator]() {
1225
+ yield* this.features;
1226
+ }
1227
+ has(feature) {
1228
+ return this.features.has(feature);
1229
+ }
1230
+ };
1044
1231
  var _Device = class {
1045
1232
  get [Symbol.toStringTag]() {
1046
1233
  return "Device";
1047
1234
  }
1048
1235
  constructor(props) {
1049
- this.props = {
1050
- ..._Device.defaultProps,
1051
- ...props
1052
- };
1236
+ this.props = { ..._Device.defaultProps, ...props };
1053
1237
  this.id = this.props.id || uid(this[Symbol.toStringTag].toLowerCase());
1054
1238
  }
1239
+ /** id of this device, primarily for debugging */
1240
+ id;
1241
+ /** stats */
1055
1242
  statsManager = lumaStats;
1243
+ /** A copy of the device props */
1244
+ props;
1245
+ /** Available for the application to store data on the device */
1056
1246
  userData = {};
1247
+ /** Used by other luma.gl modules to store data on the device */
1057
1248
  _lumaData = {};
1249
+ /** Check if a specific texture format is GPU compressed */
1250
+ isTextureFormatCompressed(format) {
1251
+ return isTextureFormatCompressed(format);
1252
+ }
1253
+ /**
1254
+ * Trigger device loss.
1255
+ * @returns `true` if context loss could actually be triggered.
1256
+ * @note primarily intended for testing how application reacts to device loss
1257
+ */
1058
1258
  loseDevice() {
1059
1259
  return false;
1060
1260
  }
1261
+ /** Returns the default / primary canvas context. Throws an error if no canvas context is available (a WebGPU compute device) */
1061
1262
  getCanvasContext() {
1062
1263
  if (!this.canvasContext) {
1063
1264
  throw new Error("Device has no CanvasContext");
@@ -1066,42 +1267,50 @@ var __exports__ = (() => {
1066
1267
  }
1067
1268
  createTexture(props) {
1068
1269
  if (props instanceof Promise || typeof props === "string") {
1069
- props = {
1070
- data: props
1071
- };
1270
+ props = { data: props };
1072
1271
  }
1073
1272
  return this._createTexture(props);
1074
1273
  }
1075
1274
  createCommandEncoder(props = {}) {
1076
1275
  throw new Error("not implemented");
1077
1276
  }
1277
+ // WebGL specific HACKS - enables app to remove webgl import
1278
+ // Use until we have a better way to handle these
1279
+ /** @deprecated - will be removed - should use command encoder */
1078
1280
  readPixelsToArrayWebGL(source, options) {
1079
1281
  throw new Error("not implemented");
1080
1282
  }
1283
+ /** @deprecated - will be removed - should use command encoder */
1081
1284
  readPixelsToBufferWebGL(source, options) {
1082
1285
  throw new Error("not implemented");
1083
1286
  }
1287
+ /** @deprecated - will be removed - should use WebGPU parameters (pipeline) */
1084
1288
  setParametersWebGL(parameters) {
1085
1289
  throw new Error("not implemented");
1086
1290
  }
1291
+ /** @deprecated - will be removed - should use WebGPU parameters (pipeline) */
1087
1292
  getParametersWebGL(parameters) {
1088
1293
  throw new Error("not implemented");
1089
1294
  }
1295
+ /** @deprecated - will be removed - should use WebGPU parameters (pipeline) */
1090
1296
  withParametersWebGL(parameters, func) {
1091
1297
  throw new Error("not implemented");
1092
1298
  }
1299
+ /** @deprecated - will be removed - should use clear arguments in RenderPass */
1093
1300
  clearWebGL(options) {
1094
1301
  throw new Error("not implemented");
1095
1302
  }
1303
+ // IMPLEMENTATION
1304
+ // Error Handling
1305
+ /** Report unhandled device errors */
1306
+ onError(error) {
1307
+ this.props.onError(error);
1308
+ }
1096
1309
  _getBufferProps(props) {
1097
1310
  if (props instanceof ArrayBuffer || ArrayBuffer.isView(props)) {
1098
- props = {
1099
- data: props
1100
- };
1311
+ props = { data: props };
1101
1312
  }
1102
- const newProps = {
1103
- ...props
1104
- };
1313
+ const newProps = { ...props };
1105
1314
  if ((props.usage || 0) & Buffer2.INDEX && !props.indexType) {
1106
1315
  if (props.data instanceof Uint32Array) {
1107
1316
  newProps.indexType = "uint32";
@@ -1120,14 +1329,26 @@ var __exports__ = (() => {
1120
1329
  type: "best-available",
1121
1330
  canvas: null,
1122
1331
  container: null,
1123
- webgl2: true,
1124
- webgl1: true,
1125
1332
  manageState: true,
1126
1333
  width: 800,
1334
+ // width are height are only used by headless gl
1127
1335
  height: 600,
1336
+ requestMaximalLimits: true,
1128
1337
  debug: Boolean(log.get("debug")),
1338
+ // Instrument context (at the expense of performance)
1339
+ spector: Boolean(log.get("spector")),
1340
+ // Initialize the SpectorJS WebGL debugger
1129
1341
  break: [],
1130
- gl: null
1342
+ // alpha: undefined,
1343
+ // depth: undefined,
1344
+ // stencil: undefined,
1345
+ // antialias: undefined,
1346
+ // premultipliedAlpha: undefined,
1347
+ // preserveDrawingBuffer: undefined,
1348
+ // failIfMajorPerformanceCaveat: undefined
1349
+ gl: null,
1350
+ // Callbacks
1351
+ onError: (error) => log.error(error.message)
1131
1352
  });
1132
1353
  __publicField(Device, "VERSION", VERSION2);
1133
1354
 
@@ -1156,11 +1377,9 @@ var __exports__ = (() => {
1156
1377
  static setDefaultDeviceProps(props) {
1157
1378
  Object.assign(Device.defaultProps, props);
1158
1379
  }
1380
+ /** Creates a device. Asynchronously. */
1159
1381
  static async createDevice(props = {}) {
1160
- props = {
1161
- ...Device.defaultProps,
1162
- ...props
1163
- };
1382
+ props = { ...Device.defaultProps, ...props };
1164
1383
  if (props.gl) {
1165
1384
  props.type = "webgl";
1166
1385
  }
@@ -1173,8 +1392,6 @@ var __exports__ = (() => {
1173
1392
  }
1174
1393
  break;
1175
1394
  case "webgl":
1176
- case "webgl1":
1177
- case "webgl2":
1178
1395
  DeviceClass = deviceList.get("webgl");
1179
1396
  if (DeviceClass) {
1180
1397
  return await DeviceClass.create(props);
@@ -1191,10 +1408,14 @@ var __exports__ = (() => {
1191
1408
  }
1192
1409
  break;
1193
1410
  }
1194
- throw new Error("No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.");
1411
+ throw new Error(
1412
+ "No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported."
1413
+ );
1195
1414
  }
1196
1415
  };
1416
+ /** Global stats for all devices */
1197
1417
  __publicField(luma, "stats", lumaStats);
1418
+ /** Global log */
1198
1419
  __publicField(luma, "log", log);
1199
1420
 
1200
1421
  // src/adapter/canvas-context.ts
@@ -1203,6 +1424,7 @@ var __exports__ = (() => {
1203
1424
  var DEFAULT_CANVAS_CONTEXT_PROPS = {
1204
1425
  canvas: null,
1205
1426
  width: 800,
1427
+ // width are height are only used by headless gl
1206
1428
  height: 600,
1207
1429
  useDevicePixels: true,
1208
1430
  autoResize: true,
@@ -1212,21 +1434,23 @@ var __exports__ = (() => {
1212
1434
  alphaMode: "opaque"
1213
1435
  };
1214
1436
  var CanvasContext = class {
1437
+ id;
1438
+ props;
1439
+ canvas;
1440
+ htmlCanvas;
1441
+ offscreenCanvas;
1442
+ type;
1215
1443
  width = 1;
1216
1444
  height = 1;
1217
- _canvasSizeInfo = {
1218
- clientWidth: 0,
1219
- clientHeight: 0,
1220
- devicePixelRatio: 1
1221
- };
1445
+ resizeObserver;
1446
+ /** State used by luma.gl classes: TODO - move to canvasContext*/
1447
+ _canvasSizeInfo = { clientWidth: 0, clientHeight: 0, devicePixelRatio: 1 };
1448
+ /** Check if the DOM is loaded */
1222
1449
  static get isPageLoaded() {
1223
1450
  return isPageLoaded();
1224
1451
  }
1225
1452
  constructor(props) {
1226
- this.props = {
1227
- ...DEFAULT_CANVAS_CONTEXT_PROPS,
1228
- ...props
1229
- };
1453
+ this.props = { ...DEFAULT_CANVAS_CONTEXT_PROPS, ...props };
1230
1454
  props = this.props;
1231
1455
  if (!isBrowser()) {
1232
1456
  this.id = "node-canvas-context";
@@ -1269,6 +1493,10 @@ var __exports__ = (() => {
1269
1493
  this.resizeObserver.observe(this.canvas);
1270
1494
  }
1271
1495
  }
1496
+ /**
1497
+ * Returns the current DPR, if props.useDevicePixels is true
1498
+ * Device refers to physical
1499
+ */
1272
1500
  getDevicePixelRatio(useDevicePixels) {
1273
1501
  if (typeof OffscreenCanvas !== "undefined" && this.canvas instanceof OffscreenCanvas) {
1274
1502
  return 1;
@@ -1283,6 +1511,12 @@ var __exports__ = (() => {
1283
1511
  }
1284
1512
  return useDevicePixels;
1285
1513
  }
1514
+ /**
1515
+ * Returns the size of drawing buffer in device pixels.
1516
+ * @note This can be different from the 'CSS' size of a canvas, and also from the
1517
+ * canvas' internal drawing buffer size (.width, .height).
1518
+ * This is the size required to cover the canvas, adjusted for DPR
1519
+ */
1286
1520
  getPixelSize() {
1287
1521
  switch (this.type) {
1288
1522
  case "node":
@@ -1301,22 +1535,30 @@ var __exports__ = (() => {
1301
1535
  const [width, height] = this.getPixelSize();
1302
1536
  return width / height;
1303
1537
  }
1538
+ /**
1539
+ * Returns multiplier need to convert CSS size to Device size
1540
+ */
1304
1541
  cssToDeviceRatio() {
1305
1542
  try {
1306
1543
  const [drawingBufferWidth] = this.getDrawingBufferSize();
1307
- const {
1308
- clientWidth
1309
- } = this._canvasSizeInfo;
1544
+ const { clientWidth } = this._canvasSizeInfo;
1310
1545
  return clientWidth ? drawingBufferWidth / clientWidth : 1;
1311
1546
  } catch {
1312
1547
  return 1;
1313
1548
  }
1314
1549
  }
1550
+ /**
1551
+ * Maps CSS pixel position to device pixel position
1552
+ */
1315
1553
  cssToDevicePixels(cssPixel, yInvert = true) {
1316
1554
  const ratio = this.cssToDeviceRatio();
1317
1555
  const [width, height] = this.getDrawingBufferSize();
1318
1556
  return scalePixels(cssPixel, ratio, width, height, yInvert);
1319
1557
  }
1558
+ /**
1559
+ * Use devicePixelRatio to set canvas width and height
1560
+ * @note this is a raw port of luma.gl v8 code. Might be worth a review
1561
+ */
1320
1562
  setDevicePixelRatio(devicePixelRatio, options = {}) {
1321
1563
  if (!this.htmlCanvas) {
1322
1564
  return;
@@ -1338,7 +1580,10 @@ var __exports__ = (() => {
1338
1580
  this.htmlCanvas.height = canvasHeight;
1339
1581
  const [drawingBufferWidth, drawingBufferHeight] = this.getDrawingBufferSize();
1340
1582
  if (drawingBufferWidth !== canvasWidth || drawingBufferHeight !== canvasHeight) {
1341
- clampedPixelRatio = Math.min(drawingBufferWidth / clientWidth, drawingBufferHeight / clientHeight);
1583
+ clampedPixelRatio = Math.min(
1584
+ drawingBufferWidth / clientWidth,
1585
+ drawingBufferHeight / clientHeight
1586
+ );
1342
1587
  this.htmlCanvas.width = Math.floor(clientWidth * clampedPixelRatio);
1343
1588
  this.htmlCanvas.height = Math.floor(clientHeight * clampedPixelRatio);
1344
1589
  log.warn("Device pixel ratio clamped")();
@@ -1348,6 +1593,8 @@ var __exports__ = (() => {
1348
1593
  this._canvasSizeInfo.devicePixelRatio = devicePixelRatio;
1349
1594
  }
1350
1595
  }
1596
+ // PRIVATE
1597
+ /** @todo Major hack done to port the CSS methods above, base canvas context should not depend on WebGL */
1351
1598
  getDrawingBufferSize() {
1352
1599
  const gl = this.device.gl;
1353
1600
  if (!gl) {
@@ -1355,12 +1602,22 @@ var __exports__ = (() => {
1355
1602
  }
1356
1603
  return [gl.drawingBufferWidth, gl.drawingBufferHeight];
1357
1604
  }
1605
+ /**
1606
+ * Allows subclass constructor to override the canvas id for auto created canvases.
1607
+ * This can really help when debugging DOM in apps that create multiple devices
1608
+ */
1358
1609
  _setAutoCreatedCanvasId(id) {
1359
1610
  if (this.htmlCanvas?.id === "lumagl-auto-created-canvas") {
1360
1611
  this.htmlCanvas.id = id;
1361
1612
  }
1362
1613
  }
1363
1614
  };
1615
+ /**
1616
+ * Get a 'lazy' promise that resolves when the DOM is loaded.
1617
+ * @note Since there may be limitations on number of `load` event listeners,
1618
+ * it is recommended avoid calling this function until actually needed.
1619
+ * I.e. don't call it until you know that you will be looking up a string in the DOM.
1620
+ */
1364
1621
  __publicField(CanvasContext, "pageLoaded", getPageLoadPromise());
1365
1622
  function getPageLoadPromise() {
1366
1623
  if (isPageLoaded() || typeof window === "undefined") {
@@ -1396,10 +1653,7 @@ var __exports__ = (() => {
1396
1653
  return canvas;
1397
1654
  }
1398
1655
  function createCanvas(props) {
1399
- const {
1400
- width,
1401
- height
1402
- } = props;
1656
+ const { width, height } = props;
1403
1657
  const targetCanvas = document.createElement("canvas");
1404
1658
  targetCanvas.id = "lumagl-auto-created-canvas";
1405
1659
  targetCanvas.width = width || 1;
@@ -1426,6 +1680,7 @@ var __exports__ = (() => {
1426
1680
  return {
1427
1681
  x,
1428
1682
  y,
1683
+ // when ratio < 1, current css pixel and next css pixel may point to same device pixel, set width/height to 1 in those cases.
1429
1684
  width: Math.max(xHigh - x + 1, 1),
1430
1685
  height: Math.max(yHigh - y + 1, 1)
1431
1686
  };
@@ -1443,6 +1698,16 @@ var __exports__ = (() => {
1443
1698
  get [Symbol.toStringTag]() {
1444
1699
  return "Texture";
1445
1700
  }
1701
+ /** dimension of this texture */
1702
+ dimension;
1703
+ /** format of this texture */
1704
+ format;
1705
+ /** width in pixels of this texture */
1706
+ width;
1707
+ /** height in pixels of this texture */
1708
+ height;
1709
+ /** depth of this texture */
1710
+ depth;
1446
1711
  constructor(device, props, defaultProps = _Texture.defaultProps) {
1447
1712
  super(device, props, defaultProps);
1448
1713
  this.dimension = this.props.dimension;
@@ -1462,12 +1727,16 @@ var __exports__ = (() => {
1462
1727
  height: void 0,
1463
1728
  depth: 1,
1464
1729
  mipmaps: true,
1465
- sampler: {},
1730
+ // type: undefined,
1466
1731
  compressed: false,
1732
+ // mipLevels: 1,
1467
1733
  usage: 0,
1734
+ // usage: GPUTextureUsage.COPY_DST
1468
1735
  mipLevels: void 0,
1469
1736
  samples: void 0,
1470
- type: void 0
1737
+ type: void 0,
1738
+ sampler: {},
1739
+ view: void 0
1471
1740
  });
1472
1741
  __publicField(Texture, "COPY_SRC", 1);
1473
1742
  __publicField(Texture, "COPY_DST", 2);
@@ -1475,6 +1744,28 @@ var __exports__ = (() => {
1475
1744
  __publicField(Texture, "STORAGE_BINDING", 8);
1476
1745
  __publicField(Texture, "RENDER_ATTACHMENT", 16);
1477
1746
 
1747
+ // src/adapter/resources/texture-view.ts
1748
+ var _TextureView = class extends Resource {
1749
+ get [Symbol.toStringTag]() {
1750
+ return "TextureView";
1751
+ }
1752
+ /** Should not be constructed directly. Use `texture.createView(props)` */
1753
+ constructor(device, props) {
1754
+ super(device, props, _TextureView.defaultProps);
1755
+ }
1756
+ };
1757
+ var TextureView = _TextureView;
1758
+ __publicField(TextureView, "defaultProps", {
1759
+ ...Resource.defaultProps,
1760
+ format: void 0,
1761
+ dimension: void 0,
1762
+ aspect: "all",
1763
+ baseMipLevel: 0,
1764
+ mipLevelCount: void 0,
1765
+ baseArrayLayer: 0,
1766
+ arrayLayerCount: void 0
1767
+ });
1768
+
1478
1769
  // src/adapter/resources/external-texture.ts
1479
1770
  var _ExternalTexture = class extends Resource {
1480
1771
  get [Symbol.toStringTag]() {
@@ -1587,20 +1878,30 @@ ${numberedLines}${positionIndicator}${message.type.toUpperCase()}: ${message.mes
1587
1878
  get [Symbol.toStringTag]() {
1588
1879
  return "Shader";
1589
1880
  }
1881
+ /** The stage of this shader */
1882
+ stage;
1883
+ /** The source code of this shader */
1884
+ source;
1885
+ /** The compilation status of the shader. 'pending' if compilation is asynchronous, and on production */
1590
1886
  compilationStatus = "pending";
1887
+ /** Create a new Shader instance */
1591
1888
  constructor(device, props) {
1592
- super(device, {
1593
- id: getShaderIdFromProps(props),
1594
- ...props
1595
- }, _Shader.defaultProps);
1889
+ super(device, { id: getShaderIdFromProps(props), ...props }, _Shader.defaultProps);
1596
1890
  this.stage = this.props.stage;
1597
1891
  this.source = this.props.source;
1598
1892
  }
1893
+ /** Get compiler log synchronously (WebGL only) */
1599
1894
  getCompilationInfoSync() {
1600
1895
  return null;
1601
1896
  }
1602
- async debugShader() {
1603
- switch (this.props.debug) {
1897
+ /** Get translated shader source in host platform's native language (HLSL, GLSL, and even GLSL ES), if available */
1898
+ getTranslatedSource() {
1899
+ return null;
1900
+ }
1901
+ // PORTABLE HELPERS
1902
+ /** In browser logging of errors */
1903
+ async debugShader(trigger = this.props.debug) {
1904
+ switch (trigger) {
1604
1905
  case "never":
1605
1906
  return;
1606
1907
  case "errors":
@@ -1618,16 +1919,19 @@ ${numberedLines}${positionIndicator}${message.type.toUpperCase()}: ${message.mes
1618
1919
  }
1619
1920
  this._displayShaderLog(messages);
1620
1921
  }
1922
+ // PRIVATE
1923
+ /** In-browser UI logging of errors */
1621
1924
  _displayShaderLog(messages) {
1622
1925
  if (typeof document === "undefined" || !document?.createElement) {
1623
1926
  return;
1624
1927
  }
1625
1928
  const shaderName = getShaderInfo(this.source).name;
1626
1929
  const shaderTitle = `${this.stage} ${shaderName}`;
1627
- const htmlLog = formatCompilerLog(messages, this.source, {
1628
- showSourceCode: "all",
1629
- html: true
1630
- });
1930
+ let htmlLog = formatCompilerLog(messages, this.source, { showSourceCode: "all", html: true });
1931
+ const translatedSource = this.getTranslatedSource();
1932
+ if (translatedSource) {
1933
+ htmlLog += `<br /><br /><h1>Translated Source</h1><br /><br /><code style="user-select:text;"><pre>${translatedSource}</pre></code>`;
1934
+ }
1631
1935
  const button = document.createElement("Button");
1632
1936
  button.innerHTML = `
1633
1937
  <h1>Shader Compilation Error in ${shaderTitle}</h1><br /><br />
@@ -1686,6 +1990,7 @@ ${htmlLog}
1686
1990
  mipmapFilter: "nearest",
1687
1991
  lodMinClamp: 0,
1688
1992
  lodMaxClamp: 32,
1993
+ // Per WebGPU spec
1689
1994
  compare: "less-equal",
1690
1995
  maxAnisotropy: 1
1691
1996
  });
@@ -1695,7 +2000,13 @@ ${htmlLog}
1695
2000
  get [Symbol.toStringTag]() {
1696
2001
  return "Framebuffer";
1697
2002
  }
2003
+ /** Width of all attachments in this framebuffer */
2004
+ width;
2005
+ /** Height of all attachments in this framebuffer */
2006
+ height;
2007
+ /** Color attachments */
1698
2008
  colorAttachments = [];
2009
+ /** Depth-stencil attachment, if provided */
1699
2010
  depthStencilAttachment = null;
1700
2011
  constructor(device, props = {}) {
1701
2012
  super(device, props, _Framebuffer.defaultProps);
@@ -1715,25 +2026,33 @@ ${htmlLog}
1715
2026
  this.resizeAttachments(this.width, this.height);
1716
2027
  }
1717
2028
  }
2029
+ /** Auto creates any textures */
1718
2030
  autoCreateAttachmentTextures() {
1719
- this.colorAttachments = this.props.colorAttachments.map((attachment) => {
1720
- if (typeof attachment === "string") {
1721
- const texture = this.createColorTexture(attachment);
2031
+ this.colorAttachments = this.props.colorAttachments.map((attachment2) => {
2032
+ if (typeof attachment2 === "string") {
2033
+ const texture = this.createColorTexture(attachment2);
1722
2034
  this.attachResource(texture);
1723
- return texture;
2035
+ return texture.view;
1724
2036
  }
1725
- return attachment;
2037
+ if (attachment2 instanceof Texture) {
2038
+ return attachment2.view;
2039
+ }
2040
+ return attachment2;
1726
2041
  });
1727
- if (this.props.depthStencilAttachment) {
1728
- if (typeof this.props.depthStencilAttachment === "string") {
1729
- const texture = this.createDepthStencilTexture(this.props.depthStencilAttachment);
2042
+ const attachment = this.props.depthStencilAttachment;
2043
+ if (attachment) {
2044
+ if (typeof attachment === "string") {
2045
+ const texture = this.createDepthStencilTexture(attachment);
1730
2046
  this.attachResource(texture);
1731
- this.depthStencilAttachment = texture;
2047
+ this.depthStencilAttachment = texture.view;
2048
+ } else if (attachment instanceof Texture) {
2049
+ this.depthStencilAttachment = attachment.view;
1732
2050
  } else {
1733
- this.depthStencilAttachment = this.props.depthStencilAttachment;
2051
+ this.depthStencilAttachment = attachment;
1734
2052
  }
1735
2053
  }
1736
2054
  }
2055
+ /** Create a color texture */
1737
2056
  createColorTexture(format) {
1738
2057
  return this.device.createTexture({
1739
2058
  id: "color-attachment",
@@ -1743,6 +2062,7 @@ ${htmlLog}
1743
2062
  height: this.height
1744
2063
  });
1745
2064
  }
2065
+ /** Create depth stencil texture */
1746
2066
  createDepthStencilTexture(format) {
1747
2067
  return this.device.createTexture({
1748
2068
  id: "depth-stencil-attachment",
@@ -1752,6 +2072,11 @@ ${htmlLog}
1752
2072
  height: this.height
1753
2073
  });
1754
2074
  }
2075
+ /**
2076
+ * Default implementation of resize
2077
+ * Creates new textures with correct size for all attachments.
2078
+ * and destroys existing textures if owned
2079
+ */
1755
2080
  resizeAttachments(width, height) {
1756
2081
  for (let i = 0; i < this.colorAttachments.length; ++i) {
1757
2082
  if (this.colorAttachments[i]) {
@@ -1761,8 +2086,8 @@ ${htmlLog}
1761
2086
  height
1762
2087
  });
1763
2088
  this.destroyAttachedResource(this.colorAttachments[i]);
1764
- this.colorAttachments[i] = resizedTexture;
1765
- this.attachResource(resizedTexture);
2089
+ this.colorAttachments[i] = resizedTexture.view;
2090
+ this.attachResource(resizedTexture.view);
1766
2091
  }
1767
2092
  }
1768
2093
  if (this.depthStencilAttachment) {
@@ -1772,7 +2097,7 @@ ${htmlLog}
1772
2097
  height
1773
2098
  });
1774
2099
  this.destroyAttachedResource(this.depthStencilAttachment);
1775
- this.depthStencilAttachment = resizedTexture;
2100
+ this.depthStencilAttachment = resizedTexture.view;
1776
2101
  this.attachResource(resizedTexture);
1777
2102
  }
1778
2103
  }
@@ -1783,7 +2108,9 @@ ${htmlLog}
1783
2108
  width: 1,
1784
2109
  height: 1,
1785
2110
  colorAttachments: [],
2111
+ // ['rgba8unorm-unsized'],
1786
2112
  depthStencilAttachment: null
2113
+ // 'depth24plus-stencil8'
1787
2114
  });
1788
2115
 
1789
2116
  // src/adapter/resources/render-pipeline.ts
@@ -1791,21 +2118,40 @@ ${htmlLog}
1791
2118
  get [Symbol.toStringTag]() {
1792
2119
  return "RenderPipeline";
1793
2120
  }
2121
+ /** The merged layout */
2122
+ shaderLayout;
2123
+ /** Buffer map describing buffer interleaving etc */
2124
+ bufferLayout;
2125
+ /** The linking status of the pipeline. 'pending' if linking is asynchronous, and on production */
2126
+ linkStatus = "pending";
2127
+ /** The hash of the pipeline */
1794
2128
  hash = "";
1795
2129
  constructor(device, props) {
1796
2130
  super(device, props, _RenderPipeline.defaultProps);
1797
2131
  this.shaderLayout = this.props.shaderLayout;
1798
2132
  this.bufferLayout = this.props.bufferLayout || [];
1799
2133
  }
2134
+ // DEPRECATED METHODS
2135
+ /**
2136
+ * Uniforms
2137
+ * @deprecated Use uniforms buffers
2138
+ * @note textures, samplers and uniform buffers should be set via `setBindings()`, these are not considered uniforms.
2139
+ * @note In WebGL uniforms have a performance penalty, they are reset before each call to enable pipeline sharing.
2140
+ */
2141
+ setUniformsWebGL(uniforms) {
2142
+ throw new Error("Use uniform blocks");
2143
+ }
1800
2144
  };
1801
2145
  var RenderPipeline = _RenderPipeline;
1802
2146
  __publicField(RenderPipeline, "defaultProps", {
1803
2147
  ...Resource.defaultProps,
1804
2148
  vs: null,
1805
2149
  vsEntryPoint: "",
2150
+ // main
1806
2151
  vsConstants: {},
1807
2152
  fs: null,
1808
2153
  fsEntryPoint: "",
2154
+ // main
1809
2155
  fsConstants: {},
1810
2156
  shaderLayout: null,
1811
2157
  bufferLayout: [],
@@ -1817,25 +2163,6 @@ ${htmlLog}
1817
2163
  uniforms: {}
1818
2164
  });
1819
2165
 
1820
- // src/adapter/resources/compute-pipeline.ts
1821
- var _ComputePipeline = class extends Resource {
1822
- get [Symbol.toStringTag]() {
1823
- return "ComputePipeline";
1824
- }
1825
- hash = "";
1826
- constructor(device, props) {
1827
- super(device, props, _ComputePipeline.defaultProps);
1828
- }
1829
- };
1830
- var ComputePipeline = _ComputePipeline;
1831
- __publicField(ComputePipeline, "defaultProps", {
1832
- ...Resource.defaultProps,
1833
- cs: void 0,
1834
- csEntryPoint: void 0,
1835
- csConstants: {},
1836
- shaderLayout: []
1837
- });
1838
-
1839
2166
  // src/adapter/resources/render-pass.ts
1840
2167
  var _RenderPass = class extends Resource {
1841
2168
  get [Symbol.toStringTag]() {
@@ -1844,8 +2171,20 @@ ${htmlLog}
1844
2171
  constructor(device, props) {
1845
2172
  super(device, props, _RenderPass.defaultProps);
1846
2173
  }
2174
+ // In WebGPU the following methods are on the renderpass instead of the renderpipeline
2175
+ // luma.gl keeps them on the pipeline for now.
2176
+ // TODO - Can we align WebGL implementation with WebGPU API?
2177
+ // abstract setPipeline(pipeline: RenderPipeline): void {}
2178
+ // abstract setIndexBuffer()
2179
+ // abstract setVertexBuffer(slot: number, buffer: Buffer, offset: number): void;
2180
+ // abstract setBindings(bindings: Record<string, Binding>): void;
2181
+ // abstract setParameters(parameters: RenderPassParameters);
2182
+ // abstract draw(options: {
2183
+ // abstract drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
2184
+ // abstract drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
1847
2185
  };
1848
2186
  var RenderPass = _RenderPass;
2187
+ /** Default properties for RenderPass */
1849
2188
  __publicField(RenderPass, "defaultProps", {
1850
2189
  ...Resource.defaultProps,
1851
2190
  framebuffer: null,
@@ -1855,20 +2194,47 @@ ${htmlLog}
1855
2194
  clearStencil: 0,
1856
2195
  depthReadOnly: false,
1857
2196
  stencilReadOnly: false,
1858
- discard: false
2197
+ discard: false,
2198
+ occlusionQuerySet: void 0,
2199
+ timestampQuerySet: void 0,
2200
+ beginTimestampIndex: void 0,
2201
+ endTimestampIndex: void 0
2202
+ });
2203
+
2204
+ // src/adapter/resources/compute-pipeline.ts
2205
+ var _ComputePipeline = class extends Resource {
2206
+ get [Symbol.toStringTag]() {
2207
+ return "ComputePipeline";
2208
+ }
2209
+ hash = "";
2210
+ constructor(device, props) {
2211
+ super(device, props, _ComputePipeline.defaultProps);
2212
+ }
2213
+ };
2214
+ var ComputePipeline = _ComputePipeline;
2215
+ __publicField(ComputePipeline, "defaultProps", {
2216
+ ...Resource.defaultProps,
2217
+ cs: void 0,
2218
+ csEntryPoint: void 0,
2219
+ csConstants: {},
2220
+ shaderLayout: []
1859
2221
  });
1860
2222
 
1861
2223
  // src/adapter/resources/compute-pass.ts
1862
- var ComputePass = class extends Resource {
2224
+ var _ComputePass = class extends Resource {
1863
2225
  get [Symbol.toStringTag]() {
1864
2226
  return "ComputePass";
1865
2227
  }
1866
2228
  constructor(device, props) {
1867
- super(device, props, Resource.defaultProps);
2229
+ super(device, props, _ComputePass.defaultProps);
1868
2230
  }
1869
2231
  };
2232
+ var ComputePass = _ComputePass;
1870
2233
  __publicField(ComputePass, "defaultProps", {
1871
- ...Resource.defaultProps
2234
+ ...Resource.defaultProps,
2235
+ timestampQuerySet: void 0,
2236
+ beginTimestampIndex: void 0,
2237
+ endTimestampIndex: void 0
1872
2238
  });
1873
2239
 
1874
2240
  // src/adapter/resources/command-encoder.ts
@@ -1879,12 +2245,9 @@ ${htmlLog}
1879
2245
  constructor(device, props) {
1880
2246
  super(device, props, _CommandEncoder.defaultProps);
1881
2247
  }
1882
- pushDebugGroup(groupLabel) {
1883
- }
1884
- popDebugGroup() {
1885
- }
1886
- insertDebugMarker(markerLabel) {
1887
- }
2248
+ // TODO - luma.gl has these on the device, should we align with WebGPU API?
2249
+ // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;
2250
+ // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;
1888
2251
  };
1889
2252
  var CommandEncoder = _CommandEncoder;
1890
2253
  __publicField(CommandEncoder, "defaultProps", {
@@ -1911,7 +2274,7 @@ ${htmlLog}
1911
2274
  const [dataType, components] = TYPE_INFO[attributeType];
1912
2275
  const integer = dataType === "i32" || dataType === "u32";
1913
2276
  const signed = dataType !== "u32";
1914
- const byteLength = TYPE_SIZES[dataType] * components;
2277
+ const byteLength = TYPE_SIZES2[dataType] * components;
1915
2278
  const defaultVertexFormat = getCompatibleVertexFormat(dataType, components);
1916
2279
  return {
1917
2280
  dataType,
@@ -1960,55 +2323,12 @@ ${htmlLog}
1960
2323
  "vec3<u32>": ["u32", 3],
1961
2324
  "vec4<u32>": ["u32", 4]
1962
2325
  };
1963
- var TYPE_SIZES = {
2326
+ var TYPE_SIZES2 = {
1964
2327
  f32: 4,
1965
2328
  f16: 2,
1966
2329
  i32: 4,
1967
2330
  u32: 4
1968
- };
1969
-
1970
- // src/adapter/type-utils/decode-data-type.ts
1971
- function decodeVertexType(type) {
1972
- const dataType = TYPE_MAP[type];
1973
- const bytes = getDataTypeBytes(dataType);
1974
- const normalized = type.includes("norm");
1975
- const integer = !normalized && !type.startsWith("float");
1976
- const signed = type.startsWith("s");
1977
- return {
1978
- dataType: TYPE_MAP[type],
1979
- byteLength: bytes,
1980
- integer,
1981
- signed,
1982
- normalized
1983
- };
1984
- }
1985
- function getDataTypeBytes(type) {
1986
- const bytes = TYPE_SIZES2[type];
1987
- return bytes;
1988
- }
1989
- var TYPE_MAP = {
1990
- uint8: "uint8",
1991
- sint8: "sint8",
1992
- unorm8: "uint8",
1993
- snorm8: "sint8",
1994
- uint16: "uint16",
1995
- sint16: "sint16",
1996
- unorm16: "uint16",
1997
- snorm16: "sint16",
1998
- float16: "float16",
1999
- float32: "float32",
2000
- uint32: "uint32",
2001
- sint32: "sint32"
2002
- };
2003
- var TYPE_SIZES2 = {
2004
- uint8: 1,
2005
- sint8: 1,
2006
- uint16: 2,
2007
- sint16: 2,
2008
- float16: 2,
2009
- float32: 4,
2010
- uint32: 4,
2011
- sint32: 4
2331
+ // 'bool-webgl': 4,
2012
2332
  };
2013
2333
 
2014
2334
  // src/adapter/type-utils/decode-vertex-format.ts
@@ -2040,7 +2360,11 @@ ${htmlLog}
2040
2360
  function getAttributeInfosFromLayouts(shaderLayout, bufferLayout) {
2041
2361
  const attributeInfos = {};
2042
2362
  for (const attribute of shaderLayout.attributes) {
2043
- attributeInfos[attribute.name] = getAttributeInfoFromLayouts(shaderLayout, bufferLayout, attribute.name);
2363
+ attributeInfos[attribute.name] = getAttributeInfoFromLayouts(
2364
+ shaderLayout,
2365
+ bufferLayout,
2366
+ attribute.name
2367
+ );
2044
2368
  }
2045
2369
  return attributeInfos;
2046
2370
  }
@@ -2071,7 +2395,9 @@ ${htmlLog}
2071
2395
  vertexFormat,
2072
2396
  bufferDataType: vertexFormatInfo.type,
2073
2397
  bufferComponents: vertexFormatInfo.components,
2398
+ // normalized is a property of the buffer's vertex format
2074
2399
  normalized: vertexFormatInfo.normalized,
2400
+ // integer is a property of the shader declaration
2075
2401
  integer: attributeTypeInfo.integer,
2076
2402
  stepMode: bufferMapping?.stepMode || shaderDeclaration.stepMode,
2077
2403
  byteOffset: bufferMapping?.byteOffset || 0,
@@ -2113,6 +2439,7 @@ ${htmlLog}
2113
2439
  bufferName: name2,
2114
2440
  stepMode: bufferLayout.stepMode,
2115
2441
  vertexFormat: bufferLayout.format,
2442
+ // If offset is needed, use `attributes` field.
2116
2443
  byteOffset: 0,
2117
2444
  byteStride: bufferLayout.byteStride || 0
2118
2445
  };
@@ -2146,9 +2473,7 @@ ${htmlLog}
2146
2473
  function mergeShaderLayout(baseLayout, overrideLayout) {
2147
2474
  const mergedLayout = {
2148
2475
  ...baseLayout,
2149
- attributes: baseLayout.attributes.map((attribute) => ({
2150
- ...attribute
2151
- }))
2476
+ attributes: baseLayout.attributes.map((attribute) => ({ ...attribute }))
2152
2477
  };
2153
2478
  for (const attribute of overrideLayout?.attributes || []) {
2154
2479
  const baseAttribute = mergedLayout.attributes.find((attr) => attr.name === attribute.name);
@@ -2167,12 +2492,28 @@ ${htmlLog}
2167
2492
  get [Symbol.toStringTag]() {
2168
2493
  return "VertexArray";
2169
2494
  }
2495
+ /** Max number of vertex attributes */
2496
+ maxVertexAttributes;
2497
+ /** Attribute infos indexed by location - TODO only needed by webgl module? */
2498
+ attributeInfos;
2499
+ /** Index buffer */
2170
2500
  indexBuffer = null;
2501
+ /** Attributes indexed by buffer slot */
2502
+ attributes;
2171
2503
  constructor(device, props) {
2172
2504
  super(device, props, _VertexArray.defaultProps);
2173
2505
  this.maxVertexAttributes = device.limits.maxVertexAttributes;
2174
2506
  this.attributes = new Array(this.maxVertexAttributes).fill(null);
2175
- this.attributeInfos = getAttributeInfosByLocation(props.renderPipeline.shaderLayout, props.renderPipeline.bufferLayout, this.maxVertexAttributes);
2507
+ this.attributeInfos = getAttributeInfosByLocation(
2508
+ props.renderPipeline.shaderLayout,
2509
+ props.renderPipeline.bufferLayout,
2510
+ this.maxVertexAttributes
2511
+ );
2512
+ }
2513
+ // DEPRECATED METHODS
2514
+ /** @deprecated Set constant attributes (WebGL only) */
2515
+ setConstantWebGL(location, value) {
2516
+ throw new Error("constant attributes not supported");
2176
2517
  }
2177
2518
  };
2178
2519
  var VertexArray = _VertexArray;
@@ -2197,92 +2538,46 @@ ${htmlLog}
2197
2538
  buffers: {}
2198
2539
  });
2199
2540
 
2541
+ // src/adapter/resources/query-set.ts
2542
+ var _QuerySet = class extends Resource {
2543
+ get [Symbol.toStringTag]() {
2544
+ return "QuerySet";
2545
+ }
2546
+ constructor(device, props) {
2547
+ super(device, props, _QuerySet.defaultProps);
2548
+ }
2549
+ };
2550
+ var QuerySet = _QuerySet;
2551
+ __publicField(QuerySet, "defaultProps", {
2552
+ ...Resource.defaultProps,
2553
+ type: void 0,
2554
+ count: void 0
2555
+ });
2556
+
2200
2557
  // src/adapter/type-utils/decode-shader-types.ts
2201
2558
  var UNIFORM_FORMATS = {
2202
- "f32": {
2203
- type: "f32",
2204
- components: 1
2205
- },
2206
- "i32": {
2207
- type: "i32",
2208
- components: 1
2209
- },
2210
- "u32": {
2211
- type: "u32",
2212
- components: 1
2213
- },
2214
- "vec2<f32>": {
2215
- type: "f32",
2216
- components: 2
2217
- },
2218
- "vec3<f32>": {
2219
- type: "f32",
2220
- components: 3
2221
- },
2222
- "vec4<f32>": {
2223
- type: "f32",
2224
- components: 4
2225
- },
2226
- "vec2<i32>": {
2227
- type: "i32",
2228
- components: 2
2229
- },
2230
- "vec3<i32>": {
2231
- type: "i32",
2232
- components: 3
2233
- },
2234
- "vec4<i32>": {
2235
- type: "i32",
2236
- components: 4
2237
- },
2238
- "vec2<u32>": {
2239
- type: "u32",
2240
- components: 2
2241
- },
2242
- "vec3<u32>": {
2243
- type: "u32",
2244
- components: 3
2245
- },
2246
- "vec4<u32>": {
2247
- type: "u32",
2248
- components: 4
2249
- },
2250
- "mat2x2<f32>": {
2251
- type: "f32",
2252
- components: 4
2253
- },
2254
- "mat2x3<f32>": {
2255
- type: "f32",
2256
- components: 6
2257
- },
2258
- "mat2x4<f32>": {
2259
- type: "f32",
2260
- components: 8
2261
- },
2262
- "mat3x2<f32>": {
2263
- type: "f32",
2264
- components: 6
2265
- },
2266
- "mat3x3<f32>": {
2267
- type: "f32",
2268
- components: 9
2269
- },
2270
- "mat3x4<f32>": {
2271
- type: "f32",
2272
- components: 12
2273
- },
2274
- "mat4x2<f32>": {
2275
- type: "f32",
2276
- components: 8
2277
- },
2278
- "mat4x3<f32>": {
2279
- type: "f32",
2280
- components: 12
2281
- },
2282
- "mat4x4<f32>": {
2283
- type: "f32",
2284
- components: 16
2285
- }
2559
+ f32: { type: "f32", components: 1 },
2560
+ i32: { type: "i32", components: 1 },
2561
+ u32: { type: "u32", components: 1 },
2562
+ // 'bool-webgl': {type: 'bool-webgl', components: 1},
2563
+ "vec2<f32>": { type: "f32", components: 2 },
2564
+ "vec3<f32>": { type: "f32", components: 3 },
2565
+ "vec4<f32>": { type: "f32", components: 4 },
2566
+ "vec2<i32>": { type: "i32", components: 2 },
2567
+ "vec3<i32>": { type: "i32", components: 3 },
2568
+ "vec4<i32>": { type: "i32", components: 4 },
2569
+ "vec2<u32>": { type: "u32", components: 2 },
2570
+ "vec3<u32>": { type: "u32", components: 3 },
2571
+ "vec4<u32>": { type: "u32", components: 4 },
2572
+ "mat2x2<f32>": { type: "f32", components: 4 },
2573
+ "mat2x3<f32>": { type: "f32", components: 6 },
2574
+ "mat2x4<f32>": { type: "f32", components: 8 },
2575
+ "mat3x2<f32>": { type: "f32", components: 6 },
2576
+ "mat3x3<f32>": { type: "f32", components: 9 },
2577
+ "mat3x4<f32>": { type: "f32", components: 12 },
2578
+ "mat4x2<f32>": { type: "f32", components: 8 },
2579
+ "mat4x3<f32>": { type: "f32", components: 12 },
2580
+ "mat4x4<f32>": { type: "f32", components: 16 }
2286
2581
  };
2287
2582
  function decodeShaderUniformType(format) {
2288
2583
  const decoded = UNIFORM_FORMATS[format];
@@ -2313,12 +2608,7 @@ ${htmlLog}
2313
2608
  return new Type(scratchArrayBuffer, 0, length);
2314
2609
  }
2315
2610
  function fillArray(options) {
2316
- const {
2317
- target,
2318
- source,
2319
- start = 0,
2320
- count = 1
2321
- } = options;
2611
+ const { target, source, start = 0, count = 1 } = options;
2322
2612
  const length = source.length;
2323
2613
  const total = count * length;
2324
2614
  let copied = 0;
@@ -2341,27 +2631,24 @@ ${htmlLog}
2341
2631
  var minBufferSize = 1024;
2342
2632
  var UniformBufferLayout = class {
2343
2633
  layout = {};
2634
+ /** number of bytes needed for buffer allocation */
2635
+ byteLength;
2636
+ /** Create a new UniformBufferLayout given a map of attributes. */
2344
2637
  constructor(uniformTypes) {
2345
2638
  let size = 0;
2346
2639
  for (const [key, uniformType] of Object.entries(uniformTypes)) {
2347
2640
  const typeAndComponents = decodeShaderUniformType(uniformType);
2348
- const {
2349
- type,
2350
- components: count
2351
- } = typeAndComponents;
2641
+ const { type, components: count } = typeAndComponents;
2352
2642
  size = alignTo(size, count);
2353
2643
  const offset = size;
2354
2644
  size += count;
2355
- this.layout[key] = {
2356
- type,
2357
- size: count,
2358
- offset
2359
- };
2645
+ this.layout[key] = { type, size: count, offset };
2360
2646
  }
2361
2647
  size += (4 - size % 4) % 4;
2362
2648
  const actualByteLength = size * 4;
2363
2649
  this.byteLength = Math.max(actualByteLength, minBufferSize);
2364
2650
  }
2651
+ /** Get the data for the complete buffer */
2365
2652
  getData(uniformValues) {
2366
2653
  const bufferSize = Math.max(this.byteLength, minBufferSize);
2367
2654
  const arrayBuffer2 = getScratchArrayBuffer(bufferSize);
@@ -2369,6 +2656,7 @@ ${htmlLog}
2369
2656
  i32: new Int32Array(arrayBuffer2),
2370
2657
  u32: new Uint32Array(arrayBuffer2),
2371
2658
  f32: new Float32Array(arrayBuffer2),
2659
+ // TODO not implemented
2372
2660
  f16: new Uint16Array(arrayBuffer2)
2373
2661
  };
2374
2662
  for (const [name2, value] of Object.entries(uniformValues)) {
@@ -2377,22 +2665,22 @@ ${htmlLog}
2377
2665
  log.warn(`Supplied uniform value ${name2} not present in uniform block layout`)();
2378
2666
  continue;
2379
2667
  }
2380
- const {
2381
- type,
2382
- size,
2383
- offset
2384
- } = uniformLayout;
2668
+ const { type, size, offset } = uniformLayout;
2385
2669
  const typedArray = typedArrays[type];
2386
2670
  if (size === 1) {
2387
2671
  if (typeof value !== "number" && typeof value !== "boolean") {
2388
- log.warn(`Supplied value for single component uniform ${name2} is not a number: ${value}`)();
2672
+ log.warn(
2673
+ `Supplied value for single component uniform ${name2} is not a number: ${value}`
2674
+ )();
2389
2675
  continue;
2390
2676
  }
2391
2677
  typedArray[offset] = Number(value);
2392
2678
  } else {
2393
2679
  const numericArray = isNumberArray(value);
2394
2680
  if (!numericArray) {
2395
- log.warn(`Supplied value for multi component / array uniform ${name2} is not a numeric array: ${value}`)();
2681
+ log.warn(
2682
+ `Supplied value for multi component / array uniform ${name2} is not a numeric array: ${value}`
2683
+ )();
2396
2684
  continue;
2397
2685
  }
2398
2686
  typedArray.set(numericArray, offset);
@@ -2400,9 +2688,11 @@ ${htmlLog}
2400
2688
  }
2401
2689
  return new Uint8Array(arrayBuffer2);
2402
2690
  }
2691
+ /** Does this layout have a field with specified name */
2403
2692
  has(name2) {
2404
2693
  return Boolean(this.layout[name2]);
2405
2694
  }
2695
+ /** Get offset and size for a field with specified name */
2406
2696
  get(name2) {
2407
2697
  const layout = this.layout[name2];
2408
2698
  return layout;
@@ -2438,6 +2728,7 @@ ${htmlLog}
2438
2728
 
2439
2729
  // src/lib/uniforms/uniform-block.ts
2440
2730
  var UniformBlock = class {
2731
+ name;
2441
2732
  uniforms = {};
2442
2733
  modifiedUniforms = {};
2443
2734
  modified = true;
@@ -2446,7 +2737,9 @@ ${htmlLog}
2446
2737
  constructor(props) {
2447
2738
  this.name = props?.name;
2448
2739
  if (props?.name && props?.shaderLayout) {
2449
- const binding = props?.shaderLayout.bindings?.find((binding2) => binding2.type === "uniform" && binding2.name === props?.name);
2740
+ const binding = props?.shaderLayout.bindings?.find(
2741
+ (binding2) => binding2.type === "uniform" && binding2.name === props?.name
2742
+ );
2450
2743
  if (!binding) {
2451
2744
  throw new Error(props?.name);
2452
2745
  }
@@ -2456,6 +2749,7 @@ ${htmlLog}
2456
2749
  }
2457
2750
  }
2458
2751
  }
2752
+ /** Set a map of uniforms */
2459
2753
  setUniforms(uniforms) {
2460
2754
  for (const [key, value] of Object.entries(uniforms)) {
2461
2755
  this._setUniform(key, value);
@@ -2467,11 +2761,13 @@ ${htmlLog}
2467
2761
  setNeedsRedraw(reason) {
2468
2762
  this.needsRedraw = this.needsRedraw || reason;
2469
2763
  }
2764
+ /** Returns all uniforms */
2470
2765
  getAllUniforms() {
2471
2766
  this.modifiedUniforms = {};
2472
2767
  this.needsRedraw = false;
2473
2768
  return this.uniforms || {};
2474
2769
  }
2770
+ /** Set a single uniform */
2475
2771
  _setUniform(key, value) {
2476
2772
  if (arrayEqual(this.uniforms[key], value)) {
2477
2773
  return;
@@ -2484,39 +2780,55 @@ ${htmlLog}
2484
2780
 
2485
2781
  // src/lib/uniforms/uniform-store.ts
2486
2782
  var UniformStore = class {
2783
+ /** Stores the uniform values for each uniform block */
2487
2784
  uniformBlocks = /* @__PURE__ */ new Map();
2785
+ /** Can generate data for a uniform buffer for each block from data */
2488
2786
  uniformBufferLayouts = /* @__PURE__ */ new Map();
2787
+ /** Actual buffer for the blocks */
2489
2788
  uniformBuffers = /* @__PURE__ */ new Map();
2789
+ /**
2790
+ * Create a new UniformStore instance
2791
+ * @param blocks
2792
+ */
2490
2793
  constructor(blocks) {
2491
2794
  for (const [bufferName, block] of Object.entries(blocks)) {
2492
2795
  const uniformBufferName = bufferName;
2493
2796
  const uniformBufferLayout = new UniformBufferLayout(block.uniformTypes || {});
2494
2797
  this.uniformBufferLayouts.set(uniformBufferName, uniformBufferLayout);
2495
- const uniformBlock = new UniformBlock({
2496
- name: bufferName
2497
- });
2798
+ const uniformBlock = new UniformBlock({ name: bufferName });
2498
2799
  uniformBlock.setUniforms(block.defaultUniforms || {});
2499
2800
  this.uniformBlocks.set(uniformBufferName, uniformBlock);
2500
2801
  }
2501
2802
  }
2803
+ /** Destroy any managed uniform buffers */
2502
2804
  destroy() {
2503
2805
  for (const uniformBuffer of Object.values(this.uniformBuffers)) {
2504
2806
  uniformBuffer.destroy();
2505
2807
  }
2506
2808
  }
2809
+ /**
2810
+ * Set uniforms
2811
+ * Makes all properties partial
2812
+ */
2507
2813
  setUniforms(uniforms) {
2508
2814
  for (const [blockName, uniformValues] of Object.entries(uniforms)) {
2509
2815
  this.uniformBlocks.get(blockName).setUniforms(uniformValues);
2510
2816
  }
2511
2817
  this.updateUniformBuffers();
2512
2818
  }
2819
+ /** Get the required minimum length of the uniform buffer */
2513
2820
  getUniformBufferByteLength(uniformBufferName) {
2514
2821
  return this.uniformBufferLayouts.get(uniformBufferName).byteLength;
2515
2822
  }
2823
+ /** Get formatted binary memory that can be uploaded to a buffer */
2516
2824
  getUniformBufferData(uniformBufferName) {
2517
2825
  const uniformValues = this.uniformBlocks.get(uniformBufferName).getAllUniforms();
2518
2826
  return this.uniformBufferLayouts.get(uniformBufferName).getData(uniformValues);
2519
2827
  }
2828
+ /**
2829
+ * Creates an unmanaged uniform buffer (umnanaged means that application is responsible for destroying it)
2830
+ * The new buffer is initialized with current / supplied values
2831
+ */
2520
2832
  createUniformBuffer(device, uniformBufferName, uniforms) {
2521
2833
  if (uniforms) {
2522
2834
  this.setUniforms(uniforms);
@@ -2530,6 +2842,7 @@ ${htmlLog}
2530
2842
  uniformBuffer.write(uniformBufferData);
2531
2843
  return uniformBuffer;
2532
2844
  }
2845
+ /** Get the managed uniform buffer. "managed" resources are destroyed when the uniformStore is destroyed. */
2533
2846
  getManagedUniformBuffer(device, uniformBufferName) {
2534
2847
  if (!this.uniformBuffers.get(uniformBufferName)) {
2535
2848
  const byteLength = this.getUniformBufferByteLength(uniformBufferName);
@@ -2541,6 +2854,7 @@ ${htmlLog}
2541
2854
  }
2542
2855
  return this.uniformBuffers.get(uniformBufferName);
2543
2856
  }
2857
+ /** Updates all uniform buffers where values have changed */
2544
2858
  updateUniformBuffers() {
2545
2859
  let reason = false;
2546
2860
  for (const uniformBufferName of this.uniformBlocks.keys()) {
@@ -2552,6 +2866,7 @@ ${htmlLog}
2552
2866
  }
2553
2867
  return reason;
2554
2868
  }
2869
+ /** Update one uniform buffer. Only updates if values have changed */
2555
2870
  updateUniformBuffer(uniformBufferName) {
2556
2871
  const uniformBlock = this.uniformBlocks.get(uniformBufferName);
2557
2872
  const uniformBuffer = this.uniformBuffers.get(uniformBufferName);
@@ -2562,112 +2877,17 @@ ${htmlLog}
2562
2877
  const uniformBuffer2 = this.uniformBuffers.get(uniformBufferName);
2563
2878
  uniformBuffer2.write(uniformBufferData);
2564
2879
  const uniformValues = this.uniformBlocks.get(uniformBufferName).getAllUniforms();
2565
- log.log(4, `Writing to uniform buffer ${String(uniformBufferName)}`, uniformBufferData, uniformValues)();
2880
+ log.log(
2881
+ 4,
2882
+ `Writing to uniform buffer ${String(uniformBufferName)}`,
2883
+ uniformBufferData,
2884
+ uniformValues
2885
+ )();
2566
2886
  }
2567
2887
  return reason;
2568
2888
  }
2569
2889
  };
2570
2890
 
2571
- // src/adapter/type-utils/decode-texture-format.ts
2572
- var REGEX = /^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;
2573
- function decodeTextureFormat(format) {
2574
- const matches = REGEX.exec(format);
2575
- if (matches) {
2576
- const [, format2, length, type, srgb, suffix] = matches;
2577
- if (format2) {
2578
- const dataType = `${type}${length}`;
2579
- const decodedType = decodeVertexType(dataType);
2580
- return {
2581
- format: format2,
2582
- components: format2.length,
2583
- srgb: srgb === "-srgb",
2584
- unsized: suffix === "-unsized",
2585
- webgl: suffix === "-webgl",
2586
- ...decodedType
2587
- };
2588
- }
2589
- }
2590
- return decodeNonStandardFormat(format);
2591
- }
2592
- var EXCEPTIONS = {
2593
- "rgba4unorm-webgl": {
2594
- format: "rgba",
2595
- bpp: 2
2596
- },
2597
- "rgb565unorm-webgl": {
2598
- format: "rgb",
2599
- bpp: 2
2600
- },
2601
- "rgb5a1unorm-webgl": {
2602
- format: "rgba",
2603
- bbp: 2
2604
- },
2605
- "rgb9e5ufloat": {
2606
- format: "rgb",
2607
- bbp: 4
2608
- },
2609
- "rg11b10ufloat": {
2610
- format: "rgb",
2611
- bbp: 4
2612
- },
2613
- "rgb10a2unorm": {
2614
- format: "rgba",
2615
- bbp: 4
2616
- },
2617
- "rgb10a2unorm-webgl": {
2618
- format: "rgba",
2619
- bbp: 4
2620
- },
2621
- "stencil8": {
2622
- components: 1,
2623
- bpp: 1,
2624
- a: "stencil"
2625
- },
2626
- "depth16unorm": {
2627
- components: 1,
2628
- bpp: 2,
2629
- a: "depth"
2630
- },
2631
- "depth24plus": {
2632
- components: 1,
2633
- bpp: 3,
2634
- a: "depth"
2635
- },
2636
- "depth32float": {
2637
- components: 1,
2638
- bpp: 4,
2639
- a: "depth"
2640
- },
2641
- "depth24plus-stencil8": {
2642
- components: 2,
2643
- bpp: 4,
2644
- a: "depth-stencil"
2645
- },
2646
- "depth24unorm-stencil8": {
2647
- components: 2,
2648
- bpp: 4,
2649
- a: "depth-stencil"
2650
- },
2651
- "depth32float-stencil8": {
2652
- components: 2,
2653
- bpp: 4,
2654
- a: "depth-stencil"
2655
- }
2656
- };
2657
- function decodeNonStandardFormat(format) {
2658
- const data = EXCEPTIONS[format];
2659
- if (!data) {
2660
- throw new Error(`Unknown format ${format}`);
2661
- }
2662
- return {
2663
- format: data.format || "",
2664
- components: data.components || data.format?.length || 1,
2665
- byteLength: data.bpp || 1,
2666
- srgb: false,
2667
- unsized: false
2668
- };
2669
- }
2670
-
2671
2891
  // src/adapter/type-utils/vertex-format-from-attribute.ts
2672
2892
  function getDataTypeFromTypedArray(arrayOrType) {
2673
2893
  const type = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;
@@ -2755,10 +2975,7 @@ ${htmlLog}
2755
2975
  return isNumberArray(value) !== null || typeof value === "number" || typeof value === "boolean";
2756
2976
  }
2757
2977
  function splitUniformsAndBindings(uniforms) {
2758
- const result = {
2759
- bindings: {},
2760
- uniforms: {}
2761
- };
2978
+ const result = { bindings: {}, uniforms: {} };
2762
2979
  Object.keys(uniforms).forEach((name2) => {
2763
2980
  const uniform = uniforms[name2];
2764
2981
  if (isUniformValue(uniform)) {
@@ -2772,10 +2989,7 @@ ${htmlLog}
2772
2989
 
2773
2990
  // src/utils/format-value.ts
2774
2991
  function formatArrayValue(v, opts = {}) {
2775
- const {
2776
- maxElts = 16,
2777
- size = 1
2778
- } = opts;
2992
+ const { maxElts = 16, size = 1 } = opts;
2779
2993
  let string = "[";
2780
2994
  for (let i = 0; i < v.length && i < maxElts; ++i) {
2781
2995
  if (i > 0) {
@@ -2788,9 +3002,7 @@ ${htmlLog}
2788
3002
  }
2789
3003
  function formatValue(v, opts = {}) {
2790
3004
  const EPSILON = 1e-16;
2791
- const {
2792
- isInteger = false
2793
- } = opts;
3005
+ const { isInteger = false } = opts;
2794
3006
  if (Array.isArray(v) || ArrayBuffer.isView(v)) {
2795
3007
  return formatArrayValue(v, opts);
2796
3008
  }
@@ -2828,11 +3040,7 @@ ${htmlLog}
2828
3040
 
2829
3041
  // src/utils/check-props.ts
2830
3042
  function checkProps(className, props, propChecks) {
2831
- const {
2832
- removedProps = {},
2833
- deprecatedProps = {},
2834
- replacedProps = {}
2835
- } = propChecks;
3043
+ const { removedProps = {}, deprecatedProps = {}, replacedProps = {} } = propChecks;
2836
3044
  for (const propName in removedProps) {
2837
3045
  if (propName in props) {
2838
3046
  const replacementProp = removedProps[propName];
@@ -2877,7 +3085,7 @@ ${htmlLog}
2877
3085
  return await createImageBitmap(image);
2878
3086
  }
2879
3087
  async function loadImage(url, opts) {
2880
- return new Promise((resolve, reject) => {
3088
+ return await new Promise((resolve, reject) => {
2881
3089
  try {
2882
3090
  const image = new Image();
2883
3091
  image.onload = () => resolve(image);