@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.
- package/CHANGELOG.md +295 -1
- package/CITATION.cff +1 -1
- package/README.md +7 -6
- package/SECURITY.md +1 -1
- package/THIRD_PARTY.md +18 -0
- package/dist/capture/c2pa-embed.d.ts +116 -0
- package/dist/capture/c2pa-embed.js +493 -0
- package/dist/capture/c2pa-embed.js.map +1 -0
- package/dist/capture/dng-import.d.ts +73 -8
- package/dist/capture/dng-import.js +315 -80
- package/dist/capture/dng-import.js.map +1 -1
- package/dist/capture/dng-lens-correction-opcodes.d.ts +2 -2
- package/dist/capture/dng-lens-correction-opcodes.js +2 -2
- package/dist/capture/dng-lens-correction-opcodes.js.map +1 -1
- package/dist/capture/dng-opcodes.d.ts +96 -0
- package/dist/capture/dng-opcodes.js +391 -0
- package/dist/capture/dng-opcodes.js.map +1 -0
- package/dist/capture/dng-profile-maps.d.ts +99 -0
- package/dist/capture/dng-profile-maps.js +381 -0
- package/dist/capture/dng-profile-maps.js.map +1 -0
- package/dist/capture/dng-stage-image.d.ts +23 -0
- package/dist/capture/dng-stage-image.js +65 -0
- package/dist/capture/dng-stage-image.js.map +1 -0
- package/dist/capture/exposure-build-up-stage.d.ts +16 -0
- package/dist/capture/exposure-build-up-stage.js +4 -0
- package/dist/capture/exposure-build-up-stage.js.map +1 -0
- package/dist/capture/jpeg-xl-tiles.d.ts +22 -0
- package/dist/capture/jpeg-xl-tiles.js +151 -0
- package/dist/capture/jpeg-xl-tiles.js.map +1 -0
- package/dist/capture/lossy-jpeg.d.ts +17 -0
- package/dist/capture/lossy-jpeg.js +369 -0
- package/dist/capture/lossy-jpeg.js.map +1 -0
- package/dist/capture/native-environment-lean.d.ts +2 -1
- package/dist/capture/native-environment-lean.js +41 -73
- package/dist/capture/native-environment-lean.js.map +1 -1
- package/dist/capture/native-environment-tabulated.js +4 -3
- package/dist/capture/native-environment-tabulated.js.map +1 -1
- package/dist/capture/native-raw-development.d.ts +2 -1
- package/dist/capture/native-raw-development.js.map +1 -1
- package/dist/capture/native-raw.d.ts +3 -2
- package/dist/capture/native-raw.js +5 -4
- package/dist/capture/native-raw.js.map +1 -1
- package/dist/capture/sensor-raw-producer.d.ts +4 -1
- package/dist/capture/sensor-raw-producer.js +12 -3
- package/dist/capture/sensor-raw-producer.js.map +1 -1
- package/dist/color/neighbor-highlight-reconstruction.d.ts +66 -0
- package/dist/color/neighbor-highlight-reconstruction.js +234 -0
- package/dist/color/neighbor-highlight-reconstruction.js.map +1 -0
- package/dist/color/sensor-color-development.d.ts +5 -0
- package/dist/color/sensor-color-development.js +7 -1
- package/dist/color/sensor-color-development.js.map +1 -1
- package/dist/color/spectral-spikiness.d.ts +11 -0
- package/dist/color/spectral-spikiness.js +23 -0
- package/dist/color/spectral-spikiness.js.map +1 -0
- package/dist/core/execution-error.d.ts +21 -0
- package/dist/core/execution-error.js +12 -0
- package/dist/core/execution-error.js.map +1 -0
- package/dist/core/version.d.ts +1 -1
- package/dist/core/version.js +1 -1
- package/dist/core/version.js.map +1 -1
- package/dist/equipment/generic-lens-catalogue.d.ts +3 -2
- package/dist/equipment/generic-lens-catalogue.js +18 -5
- package/dist/equipment/generic-lens-catalogue.js.map +1 -1
- package/dist/equipment/generic-tier-assets.d.ts +32 -0
- package/dist/equipment/generic-tier-assets.js +16 -11
- package/dist/equipment/generic-tier-assets.js.map +1 -1
- package/dist/equipment/sensor-profile-body.d.ts +78 -0
- package/dist/equipment/sensor-profile-body.js +77 -0
- package/dist/equipment/sensor-profile-body.js.map +1 -0
- package/dist/equipment/sensor-profiles.d.ts +8 -0
- package/dist/equipment/sensor-profiles.js +82 -0
- package/dist/equipment/sensor-profiles.js.map +1 -0
- package/dist/facade/catalogue-lens-signal.d.ts +28 -3
- package/dist/facade/catalogue-lens-signal.js +83 -78
- package/dist/facade/catalogue-lens-signal.js.map +1 -1
- package/dist/facade/chart-radiance-batch.js +2 -1
- package/dist/facade/chart-radiance-batch.js.map +1 -1
- package/dist/facade/defocus-image-space-provider.d.ts +7 -0
- package/dist/facade/defocus-image-space-provider.js +64 -76
- package/dist/facade/defocus-image-space-provider.js.map +1 -1
- package/dist/facade/diffraction-provider.d.ts +1 -1
- package/dist/facade/diffraction-provider.js +4 -4
- package/dist/facade/diffraction-provider.js.map +1 -1
- package/dist/facade/display-view-gpu-session.js +39 -5
- package/dist/facade/display-view-gpu-session.js.map +1 -1
- package/dist/facade/display-view-gpu.d.ts +19 -6
- package/dist/facade/display-view-gpu.js.map +1 -1
- package/dist/facade/display-view-lens-signal.js +25 -23
- package/dist/facade/display-view-lens-signal.js.map +1 -1
- package/dist/facade/display-view-normal.d.ts +15 -0
- package/dist/facade/display-view-normal.js +44 -0
- package/dist/facade/display-view-normal.js.map +1 -0
- package/dist/facade/display-view-rendering.d.ts +97 -0
- package/dist/facade/display-view-rendering.js +598 -0
- package/dist/facade/display-view-rendering.js.map +1 -0
- package/dist/facade/display-view.d.ts +37 -65
- package/dist/facade/display-view.js +152 -499
- package/dist/facade/display-view.js.map +1 -1
- package/dist/facade/expected-signal-setup.d.ts +3 -1
- package/dist/facade/expected-signal-setup.js +3 -3
- package/dist/facade/expected-signal-setup.js.map +1 -1
- package/dist/facade/expected-signal.d.ts +47 -14
- package/dist/facade/expected-signal.js +117 -112
- package/dist/facade/expected-signal.js.map +1 -1
- package/dist/facade/exposure-build-up.d.ts +70 -0
- package/dist/facade/exposure-build-up.js +164 -0
- package/dist/facade/exposure-build-up.js.map +1 -0
- package/dist/facade/fast-methods.d.ts +1 -1
- package/dist/facade/fast-methods.js +46 -9
- package/dist/facade/fast-methods.js.map +1 -1
- package/dist/facade/generic-lens-capture.d.ts +3 -3
- package/dist/facade/generic-lens-capture.js +3 -3
- package/dist/facade/generic-lens-capture.js.map +1 -1
- package/dist/facade/image-plane-enable.d.ts +7 -0
- package/dist/facade/image-plane-enable.js +17 -0
- package/dist/facade/image-plane-enable.js.map +1 -0
- package/dist/facade/image-plane-lattice-data.d.ts +6 -0
- package/dist/facade/image-plane-lattice-data.js +10 -0
- package/dist/facade/image-plane-lattice-data.js.map +1 -0
- package/dist/facade/image-plane-support.d.ts +33 -0
- package/dist/facade/image-plane-support.js +11 -0
- package/dist/facade/image-plane-support.js.map +1 -0
- package/dist/facade/image-plane.d.ts +36 -0
- package/dist/facade/image-plane.js +384 -0
- package/dist/facade/image-plane.js.map +1 -0
- package/dist/facade/mixed-illumination.d.ts +108 -0
- package/dist/facade/mixed-illumination.js +174 -0
- package/dist/facade/mixed-illumination.js.map +1 -0
- package/dist/facade/on-demand-kits.d.ts +14 -0
- package/dist/facade/on-demand-kits.js +36 -0
- package/dist/facade/on-demand-kits.js.map +1 -0
- package/dist/facade/opt-in-kit.d.ts +9 -0
- package/dist/facade/opt-in-kit.js +11 -0
- package/dist/facade/opt-in-kit.js.map +1 -0
- package/dist/facade/quality-kit.d.ts +21 -0
- package/dist/facade/quality-kit.js +23 -0
- package/dist/facade/quality-kit.js.map +1 -0
- package/dist/facade/quality-paths.d.ts +22 -0
- package/dist/facade/quality-paths.js +44 -0
- package/dist/facade/quality-paths.js.map +1 -0
- package/dist/facade/representative-light-sources.d.ts +72 -0
- package/dist/facade/representative-light-sources.js +124 -0
- package/dist/facade/representative-light-sources.js.map +1 -0
- package/dist/facade/scene-radiance.d.ts +145 -4
- package/dist/facade/scene-radiance.js +50 -13
- package/dist/facade/scene-radiance.js.map +1 -1
- package/dist/facade/simulate-capture.d.ts +68 -20
- package/dist/facade/simulate-capture.js +399 -146
- package/dist/facade/simulate-capture.js.map +1 -1
- package/dist/facade/simulate-display-view.d.ts +10 -12
- package/dist/facade/simulate-display-view.js +70 -53
- package/dist/facade/simulate-display-view.js.map +1 -1
- package/dist/gpu/chart-composite-gpu.d.ts +13 -1
- package/dist/gpu/chart-composite-gpu.js +48 -9
- package/dist/gpu/chart-composite-gpu.js.map +1 -1
- package/dist/gpu/chart-radiance-gpu.js +4 -30
- package/dist/gpu/chart-radiance-gpu.js.map +1 -1
- package/dist/gpu/display-view-composite-material-module.d.ts +10 -4
- package/dist/gpu/display-view-composite-material-module.js +39 -13
- package/dist/gpu/display-view-composite-material-module.js.map +1 -1
- package/dist/gpu/display-view-gpu-renderer.d.ts +43 -0
- package/dist/gpu/display-view-gpu-renderer.js +134 -0
- package/dist/gpu/display-view-gpu-renderer.js.map +1 -0
- package/dist/gpu/display-view-image-material-module.d.ts +87 -0
- package/dist/gpu/display-view-image-material-module.js +361 -0
- package/dist/gpu/display-view-image-material-module.js.map +1 -0
- package/dist/gpu/display-view-image-quality.d.ts +87 -0
- package/dist/gpu/display-view-image-quality.js +625 -0
- package/dist/gpu/display-view-image-quality.js.map +1 -0
- package/dist/gpu/display-view-quality-gpu.d.ts +80 -65
- package/dist/gpu/display-view-quality-gpu.js +187 -445
- package/dist/gpu/display-view-quality-gpu.js.map +1 -1
- package/dist/gpu/display-view-speed-gpu.d.ts +67 -19
- package/dist/gpu/display-view-speed-gpu.js +181 -105
- package/dist/gpu/display-view-speed-gpu.js.map +1 -1
- package/dist/gpu/image-kernel-accelerator.js +3 -0
- package/dist/gpu/image-kernel-accelerator.js.map +1 -1
- package/dist/gpu/image-kernel-execution.d.ts +2 -13
- package/dist/gpu/image-kernel-execution.js +2 -10
- package/dist/gpu/image-kernel-execution.js.map +1 -1
- package/dist/gpu/wgsl-display-view-coupled-stub.d.ts +8 -0
- package/dist/gpu/wgsl-display-view-coupled-stub.js +21 -0
- package/dist/gpu/wgsl-display-view-coupled-stub.js.map +1 -0
- package/dist/gpu/wgsl-display-view-coupled.d.ts +88 -0
- package/dist/gpu/wgsl-display-view-coupled.js +353 -0
- package/dist/gpu/wgsl-display-view-coupled.js.map +1 -0
- package/dist/gpu/wgsl-display-view-quality-kernel.d.ts +33 -24
- package/dist/gpu/wgsl-display-view-quality-kernel.js +166 -146
- package/dist/gpu/wgsl-display-view-quality-kernel.js.map +1 -1
- package/dist/gpu/wgsl-display-view-speed-kernel.d.ts +19 -44
- package/dist/gpu/wgsl-display-view-speed-kernel.js +116 -18
- package/dist/gpu/wgsl-display-view-speed-kernel.js.map +1 -1
- package/dist/gpu/wgsl-exact-sum.d.ts +20 -0
- package/dist/gpu/wgsl-exact-sum.js +42 -0
- package/dist/gpu/wgsl-exact-sum.js.map +1 -0
- package/dist/index.d.ts +22 -6
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/dist/motion/subject-motion.d.ts +66 -0
- package/dist/motion/subject-motion.js +52 -0
- package/dist/motion/subject-motion.js.map +1 -0
- package/dist/optics/generic-lens-lateral-color.d.ts +83 -0
- package/dist/optics/generic-lens-lateral-color.js +77 -0
- package/dist/optics/generic-lens-lateral-color.js.map +1 -0
- package/dist/optics/generic-lens-psf.js +54 -46
- package/dist/optics/generic-lens-psf.js.map +1 -1
- package/dist/optics/lens-psf-profile.d.ts +7 -0
- package/dist/optics/lens-psf-profile.js +2 -1
- package/dist/optics/lens-psf-profile.js.map +1 -1
- package/dist/output/camera-channel-response.d.ts +50 -0
- package/dist/output/camera-channel-response.js +69 -0
- package/dist/output/camera-channel-response.js.map +1 -0
- package/dist/output/developed-lens-corrections.d.ts +19 -5
- package/dist/output/developed-lens-corrections.js +28 -9
- package/dist/output/developed-lens-corrections.js.map +1 -1
- package/dist/output/generic-lens-corrections.d.ts +41 -5
- package/dist/output/generic-lens-corrections.js +52 -8
- package/dist/output/generic-lens-corrections.js.map +1 -1
- package/dist/output/native-capture-sdr.js +5 -2
- package/dist/output/native-capture-sdr.js.map +1 -1
- package/dist/output/print-plan.d.ts +41 -5
- package/dist/output/print-plan.js +59 -14
- package/dist/output/print-plan.js.map +1 -1
- package/dist/output/sdr-rendering.d.ts +18 -1
- package/dist/output/sdr-rendering.js +39 -2
- package/dist/output/sdr-rendering.js.map +1 -1
- package/dist/sensor/binomial-sample.d.ts +3 -0
- package/dist/sensor/binomial-sample.js +86 -0
- package/dist/sensor/binomial-sample.js.map +1 -0
- package/dist/sensor/native-sensor-report.d.ts +10 -0
- package/dist/sensor/native-sensor-report.js +16 -0
- package/dist/sensor/native-sensor-report.js.map +1 -0
- package/dist/sensor/sensor-characteristics.d.ts +91 -13
- package/dist/sensor/sensor-characteristics.js +30 -15
- package/dist/sensor/sensor-characteristics.js.map +1 -1
- package/docs/AGENT_GUIDE.md +1 -0
- package/docs/API_REFERENCE.md +214 -4
- package/docs/QUICK_START.md +162 -8
- package/docs/USAGE.md +195 -22
- package/docs/api/capture-c2pa-embed.md +177 -0
- package/docs/api/capture-dng-import.md +86 -10
- package/docs/api/capture-dng-opcodes.md +93 -0
- package/docs/api/capture-dng-profile-maps.md +141 -0
- package/docs/api/capture-dng-stage-image.md +43 -0
- package/docs/api/capture-jpeg-xl-tiles.md +33 -0
- package/docs/api/capture-lossy-jpeg.md +41 -0
- package/docs/api/capture-native-raw-development.md +2 -1
- package/docs/api/core-execution-error.md +43 -0
- package/docs/api/core-version.md +1 -1
- package/docs/api/equipment-generic-lens-catalogue.md +10 -5
- package/docs/api/equipment-sensor-profile-body.md +64 -0
- package/docs/api/equipment-sensor-profiles.md +86 -0
- package/docs/api/exports.json +460 -5
- package/docs/api/facade-display-view-gpu.md +5 -2
- package/docs/api/facade-display-view.md +11 -15
- package/docs/api/facade-exposure-build-up.md +105 -0
- package/docs/api/facade-fast-methods.md +47 -10
- package/docs/api/facade-image-plane-enable.md +16 -0
- package/docs/api/facade-mixed-illumination.md +67 -0
- package/docs/api/facade-quality-paths.md +24 -0
- package/docs/api/facade-representative-light-sources.md +131 -0
- package/docs/api/facade-scene-radiance.md +54 -3
- package/docs/api/facade-simulate-capture.md +48 -11
- package/docs/api/facade-simulate-display-view.md +10 -12
- package/docs/api/gpu-image-kernel-execution.md +0 -36
- package/docs/api/motion-subject-motion.md +23 -0
- package/docs/api/optics-generic-lens-lateral-color.md +79 -0
- package/docs/api/output-camera-channel-response.md +55 -0
- package/docs/api/output-developed-lens-corrections.md +10 -1
- package/docs/api/output-generic-lens-corrections.md +40 -4
- package/docs/api/output-print-plan.md +35 -1
- package/docs/api/output-sdr-rendering.md +6 -1
- package/docs/api/sensor-sensor-characteristics.md +54 -2
- package/llms.txt +3 -0
- package/package.json +6 -5
|
@@ -37,6 +37,7 @@ import { dwSplit, packChartScene, probeChartCompositeDevice } from "./chart-comp
|
|
|
37
37
|
import { chartPresetMaterialModule } from "./display-view-chart-material-module.js";
|
|
38
38
|
import { BUFFER_USAGE, GpuResourceScope } from "./webgpu-runtime.js";
|
|
39
39
|
import { DISPLAY_VIEW_GPU_MAXIMUM_OFFSETS } from "./wgsl-display-view-speed-kernel.js";
|
|
40
|
+
import { imagePlaneSupport } from "../facade/image-plane-support.js";
|
|
40
41
|
/** One WGSL rounding of + − × in either direction (E = 2⁻²³). */
|
|
41
42
|
const E = 2 * WEBGPU_F32_UNIT_ROUNDOFF;
|
|
42
43
|
/** The module's id in the pipeline cache (one shader per product path for every composite scene; the scene is data): the Dekker path's. */
|
|
@@ -55,24 +56,31 @@ export const DISPLAY_VIEW_LATTICE = /* @__PURE__ */ Object.freeze({ scaleUHi: 0,
|
|
|
55
56
|
* defines `material_at(p: vec2<f32>)` (see the module comment). The constants E and SLACK come from the kernel's preamble. `path`
|
|
56
57
|
* is the double-word product path the device's probe chose (default Dekker's).
|
|
57
58
|
*/
|
|
58
|
-
|
|
59
|
+
/** The composite kernel's text renamed for a display-view module: its flag is `material_uncertain`, its barrier word `lattice.zero`. */
|
|
60
|
+
function renameForDisplayView(code) {
|
|
61
|
+
return code.replace(/^const SLACK: f32 = [^\n]*\n/mu, "").replace(/\bflagged\b/gu, "material_uncertain").replace(/\bmargin\(/gu, "bmargin(").replace(/\bparams\.zero\b/gu, "lattice.zero");
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* #581: the composite kernel's common part (double-float32 with its rounding barrier, the bound arithmetic, `bfloor`) renamed for a
|
|
65
|
+
* display-view module (shared by the composite and the image-plane modules); the kernel's preamble gives E and SLACK.
|
|
66
|
+
*/
|
|
67
|
+
export function displayViewModuleCommonWgsl(path) {
|
|
59
68
|
const source = chartCompositeWgsl(path);
|
|
60
|
-
const commonStart = source.indexOf("const DW: f32"), commonEnd = source.indexOf("struct Params")
|
|
61
|
-
if (commonStart < 0 || commonEnd < commonStart
|
|
69
|
+
const commonStart = source.indexOf("const DW: f32"), commonEnd = source.indexOf("struct Params");
|
|
70
|
+
if (commonStart < 0 || commonEnd < commonStart)
|
|
62
71
|
throw new ImageKernelExecutionError("gpu-validation", "The composite chart kernel's material functions were not found.");
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
@group(1)
|
|
66
|
-
|
|
67
|
-
struct LatticeParams {
|
|
72
|
+
return renameForDisplayView(source.slice(commonStart, commonEnd));
|
|
73
|
+
}
|
|
74
|
+
/** The lattice uniform and the offsets table of a display-view module (@group(1) bindings 2 and 3; `DISPLAY_VIEW_LATTICE`). */
|
|
75
|
+
export const LATTICE_BINDINGS_WGSL = `struct LatticeParams {
|
|
68
76
|
scale_u_hi: f32, scale_u_lo: f32, scale_v_hi: f32, scale_v_lo: f32,
|
|
69
77
|
chart_k_hi: f32, chart_k_lo: f32, chart_aspect: f32, tolerance: f32,
|
|
70
78
|
offsets: u32, placed: u32, surround: u32, zero: u32,
|
|
71
79
|
};
|
|
72
80
|
@group(1) @binding(2) var<uniform> lattice: LatticeParams;
|
|
73
|
-
@group(1) @binding(3) var<storage, read> lattice_offsets: array<vec4<f32
|
|
74
|
-
|
|
75
|
-
|
|
81
|
+
@group(1) @binding(3) var<storage, read> lattice_offsets: array<vec4<f32>>;`;
|
|
82
|
+
/** The exact lattice point recovery (see the module comment), shared by the composite and the image-plane modules. */
|
|
83
|
+
export const LATTICE_POINT_WGSL = `// The exact lattice point of one axis from the kernel's p = fl(fl(x + c)·scale): the offset whose constant c puts p/scale
|
|
76
84
|
// nearest an integer x, then (x + c)·scale in double-float32 from the exact integer and the float64 constants (hi + lo).
|
|
77
85
|
fn lattice_point(p: f32, scale: D, axis: u32) -> D {
|
|
78
86
|
let rough = p / scale.h;
|
|
@@ -88,7 +96,17 @@ fn lattice_point(p: f32, scale: D, axis: u32) -> D {
|
|
|
88
96
|
}
|
|
89
97
|
if (!(best <= lattice.tolerance)) { material_uncertain = true; }
|
|
90
98
|
return d_mul(d_add(D(site, 0.0), D(c_hi, c_lo)), scale);
|
|
91
|
-
}
|
|
99
|
+
}`;
|
|
100
|
+
export function chartCompositeMaterialWgsl(path = "dekker") {
|
|
101
|
+
const source = chartCompositeWgsl(path), bodyStart = source.indexOf("const SEGMENT_BOX"), bodyEnd = source.indexOf("@compute");
|
|
102
|
+
if (bodyStart < 0 || bodyEnd < bodyStart)
|
|
103
|
+
throw new ImageKernelExecutionError("gpu-validation", "The composite chart kernel's material functions were not found.");
|
|
104
|
+
return `${displayViewModuleCommonWgsl(path)}
|
|
105
|
+
@group(1) @binding(0) var<storage, read> af: array<f32>;
|
|
106
|
+
@group(1) @binding(1) var<storage, read> ai: array<u32>;
|
|
107
|
+
${LATTICE_BINDINGS_WGSL}
|
|
108
|
+
${renameForDisplayView(source.slice(bodyStart, bodyEnd))}
|
|
109
|
+
${LATTICE_POINT_WGSL}
|
|
92
110
|
fn material_at(p: vec2<f32>) -> u32 {
|
|
93
111
|
var u = lattice_point(p.x, D(lattice.scale_u_hi, lattice.scale_u_lo), 0u);
|
|
94
112
|
var v = lattice_point(p.y, D(lattice.scale_v_hi, lattice.scale_v_lo), 1u);
|
|
@@ -190,6 +208,11 @@ function sceneOf(gpu) {
|
|
|
190
208
|
}
|
|
191
209
|
export function createDisplayViewMaterialModules(runtime, pipelines) {
|
|
192
210
|
const presets = new WeakMap(), uploads = [];
|
|
211
|
+
// #581: image-plane prints (their double-float32 arithmetic is the composite kernel's, so the same probe gates them), through the
|
|
212
|
+
// module prepareImagePlaneScenes() loaded; created on the first photo.
|
|
213
|
+
let images;
|
|
214
|
+
// A photo reaches the GPU only after the request was resolved, so the module is enabled.
|
|
215
|
+
const imageModules = async () => images ??= (await imagePlaneSupport().loadGpuModule()).createDisplayViewImageModules(runtime, probe);
|
|
193
216
|
let probed = null;
|
|
194
217
|
const wgsl = new Map();
|
|
195
218
|
const probe = (signal) => {
|
|
@@ -216,6 +239,8 @@ export function createDisplayViewMaterialModules(runtime, pipelines) {
|
|
|
216
239
|
};
|
|
217
240
|
return {
|
|
218
241
|
async moduleFor(gpu, signal) {
|
|
242
|
+
if (gpu.signalInput.scene.image)
|
|
243
|
+
return await (await imageModules()).moduleFor(gpu, signal);
|
|
219
244
|
const scene = sceneOf(gpu), placement = gpu.placement ?? null, signalInput = gpu.signalInput;
|
|
220
245
|
const tableMaterials = signalInput.scene.kind === "materials" ? signalInput.scene.materials.length : -1;
|
|
221
246
|
if (tableMaterials !== scene.materials.length + (placement ? 1 : 0))
|
|
@@ -240,9 +265,10 @@ export function createDisplayViewMaterialModules(runtime, pipelines) {
|
|
|
240
265
|
{ binding: 2, kind: "uniform", data: new Uint8Array(lattice.params) }, { binding: 3, kind: "storage", data: lattice.offsets }
|
|
241
266
|
] };
|
|
242
267
|
},
|
|
268
|
+
async imagePasses(gpu, signal) { return await (await imageModules()).qualityPasses(gpu, signal); },
|
|
243
269
|
get uploadedScenes() { return uploads.length; },
|
|
244
270
|
release() { for (const entry of uploads.splice(0))
|
|
245
|
-
entry.scope.release(); }
|
|
271
|
+
entry.scope.release(); images?.release(); }
|
|
246
272
|
};
|
|
247
273
|
}
|
|
248
274
|
//# sourceMappingURL=display-view-composite-material-module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display-view-composite-material-module.js","sourceRoot":"","sources":["../../src/gpu/display-view-composite-material-module.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAE,kBAAkB,EAAkC,MAAM,kCAAkC,CAAC;AACtG,OAAO,EAAE,kBAAkB,EAAE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AAC,CAAC;KAClF,CAAC;AACJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * The composite-chart and mask-layer material module of the GPU display view (#491): the Speed kernel's `material_at`\n * (the seam of #478, `DisplayViewGpuMaterialModule`) built from the composite chart kernel's classification (#477,\n * `wgsl-chart-composite-kernel.ts`: `material()`, its bound arithmetic and double-float32), so that composite charts,\n * every 2.3 element as a plain chart, the sine-profile Siemens star and declared `material-layers` scenes render on the\n * GPU. The scene's packed records (`packChartScene`) are uploaded once per renderer and reused across a view's parts,\n * as the composite kernel reuses them per accelerator; the device probe of the composite kernel gates the module.\n *\n * **The query point.** The Speed kernel hands the module p = fl(fl(x + c)·scale) per axis: the site coordinate x plus the\n * offset constant c = 0.5 + o − W/2 (`DISPLAY_VIEW_AUX.offsets`), times the frame-units-per-site scale rounded once to\n * float32, so p carries up to 2E relative error (E = 2⁻²³) against the reference's float64 query point. The composite\n * kernel's chirp decisions (the zone plate's phase, the stars' sector cross products) need the point to about 2⁻⁴⁰; fed\n * p directly they would flag most of a 64-cycle sine star. The module therefore **recovers the exact lattice point**: it\n * knows the offsets c_o (uploaded as float32 hi + lo pairs) and the scale (hi + lo), divides p by the scale's high part\n * (within 6E·|s| of s = x + c_o), picks the offset whose c_o puts the quotient nearest an integer x, and re-forms the point\n * in double-float32 as (x + c_o)·scale from the exact integer and the float64 constants. The host admits a lattice only\n * when the recovery is unambiguous: the distinct fractional parts of the offsets (mod 1) lie more than four tolerances\n * apart, the tolerance being 8E·max|s| + 2⁻¹²; a point whose residual exceeds the tolerance on the device is flagged.\n * The recovered point differs from the exact (x + c_o)·g by at most about 2⁻⁴⁶ relative (two double-float32 operations\n * and the split constants' 2⁻⁴⁸), inside the composite kernel's own allowance for a point (DW = 2⁻⁴⁰ relative in `bd`).\n * The reference's own float64 query point differs from the exact lattice value by its float64 rounding only: measured at\n * most 5.6·10⁻¹⁶ absolute over every site and offset of the #491 fixtures, and checked by the host at the frame's four\n * corners within 2⁻⁴⁸·(|p| + 1); that is inside the composite kernel's 10⁻¹⁴ slack for the reference's rounding. So the\n * composite kernel's bounds and SAFETY factor (4) apply unchanged, and the module's point error is far inside the Speed\n * kernel's contract (≤ 2E + 10⁻¹⁴): no Speed bound term changes.\n *\n * **A fixed-size chart** (`chartSize`): the reference maps the frame point to chart-local units, cu = (u·m)/h with m the\n * metres per frame unit and h the chart's half width, and returns the surround material outside |cu| ≤ 1, |cv| ≤ aspect.\n * The module multiplies the recovered point by k = m/h (hi + lo) in double-float32 and tests the chart rectangle in bound\n * arithmetic (flagging points within their bound of its edge); the surround is the materials table's last entry.\n */\nimport { ImageKernelExecutionError, WEBGPU_F32_UNIT_ROUNDOFF } from \"./image-kernel-execution.js\";\nimport { chartCompositeWgsl, type ChartCompositeProductPath } from \"./wgsl-chart-composite-kernel.js\";\nimport { chartGpuPresetCode } from \"./chart-radiance-gpu.js\";\nimport { dwSplit, packChartScene, probeChartCompositeDevice, type PackedChartScene } from \"./chart-composite-gpu.js\";\nimport type { ChartCompositeProbeRecord } from \"./image-kernel-execution.js\";\nimport { chartPresetMaterialModule } from \"./display-view-chart-material-module.js\";\nimport type { ChartRadianceBatchPlan } from \"../facade/chart-radiance-batch.js\";\nimport type { ResolvedChartScene } from \"../facade/chart-scenes.js\";\nimport type { ResolvedChartMaterialLayers } from \"../facade/chart-material-layers.js\";\nimport type { DisplayViewExpectedSignalInput } from \"../facade/expected-signal.js\";\nimport type { DisplayViewGpuSetup } from \"../facade/display-view.js\";\nimport { BUFFER_USAGE, GpuResourceScope, type WebGpuRuntime } from \"./webgpu-runtime.js\";\nimport { DISPLAY_VIEW_GPU_MAXIMUM_OFFSETS } from \"./wgsl-display-view-speed-kernel.js\";\nimport type { DisplayViewGpuMaterialModule } from \"./display-view-speed-gpu.js\";\n\ntype PipelineSource = (label: string, code: string) => Promise<GPUComputePipeline>;\n\n/** One WGSL rounding of + − × in either direction (E = 2⁻²³). */\nconst E = 2 * WEBGPU_F32_UNIT_ROUNDOFF;\n/** The module's id in the pipeline cache (one shader per product path for every composite scene; the scene is data): the Dekker path's. */\nexport const CHART_COMPOSITE_MATERIAL_MODULE_ID = \"chart-composite\";\n/** The module's id per product path (the fma path's shader is a different pipeline). */\nexport function chartCompositeMaterialModuleId(path: ChartCompositeProductPath): string { return path === \"dekker\" ? CHART_COMPOSITE_MATERIAL_MODULE_ID : CHART_COMPOSITE_MATERIAL_MODULE_ID + \"-fma\"; }\n/** Scenes whose records stay uploaded per renderer (the composite kernel keeps the same number per accelerator). */\nconst KEPT_SCENES = 4;\n/** The corner check of the query-point model against the reference's own query points, relative to |p| + 1 (inside the composite kernel's 10⁻¹⁴ slack). */\nconst MODEL_TOLERANCE = 2 ** -48;\n\n/** Layout of the lattice uniform (float32 / u32 words, 48 bytes) and the offsets table (one vec4 per offset: cu hi, cu lo, cv hi, cv lo). */\nexport const DISPLAY_VIEW_LATTICE = /* @__PURE__ */ Object.freeze({ scaleUHi: 0, scaleULo: 1, scaleVHi: 2, scaleVLo: 3, chartKHi: 4, chartKLo: 5, chartAspect: 6, tolerance: 7, offsets: 8, placed: 9, surround: 10, zero: 11, words: 12 });\n\n/**\n * The composite kernel's classification (`material(p: vec4<f32>)` with its bound arithmetic, double-float32, cos polynomial,\n * elements and layers) renamed for the display-view kernel, its records bound at @group(1), and the lattice recovery that\n * defines `material_at(p: vec2<f32>)` (see the module comment). The constants E and SLACK come from the kernel's preamble. `path`\n * is the double-word product path the device's probe chose (default Dekker's).\n */\nexport function chartCompositeMaterialWgsl(path: ChartCompositeProductPath = \"dekker\"): string {\n const source = chartCompositeWgsl(path);\n const commonStart = source.indexOf(\"const DW: f32\"), commonEnd = source.indexOf(\"struct Params\"), bodyStart = source.indexOf(\"const SEGMENT_BOX\"), bodyEnd = source.indexOf(\"@compute\");\n if (commonStart < 0 || commonEnd < commonStart || bodyStart < commonEnd || bodyEnd < bodyStart) throw new ImageKernelExecutionError(\"gpu-validation\", \"The composite chart kernel's material functions were not found.\");\n const rename = (code: string): string => code.replace(/^const SLACK: f32 = [^\\n]*\\n/mu, \"\").replace(/\\bflagged\\b/gu, \"material_uncertain\").replace(/\\bmargin\\(/gu, \"bmargin(\").replace(/\\bparams\\.zero\\b/gu, \"lattice.zero\");\n return `${rename(source.slice(commonStart, commonEnd))}\n@group(1) @binding(0) var<storage, read> af: array<f32>;\n@group(1) @binding(1) var<storage, read> ai: array<u32>;\nstruct LatticeParams {\n scale_u_hi: f32, scale_u_lo: f32, scale_v_hi: f32, scale_v_lo: f32,\n chart_k_hi: f32, chart_k_lo: f32, chart_aspect: f32, tolerance: f32,\n offsets: u32, placed: u32, surround: u32, zero: u32,\n};\n@group(1) @binding(2) var<uniform> lattice: LatticeParams;\n@group(1) @binding(3) var<storage, read> lattice_offsets: array<vec4<f32>>;\n${rename(source.slice(bodyStart, bodyEnd))}\n// The exact lattice point of one axis from the kernel's p = fl(fl(x + c)·scale): the offset whose constant c puts p/scale\n// nearest an integer x, then (x + c)·scale in double-float32 from the exact integer and the float64 constants (hi + lo).\nfn lattice_point(p: f32, scale: D, axis: u32) -> D {\n let rough = p / scale.h;\n var best = 3.0e38; var site = 0.0; var c_hi = 0.0; var c_lo = 0.0;\n for (var o = 0u; o < lattice.offsets; o = o + 1u) {\n let row = lattice_offsets[o];\n let hi = select(row.z, row.x, axis == 0u);\n let lo = select(row.w, row.y, axis == 0u);\n let d = rough - hi;\n let n = round(d);\n let r = abs(d - n);\n if (r < best) { best = r; site = n; c_hi = hi; c_lo = lo; }\n }\n if (!(best <= lattice.tolerance)) { material_uncertain = true; }\n return d_mul(d_add(D(site, 0.0), D(c_hi, c_lo)), scale);\n}\nfn material_at(p: vec2<f32>) -> u32 {\n var u = lattice_point(p.x, D(lattice.scale_u_hi, lattice.scale_u_lo), 0u);\n var v = lattice_point(p.y, D(lattice.scale_v_hi, lattice.scale_v_lo), 1u);\n if (lattice.placed != 0u) {\n let k = D(lattice.chart_k_hi, lattice.chart_k_lo);\n u = d_mul(u, k); v = d_mul(v, k);\n if (!(le(babs(bd(u)), bx(1.0)) && le(babs(bd(v)), bc(lattice.chart_aspect)))) { return lattice.surround; }\n }\n return material(vec4<f32>(u.h, u.l, v.h, v.l));\n}\n`;\n}\n\n/** A fixed-size chart's placement for the module: chart-local frame units per frame unit (m/h) and the chart's aspect. */\nexport interface DisplayViewChartPlacement { chartUnitsPerFrameUnit: number; aspect: number }\n\n/** The lattice constants of a render (see the module comment): the uniform words and the offsets table. */\nexport interface DisplayViewLatticeConstants { params: ArrayBuffer; offsets: Float32Array<ArrayBuffer>; tolerance: number; scaleU: number; scaleV: number }\n\n/**\n * The query lattice of an expected-signal input as the module needs it, or an `unsupported-on-backend` error: the scale per\n * axis from the reference's own query points (two sites a frame apart), the model (x + c)·scale checked against the reference\n * at the frame's four corners for every offset within 2⁻⁴⁸·(|p| + 1), the offsets as hi + lo pairs, and the recovery tolerance\n * 8E·max|x + c| + 2⁻¹², which the distinct fractional parts of the offsets must clear four times over.\n */\nexport function displayViewLatticeConstants(signalInput: DisplayViewExpectedSignalInput, placement: DisplayViewChartPlacement | null, surroundMaterial: number): DisplayViewLatticeConstants {\n const W = signalInput.nativeWidth, H = signalInput.nativeHeight, offsets = signalInput.offsets, query = signalInput.queryPoint;\n if (!query) throw new ImageKernelExecutionError(\"unsupported-on-backend\", \"The expected signal has no query points (the Quality path); use cpu-reference.\");\n if (offsets.length < 1 || offsets.length > DISPLAY_VIEW_GPU_MAXIMUM_OFFSETS) throw new ImageKernelExecutionError(\"unsupported-on-backend\", \"The kernel holds 1 to \" + DISPLAY_VIEW_GPU_MAXIMUM_OFFSETS + \" query offsets.\");\n if (!(W >= 2 && H >= 2 && W <= 2 ** 20 && H <= 2 ** 20)) throw new ImageKernelExecutionError(\"unsupported-on-backend\", \"The native frame is outside the lattice recovery's range (2 to 2^20 sites per axis).\");\n const point = new Float64Array(2), x1 = W - 1, y1 = H - 1;\n query(0, 0, 0, point); const u0 = point[0]!, v0 = point[1]!;\n query(x1, 0, 0, point); const u1 = point[0]!;\n query(0, y1, 0, point); const v1 = point[1]!;\n const scaleU = (u1 - u0) / x1, scaleV = (v1 - v0) / y1;\n if (!(Number.isFinite(scaleU) && Number.isFinite(scaleV) && scaleU !== 0 && scaleV !== 0)) throw new ImageKernelExecutionError(\"unsupported-on-backend\", \"The request's query lattice has no scale; use cpu-reference.\");\n const cu = new Float64Array(offsets.length), cv = new Float64Array(offsets.length);\n let smax = 0;\n for (let o = 0; o < offsets.length; o++) {\n const offset = offsets[o]!;\n cu[o] = 0.5 + offset.x - W / 2; cv[o] = 0.5 + offset.y - H / 2;\n smax = Math.max(smax, Math.abs(cu[o]!), Math.abs(x1 + cu[o]!), Math.abs(cv[o]!), Math.abs(y1 + cv[o]!));\n for (const [x, y] of [[0, 0], [x1, 0], [0, y1], [x1, y1]] as const) {\n query(x, y, o, point);\n const mu = (x + cu[o]!) * scaleU, mv = (y + cv[o]!) * scaleV;\n if (!(Math.abs(mu - point[0]!) <= MODEL_TOLERANCE * (Math.abs(point[0]!) + 1) && Math.abs(mv - point[1]!) <= MODEL_TOLERANCE * (Math.abs(point[1]!) + 1)))\n throw new ImageKernelExecutionError(\"unsupported-on-backend\", \"The request's query points are not a rectilinear site lattice within 2^-48; use cpu-reference.\");\n }\n }\n const tolerance = Math.fround(8 * E * smax + 2 ** -12);\n if (!(tolerance < 1 / 8)) throw new ImageKernelExecutionError(\"unsupported-on-backend\", \"The query lattice is too wide for the exact point recovery; use cpu-reference.\");\n // Distinct fractional parts of the offsets must be told apart on the device: more than four tolerances apart, or an exact integer apart (the same lattice).\n for (const axis of [cu, cv]) {\n for (let a = 0; a < axis.length; a++) for (let b = a + 1; b < axis.length; b++) {\n const delta = axis[a]! - axis[b]!, fractional = Math.abs(delta - Math.round(delta));\n if (fractional !== 0 && !(fractional > 4 * tolerance))\n throw new ImageKernelExecutionError(\"unsupported-on-backend\", \"Two query offsets are too close (mod one site) for the exact point recovery; use cpu-reference.\");\n }\n }\n const params = new ArrayBuffer(4 * DISPLAY_VIEW_LATTICE.words), floats = new Float32Array(params), words = new Uint32Array(params);\n const [suH, suL] = dwSplit(scaleU), [svH, svL] = dwSplit(scaleV);\n floats[DISPLAY_VIEW_LATTICE.scaleUHi] = suH; floats[DISPLAY_VIEW_LATTICE.scaleULo] = suL; floats[DISPLAY_VIEW_LATTICE.scaleVHi] = svH; floats[DISPLAY_VIEW_LATTICE.scaleVLo] = svL;\n if (placement) {\n const [kH, kL] = dwSplit(placement.chartUnitsPerFrameUnit);\n if (!(Number.isFinite(kH) && kH > 0 && Number.isFinite(placement.aspect) && placement.aspect > 0)) throw new ImageKernelExecutionError(\"unsupported-on-backend\", \"The chart placement is not finite.\");\n floats[DISPLAY_VIEW_LATTICE.chartKHi] = kH; floats[DISPLAY_VIEW_LATTICE.chartKLo] = kL; floats[DISPLAY_VIEW_LATTICE.chartAspect] = placement.aspect;\n }\n floats[DISPLAY_VIEW_LATTICE.tolerance] = tolerance;\n words[DISPLAY_VIEW_LATTICE.offsets] = offsets.length; words[DISPLAY_VIEW_LATTICE.placed] = placement ? 1 : 0; words[DISPLAY_VIEW_LATTICE.surround] = surroundMaterial;\n words[DISPLAY_VIEW_LATTICE.zero] = 0; // the rounding barrier's zero (`lattice.zero`)\n const table = new Float32Array(4 * offsets.length);\n for (let o = 0; o < offsets.length; o++) {\n const [uH, uL] = dwSplit(cu[o]!), [vH, vL] = dwSplit(cv[o]!);\n table[4 * o] = uH; table[4 * o + 1] = uL; table[4 * o + 2] = vH; table[4 * o + 3] = vL;\n }\n return { params, offsets: table, tolerance, scaleU, scaleV };\n}\n\n/** The resolved scene behind a GPU setup: the chart whose geometry is packed, the layers (or null) and the materials the kernel indexes. */\nfunction sceneOf(gpu: DisplayViewGpuSetup): { chart: ResolvedChartScene; layers: ResolvedChartMaterialLayers | null; materials: ResolvedChartScene[\"materials\"]; key: object } {\n if (gpu.layers) return { chart: gpu.layers.chart, layers: gpu.layers, materials: gpu.layers.materials, key: gpu.layers };\n if (gpu.chart) return { chart: gpu.chart, layers: null, materials: gpu.chart.materials, key: gpu.chart };\n throw new ImageKernelExecutionError(\"unsupported-on-backend\", \"The GPU material lookup covers chart presets, composite charts and declared material-layers scenes; a caller scene function runs on cpu-reference (describe it as material-layers).\");\n}\n\ninterface UploadedRecords { key: object; scope: GpuResourceScope; af: GPUBuffer; ai: GPUBuffer; packed: PackedChartScene }\n\n/**\n * The material modules of one display-view renderer (one device): the chart-preset module for the eight 2.0 presets filling\n * the frame, the composite module for everything else the chart kernels classify. The composite module's device probe runs\n * once per renderer (single flight; a refusal is retried on the next render), its scene records are uploaded once per scene\n * and the four most recent kept until `release()`.\n */\nexport interface DisplayViewMaterialModules {\n /** The module of a setup's scene, or an `unsupported-on-backend` error (a caller function scene, a failed probe, a materials mismatch). */\n moduleFor(gpu: DisplayViewGpuSetup, signal: AbortSignal): Promise<DisplayViewGpuMaterialModule>;\n /** Uploaded scenes (for tests). */\n readonly uploadedScenes: number;\n release(): void;\n}\n\nexport function createDisplayViewMaterialModules(runtime: WebGpuRuntime, pipelines: PipelineSource): DisplayViewMaterialModules {\n const presets = new WeakMap<ResolvedChartScene, DisplayViewGpuMaterialModule>(), uploads: UploadedRecords[] = [];\n let probed: Promise<ChartCompositeProbeRecord> | null = null;\n const wgsl = new Map<ChartCompositeProductPath, string>();\n const probe = (signal: AbortSignal): Promise<ChartCompositeProbeRecord> => {\n probed ??= probeChartCompositeDevice(runtime, pipelines, signal).catch((error: unknown) => { probed = null; throw error; });\n return probed;\n };\n const records = (scene: ReturnType<typeof sceneOf>): UploadedRecords => {\n const index = uploads.findIndex((e) => e.key === scene.key);\n if (index >= 0) { const [entry] = uploads.splice(index, 1); uploads.push(entry!); return entry!; }\n // packChartScene reads the plan's chart, layers and materials only.\n const packed = packChartScene({ chart: scene.chart, layers: scene.layers, materials: scene.materials } as unknown as ChartRadianceBatchPlan);\n if (Math.max(packed.af.byteLength, packed.ai.byteLength) > runtime.maximumStorageBindingBytes) throw new ImageKernelExecutionError(\"insufficient-limits\", \"Chart records exceed the device's storage binding limit.\");\n const scope = new GpuResourceScope(runtime);\n const entry: UploadedRecords = { key: scene.key, scope, af: scope.upload(\"photivra-display-view-chart-floats\", packed.af, BUFFER_USAGE.STORAGE), ai: scope.upload(\"photivra-display-view-chart-records\", packed.ai, BUFFER_USAGE.STORAGE), packed };\n uploads.push(entry);\n while (uploads.length > KEPT_SCENES) uploads.shift()!.scope.release();\n return entry;\n };\n return {\n async moduleFor(gpu, signal): Promise<DisplayViewGpuMaterialModule> {\n const scene = sceneOf(gpu), placement = gpu.placement ?? null, signalInput = gpu.signalInput;\n const tableMaterials = signalInput.scene.kind === \"materials\" ? signalInput.scene.materials.length : -1;\n if (tableMaterials !== scene.materials.length + (placement ? 1 : 0))\n throw new ImageKernelExecutionError(\"unsupported-on-backend\", \"The expected signal's materials do not match the scene's (\" + tableMaterials + \" against \" + scene.materials.length + (placement ? \" plus the surround\" : \"\") + \"); use cpu-reference.\");\n if (!scene.layers && !placement && chartGpuPresetCode({ chart: scene.chart } as unknown as ChartRadianceBatchPlan) !== undefined) {\n let module = presets.get(scene.chart);\n if (!module) { module = chartPresetMaterialModule(scene.chart); presets.set(scene.chart, module); }\n return module;\n }\n const record = await probe(signal), path = record.productPath ?? \"dekker\";\n const lattice = displayViewLatticeConstants(signalInput, placement, scene.materials.length), uploaded = records(scene);\n let code = wgsl.get(path);\n if (code === undefined) { code = chartCompositeMaterialWgsl(path); wgsl.set(path, code); }\n return { id: chartCompositeMaterialModuleId(path), wgsl: code, compositeProbe: record, bindings: [\n { binding: 0, kind: \"storage\", buffer: uploaded.af }, { binding: 1, kind: \"storage\", buffer: uploaded.ai },\n { binding: 2, kind: \"uniform\", data: new Uint8Array(lattice.params) }, { binding: 3, kind: \"storage\", data: lattice.offsets }] };\n },\n get uploadedScenes(): number { return uploads.length; },\n release(): void { for (const entry of uploads.splice(0)) entry.scope.release(); }\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"display-view-composite-material-module.js","sourceRoot":"","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E,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;KACrG,CAAC;AACJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * The composite-chart and mask-layer material module of the GPU display view (#491): the Speed kernel's `material_at`\n * (the seam of #478, `DisplayViewGpuMaterialModule`) built from the composite chart kernel's classification (#477,\n * `wgsl-chart-composite-kernel.ts`: `material()`, its bound arithmetic and double-float32), so that composite charts,\n * every 2.3 element as a plain chart, the sine-profile Siemens star and declared `material-layers` scenes render on the\n * GPU. The scene's packed records (`packChartScene`) are uploaded once per renderer and reused across a view's parts,\n * as the composite kernel reuses them per accelerator; the device probe of the composite kernel gates the module.\n *\n * **The query point.** The Speed kernel hands the module p = fl(fl(x + c)·scale) per axis: the site coordinate x plus the\n * offset constant c = 0.5 + o − W/2 (`DISPLAY_VIEW_AUX.offsets`), times the frame-units-per-site scale rounded once to\n * float32, so p carries up to 2E relative error (E = 2⁻²³) against the reference's float64 query point. The composite\n * kernel's chirp decisions (the zone plate's phase, the stars' sector cross products) need the point to about 2⁻⁴⁰; fed\n * p directly they would flag most of a 64-cycle sine star. The module therefore **recovers the exact lattice point**: it\n * knows the offsets c_o (uploaded as float32 hi + lo pairs) and the scale (hi + lo), divides p by the scale's high part\n * (within 6E·|s| of s = x + c_o), picks the offset whose c_o puts the quotient nearest an integer x, and re-forms the point\n * in double-float32 as (x + c_o)·scale from the exact integer and the float64 constants. The host admits a lattice only\n * when the recovery is unambiguous: the distinct fractional parts of the offsets (mod 1) lie more than four tolerances\n * apart, the tolerance being 8E·max|s| + 2⁻¹²; a point whose residual exceeds the tolerance on the device is flagged.\n * The recovered point differs from the exact (x + c_o)·g by at most about 2⁻⁴⁶ relative (two double-float32 operations\n * and the split constants' 2⁻⁴⁸), inside the composite kernel's own allowance for a point (DW = 2⁻⁴⁰ relative in `bd`).\n * The reference's own float64 query point differs from the exact lattice value by its float64 rounding only: measured at\n * most 5.6·10⁻¹⁶ absolute over every site and offset of the #491 fixtures, and checked by the host at the frame's four\n * corners within 2⁻⁴⁸·(|p| + 1); that is inside the composite kernel's 10⁻¹⁴ slack for the reference's rounding. So the\n * composite kernel's bounds and SAFETY factor (4) apply unchanged, and the module's point error is far inside the Speed\n * kernel's contract (≤ 2E + 10⁻¹⁴): no Speed bound term changes.\n *\n * **A fixed-size chart** (`chartSize`): the reference maps the frame point to chart-local units, cu = (u·m)/h with m the\n * metres per frame unit and h the chart's half width, and returns the surround material outside |cu| ≤ 1, |cv| ≤ aspect.\n * The module multiplies the recovered point by k = m/h (hi + lo) in double-float32 and tests the chart rectangle in bound\n * arithmetic (flagging points within their bound of its edge); the surround is the materials table's last entry.\n */\nimport { ImageKernelExecutionError, WEBGPU_F32_UNIT_ROUNDOFF } from \"./image-kernel-execution.js\";\nimport { chartCompositeWgsl, type ChartCompositeProductPath } from \"./wgsl-chart-composite-kernel.js\";\nimport { chartGpuPresetCode } from \"./chart-radiance-gpu.js\";\nimport { dwSplit, packChartScene, probeChartCompositeDevice, type PackedChartScene } from \"./chart-composite-gpu.js\";\nimport type { ChartCompositeProbeRecord } from \"./image-kernel-execution.js\";\nimport { chartPresetMaterialModule } from \"./display-view-chart-material-module.js\";\nimport type { ChartRadianceBatchPlan } from \"../facade/chart-radiance-batch.js\";\nimport type { ResolvedChartScene } from \"../facade/chart-scenes.js\";\nimport type { ResolvedChartMaterialLayers } from \"../facade/chart-material-layers.js\";\nimport type { DisplayViewExpectedSignalInput } from \"../facade/expected-signal.js\";\nimport type { DisplayViewGpuSetup } from \"../facade/display-view.js\";\nimport { BUFFER_USAGE, GpuResourceScope, type WebGpuRuntime } from \"./webgpu-runtime.js\";\nimport { DISPLAY_VIEW_GPU_MAXIMUM_OFFSETS } from \"./wgsl-display-view-speed-kernel.js\";\nimport type { DisplayViewGpuMaterialModule } from \"./display-view-speed-gpu.js\";\nimport { imagePlaneSupport } from \"../facade/image-plane-support.js\";\nimport type { DisplayViewImageModules } from \"./display-view-image-material-module.js\";\nimport type { DisplayViewQualityImagePasses } from \"./display-view-quality-gpu.js\";\n\ntype PipelineSource = (label: string, code: string) => Promise<GPUComputePipeline>;\n\n/** One WGSL rounding of + − × in either direction (E = 2⁻²³). */\nconst E = 2 * WEBGPU_F32_UNIT_ROUNDOFF;\n/** The module's id in the pipeline cache (one shader per product path for every composite scene; the scene is data): the Dekker path's. */\nexport const CHART_COMPOSITE_MATERIAL_MODULE_ID = \"chart-composite\";\n/** The module's id per product path (the fma path's shader is a different pipeline). */\nexport function chartCompositeMaterialModuleId(path: ChartCompositeProductPath): string { return path === \"dekker\" ? CHART_COMPOSITE_MATERIAL_MODULE_ID : CHART_COMPOSITE_MATERIAL_MODULE_ID + \"-fma\"; }\n/** Scenes whose records stay uploaded per renderer (the composite kernel keeps the same number per accelerator). */\nconst KEPT_SCENES = 4;\n/** The corner check of the query-point model against the reference's own query points, relative to |p| + 1 (inside the composite kernel's 10⁻¹⁴ slack). */\nconst MODEL_TOLERANCE = 2 ** -48;\n\n/** Layout of the lattice uniform (float32 / u32 words, 48 bytes) and the offsets table (one vec4 per offset: cu hi, cu lo, cv hi, cv lo). */\nexport const DISPLAY_VIEW_LATTICE = /* @__PURE__ */ Object.freeze({ scaleUHi: 0, scaleULo: 1, scaleVHi: 2, scaleVLo: 3, chartKHi: 4, chartKLo: 5, chartAspect: 6, tolerance: 7, offsets: 8, placed: 9, surround: 10, zero: 11, words: 12 });\n\n/**\n * The composite kernel's classification (`material(p: vec4<f32>)` with its bound arithmetic, double-float32, cos polynomial,\n * elements and layers) renamed for the display-view kernel, its records bound at @group(1), and the lattice recovery that\n * defines `material_at(p: vec2<f32>)` (see the module comment). The constants E and SLACK come from the kernel's preamble. `path`\n * is the double-word product path the device's probe chose (default Dekker's).\n */\n/** The composite kernel's text renamed for a display-view module: its flag is `material_uncertain`, its barrier word `lattice.zero`. */\nfunction renameForDisplayView(code: string): string {\n return code.replace(/^const SLACK: f32 = [^\\n]*\\n/mu, \"\").replace(/\\bflagged\\b/gu, \"material_uncertain\").replace(/\\bmargin\\(/gu, \"bmargin(\").replace(/\\bparams\\.zero\\b/gu, \"lattice.zero\");\n}\n/**\n * #581: the composite kernel's common part (double-float32 with its rounding barrier, the bound arithmetic, `bfloor`) renamed for a\n * display-view module (shared by the composite and the image-plane modules); the kernel's preamble gives E and SLACK.\n */\nexport function displayViewModuleCommonWgsl(path: ChartCompositeProductPath): string {\n const source = chartCompositeWgsl(path);\n const commonStart = source.indexOf(\"const DW: f32\"), commonEnd = source.indexOf(\"struct Params\");\n if (commonStart < 0 || commonEnd < commonStart) throw new ImageKernelExecutionError(\"gpu-validation\", \"The composite chart kernel's material functions were not found.\");\n return renameForDisplayView(source.slice(commonStart, commonEnd));\n}\n/** The lattice uniform and the offsets table of a display-view module (@group(1) bindings 2 and 3; `DISPLAY_VIEW_LATTICE`). */\nexport const LATTICE_BINDINGS_WGSL = `struct LatticeParams {\n scale_u_hi: f32, scale_u_lo: f32, scale_v_hi: f32, scale_v_lo: f32,\n chart_k_hi: f32, chart_k_lo: f32, chart_aspect: f32, tolerance: f32,\n offsets: u32, placed: u32, surround: u32, zero: u32,\n};\n@group(1) @binding(2) var<uniform> lattice: LatticeParams;\n@group(1) @binding(3) var<storage, read> lattice_offsets: array<vec4<f32>>;`;\n/** The exact lattice point recovery (see the module comment), shared by the composite and the image-plane modules. */\nexport const LATTICE_POINT_WGSL = `// The exact lattice point of one axis from the kernel's p = fl(fl(x + c)·scale): the offset whose constant c puts p/scale\n// nearest an integer x, then (x + c)·scale in double-float32 from the exact integer and the float64 constants (hi + lo).\nfn lattice_point(p: f32, scale: D, axis: u32) -> D {\n let rough = p / scale.h;\n var best = 3.0e38; var site = 0.0; var c_hi = 0.0; var c_lo = 0.0;\n for (var o = 0u; o < lattice.offsets; o = o + 1u) {\n let row = lattice_offsets[o];\n let hi = select(row.z, row.x, axis == 0u);\n let lo = select(row.w, row.y, axis == 0u);\n let d = rough - hi;\n let n = round(d);\n let r = abs(d - n);\n if (r < best) { best = r; site = n; c_hi = hi; c_lo = lo; }\n }\n if (!(best <= lattice.tolerance)) { material_uncertain = true; }\n return d_mul(d_add(D(site, 0.0), D(c_hi, c_lo)), scale);\n}`;\nexport function chartCompositeMaterialWgsl(path: ChartCompositeProductPath = \"dekker\"): string {\n const source = chartCompositeWgsl(path), bodyStart = source.indexOf(\"const SEGMENT_BOX\"), bodyEnd = source.indexOf(\"@compute\");\n if (bodyStart < 0 || bodyEnd < bodyStart) throw new ImageKernelExecutionError(\"gpu-validation\", \"The composite chart kernel's material functions were not found.\");\n return `${displayViewModuleCommonWgsl(path)}\n@group(1) @binding(0) var<storage, read> af: array<f32>;\n@group(1) @binding(1) var<storage, read> ai: array<u32>;\n${LATTICE_BINDINGS_WGSL}\n${renameForDisplayView(source.slice(bodyStart, bodyEnd))}\n${LATTICE_POINT_WGSL}\nfn material_at(p: vec2<f32>) -> u32 {\n var u = lattice_point(p.x, D(lattice.scale_u_hi, lattice.scale_u_lo), 0u);\n var v = lattice_point(p.y, D(lattice.scale_v_hi, lattice.scale_v_lo), 1u);\n if (lattice.placed != 0u) {\n let k = D(lattice.chart_k_hi, lattice.chart_k_lo);\n u = d_mul(u, k); v = d_mul(v, k);\n if (!(le(babs(bd(u)), bx(1.0)) && le(babs(bd(v)), bc(lattice.chart_aspect)))) { return lattice.surround; }\n }\n return material(vec4<f32>(u.h, u.l, v.h, v.l));\n}\n`;\n}\n\n/** A fixed-size chart's placement for the module: chart-local frame units per frame unit (m/h) and the chart's aspect. */\nexport interface DisplayViewChartPlacement { chartUnitsPerFrameUnit: number; aspect: number }\n\n/** The lattice constants of a render (see the module comment): the uniform words and the offsets table. */\nexport interface DisplayViewLatticeConstants { params: ArrayBuffer; offsets: Float32Array<ArrayBuffer>; tolerance: number; scaleU: number; scaleV: number }\n\n/**\n * The query lattice of an expected-signal input as the module needs it, or an `unsupported-on-backend` error: the scale per\n * axis from the reference's own query points (two sites a frame apart), the model (x + c)·scale checked against the reference\n * at the frame's four corners for every offset within 2⁻⁴⁸·(|p| + 1), the offsets as hi + lo pairs, and the recovery tolerance\n * 8E·max|x + c| + 2⁻¹², which the distinct fractional parts of the offsets must clear four times over.\n */\nexport function displayViewLatticeConstants(signalInput: DisplayViewExpectedSignalInput, placement: DisplayViewChartPlacement | null, surroundMaterial: number): DisplayViewLatticeConstants {\n const W = signalInput.nativeWidth, H = signalInput.nativeHeight, offsets = signalInput.offsets, query = signalInput.queryPoint;\n if (!query) throw new ImageKernelExecutionError(\"unsupported-on-backend\", \"The expected signal has no query points (the Quality path); use cpu-reference.\");\n if (offsets.length < 1 || offsets.length > DISPLAY_VIEW_GPU_MAXIMUM_OFFSETS) throw new ImageKernelExecutionError(\"unsupported-on-backend\", \"The kernel holds 1 to \" + DISPLAY_VIEW_GPU_MAXIMUM_OFFSETS + \" query offsets.\");\n if (!(W >= 2 && H >= 2 && W <= 2 ** 20 && H <= 2 ** 20)) throw new ImageKernelExecutionError(\"unsupported-on-backend\", \"The native frame is outside the lattice recovery's range (2 to 2^20 sites per axis).\");\n const point = new Float64Array(2), x1 = W - 1, y1 = H - 1;\n query(0, 0, 0, point); const u0 = point[0]!, v0 = point[1]!;\n query(x1, 0, 0, point); const u1 = point[0]!;\n query(0, y1, 0, point); const v1 = point[1]!;\n const scaleU = (u1 - u0) / x1, scaleV = (v1 - v0) / y1;\n if (!(Number.isFinite(scaleU) && Number.isFinite(scaleV) && scaleU !== 0 && scaleV !== 0)) throw new ImageKernelExecutionError(\"unsupported-on-backend\", \"The request's query lattice has no scale; use cpu-reference.\");\n const cu = new Float64Array(offsets.length), cv = new Float64Array(offsets.length);\n let smax = 0;\n for (let o = 0; o < offsets.length; o++) {\n const offset = offsets[o]!;\n cu[o] = 0.5 + offset.x - W / 2; cv[o] = 0.5 + offset.y - H / 2;\n smax = Math.max(smax, Math.abs(cu[o]!), Math.abs(x1 + cu[o]!), Math.abs(cv[o]!), Math.abs(y1 + cv[o]!));\n for (const [x, y] of [[0, 0], [x1, 0], [0, y1], [x1, y1]] as const) {\n query(x, y, o, point);\n const mu = (x + cu[o]!) * scaleU, mv = (y + cv[o]!) * scaleV;\n if (!(Math.abs(mu - point[0]!) <= MODEL_TOLERANCE * (Math.abs(point[0]!) + 1) && Math.abs(mv - point[1]!) <= MODEL_TOLERANCE * (Math.abs(point[1]!) + 1)))\n throw new ImageKernelExecutionError(\"unsupported-on-backend\", \"The request's query points are not a rectilinear site lattice within 2^-48; use cpu-reference.\");\n }\n }\n const tolerance = Math.fround(8 * E * smax + 2 ** -12);\n if (!(tolerance < 1 / 8)) throw new ImageKernelExecutionError(\"unsupported-on-backend\", \"The query lattice is too wide for the exact point recovery; use cpu-reference.\");\n // Distinct fractional parts of the offsets must be told apart on the device: more than four tolerances apart, or an exact integer apart (the same lattice).\n for (const axis of [cu, cv]) {\n for (let a = 0; a < axis.length; a++) for (let b = a + 1; b < axis.length; b++) {\n const delta = axis[a]! - axis[b]!, fractional = Math.abs(delta - Math.round(delta));\n if (fractional !== 0 && !(fractional > 4 * tolerance))\n throw new ImageKernelExecutionError(\"unsupported-on-backend\", \"Two query offsets are too close (mod one site) for the exact point recovery; use cpu-reference.\");\n }\n }\n const params = new ArrayBuffer(4 * DISPLAY_VIEW_LATTICE.words), floats = new Float32Array(params), words = new Uint32Array(params);\n const [suH, suL] = dwSplit(scaleU), [svH, svL] = dwSplit(scaleV);\n floats[DISPLAY_VIEW_LATTICE.scaleUHi] = suH; floats[DISPLAY_VIEW_LATTICE.scaleULo] = suL; floats[DISPLAY_VIEW_LATTICE.scaleVHi] = svH; floats[DISPLAY_VIEW_LATTICE.scaleVLo] = svL;\n if (placement) {\n const [kH, kL] = dwSplit(placement.chartUnitsPerFrameUnit);\n if (!(Number.isFinite(kH) && kH > 0 && Number.isFinite(placement.aspect) && placement.aspect > 0)) throw new ImageKernelExecutionError(\"unsupported-on-backend\", \"The chart placement is not finite.\");\n floats[DISPLAY_VIEW_LATTICE.chartKHi] = kH; floats[DISPLAY_VIEW_LATTICE.chartKLo] = kL; floats[DISPLAY_VIEW_LATTICE.chartAspect] = placement.aspect;\n }\n floats[DISPLAY_VIEW_LATTICE.tolerance] = tolerance;\n words[DISPLAY_VIEW_LATTICE.offsets] = offsets.length; words[DISPLAY_VIEW_LATTICE.placed] = placement ? 1 : 0; words[DISPLAY_VIEW_LATTICE.surround] = surroundMaterial;\n words[DISPLAY_VIEW_LATTICE.zero] = 0; // the rounding barrier's zero (`lattice.zero`)\n const table = new Float32Array(4 * offsets.length);\n for (let o = 0; o < offsets.length; o++) {\n const [uH, uL] = dwSplit(cu[o]!), [vH, vL] = dwSplit(cv[o]!);\n table[4 * o] = uH; table[4 * o + 1] = uL; table[4 * o + 2] = vH; table[4 * o + 3] = vL;\n }\n return { params, offsets: table, tolerance, scaleU, scaleV };\n}\n\n/** The resolved scene behind a GPU setup: the chart whose geometry is packed, the layers (or null) and the materials the kernel indexes. */\nfunction sceneOf(gpu: DisplayViewGpuSetup): { chart: ResolvedChartScene; layers: ResolvedChartMaterialLayers | null; materials: ResolvedChartScene[\"materials\"]; key: object } {\n if (gpu.layers) return { chart: gpu.layers.chart, layers: gpu.layers, materials: gpu.layers.materials, key: gpu.layers };\n if (gpu.chart) return { chart: gpu.chart, layers: null, materials: gpu.chart.materials, key: gpu.chart };\n throw new ImageKernelExecutionError(\"unsupported-on-backend\", \"The GPU material lookup covers chart presets, composite charts and declared material-layers scenes; a caller scene function runs on cpu-reference (describe it as material-layers).\");\n}\n\ninterface UploadedRecords { key: object; scope: GpuResourceScope; af: GPUBuffer; ai: GPUBuffer; packed: PackedChartScene }\n\n/**\n * The material modules of one display-view renderer (one device): the chart-preset module for the eight 2.0 presets filling\n * the frame, the composite module for everything else the chart kernels classify. The composite module's device probe runs\n * once per renderer (single flight; a refusal is retried on the next render), its scene records are uploaded once per scene\n * and the four most recent kept until `release()`.\n */\nexport interface DisplayViewMaterialModules {\n /** The module of a setup's scene, or an `unsupported-on-backend` error (a caller function scene, a failed probe, a materials mismatch). */\n moduleFor(gpu: DisplayViewGpuSetup, signal: AbortSignal): Promise<DisplayViewGpuMaterialModule>;\n /** #581: an image-plane print's Quality passes (after `prepareImagePlaneScenes()`), or an `unsupported-on-backend` error. */\n imagePasses(gpu: DisplayViewGpuSetup, signal: AbortSignal): Promise<DisplayViewQualityImagePasses>;\n /** Uploaded scenes (for tests). */\n readonly uploadedScenes: number;\n release(): void;\n}\n\nexport function createDisplayViewMaterialModules(runtime: WebGpuRuntime, pipelines: PipelineSource): DisplayViewMaterialModules {\n const presets = new WeakMap<ResolvedChartScene, DisplayViewGpuMaterialModule>(), uploads: UploadedRecords[] = [];\n // #581: image-plane prints (their double-float32 arithmetic is the composite kernel's, so the same probe gates them), through the\n // module prepareImagePlaneScenes() loaded; created on the first photo.\n let images: DisplayViewImageModules | undefined;\n // A photo reaches the GPU only after the request was resolved, so the module is enabled.\n const imageModules = async (): Promise<DisplayViewImageModules> => images ??= (await imagePlaneSupport()!.loadGpuModule()).createDisplayViewImageModules(runtime, probe) as DisplayViewImageModules;\n let probed: Promise<ChartCompositeProbeRecord> | null = null;\n const wgsl = new Map<ChartCompositeProductPath, string>();\n const probe = (signal: AbortSignal): Promise<ChartCompositeProbeRecord> => {\n probed ??= probeChartCompositeDevice(runtime, pipelines, signal).catch((error: unknown) => { probed = null; throw error; });\n return probed;\n };\n const records = (scene: ReturnType<typeof sceneOf>): UploadedRecords => {\n const index = uploads.findIndex((e) => e.key === scene.key);\n if (index >= 0) { const [entry] = uploads.splice(index, 1); uploads.push(entry!); return entry!; }\n // packChartScene reads the plan's chart, layers and materials only.\n const packed = packChartScene({ chart: scene.chart, layers: scene.layers, materials: scene.materials } as unknown as ChartRadianceBatchPlan);\n if (Math.max(packed.af.byteLength, packed.ai.byteLength) > runtime.maximumStorageBindingBytes) throw new ImageKernelExecutionError(\"insufficient-limits\", \"Chart records exceed the device's storage binding limit.\");\n const scope = new GpuResourceScope(runtime);\n const entry: UploadedRecords = { key: scene.key, scope, af: scope.upload(\"photivra-display-view-chart-floats\", packed.af, BUFFER_USAGE.STORAGE), ai: scope.upload(\"photivra-display-view-chart-records\", packed.ai, BUFFER_USAGE.STORAGE), packed };\n uploads.push(entry);\n while (uploads.length > KEPT_SCENES) uploads.shift()!.scope.release();\n return entry;\n };\n return {\n async moduleFor(gpu, signal): Promise<DisplayViewGpuMaterialModule> {\n if ((gpu.signalInput.scene as { image?: unknown }).image) return await (await imageModules()).moduleFor(gpu, signal);\n const scene = sceneOf(gpu), placement = gpu.placement ?? null, signalInput = gpu.signalInput;\n const tableMaterials = signalInput.scene.kind === \"materials\" ? signalInput.scene.materials.length : -1;\n if (tableMaterials !== scene.materials.length + (placement ? 1 : 0))\n throw new ImageKernelExecutionError(\"unsupported-on-backend\", \"The expected signal's materials do not match the scene's (\" + tableMaterials + \" against \" + scene.materials.length + (placement ? \" plus the surround\" : \"\") + \"); use cpu-reference.\");\n if (!scene.layers && !placement && chartGpuPresetCode({ chart: scene.chart } as unknown as ChartRadianceBatchPlan) !== undefined) {\n let module = presets.get(scene.chart);\n if (!module) { module = chartPresetMaterialModule(scene.chart); presets.set(scene.chart, module); }\n return module;\n }\n const record = await probe(signal), path = record.productPath ?? \"dekker\";\n const lattice = displayViewLatticeConstants(signalInput, placement, scene.materials.length), uploaded = records(scene);\n let code = wgsl.get(path);\n if (code === undefined) { code = chartCompositeMaterialWgsl(path); wgsl.set(path, code); }\n return { id: chartCompositeMaterialModuleId(path), wgsl: code, compositeProbe: record, bindings: [\n { binding: 0, kind: \"storage\", buffer: uploaded.af }, { binding: 1, kind: \"storage\", buffer: uploaded.ai },\n { binding: 2, kind: \"uniform\", data: new Uint8Array(lattice.params) }, { binding: 3, kind: \"storage\", data: lattice.offsets }] };\n },\n async imagePasses(gpu, signal): Promise<DisplayViewQualityImagePasses> { return await (await imageModules()).qualityPasses(gpu, signal); },\n get uploadedScenes(): number { return uploads.length; },\n release(): void { for (const entry of uploads.splice(0)) entry.scope.release(); images?.release(); }\n };\n}\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type DisplayViewGpuRenderer, type DisplayViewGpuRendererFactory, type DisplayViewGpuRequest } from "../facade/display-view-gpu.js";
|
|
2
|
+
import { type WebGpuRuntime } from "./webgpu-runtime.js";
|
|
3
|
+
type YieldControl = ((signal: AbortSignal) => Promise<void>) | undefined;
|
|
4
|
+
type QualityKit = typeof import("./display-view-quality-gpu.js");
|
|
5
|
+
/**
|
|
6
|
+
* #594: loads the Quality host once (a dynamic import, its own chunk in a bundler that splits) and returns it; concurrent calls
|
|
7
|
+
* share one load. A failed load rejects with `ImageKernelExecutionError` reason `quality-code-unavailable` and is not
|
|
8
|
+
* remembered, so the next call (a later Quality render, or `prepareQualityPaths()`) tries again.
|
|
9
|
+
*/
|
|
10
|
+
export declare function prepareDisplayViewQualityGpu(): Promise<QualityKit>;
|
|
11
|
+
/**
|
|
12
|
+
* Internal, for tests: replaces how the Quality host is loaded (null restores the dynamic import) and forgets a loaded one,
|
|
13
|
+
* so a test can make the load fail and then succeed. Returns nothing; the engine never calls it.
|
|
14
|
+
*/
|
|
15
|
+
export declare function setDisplayViewQualityGpuLoader(loader: (() => Promise<QualityKit>) | null): void;
|
|
16
|
+
/**
|
|
17
|
+
* Why the Quality renderer does not support a prepared request (`DisplayViewGpuRenderer.supports`), or true: engine charts and
|
|
18
|
+
* declared `material-layers` scenes (the material modules of `createDisplayViewMaterialModules`, #491), the identity or Reinhard
|
|
19
|
+
* tone curve and at most 64 query offsets (lattice groups). `lens.defocus` out of focus is supported (#492 step 2c: the site pass
|
|
20
|
+
* gathers the disc, or each node's diffraction kernel convolved with it, up to the reference's own caps of radius 64 and 96);
|
|
21
|
+
* whether a view's footprints take the exact area mean, whether the device passes the composite probe, and whether the kernel
|
|
22
|
+
* table fits the device's storage binding limit, is known only per render.
|
|
23
|
+
*/
|
|
24
|
+
export declare function displayViewQualityGpuSupports(request: DisplayViewGpuRequest): true | string;
|
|
25
|
+
/**
|
|
26
|
+
* The display view's GPU renderer on one runtime (#481's `DisplayViewGpuRenderer`): the Speed kernel for requests it covers
|
|
27
|
+
* (no diffraction, no AHD, no defocus disc, at most 16 offsets) and the Quality kernels for the rest (#492: a defocused Speed
|
|
28
|
+
* request too, with its bilinear demosaic). One pipeline cache per device, one set of
|
|
29
|
+
* material modules (#491: chart presets, composite charts, the 2.3 elements and material-layers scenes; `dispose` releases their
|
|
30
|
+
* uploaded scene records). `render` renders the part's region (`setup.gpu`
|
|
31
|
+
* carries the expected signal's input and the chart; a setup without it, a coarse view or a frame the kernels do not cover
|
|
32
|
+
* throws `unsupported-on-backend`), and throws `aborted` and `device-lost` as the accelerator's operations do. The Quality host
|
|
33
|
+
* is loaded on demand (#594, `prepareDisplayViewQualityGpu`).
|
|
34
|
+
*/
|
|
35
|
+
export declare function createDisplayViewGpuRenderer(runtime: WebGpuRuntime, options?: {
|
|
36
|
+
maximumBandBytes?: number;
|
|
37
|
+
yieldControl?: YieldControl;
|
|
38
|
+
}): DisplayViewGpuRenderer;
|
|
39
|
+
/** The factory `prepareDisplayView` creates the renderer with (one per device): the Speed and Quality kernels behind one renderer. */
|
|
40
|
+
export declare const displayViewGpuRendererFactory: DisplayViewGpuRendererFactory;
|
|
41
|
+
/** Registers the combined renderer as the display view's GPU renderer and returns the factory registered before. */
|
|
42
|
+
export declare function registerDisplayViewGpuRenderer(): DisplayViewGpuRendererFactory | null;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { createDisplayViewMaterialModules } from "./display-view-composite-material-module.js";
|
|
3
|
+
import { setDisplayViewGpuRendererFactory } from "../facade/display-view-gpu.js";
|
|
4
|
+
import { DISPLAY_VIEW_SPEED_CONFORMANCE_CASE, LARGE_DEFOCUS_REASON, sceneToneAndOffsetsReason, displayViewSpeedGpuSupports, displayViewSpeedGpuUnsupportedReason, renderDisplayViewSpeedOnGpu } from "./display-view-speed-gpu.js";
|
|
5
|
+
import { ImageKernelExecutionError } from "./image-kernel-execution.js";
|
|
6
|
+
import { abortedError, createComputePipeline } from "./webgpu-runtime.js";
|
|
7
|
+
/** Largest lattice group count the Quality tables hold (`display-view-quality-gpu.ts`). */
|
|
8
|
+
const QUALITY_MAXIMUM_GROUPS = 64;
|
|
9
|
+
const importQualityKit = () => import("./display-view-quality-gpu.js");
|
|
10
|
+
let loadQualityKit = importQualityKit;
|
|
11
|
+
let qualityKit = null;
|
|
12
|
+
/**
|
|
13
|
+
* #594: loads the Quality host once (a dynamic import, its own chunk in a bundler that splits) and returns it; concurrent calls
|
|
14
|
+
* share one load. A failed load rejects with `ImageKernelExecutionError` reason `quality-code-unavailable` and is not
|
|
15
|
+
* remembered, so the next call (a later Quality render, or `prepareQualityPaths()`) tries again.
|
|
16
|
+
*/
|
|
17
|
+
export function prepareDisplayViewQualityGpu() {
|
|
18
|
+
if (!qualityKit) {
|
|
19
|
+
const pending = Promise.resolve().then(loadQualityKit).catch((error) => {
|
|
20
|
+
if (qualityKit === pending)
|
|
21
|
+
qualityKit = null;
|
|
22
|
+
throw new ImageKernelExecutionError("quality-code-unavailable", "GPU full-quality code did not load: " + String(error));
|
|
23
|
+
});
|
|
24
|
+
qualityKit = pending;
|
|
25
|
+
}
|
|
26
|
+
return qualityKit;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Internal, for tests: replaces how the Quality host is loaded (null restores the dynamic import) and forgets a loaded one,
|
|
30
|
+
* so a test can make the load fail and then succeed. Returns nothing; the engine never calls it.
|
|
31
|
+
*/
|
|
32
|
+
export function setDisplayViewQualityGpuLoader(loader) {
|
|
33
|
+
loadQualityKit = loader ?? importQualityKit;
|
|
34
|
+
qualityKit = null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Why the Quality renderer does not support a prepared request (`DisplayViewGpuRenderer.supports`), or true: engine charts and
|
|
38
|
+
* declared `material-layers` scenes (the material modules of `createDisplayViewMaterialModules`, #491), the identity or Reinhard
|
|
39
|
+
* tone curve and at most 64 query offsets (lattice groups). `lens.defocus` out of focus is supported (#492 step 2c: the site pass
|
|
40
|
+
* gathers the disc, or each node's diffraction kernel convolved with it, up to the reference's own caps of radius 64 and 96);
|
|
41
|
+
* whether a view's footprints take the exact area mean, whether the device passes the composite probe, and whether the kernel
|
|
42
|
+
* table fits the device's storage binding limit, is known only per render.
|
|
43
|
+
*/
|
|
44
|
+
export function displayViewQualityGpuSupports(request) {
|
|
45
|
+
return sceneToneAndOffsetsReason(request, QUALITY_MAXIMUM_GROUPS);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The display view's GPU renderer on one runtime (#481's `DisplayViewGpuRenderer`): the Speed kernel for requests it covers
|
|
49
|
+
* (no diffraction, no AHD, no defocus disc, at most 16 offsets) and the Quality kernels for the rest (#492: a defocused Speed
|
|
50
|
+
* request too, with its bilinear demosaic). One pipeline cache per device, one set of
|
|
51
|
+
* material modules (#491: chart presets, composite charts, the 2.3 elements and material-layers scenes; `dispose` releases their
|
|
52
|
+
* uploaded scene records). `render` renders the part's region (`setup.gpu`
|
|
53
|
+
* carries the expected signal's input and the chart; a setup without it, a coarse view or a frame the kernels do not cover
|
|
54
|
+
* throws `unsupported-on-backend`), and throws `aborted` and `device-lost` as the accelerator's operations do. The Quality host
|
|
55
|
+
* is loaded on demand (#594, `prepareDisplayViewQualityGpu`).
|
|
56
|
+
*/
|
|
57
|
+
export function createDisplayViewGpuRenderer(runtime, options = {}) {
|
|
58
|
+
const pipelines = new Map();
|
|
59
|
+
const bandBytes = options.maximumBandBytes ?? Math.min(64 * 1024 * 1024, runtime.maximumStorageBindingBytes);
|
|
60
|
+
const source = (label, code) => {
|
|
61
|
+
let pending = pipelines.get(label);
|
|
62
|
+
if (!pending) {
|
|
63
|
+
pending = createComputePipeline(runtime, label, code, undefined);
|
|
64
|
+
pipelines.set(label, pending);
|
|
65
|
+
pending.catch(() => pipelines.delete(label));
|
|
66
|
+
}
|
|
67
|
+
return pending;
|
|
68
|
+
};
|
|
69
|
+
// #491: one set of material modules per device for both kernels (the preset module per chart; the composite module, its probe
|
|
70
|
+
// and its uploaded scene records), released by `dispose`.
|
|
71
|
+
const modules = createDisplayViewMaterialModules(runtime, source);
|
|
72
|
+
return {
|
|
73
|
+
id: "photivra-display-view",
|
|
74
|
+
supports(request) {
|
|
75
|
+
if (request.largeDefocus)
|
|
76
|
+
return LARGE_DEFOCUS_REASON;
|
|
77
|
+
// #492: out of focus the expected signal carries the defocus disc as site kernels, which only the Quality site pass gathers;
|
|
78
|
+
// a Speed request then runs the Quality passes with its own bilinear demosaic (one candidate) and finishing.
|
|
79
|
+
if (request.defocus)
|
|
80
|
+
return displayViewQualityGpuSupports(request);
|
|
81
|
+
const speed = displayViewSpeedGpuSupports(request);
|
|
82
|
+
if (speed === true)
|
|
83
|
+
return true;
|
|
84
|
+
return displayViewQualityGpuSupports(request);
|
|
85
|
+
},
|
|
86
|
+
// #594 (owner, 2026-11-10): the Speed case runs before the device's first render; the Quality cases run before the first
|
|
87
|
+
// render that takes the Quality passes, after their code has loaded.
|
|
88
|
+
conformanceCases: [DISPLAY_VIEW_SPEED_CONFORMANCE_CASE],
|
|
89
|
+
onDemandConformanceCases(setup) {
|
|
90
|
+
// The routing of `render` below: a setup the Speed kernel does not cover takes the Quality passes.
|
|
91
|
+
return setup.gpu && displayViewSpeedGpuUnsupportedReason(setup, setup.gpu.signalInput) !== null ? prepareDisplayViewQualityGpu().then((kit) => kit.DISPLAY_VIEW_QUALITY_CONFORMANCE_CASES) : null;
|
|
92
|
+
},
|
|
93
|
+
async render(part) {
|
|
94
|
+
const { setup, signal } = part;
|
|
95
|
+
if (!setup.gpu)
|
|
96
|
+
throw new ImageKernelExecutionError("unsupported-on-backend", "The display-view setup carries no GPU inputs (setup.gpu); use cpu-reference.");
|
|
97
|
+
const abort = new AbortController(), onAbort = () => abort.abort();
|
|
98
|
+
if (signal?.aborted)
|
|
99
|
+
throw abortedError();
|
|
100
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
101
|
+
try {
|
|
102
|
+
const signalInput = setup.gpu.signalInput;
|
|
103
|
+
let result;
|
|
104
|
+
let material;
|
|
105
|
+
if (displayViewSpeedGpuUnsupportedReason(setup, signalInput) === null) {
|
|
106
|
+
material = await modules.moduleFor(setup.gpu, abort.signal);
|
|
107
|
+
result = await renderDisplayViewSpeedOnGpu(runtime, bandBytes, { setup, signalInput, material }, abort, options.yieldControl, source);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
const kit = await prepareDisplayViewQualityGpu();
|
|
111
|
+
// #581: an image-plane print brings its own passes 1 and 2.
|
|
112
|
+
const image = signalInput.scene.image ? await modules.imagePasses(setup.gpu, abort.signal) : undefined;
|
|
113
|
+
material = image ? { id: "image-plane", wgsl: "", bindings: [] } : await kit.qualityMaterialModule(modules, setup.gpu, abort.signal);
|
|
114
|
+
result = await kit.renderDisplayViewQualityOnGpu(runtime, bandBytes, { setup, signalInput, material, ...(image ? { image } : {}) }, abort, options.yieldControl, source);
|
|
115
|
+
}
|
|
116
|
+
return { samples: result.samples, expected: result.expected, noiseStd: result.noiseStd, sampleCount: result.sampleCount, siteCount: result.siteCount, detailPixelCount: result.detailPixelCount,
|
|
117
|
+
uniformPixelCount: result.uniformPixelCount, estimation: result.estimation, saturated: result.saturated,
|
|
118
|
+
saturatedPixelCount: result.saturatedPixelCount, errorBound: result.expectedValueBound,
|
|
119
|
+
diagnosticUncertaintySampleCount: result.execution.diagnosticUncertaintySampleCount, ...(material.compositeProbe ? { compositeProbe: material.compositeProbe } : {}) };
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
signal?.removeEventListener("abort", onAbort);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
dispose() { modules.release(); }
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/** The factory `prepareDisplayView` creates the renderer with (one per device): the Speed and Quality kernels behind one renderer. */
|
|
129
|
+
export const displayViewGpuRendererFactory = (handle) => createDisplayViewGpuRenderer(handle);
|
|
130
|
+
/** Registers the combined renderer as the display view's GPU renderer and returns the factory registered before. */
|
|
131
|
+
export function registerDisplayViewGpuRenderer() {
|
|
132
|
+
return setDisplayViewGpuRendererFactory(displayViewGpuRendererFactory);
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=display-view-gpu-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display-view-gpu-renderer.js","sourceRoot":"","sources":["../../src/gpu/display-view-gpu-renderer.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAYtC,OAAO,EAAE,gCAAgC,EAAE,MAAM,6CAA6C,CAAC;AAC/F,OAAO,EAAE,gCAAgC,EAC2D,MAAM,+BAA+B,CAAC;AAC1I,OAAO,EAAE,mCAAmC,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,oCAAoC,EAAE,2BAA2B,EACxJ,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,yBAAyB,EAAiE,MAAM,6BAA6B,CAAC;AACvI,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAsB,MAAM,qBAAqB,CAAC;AAM9F,2FAA2F;AAC3F,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAElC,MAAM,gBAAgB,GAAG,GAAwB,EAAE,CAAC,MAAM,CAAC,+BAA+B,CAAC,CAAC;AAC5F,IAAI,cAAc,GAA8B,gBAAgB,CAAC;AACjE,IAAI,UAAU,GAA+B,IAAI,CAAC;AAClD;;;;GAIG;AACH,MAAM,UAAU,4BAA4B;IAC1C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YAC9E,IAAI,UAAU,KAAK,OAAO;gBAAE,UAAU,GAAG,IAAI,CAAC;YAC9C,MAAM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479, #481): the Speed kernel for the requests it covers and the Quality kernels for the\n * rest, behind one `DisplayViewGpuRenderer`. #594: the Quality host and its WGSL (`display-view-quality-gpu.ts`,\n * `wgsl-display-view-quality-kernel.ts`) load on demand, at the first render that takes the Quality passes, so a page that only\n * renders Speed views never downloads them. That render first runs the Quality kernels' self-check cases (the renderer's\n * `onDemandConformanceCases`); every Speed render runs only the Speed case before the device's first render. The Quality code,\n * its results and its bounds are unchanged; `prepareDisplayViewQualityGpu()` loads it ahead of time.\n */\n\nimport type { DisplayViewRenderResult, DisplayViewSetup } from \"../facade/display-view.js\";\nimport { createDisplayViewMaterialModules } from \"./display-view-composite-material-module.js\";\nimport { setDisplayViewGpuRendererFactory, type DisplayViewGpuConformanceCase, type DisplayViewGpuPart, type DisplayViewGpuRenderOutput, type DisplayViewGpuRenderer,\n type DisplayViewGpuRendererFactory, type DisplayViewGpuRequest, type DisplayViewGpuRuntimeHandle } from \"../facade/display-view-gpu.js\";\nimport { DISPLAY_VIEW_SPEED_CONFORMANCE_CASE, LARGE_DEFOCUS_REASON, sceneToneAndOffsetsReason, displayViewSpeedGpuSupports, displayViewSpeedGpuUnsupportedReason, renderDisplayViewSpeedOnGpu,\n type DisplayViewGpuMaterialModule } from \"./display-view-speed-gpu.js\";\nimport { ImageKernelExecutionError, type ImageKernelExecution, type ImageKernelRelativeErrorBound } from \"./image-kernel-execution.js\";\nimport { abortedError, createComputePipeline, type WebGpuRuntime } from \"./webgpu-runtime.js\";\n\ntype PipelineSource = (label: string, code: string) => Promise<GPUComputePipeline>;\ntype YieldControl = ((signal: AbortSignal) => Promise<void>) | undefined;\ntype QualityKit = typeof import(\"./display-view-quality-gpu.js\");\n\n/** Largest lattice group count the Quality tables hold (`display-view-quality-gpu.ts`). */\nconst QUALITY_MAXIMUM_GROUPS = 64;\n\nconst importQualityKit = (): Promise<QualityKit> => import(\"./display-view-quality-gpu.js\");\nlet loadQualityKit: () => Promise<QualityKit> = importQualityKit;\nlet qualityKit: Promise<QualityKit> | null = null;\n/**\n * #594: loads the Quality host once (a dynamic import, its own chunk in a bundler that splits) and returns it; concurrent calls\n * share one load. A failed load rejects with `ImageKernelExecutionError` reason `quality-code-unavailable` and is not\n * remembered, so the next call (a later Quality render, or `prepareQualityPaths()`) tries again.\n */\nexport function prepareDisplayViewQualityGpu(): Promise<QualityKit> {\n if (!qualityKit) {\n const pending = Promise.resolve().then(loadQualityKit).catch((error: unknown) => {\n if (qualityKit === pending) qualityKit = null;\n throw new ImageKernelExecutionError(\"quality-code-unavailable\", \"GPU full-quality code did not load: \" + String(error));\n });\n qualityKit = pending;\n }\n return qualityKit;\n}\n/**\n * Internal, for tests: replaces how the Quality host is loaded (null restores the dynamic import) and forgets a loaded one,\n * so a test can make the load fail and then succeed. Returns nothing; the engine never calls it.\n */\nexport function setDisplayViewQualityGpuLoader(loader: (() => Promise<QualityKit>) | null): void {\n loadQualityKit = loader ?? importQualityKit;\n qualityKit = null;\n}\n\n/**\n * Why the Quality renderer does not support a prepared request (`DisplayViewGpuRenderer.supports`), or true: engine charts and\n * declared `material-layers` scenes (the material modules of `createDisplayViewMaterialModules`, #491), the identity or Reinhard\n * tone curve and at most 64 query offsets (lattice groups). `lens.defocus` out of focus is supported (#492 step 2c: the site pass\n * gathers the disc, or each node's diffraction kernel convolved with it, up to the reference's own caps of radius 64 and 96);\n * whether a view's footprints take the exact area mean, whether the device passes the composite probe, and whether the kernel\n * table fits the device's storage binding limit, is known only per render.\n */\nexport function displayViewQualityGpuSupports(request: DisplayViewGpuRequest): true | string {\n return sceneToneAndOffsetsReason(request, QUALITY_MAXIMUM_GROUPS);\n}\n\n/**\n * The display view's GPU renderer on one runtime (#481's `DisplayViewGpuRenderer`): the Speed kernel for requests it covers\n * (no diffraction, no AHD, no defocus disc, at most 16 offsets) and the Quality kernels for the rest (#492: a defocused Speed\n * request too, with its bilinear demosaic). One pipeline cache per device, one set of\n * material modules (#491: chart presets, composite charts, the 2.3 elements and material-layers scenes; `dispose` releases their\n * uploaded scene records). `render` renders the part's region (`setup.gpu`\n * carries the expected signal's input and the chart; a setup without it, a coarse view or a frame the kernels do not cover\n * throws `unsupported-on-backend`), and throws `aborted` and `device-lost` as the accelerator's operations do. The Quality host\n * is loaded on demand (#594, `prepareDisplayViewQualityGpu`).\n */\nexport function createDisplayViewGpuRenderer(runtime: WebGpuRuntime, options: { maximumBandBytes?: number; yieldControl?: YieldControl } = {}): DisplayViewGpuRenderer {\n const pipelines = new Map<string, Promise<GPUComputePipeline>>();\n const bandBytes = options.maximumBandBytes ?? Math.min(64 * 1024 * 1024, runtime.maximumStorageBindingBytes);\n const source: PipelineSource = (label, code) => {\n let pending = pipelines.get(label);\n if (!pending) { pending = createComputePipeline(runtime, label, code, undefined); pipelines.set(label, pending); pending.catch(() => pipelines.delete(label)); }\n return pending;\n };\n // #491: one set of material modules per device for both kernels (the preset module per chart; the composite module, its probe\n // and its uploaded scene records), released by `dispose`.\n const modules = createDisplayViewMaterialModules(runtime, source);\n return {\n id: \"photivra-display-view\",\n supports(request: DisplayViewGpuRequest): true | string {\n if (request.largeDefocus) return LARGE_DEFOCUS_REASON;\n // #492: out of focus the expected signal carries the defocus disc as site kernels, which only the Quality site pass gathers;\n // a Speed request then runs the Quality passes with its own bilinear demosaic (one candidate) and finishing.\n if (request.defocus) return displayViewQualityGpuSupports(request);\n const speed = displayViewSpeedGpuSupports(request);\n if (speed === true) return true;\n return displayViewQualityGpuSupports(request);\n },\n // #594 (owner, 2026-11-10): the Speed case runs before the device's first render; the Quality cases run before the first\n // render that takes the Quality passes, after their code has loaded.\n conformanceCases: [DISPLAY_VIEW_SPEED_CONFORMANCE_CASE],\n onDemandConformanceCases(setup: DisplayViewSetup): Promise<readonly DisplayViewGpuConformanceCase[]> | null {\n // The routing of `render` below: a setup the Speed kernel does not cover takes the Quality passes.\n return setup.gpu && displayViewSpeedGpuUnsupportedReason(setup, setup.gpu.signalInput) !== null ? prepareDisplayViewQualityGpu().then((kit) => kit.DISPLAY_VIEW_QUALITY_CONFORMANCE_CASES) : null;\n },\n async render(part: DisplayViewGpuPart): Promise<DisplayViewGpuRenderOutput> {\n const { setup, signal } = part;\n if (!setup.gpu) throw new ImageKernelExecutionError(\"unsupported-on-backend\", \"The display-view setup carries no GPU inputs (setup.gpu); use cpu-reference.\");\n const abort = new AbortController(), onAbort = (): void => abort.abort();\n if (signal?.aborted) throw abortedError();\n signal?.addEventListener(\"abort\", onAbort, { once: true });\n try {\n const signalInput = setup.gpu.signalInput;\n let result: DisplayViewRenderResult & { expectedValueBound: ImageKernelRelativeErrorBound; execution: ImageKernelExecution };\n let material: DisplayViewGpuMaterialModule;\n if (displayViewSpeedGpuUnsupportedReason(setup, signalInput) === null) {\n material = await modules.moduleFor(setup.gpu, abort.signal);\n result = await renderDisplayViewSpeedOnGpu(runtime, bandBytes, { setup, signalInput, material }, abort, options.yieldControl, source);\n } else {\n const kit = await prepareDisplayViewQualityGpu();\n // #581: an image-plane print brings its own passes 1 and 2.\n const image = (signalInput.scene as { image?: unknown }).image ? await modules.imagePasses(setup.gpu, abort.signal) : undefined;\n material = image ? { id: \"image-plane\", wgsl: \"\", bindings: [] } : await kit.qualityMaterialModule(modules, setup.gpu, abort.signal);\n result = await kit.renderDisplayViewQualityOnGpu(runtime, bandBytes, { setup, signalInput, material, ...(image ? { image } : {}) }, abort, options.yieldControl, source);\n }\n return { samples: result.samples, expected: result.expected, noiseStd: result.noiseStd, sampleCount: result.sampleCount, siteCount: result.siteCount, detailPixelCount: result.detailPixelCount,\n uniformPixelCount: result.uniformPixelCount, estimation: result.estimation, saturated: result.saturated,\n saturatedPixelCount: result.saturatedPixelCount, errorBound: result.expectedValueBound,\n diagnosticUncertaintySampleCount: result.execution.diagnosticUncertaintySampleCount, ...(material.compositeProbe ? { compositeProbe: material.compositeProbe } : {}) };\n } finally { signal?.removeEventListener(\"abort\", onAbort); }\n },\n dispose(): void { modules.release(); }\n };\n}\n\n/** The factory `prepareDisplayView` creates the renderer with (one per device): the Speed and Quality kernels behind one renderer. */\nexport const displayViewGpuRendererFactory: DisplayViewGpuRendererFactory = (handle: DisplayViewGpuRuntimeHandle) => createDisplayViewGpuRenderer(handle as WebGpuRuntime);\n\n/** Registers the combined renderer as the display view's GPU renderer and returns the factory registered before. */\nexport function registerDisplayViewGpuRenderer(): DisplayViewGpuRendererFactory | null {\n return setDisplayViewGpuRendererFactory(displayViewGpuRendererFactory);\n}\n"]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The image-plane module of the GPU display view (#581): the Speed kernel's `scene_value` (the seam of #478 and #491,
|
|
3
|
+
* `DisplayViewGpuMaterialModule`) for an image-plane print, so that a photo renders on the device like a chart.
|
|
4
|
+
*
|
|
5
|
+
* **What the reference computes** at a query point (expected-signal.ts, the direct path's `signalAt`): the print-local point
|
|
6
|
+
* cu = u·m/h, cv = v·m/h (outside |cu| ≤ 1, |cv| ≤ aspect the surround: its reflectance times the neutral signal N_c); the
|
|
7
|
+
* pixel coordinates X = (cu + 1)·W/2, Y = (aspect − cv)·H/(2·aspect); then the bilinear weights of the four nearest pixel
|
|
8
|
+
* centers (clamped to the edge) times each pixel's channel signal S_j,c = Σ_n A_c(λ_n)·ρ_j(λ_n)·W_n, integrated from the pixel's
|
|
9
|
+
* reconstructed spectrum ρ_j (its cell's eight node spectra blended, then the paper; `ResolvedImagePlaneScene.pixelSignals`), or
|
|
10
|
+
* the nearest pixel's. No per-channel values of the lattice nodes are formed.
|
|
11
|
+
*
|
|
12
|
+
* **On the device.** The host computes every pixel's S_j,c in float64 and rounds it once to float32 (3 values per pixel). When
|
|
13
|
+
* they fit one storage binding they are uploaded once per scene and kept on the device while the renderer lives; otherwise each
|
|
14
|
+
* band of a render builds and uploads only its rows. Either way they are built and written 4 MiB of rows at a time, so the host
|
|
15
|
+
* never holds more than that of S (owner decision 2026-11-09; the bytes are those of the whole array). The module recovers the exact lattice point from the
|
|
16
|
+
* kernel's float32 point as the composite module does (`LATTICE_POINT_WGSL`, about 2⁻⁴⁶ relative), forms cu, cv, X and Y
|
|
17
|
+
* in double-float32 and decides the print's edge in the composite kernel's bound arithmetic (a point within its bound of the
|
|
18
|
+
* edge is flagged: the display pixel is recomputed on the host). Per axis it splits s = X − ½ into its integer part n and
|
|
19
|
+
* fraction f exactly (double-float32), rounds the smaller of f and 1 − f once to float32 and forms the other as 1 minus it, so
|
|
20
|
+
* each weight carries at most 2E relative error (E = 2⁻²³) besides the point's own error. The point's error moves weight
|
|
21
|
+
* between neighbors: with δ the bound of |X_gpu − X_ref| in pixels (4·(2⁻⁴⁰·(|X| + 1)) + 4·10⁻¹⁴·W/2·k: the recovery, the
|
|
22
|
+
* double-float32 steps and the reference's own float64 rounding of its query point, generously), the value moves by at most
|
|
23
|
+
* (δx + δy)·2·max S, and the point is flagged when that exceeds E times the value. So an unflagged value carries a relative
|
|
24
|
+
* error only: S's rounding 1, the weights 2 + 2, the two products and two sums 4, the flag's budget 1, that is 10 roundings
|
|
25
|
+
* beyond the table lookup's one (`extraSiteRoundings`), added to the Speed kernel's chains (docs/WEBGPU.md, "Display view (Speed)").
|
|
26
|
+
* `nearest` takes the pixel under the point, flagging a point within its bound of a pixel edge (`bfloor`). All S are
|
|
27
|
+
* non-negative (non-negative responses, illuminant and spectra), so the weighted sums need no cancellation term.
|
|
28
|
+
*
|
|
29
|
+
* The surround's three channel signals, integrated from its spectrum (its reflectance times the white radiance at each node) like
|
|
30
|
+
* a pixel's, are the kernel's binding 3 (`spectral_table`, which this module does not otherwise use).
|
|
31
|
+
*/
|
|
32
|
+
import { type ChartCompositeProbeRecord } from "./image-kernel-execution.js";
|
|
33
|
+
import { type WebGpuRuntime } from "./webgpu-runtime.js";
|
|
34
|
+
import type { ChartCompositeProductPath } from "./wgsl-chart-composite-kernel.js";
|
|
35
|
+
import type { DisplayViewGpuMaterialModule } from "./display-view-speed-gpu.js";
|
|
36
|
+
import { type DisplayViewGpuSetup } from "../facade/display-view.js";
|
|
37
|
+
import { type ImagePlaneSignalScene } from "../facade/scene-radiance.js";
|
|
38
|
+
import { type DisplayViewQualityImagePasses } from "./display-view-quality-gpu.js";
|
|
39
|
+
/** The module's id per product path. */
|
|
40
|
+
export declare function imagePlaneMaterialModuleId(path: ChartCompositeProductPath): string;
|
|
41
|
+
/** Roundings of the module's value beyond the table lookup's one (see the module comment). */
|
|
42
|
+
export declare const IMAGE_PLANE_EXTRA_SITE_ROUNDINGS = 10;
|
|
43
|
+
/** Layout of the photo uniform (float32 / u32 words, 64 bytes). */
|
|
44
|
+
export declare const IMAGE_PLANE_PARAMS: Readonly<{
|
|
45
|
+
width: 0;
|
|
46
|
+
height: 1;
|
|
47
|
+
nearest: 2;
|
|
48
|
+
row0: 3;
|
|
49
|
+
halfWHi: 4;
|
|
50
|
+
halfWLo: 5;
|
|
51
|
+
halfHHi: 6;
|
|
52
|
+
halfHLo: 7;
|
|
53
|
+
aspectHi: 8;
|
|
54
|
+
aspectLo: 9;
|
|
55
|
+
slackX: 10;
|
|
56
|
+
slackY: 11;
|
|
57
|
+
words: 16;
|
|
58
|
+
}>;
|
|
59
|
+
/** The module's WGSL with one product path (see the module comment). */
|
|
60
|
+
export declare function imagePlaneMaterialWgsl(path?: ChartCompositeProductPath): string;
|
|
61
|
+
/** The image-plane print behind a GPU setup's expected signal (`ImagePlaneSignalScene.image`), or undefined. */
|
|
62
|
+
export declare function imagePlaneOf(gpu: DisplayViewGpuSetup): ImagePlaneSignalScene["image"] | undefined;
|
|
63
|
+
/** The image-plane modules of one display-view renderer: `moduleFor` builds the setup's module (its uploads kept), `release` frees them. */
|
|
64
|
+
export interface DisplayViewImageModules {
|
|
65
|
+
/** The setup's module; the first call on a runtime runs the module's self-check (`runImagePlaneConformance`) and refuses the device if it fails. */
|
|
66
|
+
moduleFor(gpu: DisplayViewGpuSetup, signal: AbortSignal): Promise<DisplayViewGpuMaterialModule>;
|
|
67
|
+
/** The setup's module without the self-check (the self-check itself uses it). */
|
|
68
|
+
build(gpu: DisplayViewGpuSetup, path: ChartCompositeProductPath): DisplayViewGpuMaterialModule;
|
|
69
|
+
/** #581: the print's Quality passes 1 and 2 (src/gpu/display-view-image-quality.ts), after the same self-check. */
|
|
70
|
+
qualityPasses(gpu: DisplayViewGpuSetup, signal: AbortSignal): Promise<DisplayViewQualityImagePasses>;
|
|
71
|
+
release(): void;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The image-plane modules of a renderer; `probe` is the composite module's device probe (single flight), whose double-word product
|
|
75
|
+
* path the module's double-float32 takes.
|
|
76
|
+
*/
|
|
77
|
+
export declare function createDisplayViewImageModules(runtime: WebGpuRuntime, probe: (signal: AbortSignal) => Promise<ChartCompositeProbeRecord>): DisplayViewImageModules;
|
|
78
|
+
/**
|
|
79
|
+
* #581's run-time self-check of the module, run on a device's first photo: a 12 × 8 photo (a color ramp with hard edges, every
|
|
80
|
+
* lattice cell's corner colors among its pixels) printed at 0.8 of the frame's width on the 18 % surround of a 38 × 26 frame shown
|
|
81
|
+
* at 13 × 9, the GPU against `renderDisplayView` within the a-priori bounds, every flagged pixel recomputed: the Speed kernel with
|
|
82
|
+
* the 2 × 2 box, then the Quality passes with the four-spot filter's 16 offsets and synthetic radius-1 kernels at three nodes, and
|
|
83
|
+
* (#597) the same passes under mixed light (a three-source gradient with a hard edge and a point source).
|
|
84
|
+
* A device that fails the double-float32 probe refuses photos (unsupported-on-backend, as composite charts), so the check passes
|
|
85
|
+
* there without keeping the device's charts off the GPU.
|
|
86
|
+
*/
|
|
87
|
+
export declare function runImagePlaneConformance(handle: unknown, signal: AbortSignal | undefined): Promise<true | string>;
|