@luma.gl/core 9.2.5 → 9.3.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. package/dist/adapter/canvas-context.d.ts +6 -162
  2. package/dist/adapter/canvas-context.d.ts.map +1 -1
  3. package/dist/adapter/canvas-context.js +5 -419
  4. package/dist/adapter/canvas-context.js.map +1 -1
  5. package/dist/adapter/canvas-observer.d.ts +32 -0
  6. package/dist/adapter/canvas-observer.d.ts.map +1 -0
  7. package/dist/adapter/canvas-observer.js +90 -0
  8. package/dist/adapter/canvas-observer.js.map +1 -0
  9. package/dist/adapter/canvas-surface.d.ts +150 -0
  10. package/dist/adapter/canvas-surface.d.ts.map +1 -0
  11. package/dist/adapter/canvas-surface.js +392 -0
  12. package/dist/adapter/canvas-surface.js.map +1 -0
  13. package/dist/adapter/device.d.ts +81 -16
  14. package/dist/adapter/device.d.ts.map +1 -1
  15. package/dist/adapter/device.js +196 -10
  16. package/dist/adapter/device.js.map +1 -1
  17. package/dist/adapter/luma.js +1 -1
  18. package/dist/adapter/luma.js.map +1 -1
  19. package/dist/adapter/presentation-context.d.ts +11 -0
  20. package/dist/adapter/presentation-context.d.ts.map +1 -0
  21. package/dist/adapter/presentation-context.js +12 -0
  22. package/dist/adapter/presentation-context.js.map +1 -0
  23. package/dist/adapter/resources/buffer.d.ts +5 -5
  24. package/dist/adapter/resources/buffer.d.ts.map +1 -1
  25. package/dist/adapter/resources/buffer.js +18 -7
  26. package/dist/adapter/resources/buffer.js.map +1 -1
  27. package/dist/adapter/resources/command-buffer.d.ts +3 -1
  28. package/dist/adapter/resources/command-buffer.d.ts.map +1 -1
  29. package/dist/adapter/resources/command-buffer.js +3 -1
  30. package/dist/adapter/resources/command-buffer.js.map +1 -1
  31. package/dist/adapter/resources/command-encoder.d.ts +30 -7
  32. package/dist/adapter/resources/command-encoder.d.ts.map +1 -1
  33. package/dist/adapter/resources/command-encoder.js +68 -2
  34. package/dist/adapter/resources/command-encoder.js.map +1 -1
  35. package/dist/adapter/resources/compute-pipeline.d.ts +2 -2
  36. package/dist/adapter/resources/compute-pipeline.d.ts.map +1 -1
  37. package/dist/adapter/resources/fence.d.ts +16 -0
  38. package/dist/adapter/resources/fence.d.ts.map +1 -0
  39. package/dist/adapter/resources/fence.js +17 -0
  40. package/dist/adapter/resources/fence.js.map +1 -0
  41. package/dist/adapter/resources/framebuffer.d.ts +1 -1
  42. package/dist/adapter/resources/framebuffer.d.ts.map +1 -1
  43. package/dist/adapter/resources/framebuffer.js +15 -12
  44. package/dist/adapter/resources/framebuffer.js.map +1 -1
  45. package/dist/adapter/resources/query-set.d.ts +17 -1
  46. package/dist/adapter/resources/query-set.d.ts.map +1 -1
  47. package/dist/adapter/resources/query-set.js.map +1 -1
  48. package/dist/adapter/resources/render-pipeline.d.ts +28 -10
  49. package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
  50. package/dist/adapter/resources/render-pipeline.js +21 -2
  51. package/dist/adapter/resources/render-pipeline.js.map +1 -1
  52. package/dist/adapter/resources/resource.d.ts +13 -0
  53. package/dist/adapter/resources/resource.d.ts.map +1 -1
  54. package/dist/adapter/resources/resource.js +243 -14
  55. package/dist/adapter/resources/resource.js.map +1 -1
  56. package/dist/adapter/resources/shader.js +27 -25
  57. package/dist/adapter/resources/shader.js.map +1 -1
  58. package/dist/adapter/resources/shared-render-pipeline.d.ts +22 -0
  59. package/dist/adapter/resources/shared-render-pipeline.d.ts.map +1 -0
  60. package/dist/adapter/resources/shared-render-pipeline.js +25 -0
  61. package/dist/adapter/resources/shared-render-pipeline.js.map +1 -0
  62. package/dist/adapter/resources/texture-view.d.ts +1 -1
  63. package/dist/adapter/resources/texture-view.d.ts.map +1 -1
  64. package/dist/adapter/resources/texture.d.ts +168 -28
  65. package/dist/adapter/resources/texture.d.ts.map +1 -1
  66. package/dist/adapter/resources/texture.js +284 -25
  67. package/dist/adapter/resources/texture.js.map +1 -1
  68. package/dist/adapter/types/attachments.d.ts +1 -1
  69. package/dist/adapter/types/attachments.d.ts.map +1 -1
  70. package/dist/adapter/types/buffer-layout.d.ts +1 -1
  71. package/dist/adapter/types/buffer-layout.d.ts.map +1 -1
  72. package/dist/adapter/types/parameters.d.ts +3 -1
  73. package/dist/adapter/types/parameters.d.ts.map +1 -1
  74. package/dist/adapter/types/parameters.js +1 -0
  75. package/dist/adapter/types/parameters.js.map +1 -1
  76. package/dist/adapter/types/shader-layout.d.ts +10 -6
  77. package/dist/adapter/types/shader-layout.d.ts.map +1 -1
  78. package/dist/adapter/types/uniforms.d.ts +6 -0
  79. package/dist/adapter/types/uniforms.d.ts.map +1 -1
  80. package/dist/adapter-utils/bind-groups.d.ts +9 -0
  81. package/dist/adapter-utils/bind-groups.d.ts.map +1 -0
  82. package/dist/adapter-utils/bind-groups.js +41 -0
  83. package/dist/adapter-utils/bind-groups.js.map +1 -0
  84. package/dist/adapter-utils/format-compiler-log.d.ts.map +1 -1
  85. package/dist/adapter-utils/format-compiler-log.js +23 -15
  86. package/dist/adapter-utils/format-compiler-log.js.map +1 -1
  87. package/dist/adapter-utils/get-attribute-from-layouts.d.ts +2 -2
  88. package/dist/adapter-utils/get-attribute-from-layouts.d.ts.map +1 -1
  89. package/dist/adapter-utils/get-attribute-from-layouts.js +6 -6
  90. package/dist/adapter-utils/get-attribute-from-layouts.js.map +1 -1
  91. package/dist/dist.dev.js +2692 -645
  92. package/dist/dist.min.js +10 -9
  93. package/dist/factories/bind-group-factory.d.ts +20 -0
  94. package/dist/factories/bind-group-factory.d.ts.map +1 -0
  95. package/dist/factories/bind-group-factory.js +79 -0
  96. package/dist/factories/bind-group-factory.js.map +1 -0
  97. package/dist/factories/core-module-state.d.ts +7 -0
  98. package/dist/factories/core-module-state.d.ts.map +1 -0
  99. package/dist/{shadertypes/data-types/shader-types.js → factories/core-module-state.js} +1 -1
  100. package/dist/factories/core-module-state.js.map +1 -0
  101. package/dist/factories/pipeline-factory.d.ts +54 -0
  102. package/dist/factories/pipeline-factory.d.ts.map +1 -0
  103. package/dist/factories/pipeline-factory.js +270 -0
  104. package/dist/factories/pipeline-factory.js.map +1 -0
  105. package/dist/factories/shader-factory.d.ts +20 -0
  106. package/dist/factories/shader-factory.d.ts.map +1 -0
  107. package/dist/factories/shader-factory.js +84 -0
  108. package/dist/factories/shader-factory.js.map +1 -0
  109. package/dist/index.cjs +2427 -554
  110. package/dist/index.cjs.map +4 -4
  111. package/dist/index.d.ts +30 -14
  112. package/dist/index.d.ts.map +1 -1
  113. package/dist/index.js +19 -7
  114. package/dist/index.js.map +1 -1
  115. package/dist/portable/shader-block-writer.d.ts +51 -0
  116. package/dist/portable/shader-block-writer.d.ts.map +1 -0
  117. package/dist/portable/shader-block-writer.js +185 -0
  118. package/dist/portable/shader-block-writer.js.map +1 -0
  119. package/dist/portable/uniform-block.d.ts +1 -1
  120. package/dist/portable/uniform-block.d.ts.map +1 -1
  121. package/dist/portable/uniform-store.d.ts +55 -24
  122. package/dist/portable/uniform-store.d.ts.map +1 -1
  123. package/dist/portable/uniform-store.js +73 -25
  124. package/dist/portable/uniform-store.js.map +1 -1
  125. package/dist/shadertypes/data-types/data-type-decoder.d.ts +20 -0
  126. package/dist/shadertypes/data-types/data-type-decoder.d.ts.map +1 -0
  127. package/dist/shadertypes/data-types/data-type-decoder.js +79 -0
  128. package/dist/shadertypes/data-types/data-type-decoder.js.map +1 -0
  129. package/dist/shadertypes/data-types/data-types.d.ts +31 -12
  130. package/dist/shadertypes/data-types/data-types.d.ts.map +1 -1
  131. package/dist/shadertypes/data-types/decode-data-types.d.ts.map +1 -1
  132. package/dist/shadertypes/data-types/decode-data-types.js +2 -1
  133. package/dist/shadertypes/data-types/decode-data-types.js.map +1 -1
  134. package/dist/{image-utils → shadertypes/image-types}/image-types.d.ts +0 -6
  135. package/dist/shadertypes/image-types/image-types.d.ts.map +1 -0
  136. package/dist/shadertypes/image-types/image-types.js.map +1 -0
  137. package/dist/shadertypes/shader-types/shader-block-layout.d.ts +72 -0
  138. package/dist/shadertypes/shader-types/shader-block-layout.d.ts.map +1 -0
  139. package/dist/shadertypes/shader-types/shader-block-layout.js +209 -0
  140. package/dist/shadertypes/shader-types/shader-block-layout.js.map +1 -0
  141. package/dist/shadertypes/shader-types/shader-type-decoder.d.ts +41 -0
  142. package/dist/shadertypes/shader-types/shader-type-decoder.d.ts.map +1 -0
  143. package/dist/shadertypes/{data-types/decode-shader-types.js → shader-types/shader-type-decoder.js} +43 -4
  144. package/dist/shadertypes/shader-types/shader-type-decoder.js.map +1 -0
  145. package/dist/shadertypes/shader-types/shader-types.d.ts +101 -0
  146. package/dist/shadertypes/shader-types/shader-types.d.ts.map +1 -0
  147. package/dist/shadertypes/shader-types/shader-types.js +30 -0
  148. package/dist/shadertypes/shader-types/shader-types.js.map +1 -0
  149. package/dist/shadertypes/texture-types/pixel-utils.d.ts.map +1 -0
  150. package/dist/shadertypes/{textures → texture-types}/pixel-utils.js +4 -4
  151. package/dist/shadertypes/texture-types/pixel-utils.js.map +1 -0
  152. package/dist/shadertypes/texture-types/texture-format-decoder.d.ts +36 -0
  153. package/dist/shadertypes/texture-types/texture-format-decoder.d.ts.map +1 -0
  154. package/dist/shadertypes/{textures → texture-types}/texture-format-decoder.js +109 -37
  155. package/dist/shadertypes/texture-types/texture-format-decoder.js.map +1 -0
  156. package/dist/shadertypes/texture-types/texture-format-generics.d.ts +34 -0
  157. package/dist/shadertypes/texture-types/texture-format-generics.d.ts.map +1 -0
  158. package/dist/shadertypes/texture-types/texture-format-generics.js.map +1 -0
  159. package/dist/shadertypes/texture-types/texture-format-table.d.ts.map +1 -0
  160. package/dist/shadertypes/{textures → texture-types}/texture-format-table.js +10 -9
  161. package/dist/shadertypes/texture-types/texture-format-table.js.map +1 -0
  162. package/dist/shadertypes/{textures → texture-types}/texture-formats.d.ts +51 -17
  163. package/dist/shadertypes/texture-types/texture-formats.d.ts.map +1 -0
  164. package/dist/shadertypes/{textures → texture-types}/texture-formats.js +1 -0
  165. package/dist/shadertypes/texture-types/texture-formats.js.map +1 -0
  166. package/dist/shadertypes/texture-types/texture-layout.d.ts +5 -0
  167. package/dist/shadertypes/texture-types/texture-layout.d.ts.map +1 -0
  168. package/dist/shadertypes/texture-types/texture-layout.js +41 -0
  169. package/dist/shadertypes/texture-types/texture-layout.js.map +1 -0
  170. package/dist/shadertypes/vertex-types/vertex-format-decoder.d.ts +24 -0
  171. package/dist/shadertypes/vertex-types/vertex-format-decoder.d.ts.map +1 -0
  172. package/dist/shadertypes/vertex-types/vertex-format-decoder.js +106 -0
  173. package/dist/shadertypes/vertex-types/vertex-format-decoder.js.map +1 -0
  174. package/dist/shadertypes/vertex-types/vertex-formats.d.ts +50 -0
  175. package/dist/shadertypes/vertex-types/vertex-formats.d.ts.map +1 -0
  176. package/dist/shadertypes/vertex-types/vertex-formats.js.map +1 -0
  177. package/dist/utils/array-equal.d.ts +1 -1
  178. package/dist/utils/array-equal.d.ts.map +1 -1
  179. package/dist/utils/array-equal.js +15 -9
  180. package/dist/utils/array-equal.js.map +1 -1
  181. package/dist/utils/assert.d.ts +5 -0
  182. package/dist/utils/assert.d.ts.map +1 -0
  183. package/dist/utils/assert.js +17 -0
  184. package/dist/utils/assert.js.map +1 -0
  185. package/dist/utils/stats-manager.d.ts.map +1 -1
  186. package/dist/utils/stats-manager.js +61 -1
  187. package/dist/utils/stats-manager.js.map +1 -1
  188. package/package.json +6 -6
  189. package/src/adapter/canvas-context.ts +7 -556
  190. package/src/adapter/canvas-observer.ts +130 -0
  191. package/src/adapter/canvas-surface.ts +521 -0
  192. package/src/adapter/device.ts +312 -24
  193. package/src/adapter/presentation-context.ts +16 -0
  194. package/src/adapter/resources/buffer.ts +19 -9
  195. package/src/adapter/resources/command-buffer.ts +4 -2
  196. package/src/adapter/resources/command-encoder.ts +101 -10
  197. package/src/adapter/resources/compute-pipeline.ts +2 -2
  198. package/src/adapter/resources/fence.ts +32 -0
  199. package/src/adapter/resources/framebuffer.ts +16 -13
  200. package/src/adapter/resources/query-set.ts +17 -1
  201. package/src/adapter/resources/render-pipeline.ts +52 -16
  202. package/src/adapter/resources/resource.ts +289 -14
  203. package/src/adapter/resources/shader.ts +28 -28
  204. package/src/adapter/resources/shared-render-pipeline.ts +40 -0
  205. package/src/adapter/resources/texture-view.ts +1 -1
  206. package/src/adapter/resources/texture.ts +427 -49
  207. package/src/adapter/types/attachments.ts +1 -1
  208. package/src/adapter/types/buffer-layout.ts +1 -1
  209. package/src/adapter/types/parameters.ts +4 -1
  210. package/src/adapter/types/shader-layout.ts +15 -9
  211. package/src/adapter/types/uniforms.ts +12 -0
  212. package/src/adapter-utils/bind-groups.ts +71 -0
  213. package/src/adapter-utils/format-compiler-log.ts +23 -15
  214. package/src/adapter-utils/get-attribute-from-layouts.ts +8 -11
  215. package/src/factories/bind-group-factory.ts +139 -0
  216. package/src/factories/core-module-state.ts +11 -0
  217. package/src/factories/pipeline-factory.ts +328 -0
  218. package/src/factories/shader-factory.ts +103 -0
  219. package/src/index.ts +70 -26
  220. package/src/portable/shader-block-writer.ts +254 -0
  221. package/src/portable/uniform-block.ts +1 -1
  222. package/src/portable/uniform-store.ts +98 -40
  223. package/src/shadertypes/data-types/data-type-decoder.ts +105 -0
  224. package/src/shadertypes/data-types/data-types.ts +100 -48
  225. package/src/shadertypes/data-types/decode-data-types.ts +2 -1
  226. package/src/{image-utils → shadertypes/image-types}/image-types.ts +0 -7
  227. package/src/shadertypes/shader-types/shader-block-layout.ts +340 -0
  228. package/src/shadertypes/{data-types/decode-shader-types.ts → shader-types/shader-type-decoder.ts} +88 -14
  229. package/src/shadertypes/shader-types/shader-types.ts +207 -0
  230. package/src/shadertypes/{textures → texture-types}/pixel-utils.ts +4 -4
  231. package/src/shadertypes/{textures → texture-types}/texture-format-decoder.ts +166 -45
  232. package/src/shadertypes/{textures → texture-types}/texture-format-generics.ts +42 -48
  233. package/src/shadertypes/{textures → texture-types}/texture-format-table.ts +10 -9
  234. package/src/shadertypes/{textures → texture-types}/texture-formats.ts +73 -17
  235. package/src/shadertypes/texture-types/texture-layout.ts +60 -0
  236. package/src/shadertypes/vertex-types/vertex-format-decoder.ts +131 -0
  237. package/src/shadertypes/vertex-types/vertex-formats.ts +183 -0
  238. package/src/utils/array-equal.ts +21 -9
  239. package/src/utils/assert.ts +18 -0
  240. package/src/utils/stats-manager.ts +76 -2
  241. package/dist/image-utils/image-types.d.ts.map +0 -1
  242. package/dist/image-utils/image-types.js.map +0 -1
  243. package/dist/portable/uniform-buffer-layout.d.ts +0 -28
  244. package/dist/portable/uniform-buffer-layout.d.ts.map +0 -1
  245. package/dist/portable/uniform-buffer-layout.js +0 -96
  246. package/dist/portable/uniform-buffer-layout.js.map +0 -1
  247. package/dist/shadertypes/data-types/decode-shader-types.d.ts +0 -17
  248. package/dist/shadertypes/data-types/decode-shader-types.d.ts.map +0 -1
  249. package/dist/shadertypes/data-types/decode-shader-types.js.map +0 -1
  250. package/dist/shadertypes/data-types/shader-types.d.ts +0 -45
  251. package/dist/shadertypes/data-types/shader-types.d.ts.map +0 -1
  252. package/dist/shadertypes/data-types/shader-types.js.map +0 -1
  253. package/dist/shadertypes/textures/pixel-utils.d.ts.map +0 -1
  254. package/dist/shadertypes/textures/pixel-utils.js.map +0 -1
  255. package/dist/shadertypes/textures/texture-format-decoder.d.ts +0 -18
  256. package/dist/shadertypes/textures/texture-format-decoder.d.ts.map +0 -1
  257. package/dist/shadertypes/textures/texture-format-decoder.js.map +0 -1
  258. package/dist/shadertypes/textures/texture-format-generics.d.ts +0 -33
  259. package/dist/shadertypes/textures/texture-format-generics.d.ts.map +0 -1
  260. package/dist/shadertypes/textures/texture-format-generics.js.map +0 -1
  261. package/dist/shadertypes/textures/texture-format-table.d.ts.map +0 -1
  262. package/dist/shadertypes/textures/texture-format-table.js.map +0 -1
  263. package/dist/shadertypes/textures/texture-formats.d.ts.map +0 -1
  264. package/dist/shadertypes/textures/texture-formats.js.map +0 -1
  265. package/dist/shadertypes/vertex-arrays/decode-vertex-format.d.ts +0 -18
  266. package/dist/shadertypes/vertex-arrays/decode-vertex-format.d.ts.map +0 -1
  267. package/dist/shadertypes/vertex-arrays/decode-vertex-format.js +0 -100
  268. package/dist/shadertypes/vertex-arrays/decode-vertex-format.js.map +0 -1
  269. package/dist/shadertypes/vertex-arrays/vertex-formats.d.ts +0 -27
  270. package/dist/shadertypes/vertex-arrays/vertex-formats.d.ts.map +0 -1
  271. package/dist/shadertypes/vertex-arrays/vertex-formats.js.map +0 -1
  272. package/src/portable/uniform-buffer-layout.ts +0 -118
  273. package/src/shadertypes/data-types/shader-types.ts +0 -87
  274. package/src/shadertypes/vertex-arrays/decode-vertex-format.ts +0 -124
  275. package/src/shadertypes/vertex-arrays/vertex-formats.ts +0 -91
  276. /package/dist/{image-utils → shadertypes/image-types}/image-types.js +0 -0
  277. /package/dist/shadertypes/{textures → texture-types}/pixel-utils.d.ts +0 -0
  278. /package/dist/shadertypes/{textures → texture-types}/texture-format-generics.js +0 -0
  279. /package/dist/shadertypes/{textures → texture-types}/texture-format-table.d.ts +0 -0
  280. /package/dist/shadertypes/{vertex-arrays → vertex-types}/vertex-formats.js +0 -0
@@ -2,14 +2,20 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {TypedArray} from '@math.gl/types';
6
- import type {Device} from '../device';
7
- import type {TextureFormat} from '../../shadertypes/textures/texture-formats';
8
- import type {TextureView, TextureViewProps} from './texture-view';
9
- import {Resource, ResourceProps} from './resource';
10
- import {Sampler, SamplerProps} from './sampler';
11
- import {ExternalImage} from '../../image-utils/image-types';
5
+ import {type TypedArray} from '@math.gl/types';
6
+ import {type Device} from '../device';
7
+ import {
8
+ type TextureFormat,
9
+ type TextureMemoryLayout,
10
+ type TextureFormatInfo
11
+ } from '../../shadertypes/texture-types/texture-formats';
12
+ import {type ExternalImage} from '../../shadertypes/image-types/image-types';
13
+ import {type TextureView, type TextureViewProps} from './texture-view';
14
+ import {Resource, type ResourceProps} from './resource';
15
+ import {Sampler, type SamplerProps} from './sampler';
16
+ import {Buffer} from './buffer';
12
17
  import {log} from '../../utils/log';
18
+ import {textureFormatDecoder} from '../../shadertypes/texture-types/texture-format-decoder';
13
19
 
14
20
  /** Options for Texture.copyExternalImage */
15
21
  export type CopyExternalImageOptions = {
@@ -49,10 +55,18 @@ export type CopyImageDataOptions = {
49
55
  data: ArrayBuffer | SharedArrayBuffer | ArrayBufferView;
50
56
  /** Offset into the data (in addition to any offset built-in to the ArrayBufferView) */
51
57
  byteOffset?: number;
52
- /** The stride, in bytes, between the beginning of each texel block row and the subsequent texel block row. Required if there are multiple texel block rows (i.e. the copy height or depth is more than one block). */
58
+ /** The stride, in bytes, between successive texel rows in the CPU source data. Tightly packed uploads can omit this. */
53
59
  bytesPerRow?: number;
54
- /** Number or rows per image (needed if multiple images are being set) */
60
+ /** Number of rows that make up one image when uploading multiple layers or depth slices from CPU memory. */
55
61
  rowsPerImage?: number;
62
+ /** Width to copy */
63
+ width?: number;
64
+ /** Height to copy */
65
+ height?: number;
66
+ /** Copy depth or number of layers */
67
+ depthOrArrayLayers?: number;
68
+ /** @deprecated Use `depthOrArrayLayers` */
69
+ depth?: number;
56
70
  /** Start copying into offset x (default 0) */
57
71
  x?: number;
58
72
  /** Start copying into offset y (default 0) */
@@ -65,18 +79,62 @@ export type CopyImageDataOptions = {
65
79
  aspect?: 'all' | 'stencil-only' | 'depth-only';
66
80
  };
67
81
 
68
- const BASE_DIMENSIONS: Record<string, '1d' | '2d' | '3d'> = {
82
+ export type TextureReadOptions = {
83
+ /** Start reading from offset x (default 0) */
84
+ x?: number;
85
+ /** Start reading from offset y (default 0) */
86
+ y?: number;
87
+ /** Start reading from layer / depth slice z (default 0) */
88
+ z?: number;
89
+ /** Width of the region to read. Defaults to the mip width. */
90
+ width?: number;
91
+ /** Height of the region to read. Defaults to the mip height. */
92
+ height?: number;
93
+ /** Number of array layers or depth slices to read. Defaults to 1. */
94
+ depthOrArrayLayers?: number;
95
+ /** Which mip-level to read from (default 0) */
96
+ mipLevel?: number;
97
+ /** When reading from depth stencil textures (default 'all') */
98
+ aspect?: 'all' | 'stencil-only' | 'depth-only';
99
+ };
100
+
101
+ export type TextureWriteOptions = {
102
+ /** Offset into the source data or buffer, in bytes. */
103
+ byteOffset?: number;
104
+ /** The stride, in bytes, between successive texel rows in the source data or buffer. */
105
+ bytesPerRow?: number;
106
+ /** The number of rows that make up one image when writing multiple layers or slices. */
107
+ rowsPerImage?: number;
108
+ /** Start writing into offset x (default 0) */
109
+ x?: number;
110
+ /** Start writing into offset y (default 0) */
111
+ y?: number;
112
+ /** Start writing into layer / depth slice z (default 0) */
113
+ z?: number;
114
+ /** Width of the region to write. Defaults to the mip width. */
115
+ width?: number;
116
+ /** Height of the region to write. Defaults to the mip height. */
117
+ height?: number;
118
+ /** Number of array layers or depth slices to write. Defaults to 1, or the full mip depth for 3D textures. */
119
+ depthOrArrayLayers?: number;
120
+ /** Which mip-level to write into (default 0) */
121
+ mipLevel?: number;
122
+ /** When writing into depth stencil textures (default 'all') */
123
+ aspect?: 'all' | 'stencil-only' | 'depth-only';
124
+ };
125
+
126
+ const BASE_DIMENSIONS = {
69
127
  '1d': '1d',
70
128
  '2d': '2d',
71
129
  '2d-array': '2d',
72
130
  cube: '2d',
73
131
  'cube-array': '2d',
74
132
  '3d': '3d'
75
- };
133
+ } as const satisfies Record<string, '1d' | '2d' | '3d'>;
76
134
 
77
135
  /** Texture properties */
78
136
  export type TextureProps = ResourceProps & {
79
- /** @deprecated Use AsyncTexture to create textures with data. */
137
+ /** @deprecated Use DynamicTexture to create textures with data. */
80
138
  data?: ExternalImage | TypedArray | null;
81
139
  /** Dimension of this texture. Defaults to '2d' */
82
140
  dimension?: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';
@@ -130,19 +188,28 @@ export abstract class Texture extends Resource<TextureProps> {
130
188
  /** format of this texture */
131
189
  readonly format: TextureFormat;
132
190
  /** width in pixels of this texture */
133
- width: number;
191
+ readonly width: number;
134
192
  /** height in pixels of this texture */
135
- height: number;
193
+ readonly height: number;
136
194
  /** depth of this texture */
137
- depth: number;
195
+ readonly depth: number;
138
196
  /** mip levels in this texture */
139
- mipLevels: number;
197
+ readonly mipLevels: number;
198
+ /** sample count */
199
+ readonly samples: number;
200
+ /** Rows are multiples of this length, padded with extra bytes if needed */
201
+ readonly byteAlignment: number;
140
202
  /** Default sampler for this texture */
141
203
  abstract sampler: Sampler;
142
204
  /** Default view for this texture */
143
205
  abstract view: TextureView;
144
206
 
145
- /** "Time" of last update. Monotonically increasing timestamp. TODO move to AsyncTexture? */
207
+ /** The ready promise is always resolved. It is provided for type compatibility with DynamicTexture. */
208
+ readonly ready: Promise<Texture> = Promise.resolve(this);
209
+ /** isReady is always true. It is provided for type compatibility with DynamicTexture. */
210
+ readonly isReady: boolean = true;
211
+
212
+ /** "Time" of last update. Monotonically increasing timestamp. TODO move to DynamicTexture? */
146
213
  updateTimestamp: number;
147
214
 
148
215
  override get [Symbol.toStringTag](): string {
@@ -154,7 +221,7 @@ export abstract class Texture extends Resource<TextureProps> {
154
221
  }
155
222
 
156
223
  /** Do not use directly. Create with device.createTexture() */
157
- constructor(device: Device, props: TextureProps) {
224
+ constructor(device: Device, props: TextureProps, backendProps?: {byteAlignment?: number}) {
158
225
  props = Texture.normalizeProps(device, props);
159
226
  super(device, props, Texture.defaultProps);
160
227
  this.dimension = this.props.dimension;
@@ -166,6 +233,11 @@ export abstract class Texture extends Resource<TextureProps> {
166
233
  this.height = this.props.height;
167
234
  this.depth = this.props.depth;
168
235
  this.mipLevels = this.props.mipLevels;
236
+ this.samples = this.props.samples || 1;
237
+
238
+ if (this.dimension === 'cube') {
239
+ this.depth = 6;
240
+ }
169
241
 
170
242
  // Calculate size, if not provided
171
243
  if (this.props.width === undefined || this.props.height === undefined) {
@@ -178,38 +250,149 @@ export abstract class Texture extends Resource<TextureProps> {
178
250
  this.height = 1;
179
251
  if (this.props.width === undefined || this.props.height === undefined) {
180
252
  log.warn(
181
- `${this} created with undefined width or height. This is deprecated. Use AsyncTexture instead.`
253
+ `${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`
182
254
  )();
183
255
  }
184
256
  }
185
257
  }
186
258
 
259
+ this.byteAlignment = backendProps?.byteAlignment || 1;
260
+
187
261
  // TODO - perhaps this should be set on async write completion?
188
262
  this.updateTimestamp = device.incrementTimestamp();
189
263
  }
190
264
 
265
+ /**
266
+ * Create a new texture with the same parameters and optionally a different size
267
+ * @note Textures are immutable and cannot be resized after creation, but we can create a similar texture with the same parameters but a new size.
268
+ * @note Does not copy contents of the texture
269
+ */
270
+ clone(size?: {width: number; height: number}): Texture {
271
+ return this.device.createTexture({...this.props, ...size});
272
+ }
273
+
191
274
  /** Set sampler props associated with this texture */
192
275
  setSampler(sampler: Sampler | SamplerProps): void {
193
276
  this.sampler = sampler instanceof Sampler ? sampler : this.device.createSampler(sampler);
194
277
  }
278
+
195
279
  /** Create a texture view for this texture */
196
280
  abstract createView(props: TextureViewProps): TextureView;
281
+
197
282
  /** Copy an image (e.g an ImageBitmap) into the texture */
198
283
  abstract copyExternalImage(options: CopyExternalImageOptions): {width: number; height: number};
199
- /** Copy raw image data (bytes) into the texture */
200
- abstract copyImageData(options: CopyImageDataOptions): void;
201
- /** Generate mipmaps (WebGL only) */
202
- abstract generateMipmapsWebGL(): void;
203
284
 
204
285
  /**
205
- * Create a new texture with the same parameters and optionally a different size
206
- * @note Textures are immutable and cannot be resized after creation, but we can create a similar texture with the same parameters but a new size.
207
- * @note Does not copy contents of the texture
286
+ * Copy raw image data (bytes) into the texture.
287
+ *
288
+ * @note Deprecated compatibility wrapper over {@link writeData}.
289
+ * @note Uses the same layout defaults and alignment rules as {@link writeData}.
290
+ * @note Tightly packed CPU uploads can omit `bytesPerRow` and `rowsPerImage`.
291
+ * @note If the CPU source rows are padded, pass explicit `bytesPerRow` and `rowsPerImage`.
292
+ * @deprecated Use writeData()
208
293
  */
209
- clone(size?: {width: number; height: number}): Texture {
210
- return this.device.createTexture({...this.props, ...size});
294
+ copyImageData(options: CopyImageDataOptions): void {
295
+ const {data, depth, ...writeOptions} = options;
296
+ this.writeData(data, {
297
+ ...writeOptions,
298
+ depthOrArrayLayers: writeOptions.depthOrArrayLayers ?? depth
299
+ });
300
+ }
301
+
302
+ /**
303
+ * Calculates the memory layout of the texture, required when reading and writing data.
304
+ * @return the backend-aligned linear layout, in particular bytesPerRow which includes any required padding for buffer copy/read paths
305
+ */
306
+ computeMemoryLayout(options_: TextureReadOptions = {}): TextureMemoryLayout {
307
+ const options = this._normalizeTextureReadOptions(options_);
308
+ const {width = this.width, height = this.height, depthOrArrayLayers = this.depth} = options;
309
+ const {format, byteAlignment} = this;
310
+
311
+ // TODO - does the overriding above make sense?
312
+ // return textureFormatDecoder.computeMemoryLayout(this);
313
+ return textureFormatDecoder.computeMemoryLayout({
314
+ format,
315
+ width,
316
+ height,
317
+ depth: depthOrArrayLayers,
318
+ byteAlignment
319
+ });
320
+ }
321
+
322
+ /**
323
+ * Read the contents of a texture into a GPU Buffer.
324
+ * @returns A Buffer containing the texture data.
325
+ *
326
+ * @note The memory layout of the texture data is determined by the texture format and dimensions.
327
+ * @note The application can call Texture.computeMemoryLayout() to compute the backend-aligned layout.
328
+ * @note The application can call Buffer.readAsync() to read the returned buffer on the CPU.
329
+ * @note The destination buffer must be supplied by the caller and must be large enough for the requested region.
330
+ * @note On WebGPU this corresponds to a texture-to-buffer copy and uses buffer-copy alignment rules.
331
+ * @note On WebGL, luma.gl emulates the same logical readback behavior.
332
+ */
333
+ readBuffer(options?: TextureReadOptions, buffer?: Buffer): Buffer {
334
+ throw new Error('readBuffer not implemented');
211
335
  }
212
336
 
337
+ /**
338
+ * Reads data from a texture into an ArrayBuffer.
339
+ * @returns An ArrayBuffer containing the texture data.
340
+ *
341
+ * @note The memory layout of the texture data is determined by the texture format and dimensions.
342
+ * @note The application can call Texture.computeMemoryLayout() to compute the layout.
343
+ * @deprecated Use Texture.readBuffer() with an explicit destination buffer, or DynamicTexture.readAsync() for convenience readback.
344
+ */
345
+ readDataAsync(options?: TextureReadOptions): Promise<ArrayBuffer> {
346
+ throw new Error('readBuffer not implemented');
347
+ }
348
+
349
+ /**
350
+ * Writes a GPU Buffer into a texture.
351
+ *
352
+ * @param buffer - Source GPU buffer.
353
+ * @param options - Destination subresource, extent, and source layout options.
354
+ * @note The memory layout of the texture data is determined by the texture format and dimensions.
355
+ * @note The application can call Texture.computeMemoryLayout() to compute the backend-aligned layout.
356
+ * @note On WebGPU this corresponds to a buffer-to-texture copy and uses buffer-copy alignment rules.
357
+ * @note On WebGL, luma.gl emulates the same destination and layout semantics.
358
+ */
359
+ writeBuffer(buffer: Buffer, options?: TextureWriteOptions): void {
360
+ throw new Error('readBuffer not implemented');
361
+ }
362
+
363
+ /**
364
+ * Writes an array buffer into a texture.
365
+ *
366
+ * @param data - Source texel data.
367
+ * @param options - Destination subresource, extent, and source layout options.
368
+ * @note If `bytesPerRow` and `rowsPerImage` are omitted, luma.gl computes a tightly packed CPU-memory layout for the requested region.
369
+ * @note On WebGPU this corresponds to `GPUQueue.writeTexture()` and does not implicitly pad rows to 256 bytes.
370
+ * @note On WebGL, padded CPU data is supported via the same `bytesPerRow` and `rowsPerImage` options.
371
+ */
372
+ writeData(
373
+ data: ArrayBuffer | SharedArrayBuffer | ArrayBufferView,
374
+ options?: TextureWriteOptions
375
+ ): void {
376
+ throw new Error('readBuffer not implemented');
377
+ }
378
+
379
+ // IMPLEMENTATION SPECIFIC
380
+
381
+ /**
382
+ * WebGL can read data synchronously.
383
+ * @note While it is convenient, the performance penalty is very significant
384
+ */
385
+ readDataSyncWebGL(options?: TextureReadOptions): ArrayBuffer | ArrayBufferView {
386
+ throw new Error('readDataSyncWebGL not available');
387
+ }
388
+
389
+ /** Generate mipmaps (WebGL only) */
390
+ generateMipmapsWebGL(): void {
391
+ throw new Error('generateMipmapsWebGL not available');
392
+ }
393
+
394
+ // HELPERS
395
+
213
396
  /** Ensure we have integer coordinates */
214
397
  protected static normalizeProps(device: Device, props: TextureProps): TextureProps {
215
398
  const newProps = {...props};
@@ -225,8 +408,6 @@ export abstract class Texture extends Resource<TextureProps> {
225
408
  return newProps;
226
409
  }
227
410
 
228
- // HELPERS
229
-
230
411
  /** Initialize texture with supplied props */
231
412
  // eslint-disable-next-line max-statements
232
413
  _initializeData(data: TextureProps['data']): void {
@@ -263,40 +444,208 @@ export abstract class Texture extends Resource<TextureProps> {
263
444
  }
264
445
 
265
446
  _normalizeCopyImageDataOptions(options_: CopyImageDataOptions): Required<CopyImageDataOptions> {
266
- const {width, height, depth} = this;
267
- const options = {...Texture.defaultCopyDataOptions, width, height, depth, ...options_};
268
-
269
- const info = this.device.getTextureFormatInfo(this.format);
270
- if (!options_.bytesPerRow && !info.bytesPerPixel) {
271
- throw new Error(`bytesPerRow must be provided for texture format ${this.format}`);
272
- }
273
- options.bytesPerRow = options_.bytesPerRow || width * (info.bytesPerPixel || 4);
274
- options.rowsPerImage = options_.rowsPerImage || height;
275
-
276
- // WebGL will error if we try to copy outside the bounds of the texture
277
- // options.width = Math.min(options.width, this.width - options.x);
278
- // options.height = Math.min(options.height, this.height - options.y);
279
- return options;
447
+ const {data, depth, ...writeOptions} = options_;
448
+ const options = this._normalizeTextureWriteOptions({
449
+ ...writeOptions,
450
+ depthOrArrayLayers: writeOptions.depthOrArrayLayers ?? depth
451
+ });
452
+ return {data, depth: options.depthOrArrayLayers, ...options};
280
453
  }
281
454
 
282
455
  _normalizeCopyExternalImageOptions(
283
456
  options_: CopyExternalImageOptions
284
457
  ): Required<CopyExternalImageOptions> {
458
+ const optionsWithoutUndefined = Texture._omitUndefined(options_);
459
+ const mipLevel = optionsWithoutUndefined.mipLevel ?? 0;
460
+ const mipLevelSize = this._getMipLevelSize(mipLevel);
285
461
  const size = this.device.getExternalImageSize(options_.image);
286
- const options = {...Texture.defaultCopyExternalImageOptions, ...size, ...options_};
462
+ const options = {
463
+ ...Texture.defaultCopyExternalImageOptions,
464
+ ...mipLevelSize,
465
+ ...size,
466
+ ...optionsWithoutUndefined
467
+ };
287
468
  // WebGL will error if we try to copy outside the bounds of the texture
288
- options.width = Math.min(options.width, this.width - options.x);
289
- options.height = Math.min(options.height, this.height - options.y);
469
+ options.width = Math.min(options.width, mipLevelSize.width - options.x);
470
+ options.height = Math.min(options.height, mipLevelSize.height - options.y);
471
+ options.depth = Math.min(options.depth, mipLevelSize.depthOrArrayLayers - options.z);
290
472
  return options;
291
473
  }
292
474
 
293
- /** Default options */
475
+ _normalizeTextureReadOptions(options_: TextureReadOptions): Required<TextureReadOptions> {
476
+ const optionsWithoutUndefined = Texture._omitUndefined(options_);
477
+ const mipLevel = optionsWithoutUndefined.mipLevel ?? 0;
478
+ const mipLevelSize = this._getMipLevelSize(mipLevel);
479
+ const options = {
480
+ ...Texture.defaultTextureReadOptions,
481
+ ...mipLevelSize,
482
+ ...optionsWithoutUndefined
483
+ };
484
+ // WebGL will error if we try to copy outside the bounds of the texture
485
+ options.width = Math.min(options.width, mipLevelSize.width - options.x);
486
+ options.height = Math.min(options.height, mipLevelSize.height - options.y);
487
+ options.depthOrArrayLayers = Math.min(
488
+ options.depthOrArrayLayers,
489
+ mipLevelSize.depthOrArrayLayers - options.z
490
+ );
491
+ return options;
492
+ }
493
+
494
+ /**
495
+ * Normalizes a texture read request and validates the color-only readback contract used by the
496
+ * current texture read APIs. Supported dimensions are `2d`, `cube`, `cube-array`,
497
+ * `2d-array`, and `3d`.
498
+ *
499
+ * @throws if the texture format, aspect, or dimension is not supported by the first-pass
500
+ * color-read implementation.
501
+ */
502
+ protected _getSupportedColorReadOptions(
503
+ options_: TextureReadOptions
504
+ ): Required<TextureReadOptions> {
505
+ const options = this._normalizeTextureReadOptions(options_);
506
+ const formatInfo = textureFormatDecoder.getInfo(this.format);
507
+
508
+ this._validateColorReadAspect(options);
509
+ this._validateColorReadFormat(formatInfo);
510
+
511
+ switch (this.dimension) {
512
+ case '2d':
513
+ case 'cube':
514
+ case 'cube-array':
515
+ case '2d-array':
516
+ case '3d':
517
+ return options;
518
+
519
+ default:
520
+ throw new Error(`${this} color readback does not support ${this.dimension} textures`);
521
+ }
522
+ }
523
+
524
+ /** Validates that a read request targets the full color aspect of the texture. */
525
+ protected _validateColorReadAspect(options: Required<TextureReadOptions>): void {
526
+ if (options.aspect !== 'all') {
527
+ throw new Error(`${this} color readback only supports aspect 'all'`);
528
+ }
529
+ }
530
+
531
+ /** Validates that a read request targets an uncompressed color-renderable texture format. */
532
+ protected _validateColorReadFormat(formatInfo: TextureFormatInfo): void {
533
+ if (formatInfo.compressed) {
534
+ throw new Error(
535
+ `${this} color readback does not support compressed formats (${this.format})`
536
+ );
537
+ }
538
+
539
+ switch (formatInfo.attachment) {
540
+ case 'color':
541
+ return;
542
+
543
+ case 'depth':
544
+ throw new Error(`${this} color readback does not support depth formats (${this.format})`);
545
+
546
+ case 'stencil':
547
+ throw new Error(`${this} color readback does not support stencil formats (${this.format})`);
548
+
549
+ case 'depth-stencil':
550
+ throw new Error(
551
+ `${this} color readback does not support depth-stencil formats (${this.format})`
552
+ );
553
+
554
+ default:
555
+ throw new Error(`${this} color readback does not support format ${this.format}`);
556
+ }
557
+ }
558
+
559
+ _normalizeTextureWriteOptions(options_: TextureWriteOptions): Required<TextureWriteOptions> {
560
+ const optionsWithoutUndefined = Texture._omitUndefined(options_);
561
+ const mipLevel = optionsWithoutUndefined.mipLevel ?? 0;
562
+ const mipLevelSize = this._getMipLevelSize(mipLevel);
563
+ const options = {
564
+ ...Texture.defaultTextureWriteOptions,
565
+ ...mipLevelSize,
566
+ ...optionsWithoutUndefined
567
+ };
568
+
569
+ options.width = Math.min(options.width, mipLevelSize.width - options.x);
570
+ options.height = Math.min(options.height, mipLevelSize.height - options.y);
571
+ options.depthOrArrayLayers = Math.min(
572
+ options.depthOrArrayLayers,
573
+ mipLevelSize.depthOrArrayLayers - options.z
574
+ );
575
+
576
+ const layout = textureFormatDecoder.computeMemoryLayout({
577
+ format: this.format,
578
+ width: options.width,
579
+ height: options.height,
580
+ depth: options.depthOrArrayLayers,
581
+ byteAlignment: this.byteAlignment
582
+ });
583
+
584
+ const minimumBytesPerRow = layout.bytesPerPixel * options.width;
585
+ options.bytesPerRow = optionsWithoutUndefined.bytesPerRow ?? layout.bytesPerRow;
586
+ options.rowsPerImage = optionsWithoutUndefined.rowsPerImage ?? options.height;
587
+
588
+ if (options.bytesPerRow < minimumBytesPerRow) {
589
+ throw new Error(
590
+ `bytesPerRow (${options.bytesPerRow}) must be at least ${minimumBytesPerRow} for ${this.format}`
591
+ );
592
+ }
593
+ if (options.rowsPerImage < options.height) {
594
+ throw new Error(
595
+ `rowsPerImage (${options.rowsPerImage}) must be at least ${options.height} for ${this.format}`
596
+ );
597
+ }
598
+
599
+ const bytesPerPixel = this.device.getTextureFormatInfo(this.format).bytesPerPixel;
600
+ if (bytesPerPixel && options.bytesPerRow % bytesPerPixel !== 0) {
601
+ throw new Error(
602
+ `bytesPerRow (${options.bytesPerRow}) must be a multiple of bytesPerPixel (${bytesPerPixel}) for ${this.format}`
603
+ );
604
+ }
605
+
606
+ return options;
607
+ }
608
+
609
+ protected _getMipLevelSize(
610
+ mipLevel: number
611
+ ): Required<Pick<TextureReadOptions, 'width' | 'height' | 'depthOrArrayLayers'>> {
612
+ const width = Math.max(1, this.width >> mipLevel);
613
+ const height = this.baseDimension === '1d' ? 1 : Math.max(1, this.height >> mipLevel);
614
+ const depthOrArrayLayers =
615
+ this.dimension === '3d' ? Math.max(1, this.depth >> mipLevel) : this.depth;
616
+
617
+ return {width, height, depthOrArrayLayers};
618
+ }
619
+
620
+ protected getAllocatedByteLength(): number {
621
+ let allocatedByteLength = 0;
622
+
623
+ for (let mipLevel = 0; mipLevel < this.mipLevels; mipLevel++) {
624
+ const {width, height, depthOrArrayLayers} = this._getMipLevelSize(mipLevel);
625
+ allocatedByteLength += textureFormatDecoder.computeMemoryLayout({
626
+ format: this.format,
627
+ width,
628
+ height,
629
+ depth: depthOrArrayLayers,
630
+ byteAlignment: 1
631
+ }).byteLength;
632
+ }
633
+
634
+ return allocatedByteLength * this.samples;
635
+ }
636
+
637
+ protected static _omitUndefined<T extends object>(options: T): Partial<T> {
638
+ return Object.fromEntries(
639
+ Object.entries(options).filter(([, value]) => value !== undefined)
640
+ ) as Partial<T>;
641
+ }
642
+
294
643
  static override defaultProps: Required<TextureProps> = {
295
644
  ...Resource.defaultProps,
296
645
  data: null,
297
646
  dimension: '2d',
298
647
  format: 'rgba8unorm',
299
- usage: Texture.TEXTURE | Texture.RENDER_ATTACHMENT | Texture.COPY_DST,
648
+ usage: Texture.SAMPLE | Texture.RENDER | Texture.COPY_DST,
300
649
  width: undefined!,
301
650
  height: undefined!,
302
651
  depth: 1,
@@ -311,6 +660,10 @@ export abstract class Texture extends Resource<TextureProps> {
311
660
  byteOffset: 0,
312
661
  bytesPerRow: undefined!,
313
662
  rowsPerImage: undefined!,
663
+ width: undefined!,
664
+ height: undefined!,
665
+ depthOrArrayLayers: undefined!,
666
+ depth: 1,
314
667
  mipLevel: 0,
315
668
  x: 0,
316
669
  y: 0,
@@ -335,4 +688,29 @@ export abstract class Texture extends Resource<TextureProps> {
335
688
  premultipliedAlpha: false,
336
689
  flipY: false
337
690
  };
691
+
692
+ protected static defaultTextureReadOptions: Required<TextureReadOptions> = {
693
+ x: 0,
694
+ y: 0,
695
+ z: 0,
696
+ width: undefined!,
697
+ height: undefined!,
698
+ depthOrArrayLayers: 1,
699
+ mipLevel: 0,
700
+ aspect: 'all'
701
+ };
702
+
703
+ protected static defaultTextureWriteOptions: Required<TextureWriteOptions> = {
704
+ byteOffset: 0,
705
+ bytesPerRow: undefined!,
706
+ rowsPerImage: undefined!,
707
+ x: 0,
708
+ y: 0,
709
+ z: 0,
710
+ width: undefined!,
711
+ height: undefined!,
712
+ depthOrArrayLayers: 1,
713
+ mipLevel: 0,
714
+ aspect: 'all'
715
+ };
338
716
  }
@@ -6,7 +6,7 @@ import type {
6
6
  TextureFormatColor,
7
7
  TextureFormatDepthStencil,
8
8
  TextureFormat
9
- } from '../../shadertypes/textures/texture-formats';
9
+ } from '../../shadertypes/texture-types/texture-formats';
10
10
  import type {Texture} from '../resources/texture'; // TextureView...
11
11
  import type {TextureView} from '../resources/texture-view'; // TextureView...
12
12
 
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import type {VertexFormat} from '../../shadertypes/vertex-arrays/vertex-formats';
5
+ import type {VertexFormat} from '../../shadertypes/vertex-types/vertex-formats';
6
6
 
7
7
  /**
8
8
  * Provides specific details about the memory layout of the actual buffers
@@ -3,7 +3,7 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  import {NumberArray4, NumberArray6} from '@math.gl/types';
6
- import {TextureFormatDepthStencil} from '../../shadertypes/textures/texture-formats';
6
+ import {TextureFormatDepthStencil} from '../../shadertypes/texture-types/texture-formats';
7
7
 
8
8
  export type CompareFunction =
9
9
  | 'never'
@@ -102,6 +102,8 @@ export type DepthStencilParameters = {
102
102
  depthCompare?: CompareFunction;
103
103
  /** The format of depthStencilAttachment this GPURenderPipeline will be compatible with. */
104
104
  depthFormat?: TextureFormatDepthStencil;
105
+ /** Depth value used when clearing depth buffers. */
106
+ clearDepth?: number;
105
107
 
106
108
  /** Bitmask controlling which depthStencilAttachment stencil value bits are read when performing stencil comparison tests. */
107
109
  stencilReadMask?: number;
@@ -217,6 +219,7 @@ export const DEFAULT_PARAMETERS: Required<Parameters> = {
217
219
  depthWriteEnabled: false,
218
220
  depthCompare: 'always',
219
221
  depthFormat: 'depth24plus',
222
+ clearDepth: 1,
220
223
 
221
224
  depthBias: 0,
222
225
  depthBiasSlopeScale: 0,