@photivra/engine 2.20.0 → 2.22.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 (275) hide show
  1. package/CHANGELOG.md +295 -1
  2. package/CITATION.cff +1 -1
  3. package/README.md +7 -6
  4. package/SECURITY.md +1 -1
  5. package/THIRD_PARTY.md +18 -0
  6. package/dist/capture/c2pa-embed.d.ts +116 -0
  7. package/dist/capture/c2pa-embed.js +493 -0
  8. package/dist/capture/c2pa-embed.js.map +1 -0
  9. package/dist/capture/dng-import.d.ts +73 -8
  10. package/dist/capture/dng-import.js +315 -80
  11. package/dist/capture/dng-import.js.map +1 -1
  12. package/dist/capture/dng-lens-correction-opcodes.d.ts +2 -2
  13. package/dist/capture/dng-lens-correction-opcodes.js +2 -2
  14. package/dist/capture/dng-lens-correction-opcodes.js.map +1 -1
  15. package/dist/capture/dng-opcodes.d.ts +96 -0
  16. package/dist/capture/dng-opcodes.js +391 -0
  17. package/dist/capture/dng-opcodes.js.map +1 -0
  18. package/dist/capture/dng-profile-maps.d.ts +99 -0
  19. package/dist/capture/dng-profile-maps.js +381 -0
  20. package/dist/capture/dng-profile-maps.js.map +1 -0
  21. package/dist/capture/dng-stage-image.d.ts +23 -0
  22. package/dist/capture/dng-stage-image.js +65 -0
  23. package/dist/capture/dng-stage-image.js.map +1 -0
  24. package/dist/capture/exposure-build-up-stage.d.ts +16 -0
  25. package/dist/capture/exposure-build-up-stage.js +4 -0
  26. package/dist/capture/exposure-build-up-stage.js.map +1 -0
  27. package/dist/capture/jpeg-xl-tiles.d.ts +22 -0
  28. package/dist/capture/jpeg-xl-tiles.js +151 -0
  29. package/dist/capture/jpeg-xl-tiles.js.map +1 -0
  30. package/dist/capture/lossy-jpeg.d.ts +17 -0
  31. package/dist/capture/lossy-jpeg.js +369 -0
  32. package/dist/capture/lossy-jpeg.js.map +1 -0
  33. package/dist/capture/native-environment-lean.d.ts +2 -1
  34. package/dist/capture/native-environment-lean.js +41 -73
  35. package/dist/capture/native-environment-lean.js.map +1 -1
  36. package/dist/capture/native-environment-tabulated.js +4 -3
  37. package/dist/capture/native-environment-tabulated.js.map +1 -1
  38. package/dist/capture/native-raw-development.d.ts +2 -1
  39. package/dist/capture/native-raw-development.js.map +1 -1
  40. package/dist/capture/native-raw.d.ts +3 -2
  41. package/dist/capture/native-raw.js +5 -4
  42. package/dist/capture/native-raw.js.map +1 -1
  43. package/dist/capture/sensor-raw-producer.d.ts +4 -1
  44. package/dist/capture/sensor-raw-producer.js +12 -3
  45. package/dist/capture/sensor-raw-producer.js.map +1 -1
  46. package/dist/color/neighbor-highlight-reconstruction.d.ts +66 -0
  47. package/dist/color/neighbor-highlight-reconstruction.js +234 -0
  48. package/dist/color/neighbor-highlight-reconstruction.js.map +1 -0
  49. package/dist/color/sensor-color-development.d.ts +5 -0
  50. package/dist/color/sensor-color-development.js +7 -1
  51. package/dist/color/sensor-color-development.js.map +1 -1
  52. package/dist/color/spectral-spikiness.d.ts +11 -0
  53. package/dist/color/spectral-spikiness.js +23 -0
  54. package/dist/color/spectral-spikiness.js.map +1 -0
  55. package/dist/core/execution-error.d.ts +21 -0
  56. package/dist/core/execution-error.js +12 -0
  57. package/dist/core/execution-error.js.map +1 -0
  58. package/dist/core/version.d.ts +1 -1
  59. package/dist/core/version.js +1 -1
  60. package/dist/core/version.js.map +1 -1
  61. package/dist/equipment/generic-lens-catalogue.d.ts +3 -2
  62. package/dist/equipment/generic-lens-catalogue.js +18 -5
  63. package/dist/equipment/generic-lens-catalogue.js.map +1 -1
  64. package/dist/equipment/generic-tier-assets.d.ts +32 -0
  65. package/dist/equipment/generic-tier-assets.js +16 -11
  66. package/dist/equipment/generic-tier-assets.js.map +1 -1
  67. package/dist/equipment/sensor-profile-body.d.ts +78 -0
  68. package/dist/equipment/sensor-profile-body.js +77 -0
  69. package/dist/equipment/sensor-profile-body.js.map +1 -0
  70. package/dist/equipment/sensor-profiles.d.ts +8 -0
  71. package/dist/equipment/sensor-profiles.js +82 -0
  72. package/dist/equipment/sensor-profiles.js.map +1 -0
  73. package/dist/facade/catalogue-lens-signal.d.ts +28 -3
  74. package/dist/facade/catalogue-lens-signal.js +83 -78
  75. package/dist/facade/catalogue-lens-signal.js.map +1 -1
  76. package/dist/facade/chart-radiance-batch.js +2 -1
  77. package/dist/facade/chart-radiance-batch.js.map +1 -1
  78. package/dist/facade/defocus-image-space-provider.d.ts +7 -0
  79. package/dist/facade/defocus-image-space-provider.js +64 -76
  80. package/dist/facade/defocus-image-space-provider.js.map +1 -1
  81. package/dist/facade/diffraction-provider.d.ts +1 -1
  82. package/dist/facade/diffraction-provider.js +4 -4
  83. package/dist/facade/diffraction-provider.js.map +1 -1
  84. package/dist/facade/display-view-gpu-session.js +39 -5
  85. package/dist/facade/display-view-gpu-session.js.map +1 -1
  86. package/dist/facade/display-view-gpu.d.ts +19 -6
  87. package/dist/facade/display-view-gpu.js.map +1 -1
  88. package/dist/facade/display-view-lens-signal.js +25 -23
  89. package/dist/facade/display-view-lens-signal.js.map +1 -1
  90. package/dist/facade/display-view-normal.d.ts +15 -0
  91. package/dist/facade/display-view-normal.js +44 -0
  92. package/dist/facade/display-view-normal.js.map +1 -0
  93. package/dist/facade/display-view-rendering.d.ts +97 -0
  94. package/dist/facade/display-view-rendering.js +598 -0
  95. package/dist/facade/display-view-rendering.js.map +1 -0
  96. package/dist/facade/display-view.d.ts +37 -65
  97. package/dist/facade/display-view.js +152 -499
  98. package/dist/facade/display-view.js.map +1 -1
  99. package/dist/facade/expected-signal-setup.d.ts +3 -1
  100. package/dist/facade/expected-signal-setup.js +3 -3
  101. package/dist/facade/expected-signal-setup.js.map +1 -1
  102. package/dist/facade/expected-signal.d.ts +47 -14
  103. package/dist/facade/expected-signal.js +117 -112
  104. package/dist/facade/expected-signal.js.map +1 -1
  105. package/dist/facade/exposure-build-up.d.ts +70 -0
  106. package/dist/facade/exposure-build-up.js +164 -0
  107. package/dist/facade/exposure-build-up.js.map +1 -0
  108. package/dist/facade/fast-methods.d.ts +1 -1
  109. package/dist/facade/fast-methods.js +46 -9
  110. package/dist/facade/fast-methods.js.map +1 -1
  111. package/dist/facade/generic-lens-capture.d.ts +3 -3
  112. package/dist/facade/generic-lens-capture.js +3 -3
  113. package/dist/facade/generic-lens-capture.js.map +1 -1
  114. package/dist/facade/image-plane-enable.d.ts +7 -0
  115. package/dist/facade/image-plane-enable.js +17 -0
  116. package/dist/facade/image-plane-enable.js.map +1 -0
  117. package/dist/facade/image-plane-lattice-data.d.ts +6 -0
  118. package/dist/facade/image-plane-lattice-data.js +10 -0
  119. package/dist/facade/image-plane-lattice-data.js.map +1 -0
  120. package/dist/facade/image-plane-support.d.ts +33 -0
  121. package/dist/facade/image-plane-support.js +11 -0
  122. package/dist/facade/image-plane-support.js.map +1 -0
  123. package/dist/facade/image-plane.d.ts +36 -0
  124. package/dist/facade/image-plane.js +384 -0
  125. package/dist/facade/image-plane.js.map +1 -0
  126. package/dist/facade/mixed-illumination.d.ts +108 -0
  127. package/dist/facade/mixed-illumination.js +174 -0
  128. package/dist/facade/mixed-illumination.js.map +1 -0
  129. package/dist/facade/on-demand-kits.d.ts +14 -0
  130. package/dist/facade/on-demand-kits.js +36 -0
  131. package/dist/facade/on-demand-kits.js.map +1 -0
  132. package/dist/facade/opt-in-kit.d.ts +9 -0
  133. package/dist/facade/opt-in-kit.js +11 -0
  134. package/dist/facade/opt-in-kit.js.map +1 -0
  135. package/dist/facade/quality-kit.d.ts +21 -0
  136. package/dist/facade/quality-kit.js +23 -0
  137. package/dist/facade/quality-kit.js.map +1 -0
  138. package/dist/facade/quality-paths.d.ts +22 -0
  139. package/dist/facade/quality-paths.js +44 -0
  140. package/dist/facade/quality-paths.js.map +1 -0
  141. package/dist/facade/representative-light-sources.d.ts +72 -0
  142. package/dist/facade/representative-light-sources.js +124 -0
  143. package/dist/facade/representative-light-sources.js.map +1 -0
  144. package/dist/facade/scene-radiance.d.ts +145 -4
  145. package/dist/facade/scene-radiance.js +50 -13
  146. package/dist/facade/scene-radiance.js.map +1 -1
  147. package/dist/facade/simulate-capture.d.ts +68 -20
  148. package/dist/facade/simulate-capture.js +399 -146
  149. package/dist/facade/simulate-capture.js.map +1 -1
  150. package/dist/facade/simulate-display-view.d.ts +10 -12
  151. package/dist/facade/simulate-display-view.js +70 -53
  152. package/dist/facade/simulate-display-view.js.map +1 -1
  153. package/dist/gpu/chart-composite-gpu.d.ts +13 -1
  154. package/dist/gpu/chart-composite-gpu.js +48 -9
  155. package/dist/gpu/chart-composite-gpu.js.map +1 -1
  156. package/dist/gpu/chart-radiance-gpu.js +4 -30
  157. package/dist/gpu/chart-radiance-gpu.js.map +1 -1
  158. package/dist/gpu/display-view-composite-material-module.d.ts +10 -4
  159. package/dist/gpu/display-view-composite-material-module.js +39 -13
  160. package/dist/gpu/display-view-composite-material-module.js.map +1 -1
  161. package/dist/gpu/display-view-gpu-renderer.d.ts +43 -0
  162. package/dist/gpu/display-view-gpu-renderer.js +134 -0
  163. package/dist/gpu/display-view-gpu-renderer.js.map +1 -0
  164. package/dist/gpu/display-view-image-material-module.d.ts +87 -0
  165. package/dist/gpu/display-view-image-material-module.js +361 -0
  166. package/dist/gpu/display-view-image-material-module.js.map +1 -0
  167. package/dist/gpu/display-view-image-quality.d.ts +87 -0
  168. package/dist/gpu/display-view-image-quality.js +625 -0
  169. package/dist/gpu/display-view-image-quality.js.map +1 -0
  170. package/dist/gpu/display-view-quality-gpu.d.ts +80 -65
  171. package/dist/gpu/display-view-quality-gpu.js +187 -445
  172. package/dist/gpu/display-view-quality-gpu.js.map +1 -1
  173. package/dist/gpu/display-view-speed-gpu.d.ts +67 -19
  174. package/dist/gpu/display-view-speed-gpu.js +181 -105
  175. package/dist/gpu/display-view-speed-gpu.js.map +1 -1
  176. package/dist/gpu/image-kernel-accelerator.js +3 -0
  177. package/dist/gpu/image-kernel-accelerator.js.map +1 -1
  178. package/dist/gpu/image-kernel-execution.d.ts +2 -13
  179. package/dist/gpu/image-kernel-execution.js +2 -10
  180. package/dist/gpu/image-kernel-execution.js.map +1 -1
  181. package/dist/gpu/wgsl-display-view-coupled-stub.d.ts +8 -0
  182. package/dist/gpu/wgsl-display-view-coupled-stub.js +21 -0
  183. package/dist/gpu/wgsl-display-view-coupled-stub.js.map +1 -0
  184. package/dist/gpu/wgsl-display-view-coupled.d.ts +88 -0
  185. package/dist/gpu/wgsl-display-view-coupled.js +353 -0
  186. package/dist/gpu/wgsl-display-view-coupled.js.map +1 -0
  187. package/dist/gpu/wgsl-display-view-quality-kernel.d.ts +33 -24
  188. package/dist/gpu/wgsl-display-view-quality-kernel.js +166 -146
  189. package/dist/gpu/wgsl-display-view-quality-kernel.js.map +1 -1
  190. package/dist/gpu/wgsl-display-view-speed-kernel.d.ts +19 -44
  191. package/dist/gpu/wgsl-display-view-speed-kernel.js +116 -18
  192. package/dist/gpu/wgsl-display-view-speed-kernel.js.map +1 -1
  193. package/dist/gpu/wgsl-exact-sum.d.ts +20 -0
  194. package/dist/gpu/wgsl-exact-sum.js +42 -0
  195. package/dist/gpu/wgsl-exact-sum.js.map +1 -0
  196. package/dist/index.d.ts +22 -6
  197. package/dist/index.js +16 -2
  198. package/dist/index.js.map +1 -1
  199. package/dist/motion/subject-motion.d.ts +66 -0
  200. package/dist/motion/subject-motion.js +52 -0
  201. package/dist/motion/subject-motion.js.map +1 -0
  202. package/dist/optics/generic-lens-lateral-color.d.ts +83 -0
  203. package/dist/optics/generic-lens-lateral-color.js +77 -0
  204. package/dist/optics/generic-lens-lateral-color.js.map +1 -0
  205. package/dist/optics/generic-lens-psf.js +54 -46
  206. package/dist/optics/generic-lens-psf.js.map +1 -1
  207. package/dist/optics/lens-psf-profile.d.ts +7 -0
  208. package/dist/optics/lens-psf-profile.js +2 -1
  209. package/dist/optics/lens-psf-profile.js.map +1 -1
  210. package/dist/output/camera-channel-response.d.ts +50 -0
  211. package/dist/output/camera-channel-response.js +69 -0
  212. package/dist/output/camera-channel-response.js.map +1 -0
  213. package/dist/output/developed-lens-corrections.d.ts +19 -5
  214. package/dist/output/developed-lens-corrections.js +28 -9
  215. package/dist/output/developed-lens-corrections.js.map +1 -1
  216. package/dist/output/generic-lens-corrections.d.ts +41 -5
  217. package/dist/output/generic-lens-corrections.js +52 -8
  218. package/dist/output/generic-lens-corrections.js.map +1 -1
  219. package/dist/output/native-capture-sdr.js +5 -2
  220. package/dist/output/native-capture-sdr.js.map +1 -1
  221. package/dist/output/print-plan.d.ts +41 -5
  222. package/dist/output/print-plan.js +59 -14
  223. package/dist/output/print-plan.js.map +1 -1
  224. package/dist/output/sdr-rendering.d.ts +18 -1
  225. package/dist/output/sdr-rendering.js +39 -2
  226. package/dist/output/sdr-rendering.js.map +1 -1
  227. package/dist/sensor/binomial-sample.d.ts +3 -0
  228. package/dist/sensor/binomial-sample.js +86 -0
  229. package/dist/sensor/binomial-sample.js.map +1 -0
  230. package/dist/sensor/native-sensor-report.d.ts +10 -0
  231. package/dist/sensor/native-sensor-report.js +16 -0
  232. package/dist/sensor/native-sensor-report.js.map +1 -0
  233. package/dist/sensor/sensor-characteristics.d.ts +91 -13
  234. package/dist/sensor/sensor-characteristics.js +30 -15
  235. package/dist/sensor/sensor-characteristics.js.map +1 -1
  236. package/docs/AGENT_GUIDE.md +1 -0
  237. package/docs/API_REFERENCE.md +214 -4
  238. package/docs/QUICK_START.md +162 -8
  239. package/docs/USAGE.md +195 -22
  240. package/docs/api/capture-c2pa-embed.md +177 -0
  241. package/docs/api/capture-dng-import.md +86 -10
  242. package/docs/api/capture-dng-opcodes.md +93 -0
  243. package/docs/api/capture-dng-profile-maps.md +141 -0
  244. package/docs/api/capture-dng-stage-image.md +43 -0
  245. package/docs/api/capture-jpeg-xl-tiles.md +33 -0
  246. package/docs/api/capture-lossy-jpeg.md +41 -0
  247. package/docs/api/capture-native-raw-development.md +2 -1
  248. package/docs/api/core-execution-error.md +43 -0
  249. package/docs/api/core-version.md +1 -1
  250. package/docs/api/equipment-generic-lens-catalogue.md +10 -5
  251. package/docs/api/equipment-sensor-profile-body.md +64 -0
  252. package/docs/api/equipment-sensor-profiles.md +86 -0
  253. package/docs/api/exports.json +460 -5
  254. package/docs/api/facade-display-view-gpu.md +5 -2
  255. package/docs/api/facade-display-view.md +11 -15
  256. package/docs/api/facade-exposure-build-up.md +105 -0
  257. package/docs/api/facade-fast-methods.md +47 -10
  258. package/docs/api/facade-image-plane-enable.md +16 -0
  259. package/docs/api/facade-mixed-illumination.md +67 -0
  260. package/docs/api/facade-quality-paths.md +24 -0
  261. package/docs/api/facade-representative-light-sources.md +131 -0
  262. package/docs/api/facade-scene-radiance.md +54 -3
  263. package/docs/api/facade-simulate-capture.md +48 -11
  264. package/docs/api/facade-simulate-display-view.md +10 -12
  265. package/docs/api/gpu-image-kernel-execution.md +0 -36
  266. package/docs/api/motion-subject-motion.md +23 -0
  267. package/docs/api/optics-generic-lens-lateral-color.md +79 -0
  268. package/docs/api/output-camera-channel-response.md +55 -0
  269. package/docs/api/output-developed-lens-corrections.md +10 -1
  270. package/docs/api/output-generic-lens-corrections.md +40 -4
  271. package/docs/api/output-print-plan.md +35 -1
  272. package/docs/api/output-sdr-rendering.md +6 -1
  273. package/docs/api/sensor-sensor-characteristics.md +54 -2
  274. package/llms.txt +3 -0
  275. package/package.json +6 -5
@@ -1 +1 @@
1
- {"version":3,"file":"display-view-gpu.js","sourceRoot":"","sources":["../../src/facade/display-view-gpu.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAgC3E,0IAA0I;AAC1I,MAAM,UAAU,8BAA8B,CAAC,KAAc,EAAE,IAAI,GAAG,KAAK;IACzE,IAAI,KAAK,KAAK,SAAS;QAAE,KAAK,GAAG,EAAE,CAAC;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,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AY,CAAC;IAC5F,MAAM,WAAW,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,eAAe,EAAE,+BAA+B,GAAG,GAAG,GAAG,iCAAiC,GAAG,MAAM,CAAC,CAAC,CAAC;IACrL,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,kBAAkB,EAAE,IAAI,EAAE,KAAK;QACvJ,uBAAuB,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,gCAAgC,EAAE,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC,CAAC;AACvK,CAAC;AA4ED,IAAI,eAAe,GAAyC,IAAI,CAAC;AACjE;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAAC,OAA6C;IAC5F,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,UAAU;QAAE,MAAM,IAAI,yBAAyB,CAAC,8DAA8D,CAAC,CAAC;IAC3J,MAAM,QAAQ,GAAG,eAAe,CAAC;IACjC,eAAe,GAAG,OAAO,CAAC;IAC1B,OAAO,QAAQ,CAAC;AAClB,CAAC;AACD,wCAAwC;AACxC,MAAM,UAAU,6BAA6B,KAA2C,OAAO,eAAe,CAAC,CAAC,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * #481: how a prepared display view chooses between a WebGPU preview renderer and the CPU reference, and how a render labels\n * which ran. This module holds the option, the label and the renderer contract and imports nothing from the GPU code, so a\n * bundle that never asks for the GPU (`gpu: \"off\"`, the default) does not contain it; the device handling lives in\n * `display-view-gpu-session.ts`, loaded on demand by `prepareDisplayView` when `gpu` is `\"auto\"` or `\"require\"`.\n *\n * The vocabulary is the image-kernel accelerator's (`createImageKernelAccelerator`, docs/WEBGPU.md): `\"auto\"` is\n * `backend: \"webgpu-f32\"` with `fallback: \"cpu-reference\"`, `\"require\"` is `fallback: \"fail\"`, `\"off\"` is\n * `backend: \"cpu-reference\"`. The render's `diagnostics.fast.execution` names the backend that ran, the fallback reason and the\n * bound in the fields of `ImageKernelExecution`, plus the adapter and the run-time conformance check.\n *\n * No GPU display-view renderer exists yet (#478, #479): until one registers itself through {@link setDisplayViewGpuRendererFactory},\n * `\"auto\"` runs the CPU reference labelled `unsupported-on-backend` without touching a device, and `\"require\"` fails with that reason.\n */\n\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport type { ChartCompositeProbeRecord, ImageKernelAdapterDescription, ImageKernelBackend, ImageKernelExecution, ImageKernelFallbackReason } from \"../gpu/image-kernel-execution.js\";\nimport type { DisplayViewRenderResult, DisplayViewSetup } from \"./display-view.js\";\nimport type { SimulateCaptureFastReport } from \"./simulate-capture.js\";\n\n/**\n * 2.11 (#481): whether a prepared display view may render on the GPU. `\"off\"` (the default) is the CPU reference, today's\n * behaviour byte for byte. `\"auto\"` renders on WebGPU when a conforming device is available and the request is supported, and\n * otherwise runs the CPU reference and says why. `\"require\"` fails instead of falling back. In the accelerator's words: `\"auto\"`\n * is `backend: \"webgpu-f32\"` with `fallback: \"cpu-reference\"`, `\"require\"` is `fallback: \"fail\"`, `\"off\"` is `backend: \"cpu-reference\"`.\n */\nexport type DisplayViewGpuMode = \"off\" | \"auto\" | \"require\";\n\n/** 2.11 (#481): the second argument of `prepareDisplayView`. */\nexport interface PrepareDisplayViewOptions {\n /**\n * See {@link DisplayViewGpuMode}. 2.20.0: default `\"auto\"` when the request resolves to fast (`fast` omitted or true: the\n * display view's default) and `\"off\"` when it is exact (`fast: false`); an explicit value wins.\n */\n gpu?: DisplayViewGpuMode;\n /**\n * Where the device comes from, with `gpu: \"auto\"` or `\"require\"`: a WebGPU entry point (a worker's `navigator.gpu`), or an\n * `ImageKernelAccelerator` whose device the view shares (the accelerator keeps ownership; `dispose()` of the prepared view\n * leaves it alone). Without it the engine acquires a device from `globalThis.navigator.gpu` and owns it until `dispose()`.\n * Refused when `gpu` is or defaults to `\"off\"`.\n */\n gpuDevice?: unknown;\n}\n\n/** The parsed form of {@link PrepareDisplayViewOptions}. @internal */\nexport interface ParsedPrepareDisplayViewOptions { gpu: DisplayViewGpuMode; gpuDevice: unknown }\n\n/** Internal: validates the second argument of `prepareDisplayView`; `fast` is the request's resolved top-level fast (the GPU default). */\nexport function parsePrepareDisplayViewOptions(value: unknown, fast = false): ParsedPrepareDisplayViewOptions {\n if (value === undefined) value = {};\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) throw new InvalidConfigurationError(\"prepareDisplayView options must be an object { gpu, gpuDevice }.\");\n for (const key of Object.keys(value)) if (key !== \"gpu\" && key !== \"gpuDevice\") throw new InvalidConfigurationError(\"Unknown prepareDisplayView options field: \" + key + \".\");\n const { gpu, gpuDevice } = value as Record<string, unknown>;\n const mode: DisplayViewGpuMode = gpu === undefined ? fast ? \"auto\" : \"off\" : gpu as DisplayViewGpuMode;\n if (mode !== \"off\" && mode !== \"auto\" && mode !== \"require\") throw new InvalidConfigurationError(\"prepareDisplayView options.gpu must be \\\"off\\\", \\\"auto\\\" or \\\"require\\\".\");\n if (gpuDevice !== undefined && (typeof gpuDevice !== \"object\" || gpuDevice === null)) throw new InvalidConfigurationError(\"prepareDisplayView options.gpuDevice must be a WebGPU entry point (navigator.gpu) or an ImageKernelAccelerator.\");\n if (gpuDevice !== undefined && mode === \"off\") throw new InvalidConfigurationError(\"prepareDisplayView options.gpuDevice needs gpu \\\"auto\\\" or \\\"require\\\".\");\n return { gpu: mode, gpuDevice };\n}\n\n/**\n * 2.11 (#481): why a display view that asked for the GPU (`gpu: \"auto\"`) ran the CPU reference. The accelerator's acquisition\n * reasons, plus: `unsupported-on-backend` (no GPU display-view renderer exists in this version, or it does not support the\n * request), `conformance-failed` (the device failed the run-time self-check before the view's first GPU render), `device-lost`\n * (the device was lost; the rest of the view runs on the CPU) and `disposed` (the prepared view was disposed).\n */\nexport type DisplayViewGpuFallbackReason = ImageKernelFallbackReason | \"unsupported-on-backend\" | \"conformance-failed\" | \"device-lost\" | \"disposed\";\n\n/** 2.11 (#481): the run-time conformance self-check of a device, run once before the view's first GPU render. */\nexport interface DisplayViewGpuConformance {\n /** The ids of the cases run, in order (the built-in image-kernel cases, then the renderer's own). */\n cases: readonly string[];\n passed: boolean;\n /** The first case that failed, or null. */\n failedCase: string | null;\n /** What the failed case reported, or null. */\n detail: string | null;\n}\n\n/**\n * 2.11 (#481): where a display view's render ran, in the words of the image-kernel execution record (`ImageKernelExecution`):\n * `backend` names the path that ran (`cpu-reference`, the float64 engine reference, or `webgpu-f32`, a float32 approximation\n * within `errorBound`), `requestedBackend` what `gpu` asked for, and `fallbackReason` why a request for the GPU ran the CPU.\n * `adapter` describes the device's adapter whenever one was involved, also when the view then fell back; `conformance` is\n * the device's self-check once it has run. A CPU render keeps `assurance: \"engine-reference\"` and `fast: false`.\n */\nexport interface DisplayViewExecution extends Omit<ImageKernelExecution, \"fallbackReason\"> {\n /** The `gpu` option the view was prepared with. */\n gpu: DisplayViewGpuMode;\n fallbackReason: DisplayViewGpuFallbackReason | null;\n adapter: ImageKernelAdapterDescription | null;\n conformance: DisplayViewGpuConformance | null;\n /**\n * 2.11: the composite chart kernel's device probe when this render needed it (composite charts, the 2.3 elements and\n * `material-layers` scenes): the device class and the product path the kernel ran with, or, on a refusal (`fallbackReason`\n * `unsupported-on-backend`), why. Null when the render did not run the probe (the 2.0 presets, `gpu: \"off\"`).\n */\n compositeProbe: ChartCompositeProbeRecord | null;\n}\n\n/** 2.11 (#481): `diagnostics.fast` of a display view: the capture's report plus where the render ran. */\nexport interface DisplayViewFastReport extends SimulateCaptureFastReport {\n /** Where this render ran (see {@link DisplayViewExecution}). `assurance` above follows it. */\n execution: DisplayViewExecution;\n}\n\nconst CPU_LIMITATIONS = /* @__PURE__ */ Object.freeze([\"Float64 engine reference execution; results are the reference by definition\"]);\n\n/** Internal: the execution record of a display view rendered on the CPU reference. `requested` names what `gpu` asked for. */\nexport function cpuDisplayViewExecution(gpu: DisplayViewGpuMode, fallbackReason: DisplayViewGpuFallbackReason | null, adapter: ImageKernelAdapterDescription | null,\n conformance: DisplayViewGpuConformance | null, detail?: string, compositeProbe: ChartCompositeProbeRecord | null = null): DisplayViewExecution {\n const requestedBackend: ImageKernelBackend = gpu === \"off\" ? \"cpu-reference\" : \"webgpu-f32\";\n const limitations = detail === undefined ? CPU_LIMITATIONS : Object.freeze([...CPU_LIMITATIONS, \"WebGPU was requested (gpu: \\\"\" + gpu + \"\\\") and the CPU reference ran: \" + detail]);\n return Object.freeze({ gpu, backend: \"cpu-reference\", requestedBackend, fallbackReason, arithmetic: \"float64\", assurance: \"engine-reference\", fast: false,\n bitIdenticalToReference: true, errorBound: null, diagnosticsExact: true, diagnosticUncertaintySampleCount: 0, limitations, adapter, conformance, compositeProbe });\n}\n\n// ---------------------------------------------------------------------------------------------------------------\n// The renderer contract (#478 implements it; until then the only implementation is a test fake).\n\n/**\n * Internal (#481): the device a renderer or conformance case runs on. It is the engine's `WebGpuRuntime` object\n * (`src/gpu/webgpu-runtime.ts`: `device`, `guard`, `destroy` and the rest), seen here through its WebGPU-free members only so\n * that no WebGPU type reaches the published declarations (docs/WEBGPU.md); a renderer in the engine casts it to `WebGpuRuntime`.\n */\nexport interface DisplayViewGpuRuntimeHandle {\n readonly adapter: ImageKernelAdapterDescription | null;\n readonly maximumStorageBindingBytes: number;\n readonly maximumWorkgroupsPerDimension: number;\n isLost(): boolean;\n}\n\n/** What a prepared request asks of a GPU renderer (`supports`): the options that shape a render. */\nexport interface DisplayViewGpuRequest {\n ahd: boolean;\n diffraction: boolean;\n antiAliasing: boolean;\n /** Pixel-aperture samples per axis (1: centre sampling). */\n boxSamples: number;\n toneCurve: \"identity\" | \"positive-reinhard-per-channel\";\n /**\n * #492: true when `lens.defocus` needs the defocus disc (out of focus): the expected signal then carries the disc, or each\n * node's diffraction kernel convolved with it, as site kernels (#492 step 2b), which the engine's renderer gathers in its\n * Quality site pass (step 2c). Absent or false otherwise.\n */\n defocus?: boolean;\n /**\n * #564: true when the defocus kernel's radius is above 64 sites, so the expected signal convolves it by runs on the CPU\n * (`largeKernel`); no GPU renderer takes it. Absent or false otherwise.\n */\n largeDefocus?: boolean;\n /**\n * #563: true when the request has `lens.projection`, `lens.distortion`, `lens.vignetting` or camera rotation: the CPU reference\n * renders it (display-view-lens-signal.ts) and no GPU renderer is asked or device requested (`unsupported-on-backend`).\n */\n lens?: boolean;\n /** The scene's form: an engine chart, a declared `material-layers` scene (#491), or a caller function. */\n scene: \"chart\" | \"material-layers\" | \"material-function\" | \"reflectance-function\" | \"radiance-function\";\n}\n/** One render of a region: the CPU renderer's own setup (tables, readout, demosaic, region, callbacks) and the render's signal. */\nexport interface DisplayViewGpuPart { setup: DisplayViewSetup; signal: AbortSignal | undefined }\n/** What a GPU render returns: the CPU renderer's result shape plus the a-priori bound of its values against the reference. */\nexport interface DisplayViewGpuRenderOutput extends DisplayViewRenderResult {\n errorBound: NonNullable<ImageKernelExecution[\"errorBound\"]>;\n /** Samples whose float32 classification fell inside its bound (0 when none). */\n diagnosticUncertaintySampleCount?: number;\n /** The composite chart kernel's device probe record, when the render used the composite material module. */\n compositeProbe?: ChartCompositeProbeRecord;\n}\n/** A conformance case: returns `true` when the device agrees with the reference within the case's bound, or a sentence saying how it did not. */\nexport interface DisplayViewGpuConformanceCase { id: string; run(runtime: DisplayViewGpuRuntimeHandle, signal: AbortSignal | undefined): Promise<true | string> }\n/**\n * Internal (#481): the contract a GPU display-view renderer fulfils (#478). One instance serves one device, created by the\n * registered factory for each prepared view that acquires or shares a device. `supports` says whether the renderer covers a\n * prepared request (`true`) or why not (a sentence; the view then runs the CPU reference labelled `unsupported-on-backend`).\n * `render` renders one region on the device and must throw `ImageKernelExecutionError` with reason `device-lost` or `aborted`\n * for those two events, as the accelerator's operations do; a render that throws `unsupported-on-backend` (a request the\n * renderer finds it does not cover only when rendering) runs the CPU reference labelled with that reason, or fails with it under\n * `\"require\"`. `conformanceCases` are run after the built-in image-kernel cases before the device's first render; a failure keeps\n * the whole view on the CPU. `dispose` releases what the renderer holds on the device (#491: uploaded scene records); the session\n * calls it when the prepared view is disposed.\n */\nexport interface DisplayViewGpuRenderer {\n readonly id: string;\n supports(request: DisplayViewGpuRequest): true | string;\n render(part: DisplayViewGpuPart): Promise<DisplayViewGpuRenderOutput>;\n readonly conformanceCases?: readonly DisplayViewGpuConformanceCase[];\n dispose?(): void;\n}\nexport type DisplayViewGpuRendererFactory = (runtime: DisplayViewGpuRuntimeHandle) => DisplayViewGpuRenderer;\n\nlet rendererFactory: DisplayViewGpuRendererFactory | null = null;\n/**\n * Internal (#481): registers the renderer that `prepareDisplayView` uses for `gpu: \"auto\" | \"require\"`, and returns the one\n * registered before (null: none). #478's renderer registers itself here; tests register a fake. With none registered no device\n * is requested and every GPU request falls back (or fails) with `unsupported-on-backend`.\n */\nexport function setDisplayViewGpuRendererFactory(factory: DisplayViewGpuRendererFactory | null): DisplayViewGpuRendererFactory | null {\n if (factory !== null && typeof factory !== \"function\") throw new InvalidConfigurationError(\"setDisplayViewGpuRendererFactory expects a function or null.\");\n const previous = rendererFactory;\n rendererFactory = factory;\n return previous;\n}\n/** Internal: the registered factory. */\nexport function displayViewGpuRendererFactory(): DisplayViewGpuRendererFactory | null { return rendererFactory; }\n"]}
1
+ {"version":3,"file":"display-view-gpu.js","sourceRoot":"","sources":["../../src/facade/display-view-gpu.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAiC3E,0IAA0I;AAC1I,MAAM,UAAU,8BAA8B,CAAC,KAAc,EAAE,IAAI,GAAG,KAAK;IACzE,IAAI,KAAK,KAAK,SAAS;QAAE,KAAK,GAAG,EAA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,MAAe,EAAE,iBAAmD,IAAI;IACvH,MAAM,gBAAgB,GAAuB,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,YAAY,CAAC;IAC5F,MAAM,WAAW,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,eAAe,EAAE,+BAA+B,GAAG,GAAG,GAAG,iCAAiC,GAAG,MAAM,CAAC,CAAC,CAAC;IACrL,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,kBAAkB,EAAE,IAAI,EAAE,KAAK;QACvJ,uBAAuB,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,gCAAgC,EAAE,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC,CAAC;AACvK,CAAC;AAsFD,IAAI,eAAe,GAAyC,IAAI,CAAC;AACjE;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAAC,OAA6C;IAC5F,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,UAAU;QAAE,MAAM,IAAI,yBAAyB,CAAC,8DAA8D,CAAC,CAAC;IAC3J,MAAM,QAAQ,GAAG,eAAe,CAAC;IACjC,eAAe,GAAG,OAAO,CAAC;IAC1B,OAAO,QAAQ,CAAC;AAClB,CAAC;AACD,wCAAwC;AACxC,MAAM,UAAU,6BAA6B,KAA2C,OAAO,eAAe,CAAC,CAAC,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * #481: how a prepared display view chooses between a WebGPU preview renderer and the CPU reference, and how a render labels\n * which ran. This module holds the option, the label and the renderer contract and imports nothing from the GPU code, so a\n * bundle that never asks for the GPU (`gpu: \"off\"`, the default) does not contain it; the device handling lives in\n * `display-view-gpu-session.ts`, loaded on demand by `prepareDisplayView` when `gpu` is `\"auto\"` or `\"require\"`.\n *\n * The vocabulary is the image-kernel accelerator's (`createImageKernelAccelerator`, docs/WEBGPU.md): `\"auto\"` is\n * `backend: \"webgpu-f32\"` with `fallback: \"cpu-reference\"`, `\"require\"` is `fallback: \"fail\"`, `\"off\"` is\n * `backend: \"cpu-reference\"`. The render's `diagnostics.fast.execution` names the backend that ran, the fallback reason and the\n * bound in the fields of `ImageKernelExecution`, plus the adapter and the run-time conformance check.\n *\n * No GPU display-view renderer exists yet (#478, #479): until one registers itself through {@link setDisplayViewGpuRendererFactory},\n * `\"auto\"` runs the CPU reference labelled `unsupported-on-backend` without touching a device, and `\"require\"` fails with that reason.\n */\n\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport type { ChartCompositeProbeRecord, ImageKernelAdapterDescription, ImageKernelBackend, ImageKernelExecution, ImageKernelFallbackReason } from \"../gpu/image-kernel-execution.js\";\nimport type { DisplayViewRenderResult, DisplayViewSetup } from \"./display-view.js\";\nimport type { SimulateCaptureFastReport } from \"./simulate-capture.js\";\nimport type { SdrToneCurve } from \"../output/sdr-rendering.js\";\n\n/**\n * 2.11 (#481): whether a prepared display view may render on the GPU. `\"off\"` (the default) is the CPU reference, today's\n * behaviour byte for byte. `\"auto\"` renders on WebGPU when a conforming device is available and the request is supported, and\n * otherwise runs the CPU reference and says why. `\"require\"` fails instead of falling back. In the accelerator's words: `\"auto\"`\n * is `backend: \"webgpu-f32\"` with `fallback: \"cpu-reference\"`, `\"require\"` is `fallback: \"fail\"`, `\"off\"` is `backend: \"cpu-reference\"`.\n */\nexport type DisplayViewGpuMode = \"off\" | \"auto\" | \"require\";\n\n/** 2.11 (#481): the second argument of `prepareDisplayView`. */\nexport interface PrepareDisplayViewOptions {\n /**\n * See {@link DisplayViewGpuMode}. 2.20.0: default `\"auto\"` when the request resolves to fast (`fast` omitted or true: the\n * display view's default) and `\"off\"` when it is exact (`fast: false`); an explicit value wins.\n */\n gpu?: DisplayViewGpuMode;\n /**\n * Where the device comes from, with `gpu: \"auto\"` or `\"require\"`: a WebGPU entry point (a worker's `navigator.gpu`), or an\n * `ImageKernelAccelerator` whose device the view shares (the accelerator keeps ownership; `dispose()` of the prepared view\n * leaves it alone). Without it the engine acquires a device from `globalThis.navigator.gpu` and owns it until `dispose()`.\n * Refused when `gpu` is or defaults to `\"off\"`.\n */\n gpuDevice?: unknown;\n}\n\n/** The parsed form of {@link PrepareDisplayViewOptions}. @internal */\nexport interface ParsedPrepareDisplayViewOptions { gpu: DisplayViewGpuMode; gpuDevice: unknown }\n\n/** Internal: validates the second argument of `prepareDisplayView`; `fast` is the request's resolved top-level fast (the GPU default). */\nexport function parsePrepareDisplayViewOptions(value: unknown, fast = false): ParsedPrepareDisplayViewOptions {\n if (value === undefined) value = {};\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) throw new InvalidConfigurationError(\"prepareDisplayView options must be an object { gpu, gpuDevice }.\");\n for (const key of Object.keys(value)) if (key !== \"gpu\" && key !== \"gpuDevice\") throw new InvalidConfigurationError(\"Unknown prepareDisplayView options field: \" + key + \".\");\n const { gpu, gpuDevice } = value as Record<string, unknown>;\n const mode: DisplayViewGpuMode = gpu === undefined ? fast ? \"auto\" : \"off\" : gpu as DisplayViewGpuMode;\n if (mode !== \"off\" && mode !== \"auto\" && mode !== \"require\") throw new InvalidConfigurationError(\"prepareDisplayView options.gpu must be \\\"off\\\", \\\"auto\\\" or \\\"require\\\".\");\n if (gpuDevice !== undefined && (typeof gpuDevice !== \"object\" || gpuDevice === null)) throw new InvalidConfigurationError(\"prepareDisplayView options.gpuDevice must be a WebGPU entry point (navigator.gpu) or an ImageKernelAccelerator.\");\n if (gpuDevice !== undefined && mode === \"off\") throw new InvalidConfigurationError(\"prepareDisplayView options.gpuDevice needs gpu \\\"auto\\\" or \\\"require\\\".\");\n return { gpu: mode, gpuDevice };\n}\n\n/**\n * 2.11 (#481): why a display view that asked for the GPU (`gpu: \"auto\"`) ran the CPU reference. The accelerator's acquisition\n * reasons, plus: `unsupported-on-backend` (no GPU display-view renderer exists in this version, or it does not support the\n * request), `conformance-failed` (the device failed the run-time self-check before the view's first GPU render), `device-lost`\n * (the device was lost; the rest of the view runs on the CPU) and `disposed` (the prepared view was disposed). 2.22.0 (#594):\n * `quality-code-unavailable` (the on-demand GPU full-quality code could not be loaded; that render runs the CPU reference, and\n * the next render that needs the code tries to load it again).\n */\nexport type DisplayViewGpuFallbackReason = ImageKernelFallbackReason | \"unsupported-on-backend\" | \"conformance-failed\" | \"device-lost\" | \"disposed\" |\n \"quality-code-unavailable\";\n\n/** 2.11 (#481): the run-time conformance self-check of a device, run once before the view's first GPU render. */\nexport interface DisplayViewGpuConformance {\n /** The ids of the cases run, in order (the built-in image-kernel cases, then the renderer's own). */\n cases: readonly string[];\n passed: boolean;\n /** The first case that failed, or null. */\n failedCase: string | null;\n /** What the failed case reported, or null. */\n detail: string | null;\n}\n\n/**\n * 2.11 (#481): where a display view's render ran, in the words of the image-kernel execution record (`ImageKernelExecution`):\n * `backend` names the path that ran (`cpu-reference`, the float64 engine reference, or `webgpu-f32`, a float32 approximation\n * within `errorBound`), `requestedBackend` what `gpu` asked for, and `fallbackReason` why a request for the GPU ran the CPU.\n * `adapter` describes the device's adapter whenever one was involved, also when the view then fell back; `conformance` is\n * the device's self-check once it has run. A CPU render keeps `assurance: \"engine-reference\"` and `fast: false`.\n */\nexport interface DisplayViewExecution extends Omit<ImageKernelExecution, \"fallbackReason\"> {\n /** The `gpu` option the view was prepared with. */\n gpu: DisplayViewGpuMode;\n fallbackReason: DisplayViewGpuFallbackReason | null;\n adapter: ImageKernelAdapterDescription | null;\n conformance: DisplayViewGpuConformance | null;\n /**\n * 2.11: the composite chart kernel's device probe when this render needed it (composite charts, the 2.3 elements and\n * `material-layers` scenes): the device class and the product path the kernel ran with, or, on a refusal (`fallbackReason`\n * `unsupported-on-backend`), why. Null when the render did not run the probe (the 2.0 presets, `gpu: \"off\"`).\n */\n compositeProbe: ChartCompositeProbeRecord | null;\n}\n\n/** 2.11 (#481): `diagnostics.fast` of a display view: the capture's report plus where the render ran. */\nexport interface DisplayViewFastReport extends SimulateCaptureFastReport {\n /** Where this render ran (see {@link DisplayViewExecution}). `assurance` above follows it. */\n execution: DisplayViewExecution;\n}\n\nconst CPU_LIMITATIONS = /* @__PURE__ */ Object.freeze([\"Float64 engine reference execution; results are the reference by definition\"]);\n\n/** Internal: the execution record of a display view rendered on the CPU reference. `requested` names what `gpu` asked for. */\nexport function cpuDisplayViewExecution(gpu: DisplayViewGpuMode, fallbackReason: DisplayViewGpuFallbackReason | null, adapter: ImageKernelAdapterDescription | null,\n conformance: DisplayViewGpuConformance | null, detail?: string, compositeProbe: ChartCompositeProbeRecord | null = null): DisplayViewExecution {\n const requestedBackend: ImageKernelBackend = gpu === \"off\" ? \"cpu-reference\" : \"webgpu-f32\";\n const limitations = detail === undefined ? CPU_LIMITATIONS : Object.freeze([...CPU_LIMITATIONS, \"WebGPU was requested (gpu: \\\"\" + gpu + \"\\\") and the CPU reference ran: \" + detail]);\n return Object.freeze({ gpu, backend: \"cpu-reference\", requestedBackend, fallbackReason, arithmetic: \"float64\", assurance: \"engine-reference\", fast: false,\n bitIdenticalToReference: true, errorBound: null, diagnosticsExact: true, diagnosticUncertaintySampleCount: 0, limitations, adapter, conformance, compositeProbe });\n}\n\n// ---------------------------------------------------------------------------------------------------------------\n// The renderer contract (#478 implements it; until then the only implementation is a test fake).\n\n/**\n * Internal (#481): the device a renderer or conformance case runs on. It is the engine's `WebGpuRuntime` object\n * (`src/gpu/webgpu-runtime.ts`: `device`, `guard`, `destroy` and the rest), seen here through its WebGPU-free members only so\n * that no WebGPU type reaches the published declarations (docs/WEBGPU.md); a renderer in the engine casts it to `WebGpuRuntime`.\n */\nexport interface DisplayViewGpuRuntimeHandle {\n readonly adapter: ImageKernelAdapterDescription | null;\n readonly maximumStorageBindingBytes: number;\n readonly maximumWorkgroupsPerDimension: number;\n isLost(): boolean;\n}\n\n/** What a prepared request asks of a GPU renderer (`supports`): the options that shape a render. */\nexport interface DisplayViewGpuRequest {\n ahd: boolean;\n diffraction: boolean;\n antiAliasing: boolean;\n /** Pixel-aperture samples per axis (1: centre sampling). */\n boxSamples: number;\n toneCurve: SdrToneCurve;\n /** #593, #601: true with `highlightMode: \"reconstruct\"` or `gamutHandling: \"desaturate-to-luminance\"` (coupled rendering steps). */\n coupled?: boolean;\n /**\n * #492: true when `lens.defocus` needs the defocus disc (out of focus): the expected signal then carries the disc, or each\n * node's diffraction kernel convolved with it, as site kernels (#492 step 2b), which the engine's renderer gathers in its\n * Quality site pass (step 2c). Absent or false otherwise.\n */\n defocus?: boolean;\n /**\n * #564: true when the defocus kernel's radius is above 64 sites, so the expected signal convolves it by runs on the CPU\n * (`largeKernel`); no GPU renderer takes it. Absent or false otherwise.\n */\n largeDefocus?: boolean;\n /**\n * #563: true when the request has `lens.projection`, `lens.distortion`, `lens.vignetting` or camera rotation: the CPU reference\n * renders it (display-view-lens-signal.ts) and no GPU renderer is asked or device requested (`unsupported-on-backend`).\n */\n lens?: boolean;\n /**\n * #550: true when the request has `illumination` (mixed lighting): the radiance at a point is no longer a function of its\n * material, so the GPU material lookup cannot render it; the CPU reference does, exactly, and no device is requested.\n */\n mixedIllumination?: boolean;\n /** The scene's form: an engine chart, a declared `material-layers` scene (#491), or a caller function. */\n scene: \"chart\" | \"material-layers\" | \"material-function\" | \"reflectance-function\" | \"radiance-function\" | \"image-plane\";\n}\n/** One render of a region: the CPU renderer's own setup (tables, readout, demosaic, region, callbacks) and the render's signal. */\nexport interface DisplayViewGpuPart { setup: DisplayViewSetup; signal: AbortSignal | undefined }\n/** What a GPU render returns: the CPU renderer's result shape plus the a-priori bound of its values against the reference. */\nexport interface DisplayViewGpuRenderOutput extends DisplayViewRenderResult {\n errorBound: NonNullable<ImageKernelExecution[\"errorBound\"]>;\n /** Samples whose float32 classification fell inside its bound (0 when none). */\n diagnosticUncertaintySampleCount?: number;\n /** The composite chart kernel's device probe record, when the render used the composite material module. */\n compositeProbe?: ChartCompositeProbeRecord;\n}\n/** A conformance case: returns `true` when the device agrees with the reference within the case's bound, or a sentence saying how it did not. */\nexport interface DisplayViewGpuConformanceCase { id: string; run(runtime: DisplayViewGpuRuntimeHandle, signal: AbortSignal | undefined): Promise<true | string> }\n/**\n * Internal (#481): the contract a GPU display-view renderer fulfils (#478). One instance serves one device, created by the\n * registered factory for each prepared view that acquires or shares a device. `supports` says whether the renderer covers a\n * prepared request (`true`) or why not (a sentence; the view then runs the CPU reference labelled `unsupported-on-backend`).\n * `render` renders one region on the device and must throw `ImageKernelExecutionError` with reason `device-lost` or `aborted`\n * for those two events, as the accelerator's operations do; a render that throws `unsupported-on-backend` (a request the\n * renderer finds it does not cover only when rendering) runs the CPU reference labelled with that reason, or fails with it under\n * `\"require\"`. `conformanceCases` are run after the built-in image-kernel cases before the device's first render; a failure keeps\n * the whole view on the CPU. #594: `onDemandConformanceCases` returns the cases a render needs beyond those (code the renderer\n * loads on demand, such as the Quality kernels), or null; they run once, before the first render that returns them, and their\n * ids are appended to the conformance record; a failure keeps that render and every later one on the CPU. `dispose` releases\n * what the renderer holds on the device (#491: uploaded scene records); the session calls it when the prepared view is disposed.\n */\nexport interface DisplayViewGpuRenderer {\n readonly id: string;\n supports(request: DisplayViewGpuRequest): true | string;\n render(part: DisplayViewGpuPart): Promise<DisplayViewGpuRenderOutput>;\n readonly conformanceCases?: readonly DisplayViewGpuConformanceCase[];\n onDemandConformanceCases?(setup: DisplayViewSetup): Promise<readonly DisplayViewGpuConformanceCase[]> | null;\n dispose?(): void;\n}\nexport type DisplayViewGpuRendererFactory = (runtime: DisplayViewGpuRuntimeHandle) => DisplayViewGpuRenderer;\n\nlet rendererFactory: DisplayViewGpuRendererFactory | null = null;\n/**\n * Internal (#481): registers the renderer that `prepareDisplayView` uses for `gpu: \"auto\" | \"require\"`, and returns the one\n * registered before (null: none). #478's renderer registers itself here; tests register a fake. With none registered no device\n * is requested and every GPU request falls back (or fails) with `unsupported-on-backend`.\n */\nexport function setDisplayViewGpuRendererFactory(factory: DisplayViewGpuRendererFactory | null): DisplayViewGpuRendererFactory | null {\n if (factory !== null && typeof factory !== \"function\") throw new InvalidConfigurationError(\"setDisplayViewGpuRendererFactory expects a function or null.\");\n const previous = rendererFactory;\n rendererFactory = factory;\n return previous;\n}\n/** Internal: the registered factory. */\nexport function displayViewGpuRendererFactory(): DisplayViewGpuRendererFactory | null { return rendererFactory; }\n"]}
@@ -47,7 +47,7 @@
47
47
  import { InvalidConfigurationError } from "../core/configuration-error.js";
48
48
  import { createSiteKernelRunsLattice } from "../optics/site-kernel-runs.js";
49
49
  import { resolveLensSampledPsfKernel } from "../optics/lens-psf-profile.js";
50
- import { buildTables, displayViewSignalTables } from "./expected-signal.js";
50
+ import { buildTables, createMaterialSums, displayViewSignalTables, materialSpectrumSignal } from "./expected-signal.js";
51
51
  /** #569: field zones along the native raster's longer side. */
52
52
  export const DISPLAY_VIEW_LENS_PSF_ZONES = 64;
53
53
  /**
@@ -89,7 +89,7 @@ export function createDisplayViewLensPsf(psf, R, W, H, pitch, zones = DISPLAY_VI
89
89
  else {
90
90
  tables = buildTables({ ...input, kernels: { radius: R, perNode: kernelsOf(zone, input.wavelengthsNm) } }).groups;
91
91
  // Zones kept: at least 4, and at most 64 MB of them (every zone's tables have the same size).
92
- kept ||= Math.max(4, (1 << 23) / tables.reduce((n, g) => n + g.cw * g.ch * (g.neutral.length + g.spectral.flat().length + g.perNode.flat().length), 0));
92
+ kept ||= Math.max(4, (1 << 23) / tables.reduce((n, g) => n + g.cw * g.ch * (g.nodeKernels.length * input.wavelengthsNm.length + g.perNode.flat().length), 0));
93
93
  if (cache.size >= kept)
94
94
  cache.delete(cache.keys().next().value);
95
95
  }
@@ -131,7 +131,7 @@ function createLensSignal(lens, input, spanColumns) {
131
131
  const { geometry, distanceM: distance, metresPerFrameUnit: scale, pitch, imagingArea } = lens;
132
132
  const mmPerSite = pitch / 1000, scene = input.scene, offsets = input.offsets, A = input.electronsPerRadiance, channelAt = input.channelAt;
133
133
  const materials = scene.kind === "materials" ? scene : undefined, radianceAt = scene.kind === "radiance" ? scene.radianceAt : undefined;
134
- const { reflectance, spectralIndex, neutralDirect, spectralDirect, groups } = displayViewSignalTables(input);
134
+ const { spectra, groups } = displayViewSignalTables(input), acc = createMaterialSums(nodes, spectra);
135
135
  const kernels = input.kernels, R = kernels ? kernels.radius : 0;
136
136
  /** #569: the combined kernels of the zone of site (x, y), or the input's own without a field-dependent PSF. */
137
137
  const zoneTables = lens.psf ? lens.psf.tables(input) : () => groups;
@@ -157,7 +157,7 @@ function createLensSignal(lens, input, spanColumns) {
157
157
  pv = look.y * s / scale;
158
158
  pf = look.factor;
159
159
  };
160
- const materialOf = (m) => { if (spectralIndex[m] === undefined)
160
+ const materialOf = (m) => { if (spectra[m] === undefined)
161
161
  throw new InvalidConfigurationError("Unknown chart material."); return m; };
162
162
  // Without a kernel: the environment's query point of offset o of site (x, y) (native-environment-lean.ts, as buildExpectedSignalInput's queryPoint).
163
163
  const box = lens.boxSamples, siteWidthMm = pitch / 1000;
@@ -175,14 +175,14 @@ function createLensSignal(lens, input, spanColumns) {
175
175
  map((centerX - siteWidthMm / 2 + node.xPhase * siteWidthMm) - node.aaX, (centerY - siteWidthMm / 2 + node.yPhase * siteWidthMm) - node.aaY, times[ti]);
176
176
  let value;
177
177
  if (materials) {
178
- const m = materialOf(materials.materialAt(pu, pv)), si = spectralIndex[m];
179
- value = si < 0 ? reflectance[m] * neutralDirect[c] : spectralDirect[c][si];
178
+ // Integrated from the material's spectrum against the site's channel when it is read.
179
+ value = materialSpectrumSignal(A[c], spectra[materialOf(materials.materialAt(pu, pv))], nodes);
180
180
  lookups++;
181
181
  }
182
182
  else {
183
183
  value = 0;
184
184
  for (let n = 0; n < nodes; n++)
185
- value += A[c][n] * radianceAt(pu, pv, input.wavelengthsNm[n]);
185
+ value += A[c][n] * radianceAt(pu, pv, input.wavelengthsNm[n], times[ti]);
186
186
  lookups += nodes;
187
187
  }
188
188
  sum += offsets[o].weight * (pf * value);
@@ -219,7 +219,7 @@ function createLensSignal(lens, input, spanColumns) {
219
219
  }
220
220
  else {
221
221
  for (let n = 0; n < nodes; n++)
222
- radiance[n] = radianceAt(pu, pv, input.wavelengthsNm[n]);
222
+ radiance[n] = radianceAt(pu, pv, input.wavelengthsNm[n], times[ti]);
223
223
  lookups += nodes;
224
224
  }
225
225
  if (k >= 0) {
@@ -238,23 +238,24 @@ function createLensSignal(lens, input, spanColumns) {
238
238
  let total = 0;
239
239
  for (let ti = 0; ti < T; ti++) {
240
240
  let sum = 0;
241
+ acc.reset();
241
242
  for (let g = 0; g < G; g++) {
242
243
  const group = groups[g], p0 = x + group.minIx - R, q0 = y + group.minIy - R, cw = group.cw, ch = group.ch, weights = zone[g];
243
244
  if (materials) {
244
- const nk = weights.neutral[c], sk = weights.spectral[c];
245
+ const k = weights.nodeKernels[c];
245
246
  for (let dy = 0, t = 0; dy < ch; dy++) {
246
247
  // The cache row of lattice row q (read inline: the common case is a hit).
247
248
  const q = q0 + dy, row = cacheRows > 0 ? ((g * T + ti) * cacheRows + (q & rowMask)) * cacheCols : -1;
248
249
  for (let dx = 0; dx < cw; dx++, t++) {
249
- const p = p0 + dx, k = row + (p & colMask);
250
- if (row >= 0 && tagQ[k] === q && tagP[k] === p) {
251
- lm = cacheMaterial[k];
252
- lf = cacheFactor[k];
250
+ const p = p0 + dx;
251
+ const at = row + (p & colMask);
252
+ if (row >= 0 && tagQ[at] === q && tagP[at] === p) {
253
+ lm = cacheMaterial[at];
254
+ lf = cacheFactor[at];
253
255
  }
254
256
  else
255
257
  lattice(g, ti, p, q);
256
- const si = spectralIndex[lm];
257
- sum += lf * (si < 0 ? reflectance[lm] * nk[t] : sk[si][t]);
258
+ acc.add(lm, k, t * nodes, lf);
258
259
  }
259
260
  }
260
261
  }
@@ -268,7 +269,7 @@ function createLensSignal(lens, input, spanColumns) {
268
269
  sum += lf * value;
269
270
  }
270
271
  }
271
- total += sum;
272
+ total += materials ? acc.value() : sum;
272
273
  }
273
274
  return total / T;
274
275
  }
@@ -311,21 +312,20 @@ function createLensSignal(lens, input, spanColumns) {
311
312
  material[k] = materialOf(materials.materialAt(pu, pv));
312
313
  else
313
314
  for (let n = 0; n < nodes; n++)
314
- values[k * nodes + n] = radianceAt(pu, pv, input.wavelengthsNm[n]);
315
+ values[k * nodes + n] = radianceAt(pu, pv, input.wavelengthsNm[n], times[ti]);
315
316
  }
316
317
  lookups += material ? gw * gh : gw * gh * nodes;
317
318
  for (let c = 0; c < 3; c++) {
318
- const e = sum[c], nk = group.neutral[c], sk = group.spectral[c];
319
+ const e = sum[c], kc = material ? group.nodeKernels[c] : undefined;
319
320
  for (let y = 0; y < TH; y++)
320
321
  for (let x = 0; x < TW; x++) {
321
322
  let v = 0;
323
+ acc.reset();
322
324
  for (let dy = 0, t = 0; dy < ch; dy++)
323
325
  for (let dx = 0; dx < cw; dx++, t++) {
324
326
  const k = (y + dy) * gw + x + dx;
325
- if (material) {
326
- const m = material[k], si = spectralIndex[m];
327
- v += factor[k] * (si < 0 ? reflectance[m] * nk[t] : sk[si][t]);
328
- }
327
+ if (material)
328
+ acc.add(material[k], kc, t * nodes, factor[k]);
329
329
  else {
330
330
  let r = 0;
331
331
  for (let n = 0; n < nodes; n++)
@@ -333,6 +333,8 @@ function createLensSignal(lens, input, spanColumns) {
333
333
  v += factor[k] * r;
334
334
  }
335
335
  }
336
+ if (material)
337
+ v = acc.value();
336
338
  e[y * TW + x] = e[y * TW + x] + v;
337
339
  }
338
340
  }
@@ -435,7 +437,7 @@ function createLensSignal(lens, input, spanColumns) {
435
437
  try {
436
438
  for (let ti = 0; ti < T; ti++) {
437
439
  map(xMm, yMm, times[ti]);
438
- const value = beyond ? -1 : materials ? materials.materialAt(pu, pv) : radianceAt(pu, pv, pilotNode);
440
+ const value = beyond ? -1 : materials ? materials.materialAt(pu, pv) : radianceAt(pu, pv, pilotNode, times[ti]);
439
441
  lookups++;
440
442
  if (ti === 0)
441
443
  first = value;
@@ -1 +1 @@
1
- {"version":3,"file":"display-view-lens-signal.js","sourceRoot":"","sources":["../../src/facade/display-view-lens-signal.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,2BAA2B,EAAiC,MAAM,+BAA+B,CAAC;AAE3G,OAAO,EAAE,2BAA2B,EAAmC,MAAM,+BAA+B,CAAC;AAC7G,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAyF,MAAM,sBAAsB,CAAC;AAEnK,+DAA+D;AAC/D,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AAa9C;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAsE,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,KAAa,EAC7J,KAAK,GAAG,2BAA2B;IACnC,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACtF,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAChG,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,aAAgC,EAAkB,EAAE;QACnF,oHAAoH;QACpH,MAAM,EAAE,GAAG,IAAI,GAAG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,OAAO,OAAO,EAAE,CAAC,CAAC,CAAC;QAC3C,eAAe,EAAE,CAAC,CAAC;QACnB,cAAc,EAAE,KAAK;QACrB,WAAW,EAAE,KAAK;QAClB,UAAU,EAAE,KAAK;QACjB,SAAS,KAAmD,CAAC;QAC7D,MAAM,KAAuF,CAAC;QAC9F,IAAI,CAAC,CAAS,EAAE,CAAS,IAAY,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACrF,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * The display view's expected signal with a lens field mapping (`lens.projection`, `lens.distortion`), `lens.vignetting` or\n * camera rotation (#563), in focus and with `lens.defocus` out of focus. Loaded on demand (a dynamic import in `runCapture`),\n * so a display view without these options, and a bundle that never asks for them, does not load it.\n *\n * What it computes. The capture's environment chain forms, for site (i, j) of CFA channel c,\n * μ_c(i, j) = Σ_o w_o · (1/T) Σ_t Σ_λ A_c(λ) Σ_k K_λ(k) · F(s) · L(D_t(s), λ), s = q_o(i, j) − k·p,\n * with q_o the query point of offset o (pixel-aperture node minus anti-aliasing split), K_λ the site kernel (diffraction, the\n * defocus disc or both; a single unit tap without them), D_t the scene ray of sensor point s at temporal midpoint t (inverse\n * distortion, the declared projection, the camera rotation at t), F = T·A its field factor (vignetting throughput × distortion\n * area factor) and A_c(λ) the electrons per unit spectral radiance on the axis (the display view's channel response, ideal\n * optics). In focus with a kernel this is the environment PSF quadrature (the field factor applied once at the source point,\n * before the PSF spreads the light); out of focus it is #548's image-space disc, the same sum in another order\n * (`defocus-image-space-provider.ts`); without a kernel it is the environment's own per-query sum. Only the scene access changes:\n * the readout, the estimators, the demosaic and the development run unchanged on these site values.\n *\n * Scene points. Without a kernel each query point is formed with the environment's own arithmetic (the site centre, aperture node\n * and split offset of `native-environment-lean.ts`), then `lookOf` (the environment's mapping, rotation and field factor,\n * #548) and the planar provider's plane-point arithmetic, so a point exactly on a chart boundary resolves as in the capture.\n * With a kernel the sources are the site lattice of each fractional offset, with #548's lattice formula. Kernels, materials and\n * per-material sums are the display view's own tables (`displayViewSignalTables`), shared with the rectilinear path.\n *\n * Caches (memory only, never values): site values in a ring of native rows across windows, and with a kernel each lattice\n * point's material (or radiance at each node) and field factor per lattice group and temporal midpoint, in a two-dimensional\n * ring tagged with the point, sized from the window and capped at LATTICE_CACHE_LIMIT entries (beyond it, points are\n * evaluated as they are read).\n *\n * Field-dependent PSF (#569, `lens.catalogue`; {@link createDisplayViewLensPsf}). The capture's environment PSF quadrature resolves the\n * catalogue lens's sampled PSF at each query point's own field position. The view cuts the native raster into square zones of\n * Z = ⌈max(W, H) / DISPLAY_VIEW_LENS_PSF_ZONES⌉ sites (one site on frames of at most that many sites a side) and every site of a zone\n * takes the PSF the capture's own resolver gives at the zone's centre, at each spectral node (an approximation: the PSF's change\n * across half a zone). A profile kernel's rows run with image +Y (up) and its tap (i, j) reads (x − (i − c)·p, y + (j − c)·p) in\n * native coordinates (`sensorPsfSourcePoint`), so the view's kernel (reading in(x − t)) is the profile kernel flipped vertically.\n * Each zone's combined kernels are the expected signal's own tables (`buildTables`) with the zone's kernels, built when a site of\n * the zone is first read and kept per input in a least-recently-used cache of at most 64 MB (at least four zones). The zones are the\n * view's fast method for `lens.catalogue` (2.20.0); its exact method (`fast: false`) passes `zones` = max(W, H), one site per zone,\n * the capture's own PSF at each site centre (much slower).\n *\n * Large defocus kernels (#564, `input.largeKernel`, radius above 64 sites). The image-space disc D is the same at every lattice\n * group, spectral node and temporal midpoint, so it commutes with those sums as in the rectilinear signal (`expected-signal.ts`):\n * μ_c(x) = Σ_s D(s)·E_c(x − s), with E_c(x) the sum above through the in-focus kernels (each node's diffraction kernel, or a unit\n * tap) at site position x for channel c, whatever x's own channel. E is computed in fixed 64-site tiles (all three channels, each\n * group's lattice points mapped once per tile and midpoint), and D ⊛ E_c by runs (`site-kernel-runs.ts`) in fixed 128-site tiles,\n * each site taking its own channel: every value depends only on its site, so regions and parts equal the whole view.\n */\n\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { createSiteKernelRunsLattice, type SiteKernelRunsRowPattern } from \"../optics/site-kernel-runs.js\";\nimport type { PreparedDefocusImageSpaceGeometry } from \"./defocus-image-space-provider.js\";\nimport { resolveLensSampledPsfKernel, type ResolveLensSampledPsfInput } from \"../optics/lens-psf-profile.js\";\nimport { buildTables, displayViewSignalTables, type DisplayViewExpectedSignal, type DisplayViewExpectedSignalInput, type GroupTables } from \"./expected-signal.js\";\n\n/** #569: field zones along the native raster's longer side. */\nexport const DISPLAY_VIEW_LENS_PSF_ZONES = 64;\n\n/** #569: a field-dependent PSF for the display view (see the module comment). */\nexport interface DisplayViewLensPsf {\n /** Kernel radius and zone side, in sites. */\n readonly radius: number;\n readonly zoneSites: number;\n /** The kernels at the frame centre's zone, for the expected-signal input's lattice groups and reach. */\n axisKernels(wavelengthsNm: readonly number[]): { radius: number; perNode: Float64Array[] };\n /** The combined kernels of the zone of native site (x, y), for an input whose kernels are the axis kernels. */\n tables(input: DisplayViewExpectedSignalInput): (x: number, y: number) => readonly GroupTables[];\n}\n\n/**\n * #569: the field-dependent PSF of a display view from the sampled PSF the capture resolves (everything but the field point and wavelength),\n * of kernel radius R, on the W × H native raster of `pitch` µm.\n */\nexport function createDisplayViewLensPsf(psf: Omit<ResolveLensSampledPsfInput, \"fieldPointMm\" | \"wavelengthNm\">, R: number, W: number, H: number, pitch: number,\n zones = DISPLAY_VIEW_LENS_PSF_ZONES): DisplayViewLensPsf {\n const Z = Math.ceil(Math.max(W, H) / zones), zonesX = Math.ceil(W / Z), w = 2 * R + 1;\n const zoneOf = (x: number, y: number): number => Math.floor(y / Z) * zonesX + Math.floor(x / Z);\n const kernelsOf = (zone: number, wavelengthsNm: readonly number[]): Float64Array[] => {\n // The zone's centre in sites from the top-left corner (an edge zone may be narrower), in image millimetres (+Y up).\n const zx = zone % zonesX, zy = (zone - zx) / zonesX, fieldPointMm = { x: ((zx * Z + Math.min(W, zx * Z + Z)) / 2 - W / 2) * pitch / 1000,\n y: (H / 2 - (zy * Z + Math.min(H, zy * Z + Z)) / 2) * pitch / 1000 };\n return wavelengthsNm.map((wavelengthNm) => {\n // Every node of the engine-built profile has the same (2R + 1)² window, so every resolved kernel has it too.\n const values = resolveLensSampledPsfKernel({ ...psf, fieldPointMm, wavelengthNm } as ResolveLensSampledPsfInput).normalizedIntensity, out = new Float64Array(w * w);\n for (let j = 0; j < w; j++) for (let i = 0; i < w; i++) out[(w - 1 - j) * w + i] = values[j * w + i]!;\n return out;\n });\n };\n const caches = new WeakMap<DisplayViewExpectedSignalInput, (x: number, y: number) => readonly GroupTables[]>();\n return { radius: R, zoneSites: Z,\n axisKernels: (wavelengthsNm) => ({ radius: R, perNode: kernelsOf(zoneOf(W >> 1, H >> 1), wavelengthsNm) }),\n tables(input): (x: number, y: number) => readonly GroupTables[] {\n let read = caches.get(input);\n if (read) return read;\n const cache = new Map<number, readonly GroupTables[]>();\n let kept = 0, last = -1, lastTables: readonly GroupTables[] = [];\n read = (x, y): readonly GroupTables[] => {\n const zone = zoneOf(x, y);\n if (zone === last) return lastTables;\n let tables = cache.get(zone);\n if (tables) cache.delete(zone);\n else {\n tables = buildTables({ ...input, kernels: { radius: R, perNode: kernelsOf(zone, input.wavelengthsNm) } }).groups;\n // Zones kept: at least 4, and at most 64 MB of them (every zone's tables have the same size).\n kept ||= Math.max(4, (1 << 23) / tables.reduce((n, g) => n + g.cw * g.ch * (g.neutral.length + g.spectral.flat().length + g.perNode.flat().length), 0));\n if (cache.size >= kept) cache.delete(cache.keys().next().value!);\n }\n cache.set(zone, tables); last = zone; lastTables = tables;\n return tables;\n };\n caches.set(input, read);\n return read;\n } };\n}\n\n/** What the lens signal needs from the resolved request. */\nexport interface DisplayViewLensSetup {\n geometry: PreparedDefocusImageSpaceGeometry;\n /** Temporal midpoints, seconds from exposure start: (i + 0.5)·shutter/T with camera rotation, [0] without. */\n times: readonly number[];\n /** The planar provider's plane distance and frame-unit scale. */\n distanceM: number;\n metresPerFrameUnit: number;\n pitch: number;\n imagingArea: { widthMm: number; heightMm: number };\n boxSamples: number;\n /** Anti-aliasing split spots (or one zero spot), in the order of the expected signal's offsets within each aperture node. */\n spots: readonly { offsetMicrometers: { x: number; y: number } }[];\n /**\n * #569: a field-dependent lens PSF (`lens.catalogue`, {@link createDisplayViewLensPsf}): each site reads its field zone's kernels\n * instead of the input's. The input's kernels (the axis zone's) set the lattice groups and the reach; absent, every site reads them.\n */\n psf?: DisplayViewLensPsf | undefined;\n /**\n * #569 (catalogue fisheyes): a ray that does not point toward the scene plane sees no scene (zero radiance), as the capture's provider\n * with `zeroBeyondHorizon` gives it, instead of failing.\n */\n zeroBeyondHorizon?: boolean | undefined;\n}\n\n/** Largest lattice cache, in entries over all lattice groups and temporal midpoints (times the spectral nodes for radiance scenes). */\nconst LATTICE_CACHE_LIMIT = 1 << 22;\n\nconst pow2 = (n: number): number => { let p = 1; while (p < n) p *= 2; return p; };\n\n/**\n * Checks that the mapping and the vignetting profile cover the farthest source point the view reads, (W/2 + reachSites, H/2 + reachSites)\n * sites from the axis at each corner (reachSites: the kernel radius plus the largest query offset, less the half site to the outer site\n * centre), and returns the factory of the view's expected signal for this request.\n */\nexport function prepareDisplayViewLensSignal(lens: DisplayViewLensSetup, nativeWidth: number, nativeHeight: number, reachSites: number, options: string):\n (input: DisplayViewExpectedSignalInput, spanColumns?: number) => DisplayViewExpectedSignal {\n const xMm = (nativeWidth / 2 + reachSites) * lens.pitch / 1000, yMm = (nativeHeight / 2 + reachSites) * lens.pitch / 1000;\n for (const t of lens.times) for (const [x, y] of [[-xMm, -yMm], [xMm, -yMm], [-xMm, yMm], [xMm, yMm]] as const) {\n try { if (!(lens.geometry.lookOf(x, y, t).z > 0) && !lens.zeroBeyondHorizon) throw new InvalidConfigurationError(\"its ray does not point toward the scene plane.\"); } catch (error) {\n throw new InvalidConfigurationError(\"simulateDisplayView with \" + options + \" reads the scene through the lens up to \" + (reachSites + 0.5) + \" sites beyond the native \" +\n \"raster's outer site centres (the kernel radius and the query offsets), and there (\" + Math.hypot(x, y).toFixed(3) + \" mm from the axis) \" + (error as Error).message);\n }\n }\n return (input, spanColumns = Infinity) => createLensSignal(lens, input, spanColumns);\n}\n\nfunction createLensSignal(lens: DisplayViewLensSetup, input: DisplayViewExpectedSignalInput, spanColumns: number): DisplayViewExpectedSignal {\n const W = input.nativeWidth, H = input.nativeHeight, nodes = input.wavelengthsNm.length, T = lens.times.length, times = lens.times;\n const { geometry, distanceM: distance, metresPerFrameUnit: scale, pitch, imagingArea } = lens;\n const mmPerSite = pitch / 1000, scene = input.scene, offsets = input.offsets, A = input.electronsPerRadiance, channelAt = input.channelAt;\n const materials = scene.kind === \"materials\" ? scene : undefined, radianceAt = scene.kind === \"radiance\" ? scene.radianceAt : undefined;\n const { reflectance, spectralIndex, neutralDirect, spectralDirect, groups } = displayViewSignalTables(input);\n const kernels = input.kernels, R = kernels ? kernels.radius : 0;\n /** #569: the combined kernels of the zone of site (x, y), or the input's own without a field-dependent PSF. */\n const zoneTables = lens.psf ? lens.psf.tables(input) : (): typeof groups => groups;\n let lookups = 0;\n // The plane point (frame units) and field factor of native sensor point (x, y) mm at time t: the environment's mapping (lookOf) and\n // the planar provider's own arithmetic for the outgoing direction −look.\n // #569: with zeroBeyondHorizon, a ray at or beyond 90° reads the plane's origin with a zero factor (zero radiance; `beyond` is set).\n let pu = 0, pv = 0, pf = 0, beyond = false;\n const zeroBeyond = lens.zeroBeyondHorizon === true;\n const map = (xMm: number, yMm: number, t: number): void => {\n const look = geometry.lookOf(xMm, yMm, t);\n beyond = !(look.z > 0);\n if (beyond) {\n if (!zeroBeyond || !Number.isFinite(look.z)) throw new InvalidConfigurationError(\"simulateDisplayView: a query ray does not point toward the scene plane.\");\n pu = 0; pv = 0; pf = 0;\n return;\n }\n const s = distance / look.z;\n pu = look.x * s / scale; pv = look.y * s / scale; pf = look.factor;\n };\n const materialOf = (m: number): number => { if (spectralIndex[m] === undefined) throw new InvalidConfigurationError(\"Unknown chart material.\"); return m; };\n // Without a kernel: the environment's query point of offset o of site (x, y) (native-environment-lean.ts, as buildExpectedSignalInput's queryPoint).\n const box = lens.boxSamples, siteWidthMm = pitch / 1000;\n const phases = offsets.map((_, o) => {\n const node = Math.floor(o / lens.spots.length), spot = lens.spots[o % lens.spots.length]!.offsetMicrometers;\n return { xPhase: (node % box + 0.5) / box, yPhase: (Math.floor(node / box) + 0.5) / box, aaX: spot.x / 1000, aaY: spot.y / 1000 };\n });\n function directSite(x: number, y: number): number {\n const c = channelAt(x, y), centerX = -imagingArea.widthMm / 2 + (pitch / 2 + x * pitch + 0) / 1000, centerY = -imagingArea.heightMm / 2 + (pitch / 2 + y * pitch + 0) / 1000;\n let total = 0;\n for (let ti = 0; ti < T; ti++) {\n let sum = 0;\n for (let o = 0; o < offsets.length; o++) {\n const node = phases[o]!;\n map((centerX - siteWidthMm / 2 + node.xPhase * siteWidthMm) - node.aaX, (centerY - siteWidthMm / 2 + node.yPhase * siteWidthMm) - node.aaY, times[ti]!);\n let value: number;\n if (materials) {\n const m = materialOf(materials.materialAt(pu, pv)), si = spectralIndex[m]!;\n value = si < 0 ? reflectance[m]! * neutralDirect[c]! : spectralDirect[c]![si]!; lookups++;\n } else { value = 0; for (let n = 0; n < nodes; n++) value += A[c]![n]! * radianceAt!(pu, pv, input.wavelengthsNm[n]!); lookups += nodes; }\n sum += offsets[o]!.weight * (pf * value);\n }\n total += sum;\n }\n return total / T;\n }\n // With a kernel: lattice point (p, q) of group g at time t, #548's lattice formula, cached in a ring tagged with (p, q).\n const G = groups.length, slots = G * T, per = materials ? 1 : nodes;\n let cacheRows = 0, cacheCols = 0, tagQ = new Int32Array(0), tagP = new Int32Array(0), cacheMaterial = new Int32Array(0), cacheFactor = new Float64Array(0), cacheRadiance = new Float64Array(0);\n const radiance = new Float64Array(nodes);\n let lm = 0, lf = 0;\n function lattice(g: number, ti: number, p: number, q: number): void {\n let k = -1;\n if (cacheRows > 0) {\n k = ((g * T + ti) * cacheRows + (q & (cacheRows - 1))) * cacheCols + (p & (cacheCols - 1));\n if (tagQ[k] === q && tagP[k] === p) {\n lf = cacheFactor[k]!;\n if (materials) lm = cacheMaterial[k]!; else for (let n = 0; n < nodes; n++) radiance[n] = cacheRadiance[k * nodes + n]!;\n return;\n }\n }\n const group = groups[g]!;\n map((p + 0.5 + group.fx - W / 2) * mmPerSite, (q + 0.5 + group.fy - H / 2) * mmPerSite, times[ti]!);\n lf = pf;\n if (materials) { lm = materialOf(materials.materialAt(pu, pv)); lookups++; }\n else { for (let n = 0; n < nodes; n++) radiance[n] = radianceAt!(pu, pv, input.wavelengthsNm[n]!); lookups += nodes; }\n if (k >= 0) {\n tagQ[k] = q; tagP[k] = p; cacheFactor[k] = lf;\n if (materials) cacheMaterial[k] = lm; else for (let n = 0; n < nodes; n++) cacheRadiance[k * nodes + n] = radiance[n]!;\n }\n }\n function kernelSite(x: number, y: number): number {\n const c = channelAt(x, y), rowMask = cacheRows - 1, colMask = cacheCols - 1, zone = zoneTables(x, y);\n let total = 0;\n for (let ti = 0; ti < T; ti++) {\n let sum = 0;\n for (let g = 0; g < G; g++) {\n const group = groups[g]!, p0 = x + group.minIx - R, q0 = y + group.minIy - R, cw = group.cw, ch = group.ch, weights = zone[g]!;\n if (materials) {\n const nk = weights.neutral[c]!, sk = weights.spectral[c]!;\n for (let dy = 0, t = 0; dy < ch; dy++) {\n // The cache row of lattice row q (read inline: the common case is a hit).\n const q = q0 + dy, row = cacheRows > 0 ? ((g * T + ti) * cacheRows + (q & rowMask)) * cacheCols : -1;\n for (let dx = 0; dx < cw; dx++, t++) {\n const p = p0 + dx, k = row + (p & colMask);\n if (row >= 0 && tagQ[k] === q && tagP[k] === p) { lm = cacheMaterial[k]!; lf = cacheFactor[k]!; } else lattice(g, ti, p, q);\n const si = spectralIndex[lm]!;\n sum += lf * (si < 0 ? reflectance[lm]! * nk[t]! : sk[si]![t]!);\n }\n }\n } else for (let dy = 0, t = 0; dy < ch; dy++) for (let dx = 0; dx < cw; dx++, t++) {\n lattice(g, ti, p0 + dx, q0 + dy);\n let value = 0;\n for (let n = 0; n < nodes; n++) value += weights.perNode[n]![c]![t]! * radiance[n]!;\n sum += lf * value;\n }\n }\n total += sum;\n }\n return total / T;\n }\n const pilotNode = input.wavelengthsNm[Math.floor(nodes / 2)]!;\n if (input.largeKernel) return createLargeLensSignal(input, inFocusLensTile, () => lookups, pilot);\n /** E_c (#564) of the native site positions [x0, x0 + T) × [y0, y0 + T) for the three channels: kernelSite's sum for each channel. */\n function inFocusLensTile(x0: number, y0: number, TS: number): Float64Array[] {\n const out = [0, 1, 2].map(() => new Float64Array(TS * TS));\n // A fixed tile reaches past the raster: positions more than the disc's radius beyond it feed no site, so they stay 0 and are never\n // mapped (the lens profiles are checked only up to the view's reach).\n const D = input.largeKernel!.radius;\n if (x0 + TS <= -D || x0 >= W + D || y0 + TS <= -D || y0 >= H + D) return out;\n if (x0 < -D || x0 + TS > W + D || y0 < -D || y0 + TS > H + D) {\n const xa = Math.max(x0, -D), xb = Math.min(x0 + TS, W + D), ya = Math.max(y0, -D), yb = Math.min(y0 + TS, H + D);\n const part = inFocusLensRect(xa, ya, xb - xa, yb - ya);\n for (let c = 0; c < 3; c++) for (let y = ya; y < yb; y++) out[c]!.set(part[c]!.subarray((y - ya) * (xb - xa), (y - ya + 1) * (xb - xa)), (y - y0) * TS + xa - x0);\n return out;\n }\n return inFocusLensRect(x0, y0, TS, TS);\n }\n /** E_c of the native site positions [x0, x0 + w) × [y0, y0 + h), row-major, for the three channels. */\n function inFocusLensRect(x0: number, y0: number, TW: number, TH: number): Float64Array[] {\n const out = [0, 1, 2].map(() => new Float64Array(TW * TH)), sum = [0, 1, 2].map(() => new Float64Array(TW * TH));\n for (let ti = 0; ti < T; ti++) {\n for (const e of sum) e.fill(0);\n for (const group of groups) {\n const cw = group.cw, ch = group.ch, gw = TW + cw - 1, gh = TH + ch - 1, p0 = x0 + group.minIx - R, q0 = y0 + group.minIy - R;\n const factor = new Float64Array(gw * gh), material = materials ? new Int32Array(gw * gh) : undefined, values = materials ? undefined : new Float64Array(gw * gh * nodes);\n for (let j = 0; j < gh; j++) for (let i = 0; i < gw; i++) {\n const k = j * gw + i;\n map((p0 + i + 0.5 + group.fx - W / 2) * mmPerSite, (q0 + j + 0.5 + group.fy - H / 2) * mmPerSite, times[ti]!);\n factor[k] = pf;\n if (material) material[k] = materialOf(materials!.materialAt(pu, pv));\n else for (let n = 0; n < nodes; n++) values![k * nodes + n] = radianceAt!(pu, pv, input.wavelengthsNm[n]!);\n }\n lookups += material ? gw * gh : gw * gh * nodes;\n for (let c = 0; c < 3; c++) {\n const e = sum[c]!, nk = group.neutral[c], sk = group.spectral[c];\n for (let y = 0; y < TH; y++) for (let x = 0; x < TW; x++) {\n let v = 0;\n for (let dy = 0, t = 0; dy < ch; dy++) for (let dx = 0; dx < cw; dx++, t++) {\n const k = (y + dy) * gw + x + dx;\n if (material) { const m = material[k]!, si = spectralIndex[m]!; v += factor[k]! * (si < 0 ? reflectance[m]! * nk![t]! : sk![si]![t]!); }\n else { let r = 0; for (let n = 0; n < nodes; n++) r += group.perNode[n]![c]![t]! * values![k * nodes + n]!; v += factor[k]! * r; }\n }\n e[y * TW + x] = e[y * TW + x]! + v;\n }\n }\n }\n for (let c = 0; c < 3; c++) { const o = out[c]!, e = sum[c]!; for (let k = 0; k < o.length; k++) o[k] = o[k]! + e[k]!; }\n }\n for (const o of out) for (let k = 0; k < o.length; k++) o[k] = o[k]! / T;\n return out;\n }\n // Site values persist across windows in a ring of native rows (a site's value does not depend on the window).\n let ringRows = 0, ring = new Float64Array(0), ringRowId = new Int32Array(0), ringOn = false;\n const compute = kernels ? kernelSite : directSite;\n return {\n get lookups(): number { return lookups; },\n uniformMaterial: -1,\n tracksMaterial: false,\n get cachesSites(): boolean { return ringOn; },\n marksReads: false,\n markReads(): void { /* never called: marksReads is false */ },\n window(x0: number, y0: number, x1: number, y1: number): void {\n const sw = Math.max(0, x1 - x0), sh = Math.max(0, y1 - y0);\n if (sh > 0 && ringRows < 2 * sh) {\n const rows = pow2(2 * sh);\n if (rows * W <= LATTICE_CACHE_LIMIT) { ringRows = rows; ring = new Float64Array(rows * W).fill(NaN); ringRowId = new Int32Array(rows).fill(-1); }\n }\n ringOn = sh > 0 && ringRows >= 2 * sh;\n if (!kernels || sw === 0) return;\n // The lattice rectangle the window's sites read, per group; the cache keeps two such heights and the columns the render's windows span.\n let cw = 0, ch = 0;\n for (const group of groups) { cw = Math.max(cw, group.cw); ch = Math.max(ch, group.ch); }\n const height = sh + ch - 1, width = sw + cw - 1;\n let rows = pow2(2 * height), cols = pow2(Math.min(W + 2 * (R + cw), Math.max(width, (Number.isFinite(spanColumns) ? spanColumns : W) + width)));\n if (slots * per * rows * cols > LATTICE_CACHE_LIMIT) rows = pow2(height);\n if (slots * per * rows * cols > LATTICE_CACHE_LIMIT) cols = pow2(width);\n if (slots * per * rows * cols > LATTICE_CACHE_LIMIT) { cacheRows = 0; return; }\n if (rows > cacheRows || cols > cacheCols) {\n rows = Math.max(rows, cacheRows); cols = Math.max(cols, cacheCols);\n if (slots * per * rows * cols > LATTICE_CACHE_LIMIT) { rows = pow2(height); cols = pow2(width); }\n cacheRows = rows; cacheCols = cols;\n const size = slots * rows * cols;\n tagQ = new Int32Array(size).fill(-2147483648); tagP = new Int32Array(size); cacheFactor = new Float64Array(size);\n if (materials) cacheMaterial = new Int32Array(size); else cacheRadiance = new Float64Array(size * nodes);\n }\n },\n site(x: number, y: number): number {\n if (!ringOn) return compute(x, y);\n const slot = y & (ringRows - 1), k = slot * W + x;\n if (ringRowId[slot] === y) { const v = ring[k]!; if (v === v) return v; }\n else { ringRowId[slot] = y; ring.fill(NaN, slot * W, (slot + 1) * W); }\n const v = compute(x, y);\n ring[k] = v;\n return v;\n },\n pilot\n };\n /**\n * The renderer's pilot point is a rectilinear plane point of the native raster: back to the sensor point, then through the lens at\n * every temporal midpoint. A point whose scene value differs between the instants (motion) counts as detail (NaN equals nothing).\n */\n function pilot(u: number, v: number): number {\n const g = 2 / input.outputWidth, xMm = u / g * mmPerSite, yMm = -v / g * mmPerSite;\n let first = NaN;\n try {\n for (let ti = 0; ti < T; ti++) {\n map(xMm, yMm, times[ti]!);\n const value = beyond ? -1 : materials ? materials.materialAt(pu, pv) : radianceAt!(pu, pv, pilotNode);\n lookups++;\n if (ti === 0) first = value; else if (value !== first) return NaN;\n }\n } catch { return NaN; }\n return first;\n }\n}\n\n/** #564: tile sides of the large-kernel lens signal (the in-focus E and the convolved sites) and the bytes each tile cache keeps. */\nconst LARGE_E_TILE = 64, LARGE_OUTPUT_TILE = 128, LARGE_CACHE_BYTES = 32 * 1048576;\n\n/** #564: the lens signal with a defocus kernel above 64 sites: D ⊛ E_c by runs over the in-focus tiles (see the module comment). */\nfunction createLargeLensSignal(input: DisplayViewExpectedSignalInput, inFocusTile: (x0: number, y0: number, T: number) => Float64Array[], lookups: () => number,\n pilot: (u: number, v: number) => number): DisplayViewExpectedSignal {\n const runs = input.largeKernel!, channelAt = input.channelAt, TE = LARGE_E_TILE;\n // At least the in-focus tiles one output tile's source spans plus one more row of them, so the next output tile of a row reuses them.\n const span = Math.ceil((LARGE_OUTPUT_TILE + 2 * runs.radius) / TE) + 1;\n const inFocus = new Map<number, Float64Array[]>(), capacity = Math.max(span * (span + 1), Math.floor(LARGE_CACHE_BYTES / (3 * TE * TE * 8)));\n const tileAt = (tx: number, ty: number): Float64Array[] => {\n const key = (ty + 1048576) * 2097152 + tx + 1048576;\n let tile = inFocus.get(key);\n if (tile) { inFocus.delete(key); inFocus.set(key, tile); }\n else {\n tile = inFocusTile(tx * TE, ty * TE, TE);\n inFocus.set(key, tile);\n if (inFocus.size > capacity) inFocus.delete(inFocus.keys().next().value!);\n }\n return tile;\n };\n // Which sites of a tile row hold channel c: the CFA's 2 × 2 period (tile origins are even).\n const phase = [0, 1].map((py) => [0, 1].map((px) => channelAt(px, py)));\n const patterns: SiteKernelRunsRowPattern[] = [0, 1, 2].map((c) => (row: number) => {\n const p = phase[row & 1]!, even = p[0] === c, odd = p[1] === c;\n return even && odd ? { start: 0, step: 1 } : even ? { start: 0, step: 2 } : odd ? { start: 1, step: 2 } : null;\n });\n const lattice = createSiteKernelRunsLattice({ runs, tile: LARGE_OUTPUT_TILE, fields: 3, capacityBytes: LARGE_CACHE_BYTES, pattern: (c) => patterns[c],\n source: (x0, y0, width, height) => (c: number): Float64Array => {\n const samples = new Float64Array(width * height);\n for (let ty = Math.floor(y0 / TE); ty * TE < y0 + height; ty++) for (let tx = Math.floor(x0 / TE); tx * TE < x0 + width; tx++) {\n const tile = tileAt(tx, ty)[c]!, ax = Math.max(x0, tx * TE), bx = Math.min(x0 + width, (tx + 1) * TE), ay = Math.max(y0, ty * TE), by = Math.min(y0 + height, (ty + 1) * TE);\n for (let y = ay; y < by; y++) samples.set(tile.subarray((y - ty * TE) * TE + ax - tx * TE, (y - ty * TE) * TE + bx - tx * TE), (y - y0) * width + ax - x0);\n }\n return samples;\n } });\n return {\n get lookups(): number { return lookups(); },\n uniformMaterial: -1,\n tracksMaterial: false,\n cachesSites: false,\n marksReads: false,\n markReads(): void { /* never called: marksReads is false */ },\n window(): void { /* the tiles are fixed and kept for the signal; a window changes nothing */ },\n site(x: number, y: number): number { return lattice.valueAt(channelAt(x, y), x, y); },\n pilot\n };\n}\n"]}
1
+ {"version":3,"file":"display-view-lens-signal.js","sourceRoot":"","sources":["../../src/facade/display-view-lens-signal.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,2BAA2B,EAAiC,MAAM,+BAA+B,CAAC;AAE3G,OAAO,EAAE,2BAA2B,EAAmC,MA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AE,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;oBAC7K,KAAK,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE;wBAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,KAAK,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;gBAC7J,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC,EAAE,CAAC,CAAC;IACP,OAAO;QACL,IAAI,OAAO,KAAa,OAAO,OAAO,EAAE,CAAC,CAAC,CAAC;QAC3C,eAAe,EAAE,CAAC,CAAC;QACnB,cAAc,EAAE,KAAK;QACrB,WAAW,EAAE,KAAK;QAClB,UAAU,EAAE,KAAK;QACjB,SAAS,KAAmD,CAAC;QAC7D,MAAM,KAAuF,CAAC;QAC9F,IAAI,CAAC,CAAS,EAAE,CAAS,IAAY,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACrF,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * The display view's expected signal with a lens field mapping (`lens.projection`, `lens.distortion`), `lens.vignetting` or\n * camera rotation (#563), in focus and with `lens.defocus` out of focus. Loaded on demand (a dynamic import in `runCapture`),\n * so a display view without these options, and a bundle that never asks for them, does not load it.\n *\n * What it computes. The capture's environment chain forms, for site (i, j) of CFA channel c,\n * μ_c(i, j) = Σ_o w_o · (1/T) Σ_t Σ_λ A_c(λ) Σ_k K_λ(k) · F(s) · L(D_t(s), λ), s = q_o(i, j) − k·p,\n * with q_o the query point of offset o (pixel-aperture node minus anti-aliasing split), K_λ the site kernel (diffraction, the\n * defocus disc or both; a single unit tap without them), D_t the scene ray of sensor point s at temporal midpoint t (inverse\n * distortion, the declared projection, the camera rotation at t), F = T·A its field factor (vignetting throughput × distortion\n * area factor) and A_c(λ) the electrons per unit spectral radiance on the axis (the display view's channel response, ideal\n * optics). In focus with a kernel this is the environment PSF quadrature (the field factor applied once at the source point,\n * before the PSF spreads the light); out of focus it is #548's image-space disc, the same sum in another order\n * (`defocus-image-space-provider.ts`); without a kernel it is the environment's own per-query sum. Only the scene access changes:\n * the readout, the estimators, the demosaic and the development run unchanged on these site values.\n *\n * Scene points. Without a kernel each query point is formed with the environment's own arithmetic (the site centre, aperture node\n * and split offset of `native-environment-lean.ts`), then `lookOf` (the environment's mapping, rotation and field factor,\n * #548) and the planar provider's plane-point arithmetic, so a point exactly on a chart boundary resolves as in the capture.\n * With a kernel the sources are the site lattice of each fractional offset, with #548's lattice formula. Kernels, materials and\n * per-material sums are the display view's own tables (`displayViewSignalTables`), shared with the rectilinear path.\n *\n * Caches (memory only, never values): site values in a ring of native rows across windows, and with a kernel each lattice\n * point's material (or radiance at each node) and field factor per lattice group and temporal midpoint, in a two-dimensional\n * ring tagged with the point, sized from the window and capped at LATTICE_CACHE_LIMIT entries (beyond it, points are\n * evaluated as they are read).\n *\n * Field-dependent PSF (#569, `lens.catalogue`; {@link createDisplayViewLensPsf}). The capture's environment PSF quadrature resolves the\n * catalogue lens's sampled PSF at each query point's own field position. The view cuts the native raster into square zones of\n * Z = ⌈max(W, H) / DISPLAY_VIEW_LENS_PSF_ZONES⌉ sites (one site on frames of at most that many sites a side) and every site of a zone\n * takes the PSF the capture's own resolver gives at the zone's centre, at each spectral node (an approximation: the PSF's change\n * across half a zone). A profile kernel's rows run with image +Y (up) and its tap (i, j) reads (x − (i − c)·p, y + (j − c)·p) in\n * native coordinates (`sensorPsfSourcePoint`), so the view's kernel (reading in(x − t)) is the profile kernel flipped vertically.\n * Each zone's combined kernels are the expected signal's own tables (`buildTables`) with the zone's kernels, built when a site of\n * the zone is first read and kept per input in a least-recently-used cache of at most 64 MB (at least four zones). The zones are the\n * view's fast method for `lens.catalogue` (2.20.0); its exact method (`fast: false`) passes `zones` = max(W, H), one site per zone,\n * the capture's own PSF at each site centre (much slower).\n *\n * Large defocus kernels (#564, `input.largeKernel`, radius above 64 sites). The image-space disc D is the same at every lattice\n * group, spectral node and temporal midpoint, so it commutes with those sums as in the rectilinear signal (`expected-signal.ts`):\n * μ_c(x) = Σ_s D(s)·E_c(x − s), with E_c(x) the sum above through the in-focus kernels (each node's diffraction kernel, or a unit\n * tap) at site position x for channel c, whatever x's own channel. E is computed in fixed 64-site tiles (all three channels, each\n * group's lattice points mapped once per tile and midpoint), and D ⊛ E_c by runs (`site-kernel-runs.ts`) in fixed 128-site tiles,\n * each site taking its own channel: every value depends only on its site, so regions and parts equal the whole view.\n */\n\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { createSiteKernelRunsLattice, type SiteKernelRunsRowPattern } from \"../optics/site-kernel-runs.js\";\nimport type { PreparedDefocusImageSpaceGeometry } from \"./defocus-image-space-provider.js\";\nimport { resolveLensSampledPsfKernel, type ResolveLensSampledPsfInput } from \"../optics/lens-psf-profile.js\";\nimport { buildTables, createMaterialSums, displayViewSignalTables, materialSpectrumSignal, type DisplayViewExpectedSignal, type DisplayViewExpectedSignalInput, type GroupTables } from \"./expected-signal.js\";\n\n/** #569: field zones along the native raster's longer side. */\nexport const DISPLAY_VIEW_LENS_PSF_ZONES = 64;\n\n/** #569: a field-dependent PSF for the display view (see the module comment). */\nexport interface DisplayViewLensPsf {\n /** Kernel radius and zone side, in sites. */\n readonly radius: number;\n readonly zoneSites: number;\n /** The kernels at the frame centre's zone, for the expected-signal input's lattice groups and reach. */\n axisKernels(wavelengthsNm: readonly number[]): { radius: number; perNode: Float64Array[] };\n /** The combined kernels of the zone of native site (x, y), for an input whose kernels are the axis kernels. */\n tables(input: DisplayViewExpectedSignalInput): (x: number, y: number) => readonly GroupTables[];\n}\n\n/**\n * #569: the field-dependent PSF of a display view from the sampled PSF the capture resolves (everything but the field point and wavelength),\n * of kernel radius R, on the W × H native raster of `pitch` µm.\n */\nexport function createDisplayViewLensPsf(psf: Omit<ResolveLensSampledPsfInput, \"fieldPointMm\" | \"wavelengthNm\">, R: number, W: number, H: number, pitch: number,\n zones = DISPLAY_VIEW_LENS_PSF_ZONES): DisplayViewLensPsf {\n const Z = Math.ceil(Math.max(W, H) / zones), zonesX = Math.ceil(W / Z), w = 2 * R + 1;\n const zoneOf = (x: number, y: number): number => Math.floor(y / Z) * zonesX + Math.floor(x / Z);\n const kernelsOf = (zone: number, wavelengthsNm: readonly number[]): Float64Array[] => {\n // The zone's centre in sites from the top-left corner (an edge zone may be narrower), in image millimetres (+Y up).\n const zx = zone % zonesX, zy = (zone - zx) / zonesX, fieldPointMm = { x: ((zx * Z + Math.min(W, zx * Z + Z)) / 2 - W / 2) * pitch / 1000,\n y: (H / 2 - (zy * Z + Math.min(H, zy * Z + Z)) / 2) * pitch / 1000 };\n return wavelengthsNm.map((wavelengthNm) => {\n // Every node of the engine-built profile has the same (2R + 1)² window, so every resolved kernel has it too.\n const values = resolveLensSampledPsfKernel({ ...psf, fieldPointMm, wavelengthNm } as ResolveLensSampledPsfInput).normalizedIntensity, out = new Float64Array(w * w);\n for (let j = 0; j < w; j++) for (let i = 0; i < w; i++) out[(w - 1 - j) * w + i] = values[j * w + i]!;\n return out;\n });\n };\n const caches = new WeakMap<DisplayViewExpectedSignalInput, (x: number, y: number) => readonly GroupTables[]>();\n return { radius: R, zoneSites: Z,\n axisKernels: (wavelengthsNm) => ({ radius: R, perNode: kernelsOf(zoneOf(W >> 1, H >> 1), wavelengthsNm) }),\n tables(input): (x: number, y: number) => readonly GroupTables[] {\n let read = caches.get(input);\n if (read) return read;\n const cache = new Map<number, readonly GroupTables[]>();\n let kept = 0, last = -1, lastTables: readonly GroupTables[] = [];\n read = (x, y): readonly GroupTables[] => {\n const zone = zoneOf(x, y);\n if (zone === last) return lastTables;\n let tables = cache.get(zone);\n if (tables) cache.delete(zone);\n else {\n tables = buildTables({ ...input, kernels: { radius: R, perNode: kernelsOf(zone, input.wavelengthsNm) } }).groups;\n // Zones kept: at least 4, and at most 64 MB of them (every zone's tables have the same size).\n kept ||= Math.max(4, (1 << 23) / tables.reduce((n, g) => n + g.cw * g.ch * (g.nodeKernels.length * input.wavelengthsNm.length + g.perNode.flat().length), 0));\n if (cache.size >= kept) cache.delete(cache.keys().next().value!);\n }\n cache.set(zone, tables); last = zone; lastTables = tables;\n return tables;\n };\n caches.set(input, read);\n return read;\n } };\n}\n\n/** What the lens signal needs from the resolved request. */\nexport interface DisplayViewLensSetup {\n geometry: PreparedDefocusImageSpaceGeometry;\n /** Temporal midpoints, seconds from exposure start: (i + 0.5)·shutter/T with camera rotation, [0] without. */\n times: readonly number[];\n /** The planar provider's plane distance and frame-unit scale. */\n distanceM: number;\n metresPerFrameUnit: number;\n pitch: number;\n imagingArea: { widthMm: number; heightMm: number };\n boxSamples: number;\n /** Anti-aliasing split spots (or one zero spot), in the order of the expected signal's offsets within each aperture node. */\n spots: readonly { offsetMicrometers: { x: number; y: number } }[];\n /**\n * #569: a field-dependent lens PSF (`lens.catalogue`, {@link createDisplayViewLensPsf}): each site reads its field zone's kernels\n * instead of the input's. The input's kernels (the axis zone's) set the lattice groups and the reach; absent, every site reads them.\n */\n psf?: DisplayViewLensPsf | undefined;\n /**\n * #569 (catalogue fisheyes): a ray that does not point toward the scene plane sees no scene (zero radiance), as the capture's provider\n * with `zeroBeyondHorizon` gives it, instead of failing.\n */\n zeroBeyondHorizon?: boolean | undefined;\n}\n\n/** Largest lattice cache, in entries over all lattice groups and temporal midpoints (times the spectral nodes for radiance scenes). */\nconst LATTICE_CACHE_LIMIT = 1 << 22;\n\nconst pow2 = (n: number): number => { let p = 1; while (p < n) p *= 2; return p; };\n\n/**\n * Checks that the mapping and the vignetting profile cover the farthest source point the view reads, (W/2 + reachSites, H/2 + reachSites)\n * sites from the axis at each corner (reachSites: the kernel radius plus the largest query offset, less the half site to the outer site\n * centre), and returns the factory of the view's expected signal for this request.\n */\nexport function prepareDisplayViewLensSignal(lens: DisplayViewLensSetup, nativeWidth: number, nativeHeight: number, reachSites: number, options: string):\n (input: DisplayViewExpectedSignalInput, spanColumns?: number) => DisplayViewExpectedSignal {\n const xMm = (nativeWidth / 2 + reachSites) * lens.pitch / 1000, yMm = (nativeHeight / 2 + reachSites) * lens.pitch / 1000;\n for (const t of lens.times) for (const [x, y] of [[-xMm, -yMm], [xMm, -yMm], [-xMm, yMm], [xMm, yMm]] as const) {\n try { if (!(lens.geometry.lookOf(x, y, t).z > 0) && !lens.zeroBeyondHorizon) throw new InvalidConfigurationError(\"its ray does not point toward the scene plane.\"); } catch (error) {\n throw new InvalidConfigurationError(\"simulateDisplayView with \" + options + \" reads the scene through the lens up to \" + (reachSites + 0.5) + \" sites beyond the native \" +\n \"raster's outer site centres (the kernel radius and the query offsets), and there (\" + Math.hypot(x, y).toFixed(3) + \" mm from the axis) \" + (error as Error).message);\n }\n }\n return (input, spanColumns = Infinity) => createLensSignal(lens, input, spanColumns);\n}\n\nfunction createLensSignal(lens: DisplayViewLensSetup, input: DisplayViewExpectedSignalInput, spanColumns: number): DisplayViewExpectedSignal {\n const W = input.nativeWidth, H = input.nativeHeight, nodes = input.wavelengthsNm.length, T = lens.times.length, times = lens.times;\n const { geometry, distanceM: distance, metresPerFrameUnit: scale, pitch, imagingArea } = lens;\n const mmPerSite = pitch / 1000, scene = input.scene, offsets = input.offsets, A = input.electronsPerRadiance, channelAt = input.channelAt;\n const materials = scene.kind === \"materials\" ? scene : undefined, radianceAt = scene.kind === \"radiance\" ? scene.radianceAt : undefined;\n const { spectra, groups } = displayViewSignalTables(input), acc = createMaterialSums(nodes, spectra);\n const kernels = input.kernels, R = kernels ? kernels.radius : 0;\n /** #569: the combined kernels of the zone of site (x, y), or the input's own without a field-dependent PSF. */\n const zoneTables = lens.psf ? lens.psf.tables(input) : (): typeof groups => groups;\n let lookups = 0;\n // The plane point (frame units) and field factor of native sensor point (x, y) mm at time t: the environment's mapping (lookOf) and\n // the planar provider's own arithmetic for the outgoing direction −look.\n // #569: with zeroBeyondHorizon, a ray at or beyond 90° reads the plane's origin with a zero factor (zero radiance; `beyond` is set).\n let pu = 0, pv = 0, pf = 0, beyond = false;\n const zeroBeyond = lens.zeroBeyondHorizon === true;\n const map = (xMm: number, yMm: number, t: number): void => {\n const look = geometry.lookOf(xMm, yMm, t);\n beyond = !(look.z > 0);\n if (beyond) {\n if (!zeroBeyond || !Number.isFinite(look.z)) throw new InvalidConfigurationError(\"simulateDisplayView: a query ray does not point toward the scene plane.\");\n pu = 0; pv = 0; pf = 0;\n return;\n }\n const s = distance / look.z;\n pu = look.x * s / scale; pv = look.y * s / scale; pf = look.factor;\n };\n const materialOf = (m: number): number => { if (spectra[m] === undefined) throw new InvalidConfigurationError(\"Unknown chart material.\"); return m; };\n // Without a kernel: the environment's query point of offset o of site (x, y) (native-environment-lean.ts, as buildExpectedSignalInput's queryPoint).\n const box = lens.boxSamples, siteWidthMm = pitch / 1000;\n const phases = offsets.map((_, o) => {\n const node = Math.floor(o / lens.spots.length), spot = lens.spots[o % lens.spots.length]!.offsetMicrometers;\n return { xPhase: (node % box + 0.5) / box, yPhase: (Math.floor(node / box) + 0.5) / box, aaX: spot.x / 1000, aaY: spot.y / 1000 };\n });\n function directSite(x: number, y: number): number {\n const c = channelAt(x, y), centerX = -imagingArea.widthMm / 2 + (pitch / 2 + x * pitch + 0) / 1000, centerY = -imagingArea.heightMm / 2 + (pitch / 2 + y * pitch + 0) / 1000;\n let total = 0;\n for (let ti = 0; ti < T; ti++) {\n let sum = 0;\n for (let o = 0; o < offsets.length; o++) {\n const node = phases[o]!;\n map((centerX - siteWidthMm / 2 + node.xPhase * siteWidthMm) - node.aaX, (centerY - siteWidthMm / 2 + node.yPhase * siteWidthMm) - node.aaY, times[ti]!);\n let value: number;\n if (materials) {\n // Integrated from the material's spectrum against the site's channel when it is read.\n value = materialSpectrumSignal(A[c]!, spectra[materialOf(materials.materialAt(pu, pv))], nodes); lookups++;\n } else { value = 0; for (let n = 0; n < nodes; n++) value += A[c]![n]! * radianceAt!(pu, pv, input.wavelengthsNm[n]!, times[ti]!); lookups += nodes; }\n sum += offsets[o]!.weight * (pf * value);\n }\n total += sum;\n }\n return total / T;\n }\n // With a kernel: lattice point (p, q) of group g at time t, #548's lattice formula, cached in a ring tagged with (p, q).\n const G = groups.length, slots = G * T, per = materials ? 1 : nodes;\n let cacheRows = 0, cacheCols = 0, tagQ = new Int32Array(0), tagP = new Int32Array(0), cacheMaterial = new Int32Array(0), cacheFactor = new Float64Array(0), cacheRadiance = new Float64Array(0);\n const radiance = new Float64Array(nodes);\n let lm = 0, lf = 0;\n function lattice(g: number, ti: number, p: number, q: number): void {\n let k = -1;\n if (cacheRows > 0) {\n k = ((g * T + ti) * cacheRows + (q & (cacheRows - 1))) * cacheCols + (p & (cacheCols - 1));\n if (tagQ[k] === q && tagP[k] === p) {\n lf = cacheFactor[k]!;\n if (materials) lm = cacheMaterial[k]!; else for (let n = 0; n < nodes; n++) radiance[n] = cacheRadiance[k * nodes + n]!;\n return;\n }\n }\n const group = groups[g]!;\n map((p + 0.5 + group.fx - W / 2) * mmPerSite, (q + 0.5 + group.fy - H / 2) * mmPerSite, times[ti]!);\n lf = pf;\n if (materials) { lm = materialOf(materials.materialAt(pu, pv)); lookups++; }\n else { for (let n = 0; n < nodes; n++) radiance[n] = radianceAt!(pu, pv, input.wavelengthsNm[n]!, times[ti]!); lookups += nodes; }\n if (k >= 0) {\n tagQ[k] = q; tagP[k] = p; cacheFactor[k] = lf;\n if (materials) cacheMaterial[k] = lm; else for (let n = 0; n < nodes; n++) cacheRadiance[k * nodes + n] = radiance[n]!;\n }\n }\n function kernelSite(x: number, y: number): number {\n const c = channelAt(x, y), rowMask = cacheRows - 1, colMask = cacheCols - 1, zone = zoneTables(x, y);\n let total = 0;\n for (let ti = 0; ti < T; ti++) {\n let sum = 0;\n acc.reset();\n for (let g = 0; g < G; g++) {\n const group = groups[g]!, p0 = x + group.minIx - R, q0 = y + group.minIy - R, cw = group.cw, ch = group.ch, weights = zone[g]!;\n if (materials) {\n const k = weights.nodeKernels[c]!;\n for (let dy = 0, t = 0; dy < ch; dy++) {\n // The cache row of lattice row q (read inline: the common case is a hit).\n const q = q0 + dy, row = cacheRows > 0 ? ((g * T + ti) * cacheRows + (q & rowMask)) * cacheCols : -1;\n for (let dx = 0; dx < cw; dx++, t++) {\n const p = p0 + dx;\n const at = row + (p & colMask);\n if (row >= 0 && tagQ[at] === q && tagP[at] === p) { lm = cacheMaterial[at]!; lf = cacheFactor[at]!; } else lattice(g, ti, p, q);\n acc.add(lm, k, t * nodes, lf);\n }\n }\n } else for (let dy = 0, t = 0; dy < ch; dy++) for (let dx = 0; dx < cw; dx++, t++) {\n lattice(g, ti, p0 + dx, q0 + dy);\n let value = 0;\n for (let n = 0; n < nodes; n++) value += weights.perNode[n]![c]![t]! * radiance[n]!;\n sum += lf * value;\n }\n }\n total += materials ? acc.value() : sum;\n }\n return total / T;\n }\n const pilotNode = input.wavelengthsNm[Math.floor(nodes / 2)]!;\n if (input.largeKernel) return createLargeLensSignal(input, inFocusLensTile, () => lookups, pilot);\n /** E_c (#564) of the native site positions [x0, x0 + T) × [y0, y0 + T) for the three channels: kernelSite's sum for each channel. */\n function inFocusLensTile(x0: number, y0: number, TS: number): Float64Array[] {\n const out = [0, 1, 2].map(() => new Float64Array(TS * TS));\n // A fixed tile reaches past the raster: positions more than the disc's radius beyond it feed no site, so they stay 0 and are never\n // mapped (the lens profiles are checked only up to the view's reach).\n const D = input.largeKernel!.radius;\n if (x0 + TS <= -D || x0 >= W + D || y0 + TS <= -D || y0 >= H + D) return out;\n if (x0 < -D || x0 + TS > W + D || y0 < -D || y0 + TS > H + D) {\n const xa = Math.max(x0, -D), xb = Math.min(x0 + TS, W + D), ya = Math.max(y0, -D), yb = Math.min(y0 + TS, H + D);\n const part = inFocusLensRect(xa, ya, xb - xa, yb - ya);\n for (let c = 0; c < 3; c++) for (let y = ya; y < yb; y++) out[c]!.set(part[c]!.subarray((y - ya) * (xb - xa), (y - ya + 1) * (xb - xa)), (y - y0) * TS + xa - x0);\n return out;\n }\n return inFocusLensRect(x0, y0, TS, TS);\n }\n /** E_c of the native site positions [x0, x0 + w) × [y0, y0 + h), row-major, for the three channels. */\n function inFocusLensRect(x0: number, y0: number, TW: number, TH: number): Float64Array[] {\n const out = [0, 1, 2].map(() => new Float64Array(TW * TH)), sum = [0, 1, 2].map(() => new Float64Array(TW * TH));\n for (let ti = 0; ti < T; ti++) {\n for (const e of sum) e.fill(0);\n for (const group of groups) {\n const cw = group.cw, ch = group.ch, gw = TW + cw - 1, gh = TH + ch - 1, p0 = x0 + group.minIx - R, q0 = y0 + group.minIy - R;\n const factor = new Float64Array(gw * gh), material = materials ? new Int32Array(gw * gh) : undefined, values = materials ? undefined : new Float64Array(gw * gh * nodes);\n for (let j = 0; j < gh; j++) for (let i = 0; i < gw; i++) {\n const k = j * gw + i;\n map((p0 + i + 0.5 + group.fx - W / 2) * mmPerSite, (q0 + j + 0.5 + group.fy - H / 2) * mmPerSite, times[ti]!);\n factor[k] = pf;\n if (material) material[k] = materialOf(materials!.materialAt(pu, pv));\n else for (let n = 0; n < nodes; n++) values![k * nodes + n] = radianceAt!(pu, pv, input.wavelengthsNm[n]!, times[ti]!);\n }\n lookups += material ? gw * gh : gw * gh * nodes;\n for (let c = 0; c < 3; c++) {\n const e = sum[c]!, kc = material ? group.nodeKernels[c]! : undefined;\n for (let y = 0; y < TH; y++) for (let x = 0; x < TW; x++) {\n let v = 0;\n acc.reset();\n for (let dy = 0, t = 0; dy < ch; dy++) for (let dx = 0; dx < cw; dx++, t++) {\n const k = (y + dy) * gw + x + dx;\n if (material) acc.add(material[k]!, kc!, t * nodes, factor[k]!);\n else { let r = 0; for (let n = 0; n < nodes; n++) r += group.perNode[n]![c]![t]! * values![k * nodes + n]!; v += factor[k]! * r; }\n }\n if (material) v = acc.value();\n e[y * TW + x] = e[y * TW + x]! + v;\n }\n }\n }\n for (let c = 0; c < 3; c++) { const o = out[c]!, e = sum[c]!; for (let k = 0; k < o.length; k++) o[k] = o[k]! + e[k]!; }\n }\n for (const o of out) for (let k = 0; k < o.length; k++) o[k] = o[k]! / T;\n return out;\n }\n // Site values persist across windows in a ring of native rows (a site's value does not depend on the window).\n let ringRows = 0, ring = new Float64Array(0), ringRowId = new Int32Array(0), ringOn = false;\n const compute = kernels ? kernelSite : directSite;\n return {\n get lookups(): number { return lookups; },\n uniformMaterial: -1,\n tracksMaterial: false,\n get cachesSites(): boolean { return ringOn; },\n marksReads: false,\n markReads(): void { /* never called: marksReads is false */ },\n window(x0: number, y0: number, x1: number, y1: number): void {\n const sw = Math.max(0, x1 - x0), sh = Math.max(0, y1 - y0);\n if (sh > 0 && ringRows < 2 * sh) {\n const rows = pow2(2 * sh);\n if (rows * W <= LATTICE_CACHE_LIMIT) { ringRows = rows; ring = new Float64Array(rows * W).fill(NaN); ringRowId = new Int32Array(rows).fill(-1); }\n }\n ringOn = sh > 0 && ringRows >= 2 * sh;\n if (!kernels || sw === 0) return;\n // The lattice rectangle the window's sites read, per group; the cache keeps two such heights and the columns the render's windows span.\n let cw = 0, ch = 0;\n for (const group of groups) { cw = Math.max(cw, group.cw); ch = Math.max(ch, group.ch); }\n const height = sh + ch - 1, width = sw + cw - 1;\n let rows = pow2(2 * height), cols = pow2(Math.min(W + 2 * (R + cw), Math.max(width, (Number.isFinite(spanColumns) ? spanColumns : W) + width)));\n if (slots * per * rows * cols > LATTICE_CACHE_LIMIT) rows = pow2(height);\n if (slots * per * rows * cols > LATTICE_CACHE_LIMIT) cols = pow2(width);\n if (slots * per * rows * cols > LATTICE_CACHE_LIMIT) { cacheRows = 0; return; }\n if (rows > cacheRows || cols > cacheCols) {\n rows = Math.max(rows, cacheRows); cols = Math.max(cols, cacheCols);\n if (slots * per * rows * cols > LATTICE_CACHE_LIMIT) { rows = pow2(height); cols = pow2(width); }\n cacheRows = rows; cacheCols = cols;\n const size = slots * rows * cols;\n tagQ = new Int32Array(size).fill(-2147483648); tagP = new Int32Array(size); cacheFactor = new Float64Array(size);\n if (materials) cacheMaterial = new Int32Array(size); else cacheRadiance = new Float64Array(size * nodes);\n }\n },\n site(x: number, y: number): number {\n if (!ringOn) return compute(x, y);\n const slot = y & (ringRows - 1), k = slot * W + x;\n if (ringRowId[slot] === y) { const v = ring[k]!; if (v === v) return v; }\n else { ringRowId[slot] = y; ring.fill(NaN, slot * W, (slot + 1) * W); }\n const v = compute(x, y);\n ring[k] = v;\n return v;\n },\n pilot\n };\n /**\n * The renderer's pilot point is a rectilinear plane point of the native raster: back to the sensor point, then through the lens at\n * every temporal midpoint. A point whose scene value differs between the instants (motion) counts as detail (NaN equals nothing).\n */\n function pilot(u: number, v: number): number {\n const g = 2 / input.outputWidth, xMm = u / g * mmPerSite, yMm = -v / g * mmPerSite;\n let first = NaN;\n try {\n for (let ti = 0; ti < T; ti++) {\n map(xMm, yMm, times[ti]!);\n const value = beyond ? -1 : materials ? materials.materialAt(pu, pv) : radianceAt!(pu, pv, pilotNode, times[ti]!);\n lookups++;\n if (ti === 0) first = value; else if (value !== first) return NaN;\n }\n } catch { return NaN; }\n return first;\n }\n}\n\n/** #564: tile sides of the large-kernel lens signal (the in-focus E and the convolved sites) and the bytes each tile cache keeps. */\nconst LARGE_E_TILE = 64, LARGE_OUTPUT_TILE = 128, LARGE_CACHE_BYTES = 32 * 1048576;\n\n/** #564: the lens signal with a defocus kernel above 64 sites: D ⊛ E_c by runs over the in-focus tiles (see the module comment). */\nfunction createLargeLensSignal(input: DisplayViewExpectedSignalInput, inFocusTile: (x0: number, y0: number, T: number) => Float64Array[], lookups: () => number,\n pilot: (u: number, v: number) => number): DisplayViewExpectedSignal {\n const runs = input.largeKernel!, channelAt = input.channelAt, TE = LARGE_E_TILE;\n // At least the in-focus tiles one output tile's source spans plus one more row of them, so the next output tile of a row reuses them.\n const span = Math.ceil((LARGE_OUTPUT_TILE + 2 * runs.radius) / TE) + 1;\n const inFocus = new Map<number, Float64Array[]>(), capacity = Math.max(span * (span + 1), Math.floor(LARGE_CACHE_BYTES / (3 * TE * TE * 8)));\n const tileAt = (tx: number, ty: number): Float64Array[] => {\n const key = (ty + 1048576) * 2097152 + tx + 1048576;\n let tile = inFocus.get(key);\n if (tile) { inFocus.delete(key); inFocus.set(key, tile); }\n else {\n tile = inFocusTile(tx * TE, ty * TE, TE);\n inFocus.set(key, tile);\n if (inFocus.size > capacity) inFocus.delete(inFocus.keys().next().value!);\n }\n return tile;\n };\n // Which sites of a tile row hold channel c: the CFA's 2 × 2 period (tile origins are even).\n const phase = [0, 1].map((py) => [0, 1].map((px) => channelAt(px, py)));\n const patterns: SiteKernelRunsRowPattern[] = [0, 1, 2].map((c) => (row: number) => {\n const p = phase[row & 1]!, even = p[0] === c, odd = p[1] === c;\n return even && odd ? { start: 0, step: 1 } : even ? { start: 0, step: 2 } : odd ? { start: 1, step: 2 } : null;\n });\n const lattice = createSiteKernelRunsLattice({ runs, tile: LARGE_OUTPUT_TILE, fields: 3, capacityBytes: LARGE_CACHE_BYTES, pattern: (c) => patterns[c],\n source: (x0, y0, width, height) => (c: number): Float64Array => {\n const samples = new Float64Array(width * height);\n for (let ty = Math.floor(y0 / TE); ty * TE < y0 + height; ty++) for (let tx = Math.floor(x0 / TE); tx * TE < x0 + width; tx++) {\n const tile = tileAt(tx, ty)[c]!, ax = Math.max(x0, tx * TE), bx = Math.min(x0 + width, (tx + 1) * TE), ay = Math.max(y0, ty * TE), by = Math.min(y0 + height, (ty + 1) * TE);\n for (let y = ay; y < by; y++) samples.set(tile.subarray((y - ty * TE) * TE + ax - tx * TE, (y - ty * TE) * TE + bx - tx * TE), (y - y0) * width + ax - x0);\n }\n return samples;\n } });\n return {\n get lookups(): number { return lookups(); },\n uniformMaterial: -1,\n tracksMaterial: false,\n cachesSites: false,\n marksReads: false,\n markReads(): void { /* never called: marksReads is false */ },\n window(): void { /* the tiles are fixed and kept for the signal; a window changes nothing */ },\n site(x: number, y: number): number { return lattice.valueAt(channelAt(x, y), x, y); },\n pilot\n };\n}\n"]}
@@ -0,0 +1,15 @@
1
+ /** Beyond this many standard deviations from a clip level the clip changes the moments by less than 1e-15 of σ². */
2
+ export declare const CLIP_REACH_SIGMA = 8.5;
3
+ /** Standard normal density. */
4
+ export declare function phi(z: number): number;
5
+ /**
6
+ * Standard normal distribution function, Φ(z) = 1 − Q(z), with Q from the rational approximation 26.2.17 of
7
+ * Abramowitz & Stegun, Handbook of Mathematical Functions (NBS AMS 55, 1964; free, US government work):
8
+ * absolute error below 7.5e-8.
9
+ */
10
+ export declare function bigPhi(z: number): number;
11
+ /** Gauss–Legendre nodes and weights on [−1, 1], 16 points (computed once by Newton iteration on P_16 from cos(π(i + ¾)/(n + ½))). */
12
+ export declare const GL: {
13
+ x: Float64Array;
14
+ w: Float64Array;
15
+ };
@@ -0,0 +1,44 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * The display view's normal-distribution helpers (shared by the default path, display-view.ts, and the on-demand coupled
4
+ * rendering steps, display-view-rendering.ts, which must not be imported statically by the default path).
5
+ */
6
+ import { portableCosTwoPi, portableExp } from "../core/portable-math.js";
7
+ /** Beyond this many standard deviations from a clip level the clip changes the moments by less than 1e-15 of σ². */
8
+ export const CLIP_REACH_SIGMA = 8.5;
9
+ /** Standard normal density. */
10
+ export function phi(z) { return 0.3989422804014327 * portableExp(-0.5 * z * z); }
11
+ /**
12
+ * Standard normal distribution function, Φ(z) = 1 − Q(z), with Q from the rational approximation 26.2.17 of
13
+ * Abramowitz & Stegun, Handbook of Mathematical Functions (NBS AMS 55, 1964; free, US government work):
14
+ * absolute error below 7.5e-8.
15
+ */
16
+ export function bigPhi(z) {
17
+ const x = Math.abs(z), t = 1 / (1 + 0.2316419 * x);
18
+ const q = phi(x) * t * (0.319381530 + t * (-0.356563782 + t * (1.781477937 + t * (-1.821255978 + t * 1.330274429))));
19
+ return z >= 0 ? 1 - q : q;
20
+ }
21
+ /** Gauss–Legendre nodes and weights on [−1, 1], 16 points (computed once by Newton iteration on P_16 from cos(π(i + ¾)/(n + ½))). */
22
+ export const GL = /* @__PURE__ */ (() => {
23
+ const n = 16, x = new Float64Array(n), w = new Float64Array(n);
24
+ for (let i = 0; i < n; i++) {
25
+ let z = portableCosTwoPi((i + 0.75) / (2 * n + 1)), dp = 0;
26
+ for (let it = 0; it < 100; it++) {
27
+ let p0 = 1, p1 = z;
28
+ for (let k = 2; k <= n; k++) {
29
+ const p2 = ((2 * k - 1) * z * p1 - (k - 1) * p0) / k;
30
+ p0 = p1;
31
+ p1 = p2;
32
+ }
33
+ dp = n * (z * p1 - p0) / (z * z - 1);
34
+ const dz = p1 / dp;
35
+ z -= dz;
36
+ if (Math.abs(dz) < 1e-16)
37
+ break;
38
+ }
39
+ x[i] = z;
40
+ w[i] = 2 / ((1 - z * z) * dp * dp);
41
+ }
42
+ return { x, w };
43
+ })();
44
+ //# sourceMappingURL=display-view-normal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"display-view-normal.js","sourceRoot":"","sources":["../../src/facade/display-view-normal.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEzE,oHAAoH;AACpH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACpC,+BAA+B;AAC/B,MAAM,UAAU,GAAG,CAAC,CAAS,IAAY,OAAO,kBAAkB,GAAG,WAAW,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CA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,EAAE,CAAC,EAAE,EAAE,CAAC;gBAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;gBAAC,EAAE,GAAG,EAAE,CAAC;gBAAC,EAAE,GAAG,EAAE,CAAC;YAAC,CAAC;YACxG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YACrC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;YACnB,CAAC,IAAI,EAAE,CAAC;YACR,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK;gBAAE,MAAM;QAClC,CAAC;QACD,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAClB,CAAC,CAAC,EAAE,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * The display view's normal-distribution helpers (shared by the default path, display-view.ts, and the on-demand coupled\n * rendering steps, display-view-rendering.ts, which must not be imported statically by the default path).\n */\n\nimport { portableCosTwoPi, portableExp } from \"../core/portable-math.js\";\n\n/** Beyond this many standard deviations from a clip level the clip changes the moments by less than 1e-15 of σ². */\nexport const CLIP_REACH_SIGMA = 8.5;\n/** Standard normal density. */\nexport function phi(z: number): number { return 0.3989422804014327 * portableExp(-0.5 * z * z); }\n/**\n * Standard normal distribution function, Φ(z) = 1 − Q(z), with Q from the rational approximation 26.2.17 of\n * Abramowitz & Stegun, Handbook of Mathematical Functions (NBS AMS 55, 1964; free, US government work):\n * absolute error below 7.5e-8.\n */\nexport function bigPhi(z: number): number {\n const x = Math.abs(z), t = 1 / (1 + 0.2316419 * x);\n const q = phi(x) * t * (0.319381530 + t * (-0.356563782 + t * (1.781477937 + t * (-1.821255978 + t * 1.330274429))));\n return z >= 0 ? 1 - q : q;\n}\n/** Gauss–Legendre nodes and weights on [−1, 1], 16 points (computed once by Newton iteration on P_16 from cos(π(i + ¾)/(n + ½))). */\nexport const GL = /* @__PURE__ */ ((): { x: Float64Array; w: Float64Array } => {\n const n = 16, x = new Float64Array(n), w = new Float64Array(n);\n for (let i = 0; i < n; i++) {\n let z = portableCosTwoPi((i + 0.75) / (2 * n + 1)), dp = 0;\n for (let it = 0; it < 100; it++) {\n let p0 = 1, p1 = z;\n for (let k = 2; k <= n; k++) { const p2 = ((2 * k - 1) * z * p1 - (k - 1) * p0) / k; p0 = p1; p1 = p2; }\n dp = n * (z * p1 - p0) / (z * z - 1);\n const dz = p1 / dp;\n z -= dz;\n if (Math.abs(dz) < 1e-16) break;\n }\n x[i] = z; w[i] = 2 / ((1 - z * z) * dp * dp);\n }\n return { x, w };\n})();\n\n"]}