@woosh/meep-engine 3.79.0 → 3.80.0

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 (309) hide show
  1. package/CHANGELOG.md +62 -3
  2. package/README.md +1 -1
  3. package/package.json +1 -1
  4. package/src/format/image/webp/vp8/VP8BoolDecoder.d.ts +45 -0
  5. package/src/format/image/webp/vp8/VP8BoolDecoder.d.ts.map +1 -0
  6. package/src/format/image/webp/vp8/VP8BoolDecoder.js +137 -0
  7. package/src/format/image/webp/vp8/vp8_decode.d.ts +21 -0
  8. package/src/format/image/webp/vp8/vp8_decode.d.ts.map +1 -0
  9. package/src/format/image/webp/vp8/vp8_decode.js +756 -0
  10. package/src/format/image/webp/vp8/vp8_loop_filter.d.ts +31 -0
  11. package/src/format/image/webp/vp8/vp8_loop_filter.d.ts.map +1 -0
  12. package/src/format/image/webp/vp8/vp8_loop_filter.js +189 -0
  13. package/src/format/image/webp/vp8/vp8_predict.d.ts +48 -0
  14. package/src/format/image/webp/vp8/vp8_predict.d.ts.map +1 -0
  15. package/src/format/image/webp/vp8/vp8_predict.js +290 -0
  16. package/src/format/image/webp/vp8/vp8_tables.d.ts +34 -0
  17. package/src/format/image/webp/vp8/vp8_tables.d.ts.map +1 -0
  18. package/src/format/image/webp/vp8/vp8_tables.js +350 -0
  19. package/src/format/image/webp/vp8/vp8_transform.d.ts +22 -0
  20. package/src/format/image/webp/vp8/vp8_transform.d.ts.map +1 -0
  21. package/src/format/image/webp/vp8/vp8_transform.js +114 -0
  22. package/src/format/image/webp/vp8/vp8_yuv_to_rgba.d.ts +23 -0
  23. package/src/format/image/webp/vp8/vp8_yuv_to_rgba.d.ts.map +1 -0
  24. package/src/format/image/webp/vp8/vp8_yuv_to_rgba.js +133 -0
  25. package/src/format/image/webp/vp8l/VP8LBitReader.d.ts +47 -0
  26. package/src/format/image/webp/vp8l/VP8LBitReader.d.ts.map +1 -0
  27. package/src/format/image/webp/vp8l/VP8LBitReader.js +84 -0
  28. package/src/format/image/webp/vp8l/VP8LPrefixCode.d.ts +27 -0
  29. package/src/format/image/webp/vp8l/VP8LPrefixCode.d.ts.map +1 -0
  30. package/src/format/image/webp/vp8l/VP8LPrefixCode.js +184 -0
  31. package/src/format/image/webp/vp8l/vp8l_decode.d.ts +28 -0
  32. package/src/format/image/webp/vp8l/vp8l_decode.d.ts.map +1 -0
  33. package/src/format/image/webp/vp8l/vp8l_decode.js +261 -0
  34. package/src/format/image/webp/vp8l/vp8l_distance.d.ts +22 -0
  35. package/src/format/image/webp/vp8l/vp8l_distance.d.ts.map +1 -0
  36. package/src/format/image/webp/vp8l/vp8l_distance.js +62 -0
  37. package/src/format/image/webp/vp8l/vp8l_inverse_transforms.d.ts +50 -0
  38. package/src/format/image/webp/vp8l/vp8l_inverse_transforms.d.ts.map +1 -0
  39. package/src/format/image/webp/vp8l/vp8l_inverse_transforms.js +267 -0
  40. package/src/format/image/webp/vp8l/vp8l_read_prefix_code.d.ts +14 -0
  41. package/src/format/image/webp/vp8l/vp8l_read_prefix_code.d.ts.map +1 -0
  42. package/src/format/image/webp/vp8l/vp8l_read_prefix_code.js +99 -0
  43. package/src/format/image/webp/webp_decode.d.ts +23 -0
  44. package/src/format/image/webp/webp_decode.d.ts.map +1 -0
  45. package/src/format/image/webp/webp_decode.js +179 -0
  46. package/src/format/image/webp/webp_decode_alpha.d.ts +18 -0
  47. package/src/format/image/webp/webp_decode_alpha.d.ts.map +1 -0
  48. package/src/format/image/webp/webp_decode_alpha.js +84 -0
  49. package/src/format/texture/{basis → astc}/astc_block.d.ts +41 -0
  50. package/src/format/texture/astc/astc_block.d.ts.map +1 -0
  51. package/src/format/texture/{basis → astc}/astc_block.js +284 -164
  52. package/src/format/texture/astc/astc_decode_block.d.ts +68 -0
  53. package/src/format/texture/astc/astc_decode_block.d.ts.map +1 -0
  54. package/src/format/texture/astc/astc_decode_block.js +1119 -0
  55. package/src/format/texture/astc/astc_encode_block_4x4.d.ts +32 -0
  56. package/src/format/texture/astc/astc_encode_block_4x4.d.ts.map +1 -0
  57. package/src/format/texture/astc/astc_encode_block_4x4.js +181 -0
  58. package/src/format/texture/astc/astc_encode_block_4x4_rgba.d.ts +32 -0
  59. package/src/format/texture/astc/astc_encode_block_4x4_rgba.d.ts.map +1 -0
  60. package/src/format/texture/astc/astc_encode_block_4x4_rgba.js +337 -0
  61. package/src/format/texture/astc/astc_integer_sequence.d.ts.map +1 -0
  62. package/src/format/texture/{basis → astc}/astc_integer_sequence.js +251 -251
  63. package/src/format/texture/astc/astc_partition.d.ts.map +1 -0
  64. package/src/format/texture/{basis → astc}/astc_partition.js +199 -199
  65. package/src/format/texture/basis/transcode/etc1s_to_astc.js +329 -329
  66. package/src/format/texture/basis/transcode/etc1s_to_etc2.d.ts.map +1 -1
  67. package/src/format/texture/basis/transcode/etc1s_to_etc2.js +305 -332
  68. package/src/format/texture/basis/transcode/fit_endpoints.d.ts.map +1 -1
  69. package/src/format/texture/basis/transcode/fit_endpoints.js +14 -27
  70. package/src/format/texture/basis/uastc/uastc_bc7_tables.d.ts +66 -0
  71. package/src/format/texture/basis/uastc/uastc_bc7_tables.d.ts.map +1 -0
  72. package/src/format/texture/basis/uastc/uastc_bc7_tables.js +148 -0
  73. package/src/format/texture/basis/uastc/uastc_decode_block.js +463 -463
  74. package/src/format/texture/basis/uastc/uastc_to_astc.js +421 -421
  75. package/src/format/texture/basis/uastc/uastc_to_bc5.d.ts +1 -6
  76. package/src/format/texture/basis/uastc/uastc_to_bc5.d.ts.map +1 -1
  77. package/src/format/texture/basis/uastc/uastc_to_bc5.js +48 -115
  78. package/src/format/texture/basis/uastc/uastc_to_bc7.d.ts.map +1 -1
  79. package/src/format/texture/basis/uastc/uastc_to_bc7.js +604 -602
  80. package/src/format/texture/bc/bc1_decode_block.d.ts +19 -0
  81. package/src/format/texture/bc/bc1_decode_block.d.ts.map +1 -0
  82. package/src/format/texture/bc/bc1_decode_block.js +22 -0
  83. package/src/format/texture/bc/bc1_decode_colors.d.ts +27 -0
  84. package/src/format/texture/bc/bc1_decode_colors.d.ts.map +1 -0
  85. package/src/format/texture/bc/bc1_decode_colors.js +100 -0
  86. package/src/format/texture/bc/bc2_decode_block.d.ts +18 -0
  87. package/src/format/texture/bc/bc2_decode_block.d.ts.map +1 -0
  88. package/src/format/texture/bc/bc2_decode_block.js +28 -0
  89. package/src/format/texture/bc/bc3_decode_block.d.ts +18 -0
  90. package/src/format/texture/bc/bc3_decode_block.d.ts.map +1 -0
  91. package/src/format/texture/bc/bc3_decode_block.js +23 -0
  92. package/src/format/texture/bc/bc4_decode_channel.d.ts +56 -0
  93. package/src/format/texture/bc/bc4_decode_channel.d.ts.map +1 -0
  94. package/src/format/texture/bc/bc4_decode_channel.js +138 -0
  95. package/src/format/texture/bc/bc4_encode_block.d.ts +43 -0
  96. package/src/format/texture/bc/bc4_encode_block.d.ts.map +1 -0
  97. package/src/format/texture/bc/bc4_encode_block.js +324 -0
  98. package/src/format/texture/bc/bc4_snorm_decode_block.d.ts +18 -0
  99. package/src/format/texture/bc/bc4_snorm_decode_block.d.ts.map +1 -0
  100. package/src/format/texture/bc/bc4_snorm_decode_block.js +27 -0
  101. package/src/format/texture/bc/bc4_unorm_decode_block.d.ts +17 -0
  102. package/src/format/texture/bc/bc4_unorm_decode_block.d.ts.map +1 -0
  103. package/src/format/texture/bc/bc4_unorm_decode_block.js +26 -0
  104. package/src/format/texture/bc/bc5_encode_block.d.ts +25 -0
  105. package/src/format/texture/bc/bc5_encode_block.d.ts.map +1 -0
  106. package/src/format/texture/bc/bc5_encode_block.js +34 -0
  107. package/src/format/texture/bc/bc5_snorm_decode_block.d.ts +18 -0
  108. package/src/format/texture/bc/bc5_snorm_decode_block.d.ts.map +1 -0
  109. package/src/format/texture/bc/bc5_snorm_decode_block.js +27 -0
  110. package/src/format/texture/bc/bc5_unorm_decode_block.d.ts +17 -0
  111. package/src/format/texture/bc/bc5_unorm_decode_block.d.ts.map +1 -0
  112. package/src/format/texture/bc/bc5_unorm_decode_block.js +26 -0
  113. package/src/format/texture/bc/bc6h_decode_texels.d.ts +30 -0
  114. package/src/format/texture/bc/bc6h_decode_texels.d.ts.map +1 -0
  115. package/src/format/texture/bc/bc6h_decode_texels.js +430 -0
  116. package/src/format/texture/bc/bc6h_sfloat_decode_block.d.ts +20 -0
  117. package/src/format/texture/bc/bc6h_sfloat_decode_block.d.ts.map +1 -0
  118. package/src/format/texture/bc/bc6h_sfloat_decode_block.js +23 -0
  119. package/src/format/texture/bc/bc6h_ufloat_decode_block.d.ts +18 -0
  120. package/src/format/texture/bc/bc6h_ufloat_decode_block.d.ts.map +1 -0
  121. package/src/format/texture/bc/bc6h_ufloat_decode_block.js +21 -0
  122. package/src/format/texture/bc/bc7_decode_block.d.ts +30 -0
  123. package/src/format/texture/bc/bc7_decode_block.d.ts.map +1 -0
  124. package/src/format/texture/bc/bc7_decode_block.js +232 -0
  125. package/src/format/texture/bc/bc7_encode_block.d.ts +39 -0
  126. package/src/format/texture/bc/bc7_encode_block.d.ts.map +1 -0
  127. package/src/format/texture/bc/bc7_encode_block.js +423 -0
  128. package/src/format/texture/bc/bc7_tables.d.ts +126 -0
  129. package/src/format/texture/bc/bc7_tables.d.ts.map +1 -0
  130. package/src/format/texture/{basis/uastc → bc}/bc7_tables.js +225 -276
  131. package/src/format/texture/bc/bc7_write_block.d.ts +65 -0
  132. package/src/format/texture/bc/bc7_write_block.d.ts.map +1 -0
  133. package/src/format/texture/{basis/uastc → bc}/bc7_write_block.js +185 -227
  134. package/src/format/texture/etc/eac_decode_channel.d.ts +50 -0
  135. package/src/format/texture/etc/eac_decode_channel.d.ts.map +1 -0
  136. package/src/format/texture/etc/eac_decode_channel.js +142 -0
  137. package/src/format/texture/etc/eac_modifiers.d.ts +15 -0
  138. package/src/format/texture/etc/eac_modifiers.d.ts.map +1 -0
  139. package/src/format/texture/etc/eac_modifiers.js +31 -0
  140. package/src/format/texture/etc/eac_r11_snorm_decode_block.d.ts +21 -0
  141. package/src/format/texture/etc/eac_r11_snorm_decode_block.d.ts.map +1 -0
  142. package/src/format/texture/etc/eac_r11_snorm_decode_block.js +30 -0
  143. package/src/format/texture/etc/eac_r11_unorm_decode_block.d.ts +20 -0
  144. package/src/format/texture/etc/eac_r11_unorm_decode_block.d.ts.map +1 -0
  145. package/src/format/texture/etc/eac_r11_unorm_decode_block.js +29 -0
  146. package/src/format/texture/etc/eac_rg11_snorm_decode_block.d.ts +19 -0
  147. package/src/format/texture/etc/eac_rg11_snorm_decode_block.d.ts.map +1 -0
  148. package/src/format/texture/etc/eac_rg11_snorm_decode_block.js +28 -0
  149. package/src/format/texture/etc/eac_rg11_unorm_decode_block.d.ts +19 -0
  150. package/src/format/texture/etc/eac_rg11_unorm_decode_block.d.ts.map +1 -0
  151. package/src/format/texture/etc/eac_rg11_unorm_decode_block.js +28 -0
  152. package/src/format/texture/etc/etc2_decode_color.d.ts +25 -0
  153. package/src/format/texture/etc/etc2_decode_color.d.ts.map +1 -0
  154. package/src/format/texture/etc/etc2_decode_color.js +370 -0
  155. package/src/format/texture/etc/etc2_rgb8_decode_block.d.ts +18 -0
  156. package/src/format/texture/etc/etc2_rgb8_decode_block.d.ts.map +1 -0
  157. package/src/format/texture/etc/etc2_rgb8_decode_block.js +21 -0
  158. package/src/format/texture/etc/etc2_rgb8a1_decode_block.d.ts +21 -0
  159. package/src/format/texture/etc/etc2_rgb8a1_decode_block.d.ts.map +1 -0
  160. package/src/format/texture/etc/etc2_rgb8a1_decode_block.js +24 -0
  161. package/src/format/texture/etc/etc2_rgba8_decode_block.d.ts +18 -0
  162. package/src/format/texture/etc/etc2_rgba8_decode_block.d.ts.map +1 -0
  163. package/src/format/texture/etc/etc2_rgba8_decode_block.js +24 -0
  164. package/src/format/texture/fit/fit_line.d.ts +23 -0
  165. package/src/format/texture/fit/fit_line.d.ts.map +1 -0
  166. package/src/format/texture/fit/fit_line.js +123 -0
  167. package/src/format/texture/fit/fit_line_refine.d.ts +21 -0
  168. package/src/format/texture/fit/fit_line_refine.d.ts.map +1 -0
  169. package/src/format/texture/fit/fit_line_refine.js +69 -0
  170. package/src/format/texture/fit/fit_line_solve.d.ts +23 -0
  171. package/src/format/texture/fit/fit_line_solve.d.ts.map +1 -0
  172. package/src/format/texture/fit/fit_line_solve.js +71 -0
  173. package/src/format/texture/texel_decode_image.d.ts +44 -0
  174. package/src/format/texture/texel_decode_image.d.ts.map +1 -0
  175. package/src/format/texture/texel_decode_image.js +251 -0
  176. package/src/format/texture/texel_encode_image.d.ts +77 -0
  177. package/src/format/texture/texel_encode_image.d.ts.map +1 -0
  178. package/src/format/texture/texel_encode_image.js +187 -0
  179. package/src/shade/renderer/ShadeIndirectLightingMode.js +2 -0
  180. package/src/shade/renderer/acoustics/GPUAcousticLattice.d.ts +1 -1
  181. package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
  182. package/src/shade/renderer/loader/mtf/mtf_encode_texture.d.ts +1 -0
  183. package/src/shade/renderer/loader/mtf/mtf_encode_texture.d.ts.map +1 -1
  184. package/src/shade/renderer/loader/mtf/mtf_encode_texture.js +102 -28
  185. package/src/shade/renderer/loader/mtf/mtf_replace_textures.d.ts +19 -0
  186. package/src/shade/renderer/loader/mtf/mtf_replace_textures.d.ts.map +1 -0
  187. package/src/shade/renderer/loader/mtf/mtf_replace_textures.js +60 -0
  188. package/src/shade/renderer/loader/mtf/mtf_write.d.ts.map +1 -1
  189. package/src/shade/renderer/loader/mtf/mtf_write.js +7 -31
  190. package/src/shade/renderer/loader/mtf/mtf_write_collection.d.ts +23 -0
  191. package/src/shade/renderer/loader/mtf/mtf_write_collection.d.ts.map +1 -0
  192. package/src/shade/renderer/loader/mtf/mtf_write_collection.js +36 -0
  193. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4.d.ts +13 -0
  194. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4.d.ts.map +1 -0
  195. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4.js +39 -0
  196. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.d.ts +3 -2
  197. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.d.ts.map +1 -1
  198. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.js +6 -21
  199. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgba.d.ts +42 -0
  200. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgba.d.ts.map +1 -0
  201. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgba.js +612 -0
  202. package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.d.ts +5 -4
  203. package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.d.ts.map +1 -1
  204. package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.js +8 -25
  205. package/src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.d.ts.map +1 -1
  206. package/src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.js +3 -19
  207. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.d.ts +14 -4
  208. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.d.ts.map +1 -1
  209. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.js +65 -54
  210. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.d.ts +2 -2
  211. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.d.ts.map +1 -1
  212. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.js +5 -22
  213. package/src/shade/renderer/texture/encode/chunk_bc7_partition_2.js +1 -1
  214. package/src/shade/renderer/texture/encode/chunk_scatter_principal_axis.d.ts +27 -0
  215. package/src/shade/renderer/texture/encode/chunk_scatter_principal_axis.d.ts.map +1 -0
  216. package/src/shade/renderer/texture/encode/chunk_scatter_principal_axis.js +147 -0
  217. package/src/shade/renderer/texture/encode/shader_texture_encode_astc_4x4.d.ts +3 -4
  218. package/src/shade/renderer/texture/encode/shader_texture_encode_astc_4x4.d.ts.map +1 -1
  219. package/src/shade/renderer/texture/encode/shader_texture_encode_astc_4x4.js +6 -13
  220. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7_rgb.d.ts +13 -0
  221. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7_rgb.d.ts.map +1 -0
  222. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7_rgb.js +66 -0
  223. package/src/shade/renderer/texture/encode/texture_encode.d.ts +28 -1
  224. package/src/shade/renderer/texture/encode/texture_encode.d.ts.map +1 -1
  225. package/src/shade/renderer/texture/encode/texture_encode.js +202 -168
  226. package/src/shade/renderer/texture/encode/texture_encode_shader.d.ts +13 -1
  227. package/src/shade/renderer/texture/encode/texture_encode_shader.d.ts.map +1 -1
  228. package/src/shade/renderer/texture/encode/texture_encode_shader.js +146 -108
  229. package/src/shade/renderer/texture/format/texture_formats_to_build.d.ts +20 -0
  230. package/src/shade/renderer/texture/format/texture_formats_to_build.d.ts.map +1 -0
  231. package/src/shade/renderer/texture/format/texture_formats_to_build.js +98 -0
  232. package/src/shade/renderer/texture/mipmaps/WebGPUMipmapGenerator.d.ts.map +1 -1
  233. package/src/shade/renderer/texture/mipmaps/WebGPUMipmapGenerator.js +4 -23
  234. package/src/shade/renderer/texture/mipmaps/cpu/MipmapBilinearAxis.d.ts +53 -0
  235. package/src/shade/renderer/texture/mipmaps/cpu/MipmapBilinearAxis.d.ts.map +1 -0
  236. package/src/shade/renderer/texture/mipmaps/cpu/MipmapBilinearAxis.js +76 -0
  237. package/src/shade/renderer/texture/mipmaps/cpu/MipmapKernelAxis.d.ts +40 -0
  238. package/src/shade/renderer/texture/mipmaps/cpu/MipmapKernelAxis.d.ts.map +1 -0
  239. package/src/shade/renderer/texture/mipmaps/cpu/MipmapKernelAxis.js +43 -0
  240. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_centres.d.ts +17 -0
  241. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_centres.d.ts.map +1 -0
  242. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_centres.js +29 -0
  243. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_sample.d.ts +21 -0
  244. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_sample.d.ts.map +1 -0
  245. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_sample.js +91 -0
  246. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_chain_cpu.d.ts +32 -0
  247. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_chain_cpu.d.ts.map +1 -0
  248. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_chain_cpu.js +216 -0
  249. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_cubic_filter_cpu.d.ts +30 -0
  250. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_cubic_filter_cpu.d.ts.map +1 -0
  251. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_cubic_filter_cpu.js +134 -0
  252. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_catmull_rom_cpu.d.ts +16 -0
  253. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_catmull_rom_cpu.d.ts.map +1 -0
  254. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_catmull_rom_cpu.js +33 -0
  255. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_cpu.d.ts +18 -0
  256. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_cpu.d.ts.map +1 -0
  257. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_cpu.js +71 -0
  258. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_normal_cpu.d.ts +20 -0
  259. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_normal_cpu.d.ts.map +1 -0
  260. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_normal_cpu.js +57 -0
  261. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_magic_kernel_cpu.d.ts +18 -0
  262. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_magic_kernel_cpu.d.ts.map +1 -0
  263. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_magic_kernel_cpu.js +111 -0
  264. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mitchell_cpu.d.ts +16 -0
  265. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mitchell_cpu.d.ts.map +1 -0
  266. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mitchell_cpu.js +33 -0
  267. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mks_cpu.d.ts +18 -0
  268. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mks_cpu.d.ts.map +1 -0
  269. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mks_cpu.js +128 -0
  270. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_wronski2021_cpu.d.ts +21 -0
  271. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_wronski2021_cpu.d.ts.map +1 -0
  272. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_wronski2021_cpu.js +169 -0
  273. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_kernel_reduce.d.ts +21 -0
  274. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_kernel_reduce.d.ts.map +1 -0
  275. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_kernel_reduce.js +119 -0
  276. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_source_centre.d.ts +16 -0
  277. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_source_centre.d.ts.map +1 -0
  278. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_source_centre.js +19 -0
  279. package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm.d.ts +24 -0
  280. package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm.d.ts.map +1 -0
  281. package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm.js +41 -0
  282. package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm_srgb.d.ts +24 -0
  283. package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm_srgb.d.ts.map +1 -0
  284. package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm_srgb.js +140 -0
  285. package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_srgb_to_f32.d.ts +21 -0
  286. package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_srgb_to_f32.d.ts.map +1 -0
  287. package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_srgb_to_f32.js +35 -0
  288. package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_to_f32.d.ts +19 -0
  289. package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_to_f32.d.ts.map +1 -0
  290. package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_to_f32.js +27 -0
  291. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_catmull_rom.js +4 -4
  292. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_linear.d.ts +13 -0
  293. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_linear.d.ts.map +1 -1
  294. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_linear.js +54 -4
  295. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_mitchell.js +4 -4
  296. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_mks.d.ts.map +1 -1
  297. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_mks.js +9 -13
  298. package/src/shade/renderer/texture/texture_block_encodings.d.ts +33 -0
  299. package/src/shade/renderer/texture/texture_block_encodings.d.ts.map +1 -0
  300. package/src/shade/renderer/texture/texture_block_encodings.js +89 -0
  301. package/src/format/texture/basis/astc_block.d.ts.map +0 -1
  302. package/src/format/texture/basis/astc_integer_sequence.d.ts.map +0 -1
  303. package/src/format/texture/basis/astc_partition.d.ts.map +0 -1
  304. package/src/format/texture/basis/uastc/bc7_tables.d.ts +0 -111
  305. package/src/format/texture/basis/uastc/bc7_tables.d.ts.map +0 -1
  306. package/src/format/texture/basis/uastc/bc7_write_block.d.ts +0 -124
  307. package/src/format/texture/basis/uastc/bc7_write_block.d.ts.map +0 -1
  308. /package/src/format/texture/{basis → astc}/astc_integer_sequence.d.ts +0 -0
  309. /package/src/format/texture/{basis → astc}/astc_partition.d.ts +0 -0
@@ -0,0 +1,66 @@
1
+ import { chunk_grid3d_to_index } from "../../shader/chunk/grid/chunk_grid3d_to_index.js";
2
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
3
+ import { ComputeShader } from "../../shader/ComputeShader.js";
4
+ import { chunk_bc7_encode_block } from "./chunk_bc7_encode_block.js";
5
+ import { chunk_texture_encode_load_block } from "./chunk_texture_encode_load_block.js";
6
+ import { TEXTURE_ENCODE_WORKGROUP_SIZE } from "./shader_texture_encode_bc4.js";
7
+ import { texture_encode_resources } from "./texture_encode_resources.js";
8
+
9
+ /**
10
+ * Every level of a texture whose alpha nobody reads to `bc7-rgba-unorm` or its sRGB twin, one
11
+ * invocation per block.
12
+ *
13
+ * {@link shader_texture_encode_bc7} with the colour-only entry, `bc7_encode_block_rgb`: the source's
14
+ * alpha is not read, mode 6's parity bits serve the colour, and the blocks decode to alpha 254 or
15
+ * 255. The dispatch shape is {@link shader_texture_encode_bc4}'s; a block is four words.
16
+ *
17
+ * @type {ComputeShader}
18
+ */
19
+ export const shader_texture_encode_bc7_rgb = ComputeShader.from({
20
+ label: 'texture_encode/bc7-rgba-unorm/alpha-unread',
21
+ resources: texture_encode_resources(),
22
+ body: CodeChunk.from(
23
+ //language=WGSL
24
+ `
25
+ @compute @workgroup_size(${TEXTURE_ENCODE_WORKGROUP_SIZE}, 1, 1)
26
+ fn main(
27
+ @builtin(workgroup_id) workgroup_id: vec3<u32>,
28
+ @builtin(num_workgroups) groups: vec3<u32>,
29
+ @builtin(local_invocation_index) local_index: u32,
30
+ ) {
31
+ let block = grid3d_to_index(workgroup_id, groups.xy) * ${TEXTURE_ENCODE_WORKGROUP_SIZE}u + local_index;
32
+
33
+ if (block >= texture_encode_block_count()) {
34
+ return;
35
+ }
36
+
37
+ let level = texture_encode_level_of_block(block);
38
+
39
+ let local = block - level.first_block;
40
+
41
+ let block_x = local % level.blocks_x;
42
+ let block_y = local / level.blocks_x;
43
+
44
+ let texels = texture_encode_load_block(level, block_x, block_y);
45
+
46
+ var colour: array<vec3<f32>, 16>;
47
+
48
+ for (var i = 0u; i < 16u; i++) {
49
+ colour[i] = texels[i].xyz;
50
+ }
51
+
52
+ let packed = bc7_encode_block_rgb(colour);
53
+
54
+ let word = level.word_offset + block_y * level.row_stride_words + block_x * 4u;
55
+
56
+ encode_output[word] = packed.x;
57
+ encode_output[word + 1u] = packed.y;
58
+ encode_output[word + 2u] = packed.z;
59
+ encode_output[word + 3u] = packed.w;
60
+ }
61
+ `, [
62
+ chunk_grid3d_to_index,
63
+ chunk_texture_encode_load_block,
64
+ chunk_bc7_encode_block,
65
+ ]),
66
+ });
@@ -54,7 +54,34 @@
54
54
  * @author Alex Goldring
55
55
  * @copyright Company Named Limited (c) 2026
56
56
  */
57
- export function texture_encode(cmd: ShadeGPUCommandContext, { source, format, level_count, usage, label }: {
57
+ export function texture_encode(cmd: ShadeGPUCommandContext, options: {
58
+ source: GPUTexture;
59
+ format: GPUTextureFormat;
60
+ level_count: number;
61
+ usage: GPUTextureUsageFlags;
62
+ label?: string;
63
+ }): TextureEncodeResult;
64
+ /**
65
+ * {@link texture_encode} for a texture whose alpha nobody reads: the source's alpha is not read, and
66
+ * the blocks decode to whatever alpha served the colour. In BC7 that frees the low bit each end's
67
+ * channels share with alpha, which an opaque alpha kept exactly would take, and alpha decodes 254
68
+ * or 255 ({@link texture_encode_shader_rgb}). Every other target is encoded as {@link texture_encode}
69
+ * encodes it, since none of its encoders reads alpha.
70
+ *
71
+ * @param {ShadeGPUCommandContext} cmd
72
+ * @param {Object} options as {@link texture_encode}'s
73
+ * @param {GPUTexture} options.source
74
+ * @param {GPUTextureFormat} options.format
75
+ * @param {number} options.level_count
76
+ * @param {GPUTextureUsageFlags} options.usage
77
+ * @param {string} [options.label]
78
+ * @returns {TextureEncodeResult}
79
+ * @throws {Error} as {@link texture_encode}
80
+ *
81
+ * @author Alex Goldring
82
+ * @copyright Company Named Limited (c) 2026
83
+ */
84
+ export function texture_encode_rgb(cmd: ShadeGPUCommandContext, options: {
58
85
  source: GPUTexture;
59
86
  format: GPUTextureFormat;
60
87
  level_count: number;
@@ -1 +1 @@
1
- {"version":3,"file":"texture_encode.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/texture/encode/texture_encode.js"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH;IAf+B,MAAM;IAEA,MAAM;IAEhB,WAAW,EAA3B,MAAM;IACwB,KAAK;IAElB,KAAK,GAAtB,MAAM;IACJ,mBAAmB,CAgH/B"}
1
+ {"version":3,"file":"texture_encode.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/texture/encode/texture_encode.js"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH;IAf+B,MAAM;IAEA,MAAM;IAEhB,WAAW,EAA3B,MAAM;IACwB,KAAK;IAElB,KAAK,GAAtB,MAAM;IACJ,mBAAmB,CAS/B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH;IAX+B,MAAM;IACA,MAAM;IAChB,WAAW,EAA3B,MAAM;IACwB,KAAK;IAClB,KAAK,GAAtB,MAAM;IACJ,mBAAmB,CAQ/B"}
@@ -1,168 +1,202 @@
1
- import { assert } from "../../../../core/assert.js";
2
- import { gpu_texture_format_srg_to_linear } from "../format/gpu_texture_format_srg_to_linear.js";
3
- import { texture_encode_layout, texture_encode_level_table } from "./texture_encode_layout.js";
4
- import { texture_encode_shader } from "./texture_encode_shader.js";
5
-
6
- /**
7
- * What {@link texture_encode} produced.
8
- *
9
- * @typedef {Object} TextureEncodeResult
10
- * @property {GPUTexture} texture the block-compressed texture, every requested level written once
11
- * the context is submitted. The caller's, to keep and to destroy
12
- * @property {GPUBuffer} blocks the block buffer the encoder wrote and the copies read, laid out as
13
- * `layout` says. **Transient**: released back to the context's pool when the context finishes, so
14
- * anything wanting the raw blocks — a container writer, a cross-check — copies them out before then
15
- * @property {TextureEncodeLayout} layout where each level's blocks sit in `blocks`
16
- */
17
-
18
- /**
19
- * Encode a sampleable texture into a block-compressed one, on the device.
20
- *
21
- * **A texture in, a texture out, and nothing about who wants it.** The caller names the target
22
- * format outright — `bc4-r-unorm`, `bc7-rgba-unorm-srgb` — and gets a texture in that format with
23
- * `level_count` levels, each encoded from the same level of the source. No role, no preference list,
24
- * no material: a subsystem that can encode anything to a named format is what the texture manager, a
25
- * container writer, a procedural generator and a test can all stand on, and none of those want it to
26
- * have opinions about content.
27
- *
28
- * WebGPU has no writable block-compressed storage texture, so the shape is the plan's §4.4: one
29
- * compute dispatch writes every level's blocks into one storage buffer, and one `copyBufferToTexture`
30
- * per level moves them into the texture. The buffer is laid out by {@link texture_encode_layout}
31
- * with its rows padded to the copy's 256-byte stride before anything runs — the encoder writes to
32
- * the stride the copy will read, and each copy is a whole level, sized in whole blocks as the copy
33
- * commands count them.
34
- *
35
- * **The source is read as stored, not as decoded.** An `-srgb` source would arrive through
36
- * `textureLoad` already converted to linear, and an encoder fitting those values into bytes that the
37
- * sampler will then decode as sRGB again would encode the wrong picture. So an sRGB source is bound
38
- * through a view in its linear twin format, which needs the texture to have been created with that
39
- * format in its `viewFormats`; the device refuses the view otherwise, by validation error. The
40
- * `-srgb`-ness of the *target* is likewise nothing but the tag the texture is created with: the
41
- * encoded bytes are identical for both spellings.
42
- *
43
- * Everything is recorded into `cmd` and nothing runs until it is submitted. The transient buffers
44
- * are the context's and go back to its pool when it finishes.
45
- *
46
- * @param {ShadeGPUCommandContext} cmd
47
- * @param {Object} options
48
- * @param {GPUTexture} options.source a 2D, single-layer texture with `TEXTURE_BINDING`, holding at
49
- * least `level_count` levels
50
- * @param {GPUTextureFormat} options.format the target block format, exactly as the texture is to be
51
- * created
52
- * @param {number} options.level_count how many levels to encode, from level 0 down
53
- * @param {GPUTextureUsageFlags} options.usage the target texture's usage; must include `COPY_DST`,
54
- * which is how the blocks get in
55
- * @param {string} [options.label] for the target texture
56
- * @returns {TextureEncodeResult}
57
- * @throws {Error} naming the format, for a target this cannot write; naming the source, for one the
58
- * encoder cannot read
59
- *
60
- * @author Alex Goldring
61
- * @copyright Company Named Limited (c) 2026
62
- */
63
- export function texture_encode(cmd, { source, format, level_count, usage, label = `encoded ${format}` }) {
64
- assert.defined(cmd, 'cmd');
65
- assert.defined(source, 'source');
66
- assert.isString(format, 'format');
67
- assert.isPositiveInteger(level_count, 'level_count');
68
- assert.isNonNegativeInteger(usage, 'usage');
69
- assert.isString(label, 'label');
70
-
71
- const shader = texture_encode_shader(format);
72
-
73
- if (source.dimension !== "2d" || source.depthOrArrayLayers !== 1) {
74
- throw new Error(
75
- `texture_encode: source '${source.label}' is ${source.dimension} with ${source.depthOrArrayLayers} layers;`
76
- + ` only a single-layer 2D texture can be encoded`
77
- );
78
- }
79
-
80
- if ((source.usage & GPUTextureUsage.TEXTURE_BINDING) === 0) {
81
- throw new Error(`texture_encode: source '${source.label}' was not created with TEXTURE_BINDING, so it cannot be read`);
82
- }
83
-
84
- if (level_count > source.mipLevelCount) {
85
- throw new Error(
86
- `texture_encode: source '${source.label}' holds ${source.mipLevelCount} levels, and ${level_count} were asked for`
87
- );
88
- }
89
-
90
- if ((usage & GPUTextureUsage.COPY_DST) === 0) {
91
- throw new Error(`texture_encode: the target's usage must include COPY_DST, which is how the blocks reach it`);
92
- }
93
-
94
- const device = cmd.device;
95
-
96
- const layout = texture_encode_layout(format, source.width, source.height, level_count);
97
-
98
- const binding_limit = device.limits.maxStorageBufferBindingSize;
99
-
100
- if (layout.byte_length > binding_limit) {
101
- throw new Error(
102
- `texture_encode: the ${layout.levels.length}-level block buffer of a ${source.width}x${source.height} '${format}'`
103
- + ` texture is ${layout.byte_length} bytes, over this device's maxStorageBufferBindingSize of ${binding_limit}`
104
- );
105
- }
106
-
107
- const texture = device.createTexture({
108
- label,
109
- size: [source.width, source.height, 1],
110
- format,
111
- mipLevelCount: level_count,
112
- usage,
113
- });
114
-
115
- const table = texture_encode_level_table(layout);
116
-
117
- const levels = cmd.allocateTransientBufferAndLoad(table.buffer, GPUBufferUsage.STORAGE);
118
-
119
- const blocks = cmd.allocateTransientBuffer(
120
- GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC,
121
- layout.byte_length
122
- );
123
-
124
- const view = source.createView({
125
- label: `${source.label} for encoding`,
126
- format: source.format.endsWith("-srgb") ? gpu_texture_format_srg_to_linear(source.format) : source.format,
127
- dimension: "2d",
128
- });
129
-
130
- const group_count = Math.ceil(layout.block_count / shader.group_size_x);
131
-
132
- // one dimension is capped, so a large chain wraps onto a second grid row; the shader reads the
133
- // row length from num_workgroups
134
- const groups_per_row = Math.min(group_count, device.limits.maxComputeWorkgroupsPerDimension);
135
-
136
- shader.dispatch({
137
- encoder: cmd,
138
- bindings: {
139
- encode_source: view,
140
- encode_levels: levels,
141
- encode_output: blocks,
142
- },
143
- group_count_x: groups_per_row,
144
- group_count_y: Math.ceil(group_count / groups_per_row),
145
- });
146
-
147
- const encoder = cmd.gpu_encoder;
148
-
149
- for (const level of layout.levels) {
150
- encoder.copyBufferToTexture(
151
- {
152
- buffer: blocks,
153
- offset: level.byte_offset,
154
- bytesPerRow: level.bytes_per_row,
155
- rowsPerImage: level.blocks_y,
156
- },
157
- {
158
- texture,
159
- mipLevel: level.level,
160
- origin: [0, 0, 0],
161
- },
162
- // sized in whole blocks, as the copy commands count: the 1x1 tail is one 4x4 block
163
- [level.copy_width, level.copy_height, 1]
164
- );
165
- }
166
-
167
- return { texture, blocks, layout };
168
- }
1
+ import { assert } from "../../../../core/assert.js";
2
+ import { gpu_texture_format_srg_to_linear } from "../format/gpu_texture_format_srg_to_linear.js";
3
+ import { texture_encode_layout, texture_encode_level_table } from "./texture_encode_layout.js";
4
+ import { texture_encode_shader, texture_encode_shader_rgb } from "./texture_encode_shader.js";
5
+
6
+ /**
7
+ * What {@link texture_encode} produced.
8
+ *
9
+ * @typedef {Object} TextureEncodeResult
10
+ * @property {GPUTexture} texture the block-compressed texture, every requested level written once
11
+ * the context is submitted. The caller's, to keep and to destroy
12
+ * @property {GPUBuffer} blocks the block buffer the encoder wrote and the copies read, laid out as
13
+ * `layout` says. **Transient**: released back to the context's pool when the context finishes, so
14
+ * anything wanting the raw blocks — a container writer, a cross-check — copies them out before then
15
+ * @property {TextureEncodeLayout} layout where each level's blocks sit in `blocks`
16
+ */
17
+
18
+ /**
19
+ * Encode a sampleable texture into a block-compressed one, on the device.
20
+ *
21
+ * **A texture in, a texture out, and nothing about who wants it.** The caller names the target
22
+ * format outright — `bc4-r-unorm`, `bc7-rgba-unorm-srgb` — and gets a texture in that format with
23
+ * `level_count` levels, each encoded from the same level of the source. No role, no preference list,
24
+ * no material: a subsystem that can encode anything to a named format is what the texture manager, a
25
+ * container writer, a procedural generator and a test can all stand on, and none of those want it to
26
+ * have opinions about content.
27
+ *
28
+ * WebGPU has no writable block-compressed storage texture, so the shape is the plan's §4.4: one
29
+ * compute dispatch writes every level's blocks into one storage buffer, and one `copyBufferToTexture`
30
+ * per level moves them into the texture. The buffer is laid out by {@link texture_encode_layout}
31
+ * with its rows padded to the copy's 256-byte stride before anything runs — the encoder writes to
32
+ * the stride the copy will read, and each copy is a whole level, sized in whole blocks as the copy
33
+ * commands count them.
34
+ *
35
+ * **The source is read as stored, not as decoded.** An `-srgb` source would arrive through
36
+ * `textureLoad` already converted to linear, and an encoder fitting those values into bytes that the
37
+ * sampler will then decode as sRGB again would encode the wrong picture. So an sRGB source is bound
38
+ * through a view in its linear twin format, which needs the texture to have been created with that
39
+ * format in its `viewFormats`; the device refuses the view otherwise, by validation error. The
40
+ * `-srgb`-ness of the *target* is likewise nothing but the tag the texture is created with: the
41
+ * encoded bytes are identical for both spellings.
42
+ *
43
+ * Everything is recorded into `cmd` and nothing runs until it is submitted. The transient buffers
44
+ * are the context's and go back to its pool when it finishes.
45
+ *
46
+ * @param {ShadeGPUCommandContext} cmd
47
+ * @param {Object} options
48
+ * @param {GPUTexture} options.source a 2D, single-layer texture with `TEXTURE_BINDING`, holding at
49
+ * least `level_count` levels
50
+ * @param {GPUTextureFormat} options.format the target block format, exactly as the texture is to be
51
+ * created
52
+ * @param {number} options.level_count how many levels to encode, from level 0 down
53
+ * @param {GPUTextureUsageFlags} options.usage the target texture's usage; must include `COPY_DST`,
54
+ * which is how the blocks get in
55
+ * @param {string} [options.label] for the target texture
56
+ * @returns {TextureEncodeResult}
57
+ * @throws {Error} naming the format, for a target this cannot write; naming the source, for one the
58
+ * encoder cannot read
59
+ *
60
+ * @author Alex Goldring
61
+ * @copyright Company Named Limited (c) 2026
62
+ */
63
+ export function texture_encode(cmd, options) {
64
+ return texture_encode_with(cmd, options, texture_encode_shader);
65
+ }
66
+
67
+ /**
68
+ * {@link texture_encode} for a texture whose alpha nobody reads: the source's alpha is not read, and
69
+ * the blocks decode to whatever alpha served the colour. In BC7 that frees the low bit each end's
70
+ * channels share with alpha, which an opaque alpha kept exactly would take, and alpha decodes 254
71
+ * or 255 ({@link texture_encode_shader_rgb}). Every other target is encoded as {@link texture_encode}
72
+ * encodes it, since none of its encoders reads alpha.
73
+ *
74
+ * @param {ShadeGPUCommandContext} cmd
75
+ * @param {Object} options as {@link texture_encode}'s
76
+ * @param {GPUTexture} options.source
77
+ * @param {GPUTextureFormat} options.format
78
+ * @param {number} options.level_count
79
+ * @param {GPUTextureUsageFlags} options.usage
80
+ * @param {string} [options.label]
81
+ * @returns {TextureEncodeResult}
82
+ * @throws {Error} as {@link texture_encode}
83
+ *
84
+ * @author Alex Goldring
85
+ * @copyright Company Named Limited (c) 2026
86
+ */
87
+ export function texture_encode_rgb(cmd, options) {
88
+ return texture_encode_with(cmd, options, texture_encode_shader_rgb);
89
+ }
90
+
91
+ /**
92
+ * @param {ShadeGPUCommandContext} cmd
93
+ * @param {Object} options as {@link texture_encode}'s
94
+ * @param {function(GPUTextureFormat):ComputeShader} shader_for the encoder for a target
95
+ * @returns {TextureEncodeResult}
96
+ */
97
+ function texture_encode_with(cmd, { source, format, level_count, usage, label = `encoded ${format}` }, shader_for) {
98
+ assert.defined(cmd, 'cmd');
99
+ assert.defined(source, 'source');
100
+ assert.isString(format, 'format');
101
+ assert.isPositiveInteger(level_count, 'level_count');
102
+ assert.isNonNegativeInteger(usage, 'usage');
103
+ assert.isString(label, 'label');
104
+
105
+ const shader = shader_for(format);
106
+
107
+ if (source.dimension !== "2d" || source.depthOrArrayLayers !== 1) {
108
+ throw new Error(
109
+ `texture_encode: source '${source.label}' is ${source.dimension} with ${source.depthOrArrayLayers} layers;`
110
+ + ` only a single-layer 2D texture can be encoded`
111
+ );
112
+ }
113
+
114
+ if ((source.usage & GPUTextureUsage.TEXTURE_BINDING) === 0) {
115
+ throw new Error(`texture_encode: source '${source.label}' was not created with TEXTURE_BINDING, so it cannot be read`);
116
+ }
117
+
118
+ if (level_count > source.mipLevelCount) {
119
+ throw new Error(
120
+ `texture_encode: source '${source.label}' holds ${source.mipLevelCount} levels, and ${level_count} were asked for`
121
+ );
122
+ }
123
+
124
+ if ((usage & GPUTextureUsage.COPY_DST) === 0) {
125
+ throw new Error(`texture_encode: the target's usage must include COPY_DST, which is how the blocks reach it`);
126
+ }
127
+
128
+ const device = cmd.device;
129
+
130
+ const layout = texture_encode_layout(format, source.width, source.height, level_count);
131
+
132
+ const binding_limit = device.limits.maxStorageBufferBindingSize;
133
+
134
+ if (layout.byte_length > binding_limit) {
135
+ throw new Error(
136
+ `texture_encode: the ${layout.levels.length}-level block buffer of a ${source.width}x${source.height} '${format}'`
137
+ + ` texture is ${layout.byte_length} bytes, over this device's maxStorageBufferBindingSize of ${binding_limit}`
138
+ );
139
+ }
140
+
141
+ const texture = device.createTexture({
142
+ label,
143
+ size: [source.width, source.height, 1],
144
+ format,
145
+ mipLevelCount: level_count,
146
+ usage,
147
+ });
148
+
149
+ const table = texture_encode_level_table(layout);
150
+
151
+ const levels = cmd.allocateTransientBufferAndLoad(table.buffer, GPUBufferUsage.STORAGE);
152
+
153
+ const blocks = cmd.allocateTransientBuffer(
154
+ GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC,
155
+ layout.byte_length
156
+ );
157
+
158
+ const view = source.createView({
159
+ label: `${source.label} for encoding`,
160
+ format: source.format.endsWith("-srgb") ? gpu_texture_format_srg_to_linear(source.format) : source.format,
161
+ dimension: "2d",
162
+ });
163
+
164
+ const group_count = Math.ceil(layout.block_count / shader.group_size_x);
165
+
166
+ // one dimension is capped, so a large chain wraps onto a second grid row; the shader reads the
167
+ // row length from num_workgroups
168
+ const groups_per_row = Math.min(group_count, device.limits.maxComputeWorkgroupsPerDimension);
169
+
170
+ shader.dispatch({
171
+ encoder: cmd,
172
+ bindings: {
173
+ encode_source: view,
174
+ encode_levels: levels,
175
+ encode_output: blocks,
176
+ },
177
+ group_count_x: groups_per_row,
178
+ group_count_y: Math.ceil(group_count / groups_per_row),
179
+ });
180
+
181
+ const encoder = cmd.gpu_encoder;
182
+
183
+ for (const level of layout.levels) {
184
+ encoder.copyBufferToTexture(
185
+ {
186
+ buffer: blocks,
187
+ offset: level.byte_offset,
188
+ bytesPerRow: level.bytes_per_row,
189
+ rowsPerImage: level.blocks_y,
190
+ },
191
+ {
192
+ texture,
193
+ mipLevel: level.level,
194
+ origin: [0, 0, 0],
195
+ },
196
+ // sized in whole blocks, as the copy commands count: the 1x1 tail is one 4x4 block
197
+ [level.copy_width, level.copy_height, 1]
198
+ );
199
+ }
200
+
201
+ return { texture, blocks, layout };
202
+ }
@@ -1,5 +1,6 @@
1
1
  /**
2
- * The compute shader that encodes into `format`.
2
+ * The compute shader that encodes into `format`. For a texture whose alpha nobody reads,
3
+ * {@link texture_encode_shader_rgb}.
3
4
  *
4
5
  * Refuses by name rather than approximating: a target this cannot write yet is named as such, and a
5
6
  * format that was never a target is named as that. Nothing is encoded as a neighbour of what was
@@ -10,6 +11,17 @@
10
11
  * @throws {Error} naming the format, for one that is not implemented or not a target
11
12
  */
12
13
  export function texture_encode_shader(format: GPUTextureFormat): ComputeShader;
14
+ /**
15
+ * The compute shader that encodes into `format` a texture whose alpha nobody reads: the source's alpha
16
+ * is not read, and the blocks decode to whatever alpha served the colour. For BC7 that frees the low
17
+ * bit each end's channels share with alpha ({@link shader_texture_encode_bc7_rgb}); every other
18
+ * target is the shader {@link texture_encode_shader} gives, as none of them reads alpha.
19
+ *
20
+ * @param {GPUTextureFormat} format
21
+ * @returns {ComputeShader}
22
+ * @throws {Error} naming the format, for one that is not implemented or not a target
23
+ */
24
+ export function texture_encode_shader_rgb(format: GPUTextureFormat): ComputeShader;
13
25
  /**
14
26
  * Whether the block encoder can write `format` today.
15
27
  *
@@ -1 +1 @@
1
- {"version":3,"file":"texture_encode_shader.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/texture/encode/texture_encode_shader.js"],"names":[],"mappings":"AAiEA;;;;;;;;;;GAUG;AACH,+EAqBC;AAED;;;;;GAKG;AACH,qEAFa,OAAO,CAInB;AAhGD;;;;;;;;GAQG;AACH,qCAFU,kBAAkB,CAkB1B"}
1
+ {"version":3,"file":"texture_encode_shader.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/texture/encode/texture_encode_shader.js"],"names":[],"mappings":"AA+EA;;;;;;;;;;;GAWG;AACH,+EAEC;AAED;;;;;;;;;GASG;AACH,mFAEC;AA8BD;;;;;GAKG;AACH,qEAFa,OAAO,CAInB;AArID;;;;;;;;GAQG;AACH,qCAFU,kBAAkB,CAkB1B"}