@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
@@ -1,156 +1,161 @@
1
- import { assert } from "../../../core/assert.js";
2
- import { array_copy } from "../../../core/collection/array/array_copy.js";
3
- import { combine_hash } from "../../../core/collection/array/combine_hash.js";
4
- import { isArrayEqualStrict } from "../../../core/collection/array/isArrayEqualStrict.js";
5
- import { computeHashFloatArray } from "../../../core/math/hash/computeHashFloatArray.js";
6
- import { computeStringHash } from "../../../core/primitives/strings/computeStringHash.js";
7
- import {
8
- ResourceDescriptor
9
- } from "../../../engine/graphics/render/frame_graph/resource/ResourceDescriptor.js";
10
- import { compute_max_mip_count } from "../../util/compute_max_mip_count.js";
11
- import { decode_bitmask_enum } from "../decode_bitmask_enum.js";
12
-
13
- /**
14
- * **Vestigial.** Nothing branches on it — see {@link TextureResourceDescriptor.resolution_domain}.
15
- *
16
- * @enum {number}
17
- */
18
- export const TextureResolutionDomain = {
19
- Absolute: 0,
20
- PresentationRelative: 1
21
- }
22
-
23
- export class TextureResourceDescriptor extends ResourceDescriptor {
24
- /**
25
- * **Vestigial. Do not read this to decide how to interpret {@link resolution}.**
26
- *
27
- * No code branches on it; only {@link hash} folds it in. {@link from} stores whatever
28
- * resolution it is given without touching this field, and every caller gives it pixels — so a
29
- * descriptor's resolution is absolute pixels whatever this says, including on the default
30
- * `PresentationRelative` that {@link from} leaves in place.
31
- *
32
- * @type {TextureResolutionDomain|number}
33
- */
34
- resolution_domain = TextureResolutionDomain.PresentationRelative;
35
-
36
- // TODO use Uint32 instead
37
- resolution = new Float64Array([1, 1, 1]);
38
- sampleCount = 1;
39
-
40
- mipLevelCount = 1;
41
-
42
- /**
43
- *
44
- * @type {GPUTextureDimension|string}
45
- */
46
- dimension = "2d"
47
-
48
- /**
49
- * @type {string|GPUTextureFormat}
50
- */
51
- format = "rgba8unorm";
52
-
53
- /**
54
- * @type {number|GPUTextureUsageFlags}
55
- */
56
- usage = GPUTextureUsage.TEXTURE_BINDING;
57
-
58
- /**
59
- *
60
- * @param {number[]} resolution
61
- * @param {GPUTextureDimension|string} [dimension]
62
- * @param {GPUTextureFormat|string} format
63
- * @param {GPUTextureUsageFlags|number} [usage]
64
- * @param {boolean} [enableMips]
65
- * @returns {TextureResourceDescriptor}
66
- */
67
- static from({
68
- resolution,
69
- dimension = "2d",
70
- format,
71
- usage = GPUTextureUsage.TEXTURE_BINDING,
72
- enableMips = false
73
- }) {
74
-
75
- assert.isString(format, 'format');
76
- assert.defined(resolution, 'resolution');
77
- assert.isArrayLike(resolution, 'resolution');
78
- assert.isBoolean(enableMips, 'enableMips');
79
-
80
- const r = new TextureResourceDescriptor();
81
-
82
- array_copy(resolution, 0, r.resolution, 0, Math.min(r.resolution.length, resolution.length));
83
- r.dimension = dimension;
84
- r.format = format;
85
- r.usage = usage;
86
-
87
- if (enableMips === true) {
88
-
89
- r.mipLevelCount = compute_max_mip_count(resolution[0], resolution[1]);
90
-
91
- }
92
-
93
- return r;
94
-
95
- }
96
-
97
- /**
98
- *
99
- * @param {GPUTexture} texture
100
- * @returns {TextureResourceDescriptor}
101
- */
102
- static fromTexture(texture) {
103
- const r = new TextureResourceDescriptor();
104
-
105
- r.format = texture.format;
106
- r.dimension = texture.dimension;
107
-
108
- r.usage = texture.usage;
109
- r.sampleCount = texture.sampleCount;
110
- r.resolution_domain = TextureResolutionDomain.Absolute;
111
-
112
- r.resolution[0] = texture.width;
113
- r.resolution[1] = texture.height;
114
- r.resolution[2] = texture.depthOrArrayLayers;
115
-
116
-
117
- r.mipLevelCount = texture.mipLevelCount;
118
-
119
- return r;
120
- }
121
-
122
- get type() {
123
- return "texture";
124
- }
125
-
126
- hash() {
127
- return combine_hash(
128
- this.resolution_domain,
129
- this.mipLevelCount,
130
- computeHashFloatArray(this.resolution),
131
- this.sampleCount,
132
- this.usage,
133
- computeStringHash(this.format)
134
- );
135
- }
136
-
137
- /**
138
- *
139
- * @param {TextureResourceDescriptor} other
140
- * @returns {boolean}
141
- */
142
- equals(other) {
143
- return isArrayEqualStrict(this.resolution, other.resolution)
144
- && this.mipLevelCount === other.mipLevelCount
145
- && this.resolution_domain === other.resolution_domain
146
- && this.sampleCount === other.sampleCount
147
- && this.dimension === other.dimension
148
- && this.format === other.format
149
- && this.usage === other.usage
150
- ;
151
- }
152
-
153
- toString() {
154
- return `Texture{ resolution = [${this.resolution.join(",")}], mipLevelCount = ${this.mipLevelCount}, dimension = ${this.dimension}, format = ${this.format}, usage = ${decode_bitmask_enum(this.usage, GPUTextureUsage).join(' | ')}, sampleCount = ${this.sampleCount} }`;
155
- }
1
+ import { assert } from "../../../core/assert.js";
2
+ import { array_copy } from "../../../core/collection/array/array_copy.js";
3
+ import { combine_hash } from "../../../core/collection/array/combine_hash.js";
4
+ import { isArrayEqualStrict } from "../../../core/collection/array/isArrayEqualStrict.js";
5
+ import { computeHashFloatArray } from "../../../core/math/hash/computeHashFloatArray.js";
6
+ import { computeStringHash } from "../../../core/primitives/strings/computeStringHash.js";
7
+ import {
8
+ ResourceDescriptor
9
+ } from "../../../engine/graphics/render/frame_graph/resource/ResourceDescriptor.js";
10
+ import { texture_mip_level_count } from "../../util/texture_mip_extent.js";
11
+ import { decode_bitmask_enum } from "../decode_bitmask_enum.js";
12
+ import { GPUTextureUsage } from "../../descriptor/GPUTextureUsage.js";
13
+
14
+ /**
15
+ * **Vestigial.** Nothing branches on it — see {@link TextureResourceDescriptor.resolution_domain}.
16
+ *
17
+ * @enum {number}
18
+ */
19
+ export const TextureResolutionDomain = {
20
+ Absolute: 0,
21
+ PresentationRelative: 1
22
+ }
23
+
24
+ export class TextureResourceDescriptor extends ResourceDescriptor {
25
+ /**
26
+ * **Vestigial. Do not read this to decide how to interpret {@link resolution}.**
27
+ *
28
+ * No code branches on it; only {@link hash} folds it in. {@link from} stores whatever
29
+ * resolution it is given without touching this field, and every caller gives it pixels — so a
30
+ * descriptor's resolution is absolute pixels whatever this says, including on the default
31
+ * `PresentationRelative` that {@link from} leaves in place.
32
+ *
33
+ * @type {TextureResolutionDomain|number}
34
+ */
35
+ resolution_domain = TextureResolutionDomain.PresentationRelative;
36
+
37
+ // TODO use Uint32 instead
38
+ resolution = new Float64Array([1, 1, 1]);
39
+ sampleCount = 1;
40
+
41
+ mipLevelCount = 1;
42
+
43
+ /**
44
+ *
45
+ * @type {GPUTextureDimension|string}
46
+ */
47
+ dimension = "2d"
48
+
49
+ /**
50
+ * @type {string|GPUTextureFormat}
51
+ */
52
+ format = "rgba8unorm";
53
+
54
+ /**
55
+ * @type {number|GPUTextureUsageFlags}
56
+ */
57
+ usage = GPUTextureUsage.TEXTURE_BINDING;
58
+
59
+ /**
60
+ *
61
+ * @param {number[]} resolution
62
+ * @param {GPUTextureDimension|string} [dimension]
63
+ * @param {GPUTextureFormat|string} format
64
+ * @param {GPUTextureUsageFlags|number} [usage]
65
+ * @param {boolean} [enableMips]
66
+ * @returns {TextureResourceDescriptor}
67
+ */
68
+ static from({
69
+ resolution,
70
+ dimension = "2d",
71
+ format,
72
+ usage = GPUTextureUsage.TEXTURE_BINDING,
73
+ enableMips = false
74
+ }) {
75
+
76
+ assert.isString(format, 'format');
77
+ assert.defined(resolution, 'resolution');
78
+ assert.isArrayLike(resolution, 'resolution');
79
+ assert.isBoolean(enableMips, 'enableMips');
80
+
81
+ const r = new TextureResourceDescriptor();
82
+
83
+ array_copy(resolution, 0, r.resolution, 0, Math.min(r.resolution.length, resolution.length));
84
+ r.dimension = dimension;
85
+ r.format = format;
86
+ r.usage = usage;
87
+
88
+ if (enableMips === true) {
89
+
90
+ // `r.resolution` rather than the argument: it has already been padded to three, so a
91
+ // caller that gave two axes reads as depth 1 instead of `undefined`
92
+ r.mipLevelCount = texture_mip_level_count(
93
+ r.resolution[0], r.resolution[1], r.resolution[2], r.dimension
94
+ );
95
+
96
+ }
97
+
98
+ return r;
99
+
100
+ }
101
+
102
+ /**
103
+ *
104
+ * @param {GPUTexture} texture
105
+ * @returns {TextureResourceDescriptor}
106
+ */
107
+ static fromTexture(texture) {
108
+ const r = new TextureResourceDescriptor();
109
+
110
+ r.format = texture.format;
111
+ r.dimension = texture.dimension;
112
+
113
+ r.usage = texture.usage;
114
+ r.sampleCount = texture.sampleCount;
115
+ r.resolution_domain = TextureResolutionDomain.Absolute;
116
+
117
+ r.resolution[0] = texture.width;
118
+ r.resolution[1] = texture.height;
119
+ r.resolution[2] = texture.depthOrArrayLayers;
120
+
121
+
122
+ r.mipLevelCount = texture.mipLevelCount;
123
+
124
+ return r;
125
+ }
126
+
127
+ get type() {
128
+ return "texture";
129
+ }
130
+
131
+ hash() {
132
+ return combine_hash(
133
+ this.resolution_domain,
134
+ this.mipLevelCount,
135
+ computeHashFloatArray(this.resolution),
136
+ this.sampleCount,
137
+ this.usage,
138
+ computeStringHash(this.format)
139
+ );
140
+ }
141
+
142
+ /**
143
+ *
144
+ * @param {TextureResourceDescriptor} other
145
+ * @returns {boolean}
146
+ */
147
+ equals(other) {
148
+ return isArrayEqualStrict(this.resolution, other.resolution)
149
+ && this.mipLevelCount === other.mipLevelCount
150
+ && this.resolution_domain === other.resolution_domain
151
+ && this.sampleCount === other.sampleCount
152
+ && this.dimension === other.dimension
153
+ && this.format === other.format
154
+ && this.usage === other.usage
155
+ ;
156
+ }
157
+
158
+ toString() {
159
+ return `Texture{ resolution = [${this.resolution.join(",")}], mipLevelCount = ${this.mipLevelCount}, dimension = ${this.dimension}, format = ${this.format}, usage = ${decode_bitmask_enum(this.usage, GPUTextureUsage).join(' | ')}, sampleCount = ${this.sampleCount} }`;
160
+ }
156
161
  }
@@ -19,10 +19,17 @@ export class SoftwareGPUQueue implements GPUQueue {
19
19
  */
20
20
  writeBuffer(buffer: GPUBuffer, bufferOffset: number, data: BufferSource, dataOffset?: number, size?: number): void;
21
21
  /**
22
- * 2D single-layer subset of {@link GPUQueue#writeTexture}: copies rows
23
- * from a BufferSource into the destination mip's lazily-allocated
24
- * storage. `dataLayout.offset` is in bytes (spec), `bytesPerRow`
25
- * defaults to a tightly-packed row.
22
+ * Emulates {@link GPUQueue#writeTexture}: copies rows of texel blocks from a BufferSource into
23
+ * the destination mip's lazily-allocated storage.
24
+ *
25
+ * The same operation as {@link SoftwareGPUCommandEncoder#copyBufferToTexture} with the bytes
26
+ * supplied inline rather than through a `GPUBuffer`, and it runs on the same two functions —
27
+ * which is what makes it block-aware, multi-layer and `rowsPerImage`-honouring rather than the
28
+ * 2D single-layer `bytes_per_texel` subset it used to be. A BC7 write is not a special case here;
29
+ * it is the same row loop over a row that happens to be four texels tall.
30
+ *
31
+ * `dataLayout.offset` is in bytes (spec), `bytesPerRow` defaults to a tightly packed row of
32
+ * blocks.
26
33
  *
27
34
  * @param {GPUTexelCopyTextureInfo} destination
28
35
  * @param {BufferSource} data
@@ -1 +1 @@
1
- {"version":3,"file":"SoftwareGPUQueue.d.ts","sourceRoot":"","sources":["../../../../../src/shade/device/mock/SoftwareGPUQueue.js"],"names":[],"mappings":"AA2DA;;;GAGG;AACH,yCAFgB,QAAQ;IAYpB;;OAEG;IACH,uCAEC;IAoDD;;;;;;;;;OASG;IACH,6CALW,MAAM,QACN,YAAY,eACZ,MAAM,SACN,MAAM,QA6ChB;IAED;;;;;;;;;;OAUG;IACH,yDAJW,YAAY,iEAiDtB;IAED;;;;;;;;;;;;;OAaG;IACH,2IAmEC;IAED;;;OAGG;IACH,uBAFW,0BAA0B,QA0BpC;IAED;;;;;;OAMG;IACH,uBAFa,QAAQ,SAAS,CAAC,CAI9B;;CACJ"}
1
+ {"version":3,"file":"SoftwareGPUQueue.d.ts","sourceRoot":"","sources":["../../../../../src/shade/device/mock/SoftwareGPUQueue.js"],"names":[],"mappings":"AA4DA;;;GAGG;AACH,yCAFgB,QAAQ;IAYpB;;OAEG;IACH,uCAEC;IAoDD;;;;;;;;;OASG;IACH,6CALW,MAAM,QACN,YAAY,eACZ,MAAM,SACN,MAAM,QA6ChB;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,yDAJW,YAAY,iEAmCtB;IAED;;;;;;;;;;;;;OAaG;IACH,2IAmEC;IAED;;;OAGG;IACH,uBAFW,0BAA0B,QA0BpC;IAED;;;;;;OAMG;IACH,uBAFa,QAAQ,SAAS,CAAC,CAI9B;;CACJ"}
@@ -1,5 +1,6 @@
1
1
  import { assert } from "../../../core/assert.js";
2
2
  import { array_buffer_copy } from "../../../core/collection/array/typed/array_buffer_copy.js";
3
+ import { texture_copy_execute, texture_copy_refusal } from "./texture_copy.js";
3
4
  import { SoftwareGPUValidationError } from "./SoftwareGPUError.js";
4
5
 
5
6
  /**
@@ -184,10 +185,17 @@ export class SoftwareGPUQueue {
184
185
  }
185
186
 
186
187
  /**
187
- * 2D single-layer subset of {@link GPUQueue#writeTexture}: copies rows
188
- * from a BufferSource into the destination mip's lazily-allocated
189
- * storage. `dataLayout.offset` is in bytes (spec), `bytesPerRow`
190
- * defaults to a tightly-packed row.
188
+ * Emulates {@link GPUQueue#writeTexture}: copies rows of texel blocks from a BufferSource into
189
+ * the destination mip's lazily-allocated storage.
190
+ *
191
+ * The same operation as {@link SoftwareGPUCommandEncoder#copyBufferToTexture} with the bytes
192
+ * supplied inline rather than through a `GPUBuffer`, and it runs on the same two functions —
193
+ * which is what makes it block-aware, multi-layer and `rowsPerImage`-honouring rather than the
194
+ * 2D single-layer `bytes_per_texel` subset it used to be. A BC7 write is not a special case here;
195
+ * it is the same row loop over a row that happens to be four texels tall.
196
+ *
197
+ * `dataLayout.offset` is in bytes (spec), `bytesPerRow` defaults to a tightly packed row of
198
+ * blocks.
191
199
  *
192
200
  * @param {GPUTexelCopyTextureInfo} destination
193
201
  * @param {BufferSource} data
@@ -199,46 +207,32 @@ export class SoftwareGPUQueue {
199
207
 
200
208
  assert.equal(texture.isSoftwareGPUTexture, true, 'texture.isSoftwareGPUTexture !== true');
201
209
 
202
- const texture_refusal = texture_write_refusal(texture);
210
+ /*
211
+ The destination half of a copy's validation, which is a superset of what this used to check
212
+ for itself: the same invalid/destroyed/COPY_DST refusals, and additionally a format WebGPU
213
+ forbids copies of, a mip outside the chain, and a region past the edge of it.
214
+ */
215
+ const refusal = texture_copy_refusal({ texture_destination: destination, size });
203
216
 
204
- if (texture_refusal !== null) {
205
- this.#device.generate_error(new SoftwareGPUValidationError(`writeTexture: ${texture_refusal}`));
217
+ if (refusal !== null) {
218
+ this.#device.generate_error(new SoftwareGPUValidationError(`writeTexture: ${refusal}`));
206
219
 
207
220
  return;
208
221
  }
209
222
 
210
- const width = size.width ?? size[0] ?? 1;
211
- const height = size.height ?? size[1] ?? 1;
212
- const depth = size.depthOrArrayLayers ?? size[2] ?? 1;
213
-
214
- assert.equal(depth, 1, 'only single-layer writes are emulated');
215
-
216
- const mip = destination.mipLevel ?? 0;
217
- const origin_x = destination.origin?.x ?? destination.origin?.[0] ?? 0;
218
- const origin_y = destination.origin?.y ?? destination.origin?.[1] ?? 0;
219
-
220
- const bytes_per_texel = texture.bytes_per_texel;
221
-
222
223
  const source = normalize_buffer_source(data);
223
224
 
224
- const source_offset = source.byteOffset + (dataLayout?.offset ?? 0);
225
- const bytes_per_row = dataLayout?.bytesPerRow ?? width * bytes_per_texel;
226
-
227
- const mip_data = texture.get_mip_data(mip);
228
- const dst_stride = texture.mip_width(mip) * bytes_per_texel;
229
-
230
- assert.lessThanOrEqual(origin_x + width, texture.mip_width(mip), 'write exceeds mip width');
231
- assert.lessThanOrEqual(origin_y + height, texture.mip_height(mip), 'write exceeds mip height');
232
-
233
- for (let row = 0; row < height; row++) {
234
- array_buffer_copy(
235
- source.buffer,
236
- source_offset + row * bytes_per_row,
237
- mip_data,
238
- (origin_y + row) * dst_stride + origin_x * bytes_per_texel,
239
- width * bytes_per_texel
240
- );
241
- }
225
+ texture_copy_execute({
226
+ buffer_source: {
227
+ // the inline bytes, in the shape the buffer endpoint reads
228
+ buffer: { data: source.buffer },
229
+ offset: source.byteOffset + (dataLayout?.offset ?? 0),
230
+ bytesPerRow: dataLayout?.bytesPerRow,
231
+ rowsPerImage: dataLayout?.rowsPerImage,
232
+ },
233
+ texture_destination: destination,
234
+ size,
235
+ });
242
236
  }
243
237
 
244
238
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"SoftwareGPUTexture.d.ts","sourceRoot":"","sources":["../../../../../src/shade/device/mock/SoftwareGPUTexture.js"],"names":[],"mappings":"AAQA;;;;;;;;;GASG;AACH,yEAFgB,UAAU;IA+CtB;;;;;OAKG;IACH,kDAFa,kBAAkB,CAI9B;IA/BD;;;OAGG;IACH,sDAFW,OAAO,EAmBjB;IAtCD;;;;;;OAMG;IACH,uBAEC;IAoBG,WAAuC;IACvC,YAAyC;IACzC,wBAAiE;IAEjE,YAA+B;IAC/B,eAA6C;IAC7C,WAA6B;IAC7B,iBAA8C;IAC9C,mBAAkD;IAatD;;OAEG;IACH,2BAEC;IAED;;;;OAIG;IACH,wCAEC;IAED;;;;;;;;;OASG;IACH,8BAUC;IAED;;;OAGG;IACH,eAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;OAGG;IACH,gBAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,gBAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,gBAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;OAKG;IACH,kBAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,mBAHW,MAAM,GACJ,WAAW,CAgBvB;IAED;;;OAGG;IACH,kEAMC;IAED;;;OAGG;IACH,gBAOC;IAGL;;;OAGG;IACH,+BAFU,OAAO,CAEgC;;CANhD;sCAzMqC,4BAA4B"}
1
+ {"version":3,"file":"SoftwareGPUTexture.d.ts","sourceRoot":"","sources":["../../../../../src/shade/device/mock/SoftwareGPUTexture.js"],"names":[],"mappings":"AAWA;;;;;;;;;GASG;AACH,yEAFgB,UAAU;IA+CtB;;;;;OAKG;IACH,kDAFa,kBAAkB,CAI9B;IA/BD;;;OAGG;IACH,sDAFW,OAAO,EAmBjB;IAtCD;;;;;;OAMG;IACH,uBAEC;IAoBG,WAAuC;IACvC,YAAyC;IACzC,wBAAiE;IAEjE,YAA+B;IAC/B,eAA6C;IAC7C,WAA6B;IAC7B,iBAA8C;IAC9C,mBAAkD;IAatD;;OAEG;IACH,2BAEC;IAED;;;;OAIG;IACH,wCAEC;IAED;;;;;;;;;OASG;IACH,8BAUC;IAED;;;OAGG;IACH,eAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;OAGG;IACH,gBAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,gBAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,gBAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;OAKG;IACH,kBAHW,MAAM,GACJ,MAAM,CAKlB;IAED;;;;;;OAMG;IACH,mBAHW,MAAM,GACJ,WAAW,CAgBvB;IAED;;;OAGG;IACH,kEAMC;IAED;;;OAGG;IACH,gBAOC;IAGL;;;OAGG;IACH,+BAFU,OAAO,CAEgC;;CANhD;sCA1MqC,4BAA4B"}
@@ -1,8 +1,11 @@
1
1
  import {
2
2
  gpu_texture_format_info,
3
+ gpu_texture_format_is_block_compressed,
4
+ gpu_texture_format_level_bytes,
3
5
  gpu_texture_format_row_bytes,
4
6
  gpu_texture_format_row_count
5
7
  } from "../../descriptor/texture/format/gpu_texture_format_info.js";
8
+ import { texture_mip_size } from "../../util/texture_mip_extent.js";
6
9
  import { SoftwareGPUObjectBase } from "./SoftwareGPUObjectBase.js";
7
10
  import { SoftwareGPUTextureView } from "./SoftwareGPUTextureView.js";
8
11
 
@@ -100,7 +103,7 @@ export class SoftwareGPUTexture extends SoftwareGPUObjectBase {
100
103
  get bytes_per_texel() {
101
104
  const info = this.format_info;
102
105
 
103
- if (info.block_width !== 1 || info.block_height !== 1) {
106
+ if (gpu_texture_format_is_block_compressed(this.format)) {
104
107
  throw new Error(
105
108
  `bytes_per_texel: '${this.format}' is block-compressed (${info.block_width}x${info.block_height}), use row_bytes instead`
106
109
  );
@@ -114,7 +117,7 @@ export class SoftwareGPUTexture extends SoftwareGPUObjectBase {
114
117
  * @returns {number}
115
118
  */
116
119
  mip_width(mip) {
117
- return Math.max(1, this.width >> mip);
120
+ return texture_mip_size(this.width, mip);
118
121
  }
119
122
 
120
123
  /**
@@ -122,7 +125,7 @@ export class SoftwareGPUTexture extends SoftwareGPUObjectBase {
122
125
  * @returns {number}
123
126
  */
124
127
  mip_height(mip) {
125
- return Math.max(1, this.height >> mip);
128
+ return texture_mip_size(this.height, mip);
126
129
  }
127
130
 
128
131
  /**
@@ -154,7 +157,8 @@ export class SoftwareGPUTexture extends SoftwareGPUObjectBase {
154
157
  * @returns {number}
155
158
  */
156
159
  layer_bytes(mip = 0) {
157
- return this.row_bytes(mip) * this.row_count(mip);
160
+ // one layer, hence the 1 — get_mip_data multiplies by depthOrArrayLayers itself
161
+ return gpu_texture_format_level_bytes(this.format, this.mip_width(mip), this.mip_height(mip), 1);
158
162
  }
159
163
 
160
164
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"frame_graph_extract_topology.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/device/timing/profile/frame_graph_extract_topology.js"],"names":[],"mappings":"AA+CA;;;;;;;;;;;;;;;;GAgBG;AACH,iEALa,kBAAkB,CAkH9B;mCArKM,yBAAyB"}
1
+ {"version":3,"file":"frame_graph_extract_topology.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/device/timing/profile/frame_graph_extract_topology.js"],"names":[],"mappings":"AAqCA;;;;;;;;;;;;;;;;GAgBG;AACH,iEALa,kBAAkB,CAkH9B;mCA3JM,yBAAyB"}