@photivra/engine 2.10.0 → 2.11.1
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 +139 -1
- package/CITATION.cff +1 -1
- package/NODE_SUPPORT.md +21 -3
- package/README.md +6 -6
- package/SECURITY.md +1 -1
- package/dist/core/portable-math.d.ts +6 -0
- package/dist/core/portable-math.js +39 -0
- package/dist/core/portable-math.js.map +1 -1
- 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/facade/chart-material-layers.d.ts +115 -0
- package/dist/facade/chart-material-layers.js +224 -0
- package/dist/facade/chart-material-layers.js.map +1 -0
- package/dist/facade/chart-radiance-batch.d.ts +8 -2
- package/dist/facade/chart-radiance-batch.js +11 -4
- package/dist/facade/chart-radiance-batch.js.map +1 -1
- package/dist/facade/chart-scenes.d.ts +134 -0
- package/dist/facade/chart-scenes.js +32 -22
- package/dist/facade/chart-scenes.js.map +1 -1
- package/dist/facade/diffraction-provider.d.ts +8 -2
- package/dist/facade/diffraction-provider.js +71 -2
- package/dist/facade/diffraction-provider.js.map +1 -1
- package/dist/facade/display-view-gpu-session.d.ts +18 -0
- package/dist/facade/display-view-gpu-session.js +280 -0
- package/dist/facade/display-view-gpu-session.js.map +1 -0
- package/dist/facade/display-view-gpu.d.ts +146 -0
- package/dist/facade/display-view-gpu.js +59 -0
- package/dist/facade/display-view-gpu.js.map +1 -0
- package/dist/facade/display-view.d.ts +48 -1
- package/dist/facade/display-view.js +7 -7
- package/dist/facade/display-view.js.map +1 -1
- package/dist/facade/expected-signal-setup.d.ts +5 -0
- package/dist/facade/expected-signal-setup.js +16 -0
- package/dist/facade/expected-signal-setup.js.map +1 -1
- package/dist/facade/expected-signal.d.ts +48 -3
- package/dist/facade/expected-signal.js +8 -0
- package/dist/facade/expected-signal.js.map +1 -1
- package/dist/facade/scene-radiance.d.ts +4 -2
- package/dist/facade/scene-radiance.js +7 -4
- package/dist/facade/scene-radiance.js.map +1 -1
- package/dist/facade/simulate-capture.d.ts +32 -5
- package/dist/facade/simulate-capture.js +148 -24
- package/dist/facade/simulate-capture.js.map +1 -1
- package/dist/facade/simulate-display-view.d.ts +31 -3
- package/dist/facade/simulate-display-view.js +72 -12
- package/dist/facade/simulate-display-view.js.map +1 -1
- package/dist/gpu/chart-composite-gpu.d.ts +119 -0
- package/dist/gpu/chart-composite-gpu.js +572 -0
- package/dist/gpu/chart-composite-gpu.js.map +1 -0
- package/dist/gpu/chart-radiance-gpu.d.ts +6 -6
- package/dist/gpu/chart-radiance-gpu.js +9 -11
- package/dist/gpu/chart-radiance-gpu.js.map +1 -1
- package/dist/gpu/display-view-chart-material-module.d.ts +10 -0
- package/dist/gpu/display-view-chart-material-module.js +58 -0
- package/dist/gpu/display-view-chart-material-module.js.map +1 -0
- package/dist/gpu/display-view-composite-material-module.d.ts +68 -0
- package/dist/gpu/display-view-composite-material-module.js +248 -0
- package/dist/gpu/display-view-composite-material-module.js.map +1 -0
- package/dist/gpu/display-view-quality-gpu.d.ts +185 -0
- package/dist/gpu/display-view-quality-gpu.js +1000 -0
- package/dist/gpu/display-view-quality-gpu.js.map +1 -0
- package/dist/gpu/display-view-speed-gpu.d.ts +156 -0
- package/dist/gpu/display-view-speed-gpu.js +524 -0
- package/dist/gpu/display-view-speed-gpu.js.map +1 -0
- package/dist/gpu/image-kernel-accelerator.d.ts +23 -4
- package/dist/gpu/image-kernel-accelerator.js +58 -10
- package/dist/gpu/image-kernel-accelerator.js.map +1 -1
- package/dist/gpu/image-kernel-execution.d.ts +55 -3
- package/dist/gpu/image-kernel-execution.js.map +1 -1
- package/dist/gpu/sensor-stage-gpu.d.ts +11 -0
- package/dist/gpu/sensor-stage-gpu.js +42 -13
- package/dist/gpu/sensor-stage-gpu.js.map +1 -1
- package/dist/gpu/webgpu-runtime.d.ts +4 -2
- package/dist/gpu/webgpu-runtime.js +13 -4
- package/dist/gpu/webgpu-runtime.js.map +1 -1
- package/dist/gpu/webgpu-switch.d.ts +4 -0
- package/dist/gpu/webgpu-switch.js +29 -0
- package/dist/gpu/webgpu-switch.js.map +1 -0
- package/dist/gpu/wgsl-chart-composite-kernel.d.ts +52 -0
- package/dist/gpu/wgsl-chart-composite-kernel.js +515 -0
- package/dist/gpu/wgsl-chart-composite-kernel.js.map +1 -0
- package/dist/gpu/wgsl-chart-kernel.d.ts +11 -9
- package/dist/gpu/wgsl-chart-kernel.js +33 -27
- package/dist/gpu/wgsl-chart-kernel.js.map +1 -1
- package/dist/gpu/wgsl-display-view-quality-kernel.d.ts +95 -0
- package/dist/gpu/wgsl-display-view-quality-kernel.js +769 -0
- package/dist/gpu/wgsl-display-view-quality-kernel.js.map +1 -0
- package/dist/gpu/wgsl-display-view-speed-kernel.d.ts +75 -0
- package/dist/gpu/wgsl-display-view-speed-kernel.js +386 -0
- package/dist/gpu/wgsl-display-view-speed-kernel.js.map +1 -0
- package/dist/gpu/wgsl-sensor-kernel.d.ts +28 -9
- package/dist/gpu/wgsl-sensor-kernel.js +94 -50
- package/dist/gpu/wgsl-sensor-kernel.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/optics/defocus-disc-kernel.d.ts +61 -0
- package/dist/optics/defocus-disc-kernel.js +191 -0
- package/dist/optics/defocus-disc-kernel.js.map +1 -0
- package/docs/API_REFERENCE.md +45 -1
- package/docs/QUICK_START.md +102 -3
- package/docs/USAGE.md +52 -2
- package/docs/api/core-version.md +1 -1
- package/docs/api/exports.json +117 -2
- package/docs/api/facade-chart-material-layers.md +137 -0
- package/docs/api/facade-chart-radiance-batch.md +7 -2
- package/docs/api/facade-display-view-gpu.md +94 -0
- package/docs/api/facade-scene-radiance.md +3 -2
- package/docs/api/facade-simulate-capture.md +23 -6
- package/docs/api/facade-simulate-display-view.md +17 -2
- package/docs/api/gpu-image-kernel-accelerator.md +10 -3
- package/docs/api/gpu-image-kernel-execution.md +71 -4
- package/docs/api/gpu-webgpu-switch.md +23 -0
- package/package.json +3 -1
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { ChartRadianceBatchPlan } from "../facade/chart-radiance-batch.js";
|
|
2
|
+
import { type ChartGeometry, type ResolvedChartScene } from "../facade/chart-scenes.js";
|
|
3
|
+
import { ImageKernelExecutionError, type ChartCompositeProbeComponent, type ChartCompositeProbeRecord } from "./image-kernel-execution.js";
|
|
4
|
+
import type { ChartRadianceResult } from "./image-kernel-accelerator.js";
|
|
5
|
+
import { GpuResourceScope, type WebGpuRuntime } from "./webgpu-runtime.js";
|
|
6
|
+
type PipelineSource = (label: string, code: string) => Promise<GPUComputePipeline>;
|
|
7
|
+
type YieldControl = ((signal: AbortSignal) => Promise<void>) | undefined;
|
|
8
|
+
export type Dw = readonly [hi: number, lo: number];
|
|
9
|
+
export declare function dwSplit(x: number): Dw;
|
|
10
|
+
export declare function twoSum(a: number, b: number): Dw;
|
|
11
|
+
export declare function quickTwoSum(a: number, b: number): Dw;
|
|
12
|
+
export declare function twoProd(a: number, b: number): Dw;
|
|
13
|
+
export declare function dwAdd(a: Dw, b: Dw): Dw;
|
|
14
|
+
export declare function dwSub(a: Dw, b: Dw): Dw;
|
|
15
|
+
export declare function dwMul(a: Dw, b: Dw): Dw;
|
|
16
|
+
/**
|
|
17
|
+
* fma on float32 operands with one rounding to nearest (ties to even), as a fused `fma` evaluates it: the product of two float32
|
|
18
|
+
* values is exact in float64 (48 significant bits), the float64 TwoSum gives the sum's exact error, and the one case where rounding
|
|
19
|
+
* the float64 sum to float32 differs from rounding the exact sum (the float64 sum lands on a float32 midpoint) is resolved by the error's sign.
|
|
20
|
+
*/
|
|
21
|
+
export declare function fmaF32(a: number, b: number, c: number): number;
|
|
22
|
+
/** The fma TwoProduct: p = fl(a·b) and its exact error fma(a, b, −p) (exact for a fused fma; Joldes, Muller & Popescu 2017, Algorithm 2). */
|
|
23
|
+
export declare function twoProdFma(a: number, b: number): Dw;
|
|
24
|
+
/** The cross-term sum t = a.h·b.l + a.l·b.h of a double-word product: unfused (the default), or with one of the two products fused into the addition. */
|
|
25
|
+
export declare function dwCrossTerm(a: Dw, b: Dw, contraction?: "none" | "first" | "second"): number;
|
|
26
|
+
/**
|
|
27
|
+
* The fma path's double-word product (`d_mul_fma`): s = fma(a.h, b.h, t), lo = fl(fma(a.h, b.h, −s) + t), with t the cross-term
|
|
28
|
+
* sum. No rounded product is an operand of an addition, so a contraction cannot change it; see docs/WEBGPU.md for its error bound.
|
|
29
|
+
*/
|
|
30
|
+
export declare function dwMulFma(a: Dw, b: Dw, t?: number): Dw;
|
|
31
|
+
/** The Dekker path's double-word product with a given cross-term sum (`dwMul` is it with the unfused one). */
|
|
32
|
+
export declare function dwMulDekker(a: Dw, b: Dw, t?: number): Dw;
|
|
33
|
+
/**
|
|
34
|
+
* Probe inputs (x, y, z, w): pairs whose TwoSum and TwoProduct low parts are non-zero, double words to add and multiply, and sums and
|
|
35
|
+
* products that a directed (truncating or upward) rounding would place on the other neighbour than round-to-nearest: 1 + 3·2^-26
|
|
36
|
+
* rounds up to 1 + 2^-23 (nearest) but down to 1 (truncation); −1 − 3·2^-26 the mirror; 1.25 · (1 + 2^-23) likewise. The last four
|
|
37
|
+
* (2.11.0, the M5 Pro finding) are normalized double words whose products have non-zero TwoProduct errors on both operand pairs, so
|
|
38
|
+
* a contraction of the Dekker path's final Fast2Sum (which then adds the product's error twice) shows in the double-word product.
|
|
39
|
+
*/
|
|
40
|
+
export declare const PROBE_INPUTS: readonly (readonly [number, number, number, number])[];
|
|
41
|
+
/** The components of the probe in output order (see `CHART_COMPOSITE_PROBE_WGSL`). */
|
|
42
|
+
export declare const PROBE_COMPONENTS: readonly ChartCompositeProbeComponent[];
|
|
43
|
+
/**
|
|
44
|
+
* The probe's output per input on a device that evaluates as written, round to nearest, unfused, with a fused `fma`, in the shader's
|
|
45
|
+
* order: [TwoSum lo, Dekker TwoProduct lo, double-word sum lo, fma TwoProduct lo, Dekker product hi, lo, fma product hi, lo].
|
|
46
|
+
*/
|
|
47
|
+
export declare function probeExpectation(input: readonly [number, number, number, number]): [number, number, number, number, number, number, number, number];
|
|
48
|
+
/**
|
|
49
|
+
* Classifies the probe's output (`CHART_COMPOSITE_PROBE_OUTPUTS` floats per input of `PROBE_INPUTS`). TwoSum, both TwoProducts and the
|
|
50
|
+
* double-word sum must equal their exact values bit for bit (each is error-free, or a fixed sequence of roundings to nearest); a
|
|
51
|
+
* double-word product must equal the written-order evaluation for the unfused cross-term sum t = a.h·b.l + a.l·b.h or for either
|
|
52
|
+
* product of t fused into its addition (a contraction WGSL permits, "Reassociation and Fusion", and harmless there: t is an ordinary
|
|
53
|
+
* bounded sum). Anything else is a mismatch, recorded with the float32 bits.
|
|
54
|
+
*/
|
|
55
|
+
export declare function classifyChartCompositeProbe(got: Float32Array): ChartCompositeProbeRecord;
|
|
56
|
+
/**
|
|
57
|
+
* One log line for a probe record: the class, the chosen path, each differing component with its count and the probe input
|
|
58
|
+
* indices that differ, and the first difference with its float32 bits.
|
|
59
|
+
*/
|
|
60
|
+
export declare function describeChartCompositeProbe(probe: ChartCompositeProbeRecord): string;
|
|
61
|
+
/** The probe's refusal: `unsupported-on-backend` with the probe record (`probe`) for the execution diagnostics. */
|
|
62
|
+
export declare class ChartCompositeProbeError extends ImageKernelExecutionError {
|
|
63
|
+
readonly probe: ChartCompositeProbeRecord;
|
|
64
|
+
constructor(probe: ChartCompositeProbeRecord);
|
|
65
|
+
}
|
|
66
|
+
/** Packed records of one scene: the kernel's float and integer arrays and its material count. */
|
|
67
|
+
export interface PackedChartScene {
|
|
68
|
+
af: Float32Array<ArrayBuffer>;
|
|
69
|
+
ai: Uint32Array<ArrayBuffer>;
|
|
70
|
+
materials: number;
|
|
71
|
+
elementCount: number;
|
|
72
|
+
layerCount: number;
|
|
73
|
+
}
|
|
74
|
+
/** Sector boundary table of a Siemens star (bar or sine profile): directions, per-sector levels from the reference, bucket index and search window. */
|
|
75
|
+
export declare function starSectorTable(chart: ResolvedChartScene, g: Extract<ChartGeometry, {
|
|
76
|
+
kind: "siemens-star";
|
|
77
|
+
}>): {
|
|
78
|
+
thetas: Float64Array;
|
|
79
|
+
levels: Uint32Array;
|
|
80
|
+
buckets: Uint32Array;
|
|
81
|
+
window: number;
|
|
82
|
+
};
|
|
83
|
+
/** Packs the plan's chart (a composite, an element preset, or the chart under layers) and its layers into the kernel's record arrays. */
|
|
84
|
+
export declare function packChartScene(plan: ChartRadianceBatchPlan): PackedChartScene;
|
|
85
|
+
/** Per-material values in float64 (the reference's operations), rounded once; a failing spectrum is NaN and its points are recomputed. */
|
|
86
|
+
export declare function chartMaterialTable(plan: ChartRadianceBatchPlan): Float32Array<ArrayBuffer>;
|
|
87
|
+
/** The scene key of a batch input: the scene's data and the aspect (every record derives from them). */
|
|
88
|
+
export declare function chartSceneKey(scene: unknown, aspect: number): string;
|
|
89
|
+
/**
|
|
90
|
+
* The device's double-float32 probe (`CHART_COMPOSITE_PROBE_WGSL`, classified by `classifyChartCompositeProbe`): resolves with the probe
|
|
91
|
+
* record (its `productPath` is the variant the composite kernel is compiled with), or rejects with `ChartCompositeProbeError`
|
|
92
|
+
* (`unsupported-on-backend`, the record in `probe`) on a device that neither product path holds on. Run once per accelerator by
|
|
93
|
+
* `ChartSceneUploads.probe`, and once per display-view renderer by the composite material module (#491).
|
|
94
|
+
*/
|
|
95
|
+
export declare function probeChartCompositeDevice(runtime: WebGpuRuntime, pipelines: PipelineSource, signal: AbortSignal): Promise<ChartCompositeProbeRecord>;
|
|
96
|
+
interface UploadedScene {
|
|
97
|
+
key: string;
|
|
98
|
+
scope: GpuResourceScope;
|
|
99
|
+
af: GPUBuffer;
|
|
100
|
+
ai: GPUBuffer;
|
|
101
|
+
packed: PackedChartScene;
|
|
102
|
+
}
|
|
103
|
+
/** Per accelerator: the uploaded records of recent scenes (a prepared view's scene is uploaded once) and the device probe. */
|
|
104
|
+
export declare class ChartSceneUploads {
|
|
105
|
+
#private;
|
|
106
|
+
private readonly runtime;
|
|
107
|
+
private readonly keep;
|
|
108
|
+
constructor(runtime: WebGpuRuntime, keep?: number);
|
|
109
|
+
/** The device's double-float32 probe, run once per accelerator (single flight; a refusal is retried on the next call): the record, or `ChartCompositeProbeError`. */
|
|
110
|
+
probe(pipelines: PipelineSource, signal: AbortSignal): Promise<ChartCompositeProbeRecord>;
|
|
111
|
+
get(plan: ChartRadianceBatchPlan, scene: unknown, aspect: number): UploadedScene;
|
|
112
|
+
/** Scenes currently uploaded (for tests). */
|
|
113
|
+
get size(): number;
|
|
114
|
+
release(): void;
|
|
115
|
+
}
|
|
116
|
+
/** Points as float32 pairs (hi, lo) per coordinate: the float64 point to 2^-48. */
|
|
117
|
+
export declare function splitPoints(points: Float32Array | Float64Array): Float32Array<ArrayBuffer>;
|
|
118
|
+
export declare function evaluateChartCompositeOnGpu(runtime: WebGpuRuntime, bandBytes: number, plan: ChartRadianceBatchPlan, scene: unknown, points: Float32Array | Float64Array, indices: Uint8Array | Uint16Array | undefined, abort: AbortController, yieldControl: YieldControl, pipelines: PipelineSource, uploads: ChartSceneUploads): Promise<ChartRadianceResult>;
|
|
119
|
+
export {};
|