@woosh/meep-engine 3.14.0 → 3.14.2

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 (220) hide show
  1. package/README.md +33 -64
  2. package/package.json +1 -1
  3. package/src/avif/native/DECISIONS.md +544 -536
  4. package/src/avif/native/heif/parse_avif_file.d.ts.map +1 -1
  5. package/src/avif/native/heif/parse_avif_file.js +384 -383
  6. package/src/avif/native/heif/parse_image_grid.d.ts.map +1 -1
  7. package/src/avif/native/heif/parse_image_grid.js +49 -48
  8. package/src/basis/BasisBitReader.d.ts +77 -0
  9. package/src/basis/BasisBitReader.d.ts.map +1 -0
  10. package/src/basis/BasisBitReader.js +231 -0
  11. package/src/basis/BasisHuffmanTable.d.ts +53 -0
  12. package/src/basis/BasisHuffmanTable.d.ts.map +1 -0
  13. package/src/basis/BasisHuffmanTable.js +263 -0
  14. package/src/basis/basis_read_huffman_table.d.ts +20 -0
  15. package/src/basis/basis_read_huffman_table.d.ts.map +1 -0
  16. package/src/basis/basis_read_huffman_table.js +187 -0
  17. package/src/basis/etc1s/Etc1sSelectorHistory.d.ts +50 -0
  18. package/src/basis/etc1s/Etc1sSelectorHistory.d.ts.map +1 -0
  19. package/src/basis/etc1s/Etc1sSelectorHistory.js +89 -0
  20. package/src/basis/etc1s/etc1s_block_colors.d.ts +14 -0
  21. package/src/basis/etc1s/etc1s_block_colors.d.ts.map +1 -0
  22. package/src/basis/etc1s/etc1s_block_colors.js +75 -0
  23. package/src/basis/etc1s/etc1s_decode_slice.d.ts +57 -0
  24. package/src/basis/etc1s/etc1s_decode_slice.d.ts.map +1 -0
  25. package/src/basis/etc1s/etc1s_decode_slice.js +258 -0
  26. package/src/basis/etc1s/etc1s_read_endpoint_codebook.d.ts +48 -0
  27. package/src/basis/etc1s/etc1s_read_endpoint_codebook.d.ts.map +1 -0
  28. package/src/basis/etc1s/etc1s_read_endpoint_codebook.js +111 -0
  29. package/src/basis/etc1s/etc1s_read_selector_codebook.d.ts +42 -0
  30. package/src/basis/etc1s/etc1s_read_selector_codebook.d.ts.map +1 -0
  31. package/src/basis/etc1s/etc1s_read_selector_codebook.js +127 -0
  32. package/src/basis/etc1s/etc1s_read_slice_tables.d.ts +54 -0
  33. package/src/basis/etc1s/etc1s_read_slice_tables.d.ts.map +1 -0
  34. package/src/basis/etc1s/etc1s_read_slice_tables.js +47 -0
  35. package/src/basis/transcode/build_range_plan.js +54 -0
  36. package/src/basis/transcode/etc1s_to_bc1.d.ts +24 -0
  37. package/src/basis/transcode/etc1s_to_bc1.d.ts.map +1 -0
  38. package/src/basis/transcode/etc1s_to_bc1.js +205 -0
  39. package/src/basis/transcode/etc1s_to_bc7.d.ts +30 -0
  40. package/src/basis/transcode/etc1s_to_bc7.d.ts.map +1 -0
  41. package/src/basis/transcode/etc1s_to_bc7.js +496 -0
  42. package/src/basis/transcode/fit_endpoints.d.ts +59 -0
  43. package/src/basis/transcode/fit_endpoints.d.ts.map +1 -0
  44. package/src/basis/transcode/fit_endpoints.js +226 -0
  45. package/src/{avif/native/isobmff → core/binary}/ByteCursor.d.ts +19 -6
  46. package/src/core/binary/ByteCursor.d.ts.map +1 -0
  47. package/src/{avif/native/isobmff → core/binary}/ByteCursor.js +41 -14
  48. package/src/engine/EngineHarness.js +1 -1
  49. package/src/engine/asset/codec/Codec.d.ts.map +1 -0
  50. package/src/engine/asset/codec/CodecWithFallback.d.ts.map +1 -0
  51. package/src/engine/asset/{loaders/image/codec → codec}/CodecWithFallback.js +2 -2
  52. package/src/engine/asset/loaders/image/IMAGE_CODEC_REVIEW_2026_08_28.md +4 -4
  53. package/src/engine/asset/loaders/image/ImageRGBADataLoader.d.ts +1 -1
  54. package/src/engine/asset/loaders/image/ImageRGBADataLoader.d.ts.map +1 -1
  55. package/src/engine/asset/loaders/image/ImageRGBADataLoader.js +1 -1
  56. package/src/engine/asset/loaders/image/codec/NativeImageDecoder.d.ts +1 -1
  57. package/src/engine/asset/loaders/image/codec/NativeImageDecoder.d.ts.map +1 -1
  58. package/src/engine/asset/loaders/image/codec/NativeImageDecoder.js +1 -1
  59. package/src/engine/asset/loaders/image/codec/ThreadedImageDecoder.d.ts +1 -1
  60. package/src/engine/asset/loaders/image/codec/ThreadedImageDecoder.d.ts.map +1 -1
  61. package/src/engine/asset/loaders/image/codec/ThreadedImageDecoder.js +1 -1
  62. package/src/engine/graphics/texture/atlas/TextureAtlas.d.ts.map +1 -1
  63. package/src/engine/graphics/texture/atlas/TextureAtlas.js +13 -0
  64. package/src/engine/physics/broadphase/generate_pairs.d.ts.map +1 -1
  65. package/src/engine/physics/broadphase/generate_pairs.js +7 -1
  66. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  67. package/src/ktx2/KTX2_IDENTIFIER.d.ts +14 -0
  68. package/src/ktx2/KTX2_IDENTIFIER.d.ts.map +1 -0
  69. package/src/ktx2/KTX2_IDENTIFIER.js +15 -0
  70. package/src/ktx2/KhrDfModel.d.ts +35 -0
  71. package/src/ktx2/KhrDfModel.d.ts.map +1 -0
  72. package/src/ktx2/KhrDfModel.js +49 -0
  73. package/src/ktx2/SupercompressionScheme.d.ts +16 -0
  74. package/src/ktx2/SupercompressionScheme.d.ts.map +1 -0
  75. package/src/ktx2/SupercompressionScheme.js +23 -0
  76. package/src/ktx2/ktx2_read.d.ts +71 -0
  77. package/src/ktx2/ktx2_read.d.ts.map +1 -0
  78. package/src/ktx2/ktx2_read.js +581 -0
  79. package/src/ktx2/ktx2_read_basis_lz_global_data.d.ts +27 -0
  80. package/src/ktx2/ktx2_read_basis_lz_global_data.d.ts.map +1 -0
  81. package/src/ktx2/ktx2_read_basis_lz_global_data.js +189 -0
  82. package/src/ktx2/vk_format_to_texture_format.d.ts +55 -0
  83. package/src/ktx2/vk_format_to_texture_format.d.ts.map +1 -0
  84. package/src/ktx2/vk_format_to_texture_format.js +290 -0
  85. package/src/shade/descriptor/GPUTextureUsage.d.ts +23 -0
  86. package/src/shade/descriptor/GPUTextureUsage.d.ts.map +1 -0
  87. package/src/shade/descriptor/GPUTextureUsage.js +24 -0
  88. package/src/shade/descriptor/WebGPUExtensionType.d.ts +3 -0
  89. package/src/shade/descriptor/WebGPUExtensionType.js +26 -0
  90. package/src/shade/descriptor/texture/TextureDescriptor.d.ts +2 -6
  91. package/src/shade/descriptor/texture/TextureDescriptor.d.ts.map +1 -1
  92. package/src/shade/descriptor/texture/TextureDescriptor.js +24 -40
  93. package/src/shade/descriptor/texture/format/TextureFormat.d.ts +125 -0
  94. package/src/shade/descriptor/texture/format/TextureFormat.d.ts.map +1 -0
  95. package/src/shade/descriptor/texture/format/TextureFormat.js +146 -0
  96. package/src/shade/descriptor/texture/format/gpu_texture_format_info.d.ts +60 -0
  97. package/src/shade/descriptor/texture/format/gpu_texture_format_info.d.ts.map +1 -1
  98. package/src/shade/descriptor/texture/format/gpu_texture_format_info.js +102 -0
  99. package/src/shade/device/graph/TextureResourceDescriptor.d.ts.map +1 -1
  100. package/src/shade/device/graph/TextureResourceDescriptor.js +160 -155
  101. package/src/shade/device/mock/SoftwareGPUQueue.d.ts +11 -4
  102. package/src/shade/device/mock/SoftwareGPUQueue.d.ts.map +1 -1
  103. package/src/shade/device/mock/SoftwareGPUQueue.js +31 -37
  104. package/src/shade/device/mock/SoftwareGPUTexture.d.ts.map +1 -1
  105. package/src/shade/device/mock/SoftwareGPUTexture.js +8 -4
  106. package/src/shade/device/timing/profile/frame_graph_extract_topology.d.ts.map +1 -1
  107. package/src/shade/device/timing/profile/frame_graph_extract_topology.js +164 -174
  108. package/src/shade/playground/ground_seam/README.md +235 -0
  109. package/src/shade/playground/ground_seam/capture_scene_color.d.ts +45 -0
  110. package/src/shade/playground/ground_seam/capture_scene_color.d.ts.map +1 -0
  111. package/src/shade/playground/ground_seam/capture_scene_color.js +242 -0
  112. package/src/shade/playground/ground_seam/depth_step_across_seam.d.ts +11 -0
  113. package/src/shade/playground/ground_seam/depth_step_across_seam.d.ts.map +1 -0
  114. package/src/shade/playground/ground_seam/depth_step_across_seam.js +185 -0
  115. package/src/shade/playground/ground_seam/index.html +195 -0
  116. package/src/shade/playground/ground_seam/main.d.ts +2 -0
  117. package/src/shade/playground/ground_seam/main.d.ts.map +1 -0
  118. package/src/shade/playground/ground_seam/main.js +879 -0
  119. package/src/shade/playground/ground_seam/make_grid_texture.d.ts +29 -0
  120. package/src/shade/playground/ground_seam/make_grid_texture.d.ts.map +1 -0
  121. package/src/shade/playground/ground_seam/make_grid_texture.js +105 -0
  122. package/src/shade/playground/ground_seam/make_ground.d.ts +70 -0
  123. package/src/shade/playground/ground_seam/make_ground.d.ts.map +1 -0
  124. package/src/shade/playground/ground_seam/make_ground.js +161 -0
  125. package/src/shade/playground/ground_seam/measure_flicker.d.ts +71 -0
  126. package/src/shade/playground/ground_seam/measure_flicker.d.ts.map +1 -0
  127. package/src/shade/playground/ground_seam/measure_flicker.js +531 -0
  128. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  129. package/src/shade/renderer/Renderer.js +2519 -2511
  130. package/src/shade/renderer/hiz/HierarchicalZBuffer.d.ts.map +1 -1
  131. package/src/shade/renderer/hiz/HierarchicalZBuffer.js +275 -274
  132. package/src/shade/renderer/light/GPULightCollection.d.ts.map +1 -1
  133. package/src/shade/renderer/light/GPULightCollection.js +323 -314
  134. package/src/shade/renderer/lightmap/GPULightMap.js +336 -336
  135. package/src/shade/renderer/material/resident/GPUResidentMaterialContext.d.ts.map +1 -1
  136. package/src/shade/renderer/material/resident/GPUResidentMaterialContext.js +12 -2
  137. package/src/shade/renderer/material/standard/fragment_gbuffer.d.ts.map +1 -1
  138. package/src/shade/renderer/material/standard/fragment_gbuffer.js +3 -1
  139. package/src/shade/renderer/material/standard/fragment_gbuffer_vt.js +169 -169
  140. package/src/shade/renderer/path_tracer/shader/chunk_sample_material_data.d.ts.map +1 -1
  141. package/src/shade/renderer/path_tracer/shader/chunk_sample_material_data.js +3 -1
  142. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  143. package/src/shade/renderer/rasterize/native/oit/chunk_forward_shade_standard_fragment_brick4.d.ts.map +1 -1
  144. package/src/shade/renderer/rasterize/native/oit/chunk_forward_shade_standard_fragment_brick4.js +3 -1
  145. package/src/shade/renderer/rasterize/native/oit/chunk_forward_shade_standard_fragment_ibl.d.ts.map +1 -1
  146. package/src/shade/renderer/rasterize/native/oit/chunk_forward_shade_standard_fragment_ibl.js +3 -1
  147. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_decode_tangent_normal.d.ts +28 -0
  148. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_decode_tangent_normal.d.ts.map +1 -0
  149. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_decode_tangent_normal.js +39 -0
  150. package/src/shade/renderer/shader/chunk/geometry/triangle/chunk_barycentric_full.d.ts +45 -0
  151. package/src/shade/renderer/shader/chunk/geometry/triangle/chunk_barycentric_full.d.ts.map +1 -1
  152. package/src/shade/renderer/shader/chunk/geometry/triangle/chunk_barycentric_full.js +94 -61
  153. package/src/shade/renderer/shader/chunk/geometry/triangle/chunk_barycentric_solve.d.ts +24 -0
  154. package/src/shade/renderer/shader/chunk/geometry/triangle/chunk_barycentric_solve.d.ts.map +1 -0
  155. package/src/shade/renderer/shader/chunk/geometry/triangle/chunk_barycentric_solve.js +43 -0
  156. package/src/shade/renderer/texture/COMPRESSED_TEXTURE_PLAN_2026_09_01.md +1462 -0
  157. package/src/shade/renderer/texture/TextureManager.d.ts.map +1 -1
  158. package/src/shade/renderer/texture/TextureManager.js +20 -8
  159. package/src/shade/renderer/texture/TextureRole.d.ts +19 -0
  160. package/src/shade/renderer/texture/TextureRole.d.ts.map +1 -0
  161. package/src/shade/renderer/texture/TextureRole.js +26 -0
  162. package/src/shade/renderer/texture/TextureVariantSet.d.ts +71 -0
  163. package/src/shade/renderer/texture/TextureVariantSet.d.ts.map +1 -0
  164. package/src/shade/renderer/texture/TextureVariantSet.js +105 -0
  165. package/src/shade/renderer/texture/download_texture_data.d.ts.map +1 -1
  166. package/src/shade/renderer/texture/download_texture_data.js +22 -0
  167. package/src/shade/renderer/texture/format/gpu_texture_compression_support.d.ts +15 -0
  168. package/src/shade/renderer/texture/format/gpu_texture_compression_support.d.ts.map +1 -0
  169. package/src/shade/renderer/texture/format/gpu_texture_compression_support.js +50 -0
  170. package/src/shade/renderer/texture/format/gpu_texture_format_can_generate_mipmaps.d.ts +27 -0
  171. package/src/shade/renderer/texture/format/gpu_texture_format_can_generate_mipmaps.d.ts.map +1 -0
  172. package/src/shade/renderer/texture/format/gpu_texture_format_can_generate_mipmaps.js +65 -0
  173. package/src/shade/renderer/texture/format/infer_format_from_parameters.d.ts +11 -0
  174. package/src/shade/renderer/texture/format/infer_format_from_parameters.d.ts.map +1 -0
  175. package/src/shade/renderer/texture/format/infer_format_from_parameters.js +88 -0
  176. package/src/shade/renderer/texture/format/texture_format_from_shade_image.d.ts +24 -0
  177. package/src/shade/renderer/texture/format/texture_format_from_shade_image.d.ts.map +1 -0
  178. package/src/shade/renderer/texture/format/texture_format_from_shade_image.js +71 -0
  179. package/src/shade/renderer/texture/format/texture_format_preference.d.ts +22 -0
  180. package/src/shade/renderer/texture/format/texture_format_preference.d.ts.map +1 -0
  181. package/src/shade/renderer/texture/format/texture_format_preference.js +89 -0
  182. package/src/shade/renderer/texture/format/texture_variant_select.d.ts +24 -0
  183. package/src/shade/renderer/texture/format/texture_variant_select.d.ts.map +1 -0
  184. package/src/shade/renderer/texture/format/texture_variant_select.js +38 -0
  185. package/src/shade/renderer/texture/shade_texture_might_have_alpha.d.ts +9 -1
  186. package/src/shade/renderer/texture/shade_texture_might_have_alpha.d.ts.map +1 -1
  187. package/src/shade/renderer/texture/shade_texture_might_have_alpha.js +73 -8
  188. package/src/shade/renderer/texture/source/AlphaMode.d.ts +27 -0
  189. package/src/shade/renderer/texture/source/AlphaMode.d.ts.map +1 -0
  190. package/src/shade/renderer/texture/source/AlphaMode.js +52 -0
  191. package/src/shade/renderer/texture/source/ShadeImage.d.ts +33 -0
  192. package/src/shade/renderer/texture/source/ShadeImage.d.ts.map +1 -1
  193. package/src/shade/renderer/texture/source/ShadeImage.js +74 -0
  194. package/src/shade/renderer/texture/source/ShadeTexelData.d.ts +78 -0
  195. package/src/shade/renderer/texture/source/ShadeTexelData.d.ts.map +1 -0
  196. package/src/shade/renderer/texture/source/ShadeTexelData.js +158 -0
  197. package/src/shade/renderer/texture/texture_descriptor_from_texture_shade.d.ts +0 -10
  198. package/src/shade/renderer/texture/texture_descriptor_from_texture_shade.d.ts.map +1 -1
  199. package/src/shade/renderer/texture/texture_descriptor_from_texture_shade.js +73 -175
  200. package/src/shade/renderer/texture/texture_write_level.d.ts +32 -0
  201. package/src/shade/renderer/texture/texture_write_level.d.ts.map +1 -0
  202. package/src/shade/renderer/texture/texture_write_level.js +77 -0
  203. package/src/shade/renderer/texture/texture_write_to_gpu.d.ts +8 -1
  204. package/src/shade/renderer/texture/texture_write_to_gpu.d.ts.map +1 -1
  205. package/src/shade/renderer/texture/texture_write_to_gpu.js +62 -37
  206. package/src/shade/renderer/texture/virtual/source/VTSourceImage.d.ts +8 -0
  207. package/src/shade/renderer/texture/virtual/source/VTSourceImage.d.ts.map +1 -1
  208. package/src/shade/renderer/texture/virtual/source/VTSourceImage.js +8 -0
  209. package/src/shade/util/texture_mip_extent.d.ts +49 -0
  210. package/src/shade/util/texture_mip_extent.d.ts.map +1 -0
  211. package/src/shade/util/texture_mip_extent.js +87 -0
  212. package/src/avif/native/isobmff/ByteCursor.d.ts.map +0 -1
  213. package/src/engine/asset/loaders/image/codec/Codec.d.ts.map +0 -1
  214. package/src/engine/asset/loaders/image/codec/CodecWithFallback.d.ts.map +0 -1
  215. package/src/shade/util/compute_max_mip_count.d.ts +0 -8
  216. package/src/shade/util/compute_max_mip_count.d.ts.map +0 -1
  217. package/src/shade/util/compute_max_mip_count.js +0 -27
  218. /package/src/engine/asset/{loaders/image/codec → codec}/Codec.d.ts +0 -0
  219. /package/src/engine/asset/{loaders/image/codec → codec}/Codec.js +0 -0
  220. /package/src/engine/asset/{loaders/image/codec → codec}/CodecWithFallback.d.ts +0 -0
@@ -5,8 +5,9 @@ import { isArrayEqualStrict } from "../../../core/collection/array/isArrayEqualS
5
5
  import Signal from "../../../core/events/signal/Signal.js";
6
6
  import { computeStringHash } from "../../../core/primitives/strings/computeStringHash.js";
7
7
  import { warn_limited } from "../../util/warn_limited.js";
8
- import { gpu_texture_format_channel_bit_count } from "./format/gpu_texture_format_channel_bit_count.js";
8
+ import { gpu_texture_format_memory_footprint } from "./format/gpu_texture_format_info.js";
9
9
  import { ObjectDescriptorBase } from "../ObjectDescriptorBase.js";
10
+ import { GPUTextureUsage } from "../GPUTextureUsage.js";
10
11
 
11
12
 
12
13
  /**
@@ -93,52 +94,35 @@ export class TextureDescriptor extends ObjectDescriptorBase {
93
94
  }
94
95
 
95
96
 
96
- /**
97
- *
98
- * @return {number}
99
- */
100
- get bits_per_sample() {
101
- const f = this.format;
102
-
103
- const bit_counts = gpu_texture_format_channel_bit_count[f];
104
-
105
- if (bit_counts === undefined) {
106
- // unknown
107
- warn_limited(`Unsupported texture format: ${f}`);
108
- return 0;
109
- }
110
-
111
- let total = 0;
112
-
113
- for (let i = 0; i < bit_counts.length; i++) {
114
- total += bit_counts[i];
115
- }
116
-
117
- return total;
118
- }
119
-
120
-
121
97
  /**
122
98
  * The number is just an estimate, actual VRAM usage will depend on the GPU.
123
99
  * Usually accurate, but when it's not - it's close.
124
- * @returns {number}
100
+ *
101
+ * @returns {number} bytes
125
102
  */
126
103
  get memory_footprint() {
127
- const size = this.#size;
104
+ try {
105
+ return gpu_texture_format_memory_footprint(
106
+ this.format,
107
+ this.#size,
108
+ this.dimension,
109
+ this.mipLevelCount,
110
+ this.sampleCount
111
+ );
112
+ } catch (e) {
113
+ /*
114
+ Usually an unknown format, which for a descriptor means one `createTexture` would refuse
115
+ anyway. Reporting zero keeps a budget readout and a pool eviction from taking a frame
116
+ down over an accounting number, and the warning is what says so out loud.
117
+
118
+ The message carries the cause rather than naming the format as the culprit: this also
119
+ catches the argument asserts, and a descriptor with a garbage `mipLevelCount` should not
120
+ be reported as having a bad format.
121
+ */
122
+ warn_limited(`Cannot size texture '${this.label}' (${this.format}): ${e.message}`);
128
123
 
129
- let pixel_count = 0;
130
-
131
- // add up mip pixels
132
- for (let i = 0; i < this.mipLevelCount; i++) {
133
- let mip_w = Math.max(size[0] >> i, 1);
134
- let mip_h = Math.max(size[1] >> i, 1);
135
- let mip_d = Math.max(size[2] >> i, 1);
136
-
137
- pixel_count += mip_w * mip_h * mip_d;
124
+ return 0;
138
125
  }
139
-
140
- // consumers (gpu_memory_usage) expect bytes
141
- return (pixel_count * this.bits_per_sample * this.sampleCount) / 8;
142
126
  }
143
127
 
144
128
  /**
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Every {@link GPUTextureFormat }, as a named constant.
3
+ *
4
+ * `GPUTextureFormat` is a WebIDL enum, which in JavaScript means a bare string — there is no global
5
+ * to read and nothing here is a shim for a missing one. What this adds is threefold:
6
+ *
7
+ * 1. **A resolvable type.** `@webgpu/types` is not a dependency of this package, so every
8
+ * `@param {GPUTextureFormat}` in the tree resolves to nothing and `generate-types` emits `any`.
9
+ * An in-tree `@enum {string}` types those parameters without putting browser typings on a node
10
+ * tool's path.
11
+ * 2. **A typo is `undefined` at the call site**, rather than `'rgba8'` travelling one layer down to
12
+ * {@link gpu_texture_format_info } and throwing there.
13
+ * 3. **One enumeration.** The names were already the key set of that table; naming them makes the
14
+ * set the source rather than an implementation detail of a lookup.
15
+ *
16
+ * **The values are the WebGPU strings verbatim**, so a member is passable straight to
17
+ * `createTexture` and no translation exists at any boundary — the same discipline
18
+ * {@link WebGPUExtensionType } keeps. Keys are the value uppercased with `-` as `_`, mechanically and
19
+ * without exception, which is what `TextureFormat.spec.js` asserts in both directions.
20
+ */
21
+ export type TextureFormat = string;
22
+ export namespace TextureFormat {
23
+ let R8UNORM: string;
24
+ let R8SNORM: string;
25
+ let R8UINT: string;
26
+ let R8SINT: string;
27
+ let R16UNORM: string;
28
+ let R16SNORM: string;
29
+ let R16UINT: string;
30
+ let R16SINT: string;
31
+ let R16FLOAT: string;
32
+ let RG8UNORM: string;
33
+ let RG8SNORM: string;
34
+ let RG8UINT: string;
35
+ let RG8SINT: string;
36
+ let R32UINT: string;
37
+ let R32SINT: string;
38
+ let R32FLOAT: string;
39
+ let RG16UNORM: string;
40
+ let RG16SNORM: string;
41
+ let RG16UINT: string;
42
+ let RG16SINT: string;
43
+ let RG16FLOAT: string;
44
+ let RGBA8UNORM: string;
45
+ let RGBA8UNORM_SRGB: string;
46
+ let RGBA8SNORM: string;
47
+ let RGBA8UINT: string;
48
+ let RGBA8SINT: string;
49
+ let BGRA8UNORM: string;
50
+ let BGRA8UNORM_SRGB: string;
51
+ let RGB9E5UFLOAT: string;
52
+ let RGB10A2UINT: string;
53
+ let RGB10A2UNORM: string;
54
+ let RG11B10UFLOAT: string;
55
+ let RG32UINT: string;
56
+ let RG32SINT: string;
57
+ let RG32FLOAT: string;
58
+ let RGBA16UNORM: string;
59
+ let RGBA16SNORM: string;
60
+ let RGBA16UINT: string;
61
+ let RGBA16SINT: string;
62
+ let RGBA16FLOAT: string;
63
+ let RGBA32UINT: string;
64
+ let RGBA32SINT: string;
65
+ let RGBA32FLOAT: string;
66
+ let STENCIL8: string;
67
+ let DEPTH16UNORM: string;
68
+ let DEPTH24PLUS: string;
69
+ let DEPTH24PLUS_STENCIL8: string;
70
+ let DEPTH32FLOAT: string;
71
+ let DEPTH32FLOAT_STENCIL8: string;
72
+ let BC1_RGBA_UNORM: string;
73
+ let BC1_RGBA_UNORM_SRGB: string;
74
+ let BC2_RGBA_UNORM: string;
75
+ let BC2_RGBA_UNORM_SRGB: string;
76
+ let BC3_RGBA_UNORM: string;
77
+ let BC3_RGBA_UNORM_SRGB: string;
78
+ let BC4_R_UNORM: string;
79
+ let BC4_R_SNORM: string;
80
+ let BC5_RG_UNORM: string;
81
+ let BC5_RG_SNORM: string;
82
+ let BC6H_RGB_UFLOAT: string;
83
+ let BC6H_RGB_FLOAT: string;
84
+ let BC7_RGBA_UNORM: string;
85
+ let BC7_RGBA_UNORM_SRGB: string;
86
+ let ETC2_RGB8UNORM: string;
87
+ let ETC2_RGB8UNORM_SRGB: string;
88
+ let ETC2_RGB8A1UNORM: string;
89
+ let ETC2_RGB8A1UNORM_SRGB: string;
90
+ let ETC2_RGBA8UNORM: string;
91
+ let ETC2_RGBA8UNORM_SRGB: string;
92
+ let EAC_R11UNORM: string;
93
+ let EAC_R11SNORM: string;
94
+ let EAC_RG11UNORM: string;
95
+ let EAC_RG11SNORM: string;
96
+ let ASTC_4X4_UNORM: string;
97
+ let ASTC_4X4_UNORM_SRGB: string;
98
+ let ASTC_5X4_UNORM: string;
99
+ let ASTC_5X4_UNORM_SRGB: string;
100
+ let ASTC_5X5_UNORM: string;
101
+ let ASTC_5X5_UNORM_SRGB: string;
102
+ let ASTC_6X5_UNORM: string;
103
+ let ASTC_6X5_UNORM_SRGB: string;
104
+ let ASTC_6X6_UNORM: string;
105
+ let ASTC_6X6_UNORM_SRGB: string;
106
+ let ASTC_8X5_UNORM: string;
107
+ let ASTC_8X5_UNORM_SRGB: string;
108
+ let ASTC_8X6_UNORM: string;
109
+ let ASTC_8X6_UNORM_SRGB: string;
110
+ let ASTC_8X8_UNORM: string;
111
+ let ASTC_8X8_UNORM_SRGB: string;
112
+ let ASTC_10X5_UNORM: string;
113
+ let ASTC_10X5_UNORM_SRGB: string;
114
+ let ASTC_10X6_UNORM: string;
115
+ let ASTC_10X6_UNORM_SRGB: string;
116
+ let ASTC_10X8_UNORM: string;
117
+ let ASTC_10X8_UNORM_SRGB: string;
118
+ let ASTC_10X10_UNORM: string;
119
+ let ASTC_10X10_UNORM_SRGB: string;
120
+ let ASTC_12X10_UNORM: string;
121
+ let ASTC_12X10_UNORM_SRGB: string;
122
+ let ASTC_12X12_UNORM: string;
123
+ let ASTC_12X12_UNORM_SRGB: string;
124
+ }
125
+ //# sourceMappingURL=TextureFormat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextureFormat.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/descriptor/texture/format/TextureFormat.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;4BAqBU,MAAM"}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Every {@link GPUTextureFormat}, as a named constant.
3
+ *
4
+ * `GPUTextureFormat` is a WebIDL enum, which in JavaScript means a bare string — there is no global
5
+ * to read and nothing here is a shim for a missing one. What this adds is threefold:
6
+ *
7
+ * 1. **A resolvable type.** `@webgpu/types` is not a dependency of this package, so every
8
+ * `@param {GPUTextureFormat}` in the tree resolves to nothing and `generate-types` emits `any`.
9
+ * An in-tree `@enum {string}` types those parameters without putting browser typings on a node
10
+ * tool's path.
11
+ * 2. **A typo is `undefined` at the call site**, rather than `'rgba8'` travelling one layer down to
12
+ * {@link gpu_texture_format_info} and throwing there.
13
+ * 3. **One enumeration.** The names were already the key set of that table; naming them makes the
14
+ * set the source rather than an implementation detail of a lookup.
15
+ *
16
+ * **The values are the WebGPU strings verbatim**, so a member is passable straight to
17
+ * `createTexture` and no translation exists at any boundary — the same discipline
18
+ * {@link WebGPUExtensionType} keeps. Keys are the value uppercased with `-` as `_`, mechanically and
19
+ * without exception, which is what `TextureFormat.spec.js` asserts in both directions.
20
+ *
21
+ * @see https://www.w3.org/TR/webgpu/#enumdef-gputextureformat
22
+ * @enum {string}
23
+ */
24
+ export const TextureFormat = {
25
+ // 8-bit
26
+ R8UNORM: "r8unorm",
27
+ R8SNORM: "r8snorm",
28
+ R8UINT: "r8uint",
29
+ R8SINT: "r8sint",
30
+
31
+ // 16-bit
32
+ R16UNORM: "r16unorm",
33
+ R16SNORM: "r16snorm",
34
+ R16UINT: "r16uint",
35
+ R16SINT: "r16sint",
36
+ R16FLOAT: "r16float",
37
+ RG8UNORM: "rg8unorm",
38
+ RG8SNORM: "rg8snorm",
39
+ RG8UINT: "rg8uint",
40
+ RG8SINT: "rg8sint",
41
+
42
+ // 32-bit
43
+ R32UINT: "r32uint",
44
+ R32SINT: "r32sint",
45
+ R32FLOAT: "r32float",
46
+ RG16UNORM: "rg16unorm",
47
+ RG16SNORM: "rg16snorm",
48
+ RG16UINT: "rg16uint",
49
+ RG16SINT: "rg16sint",
50
+ RG16FLOAT: "rg16float",
51
+ RGBA8UNORM: "rgba8unorm",
52
+ RGBA8UNORM_SRGB: "rgba8unorm-srgb",
53
+ RGBA8SNORM: "rgba8snorm",
54
+ RGBA8UINT: "rgba8uint",
55
+ RGBA8SINT: "rgba8sint",
56
+ BGRA8UNORM: "bgra8unorm",
57
+ BGRA8UNORM_SRGB: "bgra8unorm-srgb",
58
+ // packed — the name says nothing useful about the size
59
+ RGB9E5UFLOAT: "rgb9e5ufloat",
60
+ RGB10A2UINT: "rgb10a2uint",
61
+ RGB10A2UNORM: "rgb10a2unorm",
62
+ RG11B10UFLOAT: "rg11b10ufloat",
63
+
64
+ // 64-bit
65
+ RG32UINT: "rg32uint",
66
+ RG32SINT: "rg32sint",
67
+ RG32FLOAT: "rg32float",
68
+ RGBA16UNORM: "rgba16unorm",
69
+ RGBA16SNORM: "rgba16snorm",
70
+ RGBA16UINT: "rgba16uint",
71
+ RGBA16SINT: "rgba16sint",
72
+ RGBA16FLOAT: "rgba16float",
73
+
74
+ // 128-bit
75
+ RGBA32UINT: "rgba32uint",
76
+ RGBA32SINT: "rgba32sint",
77
+ RGBA32FLOAT: "rgba32float",
78
+
79
+ // depth and stencil
80
+ STENCIL8: "stencil8",
81
+ DEPTH16UNORM: "depth16unorm",
82
+ // no defined byte layout for the depth aspect, so WebGPU forbids copying it; 4 is what this mock
83
+ // allocates, which is enough for a render target and is never handed to a copy
84
+ DEPTH24PLUS: "depth24plus",
85
+ DEPTH24PLUS_STENCIL8: "depth24plus-stencil8",
86
+ DEPTH32FLOAT: "depth32float",
87
+ DEPTH32FLOAT_STENCIL8: "depth32float-stencil8",
88
+
89
+ // BC, 4×4 blocks
90
+ BC1_RGBA_UNORM: "bc1-rgba-unorm",
91
+ BC1_RGBA_UNORM_SRGB: "bc1-rgba-unorm-srgb",
92
+ BC2_RGBA_UNORM: "bc2-rgba-unorm",
93
+ BC2_RGBA_UNORM_SRGB: "bc2-rgba-unorm-srgb",
94
+ BC3_RGBA_UNORM: "bc3-rgba-unorm",
95
+ BC3_RGBA_UNORM_SRGB: "bc3-rgba-unorm-srgb",
96
+ BC4_R_UNORM: "bc4-r-unorm",
97
+ BC4_R_SNORM: "bc4-r-snorm",
98
+ BC5_RG_UNORM: "bc5-rg-unorm",
99
+ BC5_RG_SNORM: "bc5-rg-snorm",
100
+ BC6H_RGB_UFLOAT: "bc6h-rgb-ufloat",
101
+ BC6H_RGB_FLOAT: "bc6h-rgb-float",
102
+ BC7_RGBA_UNORM: "bc7-rgba-unorm",
103
+ BC7_RGBA_UNORM_SRGB: "bc7-rgba-unorm-srgb",
104
+
105
+ // ETC2 / EAC, 4×4 blocks
106
+ ETC2_RGB8UNORM: "etc2-rgb8unorm",
107
+ ETC2_RGB8UNORM_SRGB: "etc2-rgb8unorm-srgb",
108
+ ETC2_RGB8A1UNORM: "etc2-rgb8a1unorm",
109
+ ETC2_RGB8A1UNORM_SRGB: "etc2-rgb8a1unorm-srgb",
110
+ ETC2_RGBA8UNORM: "etc2-rgba8unorm",
111
+ ETC2_RGBA8UNORM_SRGB: "etc2-rgba8unorm-srgb",
112
+ EAC_R11UNORM: "eac-r11unorm",
113
+ EAC_R11SNORM: "eac-r11snorm",
114
+ EAC_RG11UNORM: "eac-rg11unorm",
115
+ EAC_RG11SNORM: "eac-rg11snorm",
116
+
117
+ // ASTC — every block size, all 16 bytes
118
+ ASTC_4X4_UNORM: "astc-4x4-unorm",
119
+ ASTC_4X4_UNORM_SRGB: "astc-4x4-unorm-srgb",
120
+ ASTC_5X4_UNORM: "astc-5x4-unorm",
121
+ ASTC_5X4_UNORM_SRGB: "astc-5x4-unorm-srgb",
122
+ ASTC_5X5_UNORM: "astc-5x5-unorm",
123
+ ASTC_5X5_UNORM_SRGB: "astc-5x5-unorm-srgb",
124
+ ASTC_6X5_UNORM: "astc-6x5-unorm",
125
+ ASTC_6X5_UNORM_SRGB: "astc-6x5-unorm-srgb",
126
+ ASTC_6X6_UNORM: "astc-6x6-unorm",
127
+ ASTC_6X6_UNORM_SRGB: "astc-6x6-unorm-srgb",
128
+ ASTC_8X5_UNORM: "astc-8x5-unorm",
129
+ ASTC_8X5_UNORM_SRGB: "astc-8x5-unorm-srgb",
130
+ ASTC_8X6_UNORM: "astc-8x6-unorm",
131
+ ASTC_8X6_UNORM_SRGB: "astc-8x6-unorm-srgb",
132
+ ASTC_8X8_UNORM: "astc-8x8-unorm",
133
+ ASTC_8X8_UNORM_SRGB: "astc-8x8-unorm-srgb",
134
+ ASTC_10X5_UNORM: "astc-10x5-unorm",
135
+ ASTC_10X5_UNORM_SRGB: "astc-10x5-unorm-srgb",
136
+ ASTC_10X6_UNORM: "astc-10x6-unorm",
137
+ ASTC_10X6_UNORM_SRGB: "astc-10x6-unorm-srgb",
138
+ ASTC_10X8_UNORM: "astc-10x8-unorm",
139
+ ASTC_10X8_UNORM_SRGB: "astc-10x8-unorm-srgb",
140
+ ASTC_10X10_UNORM: "astc-10x10-unorm",
141
+ ASTC_10X10_UNORM_SRGB: "astc-10x10-unorm-srgb",
142
+ ASTC_12X10_UNORM: "astc-12x10-unorm",
143
+ ASTC_12X10_UNORM_SRGB: "astc-12x10-unorm-srgb",
144
+ ASTC_12X12_UNORM: "astc-12x12-unorm",
145
+ ASTC_12X12_UNORM_SRGB: "astc-12x12-unorm-srgb",
146
+ };
@@ -18,6 +18,21 @@ export function gpu_texture_format_info(format: GPUTextureFormat): GPUTextureFor
18
18
  * @returns {GPUTextureFormat[]}
19
19
  */
20
20
  export function gpu_texture_format_names(): GPUTextureFormat[];
21
+ /**
22
+ * Whether `format` stores more than one texel per block.
23
+ *
24
+ * The one question the plain `block_width !== 1 || block_height !== 1` answers, and it was written
25
+ * out inline in three places — {@link SoftwareGPUTexture.bytes_per_texel},
26
+ * {@link gpu_texture_format_can_generate_mipmaps} and {@link download_texture_data} — each of which
27
+ * needs it to refuse something. A container reader asking "may this file even be a 3D texture" makes
28
+ * four, which is the count at which the same arithmetic in four places has already gone wrong once in
29
+ * this tree.
30
+ *
31
+ * @param {GPUTextureFormat} format
32
+ * @returns {boolean}
33
+ * @throws {Error} for a name that is not a GPUTextureFormat
34
+ */
35
+ export function gpu_texture_format_is_block_compressed(format: GPUTextureFormat): boolean;
21
36
  /**
22
37
  * Bytes one row of `width` texels occupies, tightly packed.
23
38
  *
@@ -37,6 +52,51 @@ export function gpu_texture_format_row_bytes(format: GPUTextureFormat, width: nu
37
52
  * @returns {number}
38
53
  */
39
54
  export function gpu_texture_format_row_count(format: GPUTextureFormat, height: number): number;
55
+ /**
56
+ * Bytes one mip level occupies, tightly packed, all its layers included.
57
+ *
58
+ * The composition of {@link gpu_texture_format_row_bytes} and
59
+ * {@link gpu_texture_format_row_count} — which is trivial, and was written out in four places before
60
+ * it was written down in one.
61
+ *
62
+ * @param {GPUTextureFormat} format
63
+ * @param {number} width texels, at this level
64
+ * @param {number} height texels, at this level
65
+ * @param {number} depth_or_layers at this level
66
+ * @returns {number} bytes
67
+ */
68
+ export function gpu_texture_format_level_bytes(format: GPUTextureFormat, width: number, height: number, depth_or_layers: number): number;
69
+ /**
70
+ * Bytes a whole texture occupies, mip chain included.
71
+ *
72
+ * Block-aware, which is the point: `channels × bytes_per_channel × width × height` is right only for
73
+ * the 1×1-block formats and reports nonsense — or, where the caller consults a per-channel table
74
+ * that has no entry, zero — for every BC, ETC2 and ASTC format.
75
+ *
76
+ * **Only a 3D texture's depth halves per level.** The third component of an array texture's size is
77
+ * its layer count, and every layer has every mip; halving it under-reports a six-layer cube map by
78
+ * close to half. Hence `dimension`, which both descriptors that call this already carry.
79
+ *
80
+ * Every argument is required. There is no sensible default for a mip count or a sample count — a
81
+ * caller that does not know them is not in a position to ask this question, and a defaulted `1`
82
+ * would answer a different one convincingly.
83
+ *
84
+ * An estimate, in that a driver may pad, align or compress behind the API. Usually exact, and close
85
+ * when it is not.
86
+ *
87
+ * @param {GPUTextureFormat} format
88
+ * @param {ArrayLike<number>} size `[width, height, depthOrArrayLayers]` in texels. Read by index,
89
+ * and floored — `TextureResourceDescriptor.resolution` is a `Float64Array`
90
+ * @param {GPUTextureDimension|string} dimension `"3d"` makes the third component a depth that
91
+ * halves per level; anything else makes it a layer count that does not
92
+ * @param {number} mip_level_count
93
+ * @param {number} sample_count
94
+ * @returns {number} bytes
95
+ * @throws {Error} for a name that is not a GPUTextureFormat — see {@link gpu_texture_format_info}.
96
+ * A caller that would rather report something than fail (a profile capture, a memory readout) is the
97
+ * one placed to decide that, and says so where it catches
98
+ */
99
+ export function gpu_texture_format_memory_footprint(format: GPUTextureFormat, size: ArrayLike<number>, dimension: GPUTextureDimension | string, mip_level_count: number, sample_count: number): number;
40
100
  /**
41
101
  * What one texel block of a {@link GPUTextureFormat } is.
42
102
  *
@@ -1 +1 @@
1
- {"version":3,"file":"gpu_texture_format_info.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/descriptor/texture/format/gpu_texture_format_info.js"],"names":[],"mappings":"AA+MA;;;;;;;;;;;;GAYG;AACH,mEAJa,oBAAoB,CAYhC;AAED;;;;GAIG;AACH,4CAFa,kBAAkB,CAI9B;AAED;;;;;;;;;GASG;AACH,8EAHW,MAAM,GACJ,MAAM,CAMlB;AAED;;;;;;GAMG;AACH,+EAHW,MAAM,GACJ,MAAM,CAMlB;;;;;;;;;;;;iBAlQa,MAAM;;;;kBACN,MAAM;;;;qBACN,MAAM;;;;;aACN,kBAAkB;;;;;cAElB,OAAO"}
1
+ {"version":3,"file":"gpu_texture_format_info.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/descriptor/texture/format/gpu_texture_format_info.js"],"names":[],"mappings":"AAkNA;;;;;;;;;;;;GAYG;AACH,mEAJa,oBAAoB,CAYhC;AAED;;;;GAIG;AACH,4CAFa,kBAAkB,CAI9B;AAED;;;;;;;;;;;;;GAaG;AACH,kFAHa,OAAO,CAOnB;AAED;;;;;;;;;GASG;AACH,8EAHW,MAAM,GACJ,MAAM,CAMlB;AAED;;;;;;GAMG;AACH,+EAHW,MAAM,GACJ,MAAM,CAMlB;AAED;;;;;;;;;;;;GAYG;AACH,gFALW,MAAM,UACN,MAAM,mBACN,MAAM,GACJ,MAAM,CAMlB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,oFAXW,UAAU,MAAM,CAAC,aAEjB,sBAAoB,MAAM,mBAE1B,MAAM,gBACN,MAAM,GACJ,MAAM,CAiClB;;;;;;;;;;;;iBArWa,MAAM;;;;kBACN,MAAM;;;;qBACN,MAAM;;;;;aACN,kBAAkB;;;;;cAElB,OAAO"}
@@ -1,3 +1,6 @@
1
+ import { assert } from "../../../../core/assert.js";
2
+ import { texture_mip_extent } from "../../../util/texture_mip_extent.js";
3
+
1
4
  /**
2
5
  * What one texel block of a {@link GPUTextureFormat} is.
3
6
  *
@@ -237,6 +240,26 @@ export function gpu_texture_format_names() {
237
240
  return Object.keys(FORMATS);
238
241
  }
239
242
 
243
+ /**
244
+ * Whether `format` stores more than one texel per block.
245
+ *
246
+ * The one question the plain `block_width !== 1 || block_height !== 1` answers, and it was written
247
+ * out inline in three places — {@link SoftwareGPUTexture.bytes_per_texel},
248
+ * {@link gpu_texture_format_can_generate_mipmaps} and {@link download_texture_data} — each of which
249
+ * needs it to refuse something. A container reader asking "may this file even be a 3D texture" makes
250
+ * four, which is the count at which the same arithmetic in four places has already gone wrong once in
251
+ * this tree.
252
+ *
253
+ * @param {GPUTextureFormat} format
254
+ * @returns {boolean}
255
+ * @throws {Error} for a name that is not a GPUTextureFormat
256
+ */
257
+ export function gpu_texture_format_is_block_compressed(format) {
258
+ const info = gpu_texture_format_info(format);
259
+
260
+ return info.block_width !== 1 || info.block_height !== 1;
261
+ }
262
+
240
263
  /**
241
264
  * Bytes one row of `width` texels occupies, tightly packed.
242
265
  *
@@ -265,3 +288,82 @@ export function gpu_texture_format_row_count(format, height) {
265
288
 
266
289
  return Math.ceil(height / info.block_height);
267
290
  }
291
+
292
+ /**
293
+ * Bytes one mip level occupies, tightly packed, all its layers included.
294
+ *
295
+ * The composition of {@link gpu_texture_format_row_bytes} and
296
+ * {@link gpu_texture_format_row_count} — which is trivial, and was written out in four places before
297
+ * it was written down in one.
298
+ *
299
+ * @param {GPUTextureFormat} format
300
+ * @param {number} width texels, at this level
301
+ * @param {number} height texels, at this level
302
+ * @param {number} depth_or_layers at this level
303
+ * @returns {number} bytes
304
+ */
305
+ export function gpu_texture_format_level_bytes(format, width, height, depth_or_layers) {
306
+ return gpu_texture_format_row_bytes(format, width)
307
+ * gpu_texture_format_row_count(format, height)
308
+ * depth_or_layers;
309
+ }
310
+
311
+ /**
312
+ * Bytes a whole texture occupies, mip chain included.
313
+ *
314
+ * Block-aware, which is the point: `channels × bytes_per_channel × width × height` is right only for
315
+ * the 1×1-block formats and reports nonsense — or, where the caller consults a per-channel table
316
+ * that has no entry, zero — for every BC, ETC2 and ASTC format.
317
+ *
318
+ * **Only a 3D texture's depth halves per level.** The third component of an array texture's size is
319
+ * its layer count, and every layer has every mip; halving it under-reports a six-layer cube map by
320
+ * close to half. Hence `dimension`, which both descriptors that call this already carry.
321
+ *
322
+ * Every argument is required. There is no sensible default for a mip count or a sample count — a
323
+ * caller that does not know them is not in a position to ask this question, and a defaulted `1`
324
+ * would answer a different one convincingly.
325
+ *
326
+ * An estimate, in that a driver may pad, align or compress behind the API. Usually exact, and close
327
+ * when it is not.
328
+ *
329
+ * @param {GPUTextureFormat} format
330
+ * @param {ArrayLike<number>} size `[width, height, depthOrArrayLayers]` in texels. Read by index,
331
+ * and floored — `TextureResourceDescriptor.resolution` is a `Float64Array`
332
+ * @param {GPUTextureDimension|string} dimension `"3d"` makes the third component a depth that
333
+ * halves per level; anything else makes it a layer count that does not
334
+ * @param {number} mip_level_count
335
+ * @param {number} sample_count
336
+ * @returns {number} bytes
337
+ * @throws {Error} for a name that is not a GPUTextureFormat — see {@link gpu_texture_format_info}.
338
+ * A caller that would rather report something than fail (a profile capture, a memory readout) is the
339
+ * one placed to decide that, and says so where it catches
340
+ */
341
+ export function gpu_texture_format_memory_footprint(
342
+ format,
343
+ size,
344
+ dimension,
345
+ mip_level_count,
346
+ sample_count
347
+ ) {
348
+ assert.isArrayLike(size, 'size');
349
+ assert.isString(dimension, 'dimension');
350
+ assert.isNonNegativeInteger(mip_level_count, 'mip_level_count');
351
+ assert.isNonNegativeInteger(sample_count, 'sample_count');
352
+
353
+ // throws here rather than inside the loop, for a name that is not a GPUTextureFormat
354
+ gpu_texture_format_info(format);
355
+
356
+ const width = Math.floor(size[0]);
357
+ const height = Math.floor(size[1]);
358
+ const depth_or_layers = Math.floor(size[2]);
359
+
360
+ let total = 0;
361
+
362
+ for (let mip = 0; mip < mip_level_count; mip++) {
363
+ const extent = texture_mip_extent(width, height, depth_or_layers, dimension, mip);
364
+
365
+ total += gpu_texture_format_level_bytes(format, extent[0], extent[1], extent[2]);
366
+ }
367
+
368
+ return total * sample_count;
369
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"TextureResourceDescriptor.d.ts","sourceRoot":"","sources":["../../../../../src/shade/device/graph/TextureResourceDescriptor.js"],"names":[],"mappings":";;;sCAeU,MAAM;;;;;AAOhB;IAmCI;;;;;;;;OAQG;IACH,kEAPW,MAAM,EAAE,GAKN,yBAAyB,CA8BrC;IAED;;;;OAIG;IACH,yCAFa,yBAAyB,CAoBrC;IAhGD;;;;;;;;;OASG;IACH,mBAFU,uBAAuB,GAAC,MAAM,CAEyB;IAGjE,yBAAyC;IACzC,oBAAgB;IAEhB,sBAAkB;IAElB;;;OAGG;IACH,WAFU,sBAAoB,MAAM,CAEpB;IAEhB;;OAEG;IACH,QAFU,MAAM,mBAAiB,CAEX;IAEtB;;OAEG;IACH,OAFU,MAAM,uBAAqB,CAEG;IAiFxC;;;;OAIG;IACH,cAHW,yBAAyB,GACvB,OAAO,CAWnB;CAKJ;mCAnJM,4EAA4E"}
1
+ {"version":3,"file":"TextureResourceDescriptor.d.ts","sourceRoot":"","sources":["../../../../../src/shade/device/graph/TextureResourceDescriptor.js"],"names":[],"mappings":";;;sCAgBU,MAAM;;;;;AAOhB;IAmCI;;;;;;;;OAQG;IACH,kEAPW,MAAM,EAAE,GAKN,yBAAyB,CAkCrC;IAED;;;;OAIG;IACH,yCAFa,yBAAyB,CAoBrC;IApGD;;;;;;;;;OASG;IACH,mBAFU,uBAAuB,GAAC,MAAM,CAEyB;IAGjE,yBAAyC;IACzC,oBAAgB;IAEhB,sBAAkB;IAElB;;;OAGG;IACH,WAFU,sBAAoB,MAAM,CAEpB;IAEhB;;OAEG;IACH,QAFU,MAAM,mBAAiB,CAEX;IAEtB;;OAEG;IACH,OAFU,MAAM,uBAAqB,CAEG;IAqFxC;;;;OAIG;IACH,cAHW,yBAAyB,GACvB,OAAO,CAWnB;CAKJ;mCAxJM,4EAA4E"}