@motion-core/motion-gpu 0.4.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +99 -0
  2. package/dist/advanced.js +3 -1
  3. package/dist/core/advanced.js +3 -1
  4. package/dist/core/compute-bindgroup-cache.d.ts +13 -0
  5. package/dist/core/compute-bindgroup-cache.d.ts.map +1 -0
  6. package/dist/core/compute-bindgroup-cache.js +45 -0
  7. package/dist/core/compute-bindgroup-cache.js.map +1 -0
  8. package/dist/core/compute-shader.d.ts +135 -0
  9. package/dist/core/compute-shader.d.ts.map +1 -0
  10. package/dist/core/compute-shader.js +238 -0
  11. package/dist/core/compute-shader.js.map +1 -0
  12. package/dist/core/error-diagnostics.d.ts +8 -1
  13. package/dist/core/error-diagnostics.d.ts.map +1 -1
  14. package/dist/core/error-diagnostics.js +7 -3
  15. package/dist/core/error-diagnostics.js.map +1 -1
  16. package/dist/core/error-report.d.ts +1 -1
  17. package/dist/core/error-report.d.ts.map +1 -1
  18. package/dist/core/error-report.js +82 -1
  19. package/dist/core/error-report.js.map +1 -1
  20. package/dist/core/frame-registry.d.ts.map +1 -1
  21. package/dist/core/frame-registry.js +1 -1
  22. package/dist/core/frame-registry.js.map +1 -1
  23. package/dist/core/index.d.ts +5 -2
  24. package/dist/core/index.d.ts.map +1 -1
  25. package/dist/core/index.js +3 -1
  26. package/dist/core/material-preprocess.d.ts.map +1 -1
  27. package/dist/core/material-preprocess.js +5 -3
  28. package/dist/core/material-preprocess.js.map +1 -1
  29. package/dist/core/material.d.ts +22 -6
  30. package/dist/core/material.d.ts.map +1 -1
  31. package/dist/core/material.js +32 -4
  32. package/dist/core/material.js.map +1 -1
  33. package/dist/core/render-graph.d.ts +7 -3
  34. package/dist/core/render-graph.d.ts.map +1 -1
  35. package/dist/core/render-graph.js +22 -6
  36. package/dist/core/render-graph.js.map +1 -1
  37. package/dist/core/renderer.d.ts.map +1 -1
  38. package/dist/core/renderer.js +489 -29
  39. package/dist/core/renderer.js.map +1 -1
  40. package/dist/core/runtime-loop.d.ts +2 -2
  41. package/dist/core/runtime-loop.d.ts.map +1 -1
  42. package/dist/core/runtime-loop.js +74 -14
  43. package/dist/core/runtime-loop.js.map +1 -1
  44. package/dist/core/shader.d.ts +16 -3
  45. package/dist/core/shader.d.ts.map +1 -1
  46. package/dist/core/shader.js +22 -2
  47. package/dist/core/shader.js.map +1 -1
  48. package/dist/core/storage-buffers.d.ts +37 -0
  49. package/dist/core/storage-buffers.d.ts.map +1 -0
  50. package/dist/core/storage-buffers.js +95 -0
  51. package/dist/core/storage-buffers.js.map +1 -0
  52. package/dist/core/texture-loader.d.ts.map +1 -1
  53. package/dist/core/texture-loader.js +4 -0
  54. package/dist/core/texture-loader.js.map +1 -1
  55. package/dist/core/textures.d.ts +16 -0
  56. package/dist/core/textures.d.ts.map +1 -1
  57. package/dist/core/textures.js +8 -2
  58. package/dist/core/textures.js.map +1 -1
  59. package/dist/core/types.d.ts +146 -4
  60. package/dist/core/types.d.ts.map +1 -1
  61. package/dist/index.js +3 -1
  62. package/dist/passes/ComputePass.d.ts +83 -0
  63. package/dist/passes/ComputePass.d.ts.map +1 -0
  64. package/dist/passes/ComputePass.js +92 -0
  65. package/dist/passes/ComputePass.js.map +1 -0
  66. package/dist/passes/PingPongComputePass.d.ts +104 -0
  67. package/dist/passes/PingPongComputePass.d.ts.map +1 -0
  68. package/dist/passes/PingPongComputePass.js +132 -0
  69. package/dist/passes/PingPongComputePass.js.map +1 -0
  70. package/dist/passes/ShaderPass.d.ts.map +1 -1
  71. package/dist/passes/ShaderPass.js +2 -1
  72. package/dist/passes/ShaderPass.js.map +1 -1
  73. package/dist/passes/index.d.ts +2 -0
  74. package/dist/passes/index.d.ts.map +1 -1
  75. package/dist/passes/index.js +3 -1
  76. package/dist/react/FragCanvas.d.ts +2 -2
  77. package/dist/react/FragCanvas.d.ts.map +1 -1
  78. package/dist/react/FragCanvas.js.map +1 -1
  79. package/dist/react/MotionGPUErrorOverlay.d.ts.map +1 -1
  80. package/dist/react/MotionGPUErrorOverlay.js +123 -20
  81. package/dist/react/MotionGPUErrorOverlay.js.map +1 -1
  82. package/dist/react/advanced.js +3 -1
  83. package/dist/react/index.d.ts +5 -2
  84. package/dist/react/index.d.ts.map +1 -1
  85. package/dist/react/index.js +3 -1
  86. package/dist/svelte/FragCanvas.svelte +2 -2
  87. package/dist/svelte/FragCanvas.svelte.d.ts +2 -2
  88. package/dist/svelte/FragCanvas.svelte.d.ts.map +1 -1
  89. package/dist/svelte/MotionGPUErrorOverlay.svelte +137 -7
  90. package/dist/svelte/MotionGPUErrorOverlay.svelte.d.ts.map +1 -1
  91. package/dist/svelte/advanced.js +3 -1
  92. package/dist/svelte/index.d.ts +5 -2
  93. package/dist/svelte/index.d.ts.map +1 -1
  94. package/dist/svelte/index.js +3 -1
  95. package/package.json +1 -1
  96. package/src/lib/core/compute-bindgroup-cache.ts +73 -0
  97. package/src/lib/core/compute-shader.ts +412 -0
  98. package/src/lib/core/error-diagnostics.ts +29 -4
  99. package/src/lib/core/error-report.ts +155 -1
  100. package/src/lib/core/frame-registry.ts +2 -1
  101. package/src/lib/core/index.ts +18 -1
  102. package/src/lib/core/material-preprocess.ts +17 -6
  103. package/src/lib/core/material.ts +103 -21
  104. package/src/lib/core/render-graph.ts +39 -9
  105. package/src/lib/core/renderer.ts +768 -48
  106. package/src/lib/core/runtime-loop.ts +116 -16
  107. package/src/lib/core/shader.ts +58 -4
  108. package/src/lib/core/storage-buffers.ts +142 -0
  109. package/src/lib/core/texture-loader.ts +6 -0
  110. package/src/lib/core/textures.ts +29 -2
  111. package/src/lib/core/types.ts +165 -4
  112. package/src/lib/passes/ComputePass.ts +136 -0
  113. package/src/lib/passes/PingPongComputePass.ts +180 -0
  114. package/src/lib/passes/ShaderPass.ts +2 -1
  115. package/src/lib/passes/index.ts +6 -0
  116. package/src/lib/react/FragCanvas.tsx +3 -3
  117. package/src/lib/react/MotionGPUErrorOverlay.tsx +137 -5
  118. package/src/lib/react/index.ts +18 -1
  119. package/src/lib/svelte/FragCanvas.svelte +2 -2
  120. package/src/lib/svelte/MotionGPUErrorOverlay.svelte +137 -7
  121. package/src/lib/svelte/index.ts +18 -1
@@ -0,0 +1,92 @@
1
+ import { assertComputeContract, extractWorkgroupSize } from "../core/compute-shader.js";
2
+ //#region src/lib/passes/ComputePass.ts
3
+ /**
4
+ * Compute pass class used within the render graph.
5
+ *
6
+ * Validates compute shader contract, parses workgroup size,
7
+ * and resolves dispatch dimensions. Does **not** manage GPU resources
8
+ * (that responsibility belongs to the renderer).
9
+ */
10
+ var ComputePass = class {
11
+ /**
12
+ * Enables/disables this pass without removing it from graph.
13
+ */
14
+ enabled;
15
+ /**
16
+ * Discriminant flag for render graph to identify compute passes.
17
+ */
18
+ isCompute = true;
19
+ compute;
20
+ workgroupSize;
21
+ dispatch;
22
+ constructor(options) {
23
+ assertComputeContract(options.compute);
24
+ const workgroupSize = extractWorkgroupSize(options.compute);
25
+ this.compute = options.compute;
26
+ this.workgroupSize = workgroupSize;
27
+ this.dispatch = options.dispatch ?? "auto";
28
+ this.enabled = options.enabled ?? true;
29
+ }
30
+ /**
31
+ * Replaces current compute shader and updates workgroup size.
32
+ *
33
+ * @param compute - New compute shader WGSL source.
34
+ * @throws {Error} When shader does not match the compute contract.
35
+ */
36
+ setCompute(compute) {
37
+ assertComputeContract(compute);
38
+ const workgroupSize = extractWorkgroupSize(compute);
39
+ this.compute = compute;
40
+ this.workgroupSize = workgroupSize;
41
+ }
42
+ /**
43
+ * Updates dispatch strategy.
44
+ */
45
+ setDispatch(dispatch) {
46
+ this.dispatch = dispatch ?? "auto";
47
+ }
48
+ /**
49
+ * Returns current compute shader source.
50
+ */
51
+ getCompute() {
52
+ return this.compute;
53
+ }
54
+ /**
55
+ * Returns parsed workgroup size from current compute shader.
56
+ */
57
+ getWorkgroupSize() {
58
+ return [...this.workgroupSize];
59
+ }
60
+ /**
61
+ * Resolves dispatch workgroup counts for current frame.
62
+ *
63
+ * @param ctx - Dispatch context with canvas dimensions and timing.
64
+ * @returns Tuple [x, y, z] workgroup counts.
65
+ */
66
+ resolveDispatch(ctx) {
67
+ if (this.dispatch === "auto") return [
68
+ Math.ceil(ctx.width / this.workgroupSize[0]),
69
+ Math.ceil(ctx.height / this.workgroupSize[1]),
70
+ Math.ceil(1 / this.workgroupSize[2])
71
+ ];
72
+ if (typeof this.dispatch === "function") return this.dispatch(ctx);
73
+ if (Array.isArray(this.dispatch)) return [
74
+ this.dispatch[0],
75
+ this.dispatch[1] ?? 1,
76
+ this.dispatch[2] ?? 1
77
+ ];
78
+ return [
79
+ 1,
80
+ 1,
81
+ 1
82
+ ];
83
+ }
84
+ /**
85
+ * Releases resources (no-op since GPU resource lifecycle is renderer-managed).
86
+ */
87
+ dispose() {}
88
+ };
89
+ //#endregion
90
+ export { ComputePass };
91
+
92
+ //# sourceMappingURL=ComputePass.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComputePass.js","names":[],"sources":["../../src/lib/passes/ComputePass.ts"],"sourcesContent":["import { assertComputeContract, extractWorkgroupSize } from '../core/compute-shader.js';\n\n/**\n * Dispatch context provided to dynamic dispatch callbacks.\n */\nexport interface ComputeDispatchContext {\n\twidth: number;\n\theight: number;\n\ttime: number;\n\tdelta: number;\n\tworkgroupSize: [number, number, number];\n}\n\n/**\n * Options for constructing a `ComputePass`.\n */\nexport interface ComputePassOptions {\n\t/**\n\t * Compute shader WGSL source code.\n\t * Must declare `@compute @workgroup_size(...) fn compute(@builtin(global_invocation_id) ...)`.\n\t */\n\tcompute: string;\n\t/**\n\t * Dispatch workgroup counts.\n\t * - Static tuple: `[x]`, `[x, y]`, or `[x, y, z]`\n\t * - `'auto'`: derived from canvas size / workgroup size\n\t * - Function: dynamic dispatch based on frame context\n\t */\n\tdispatch?:\n\t\t| [number, number?, number?]\n\t\t| 'auto'\n\t\t| ((ctx: ComputeDispatchContext) => [number, number, number]);\n\t/**\n\t * Enables/disables this compute pass.\n\t */\n\tenabled?: boolean;\n}\n\n/**\n * Compute pass class used within the render graph.\n *\n * Validates compute shader contract, parses workgroup size,\n * and resolves dispatch dimensions. Does **not** manage GPU resources\n * (that responsibility belongs to the renderer).\n */\nexport class ComputePass {\n\t/**\n\t * Enables/disables this pass without removing it from graph.\n\t */\n\tenabled: boolean;\n\n\t/**\n\t * Discriminant flag for render graph to identify compute passes.\n\t */\n\treadonly isCompute = true as const;\n\n\tprivate compute: string;\n\tprivate workgroupSize: [number, number, number];\n\tprivate dispatch: ComputePassOptions['dispatch'];\n\n\tconstructor(options: ComputePassOptions) {\n\t\tassertComputeContract(options.compute);\n\t\tconst workgroupSize = extractWorkgroupSize(options.compute);\n\t\tthis.compute = options.compute;\n\t\tthis.workgroupSize = workgroupSize;\n\t\tthis.dispatch = options.dispatch ?? 'auto';\n\t\tthis.enabled = options.enabled ?? true;\n\t}\n\n\t/**\n\t * Replaces current compute shader and updates workgroup size.\n\t *\n\t * @param compute - New compute shader WGSL source.\n\t * @throws {Error} When shader does not match the compute contract.\n\t */\n\tsetCompute(compute: string): void {\n\t\tassertComputeContract(compute);\n\t\tconst workgroupSize = extractWorkgroupSize(compute);\n\t\tthis.compute = compute;\n\t\tthis.workgroupSize = workgroupSize;\n\t}\n\n\t/**\n\t * Updates dispatch strategy.\n\t */\n\tsetDispatch(dispatch: ComputePassOptions['dispatch']): void {\n\t\tthis.dispatch = dispatch ?? 'auto';\n\t}\n\n\t/**\n\t * Returns current compute shader source.\n\t */\n\tgetCompute(): string {\n\t\treturn this.compute;\n\t}\n\n\t/**\n\t * Returns parsed workgroup size from current compute shader.\n\t */\n\tgetWorkgroupSize(): [number, number, number] {\n\t\treturn [...this.workgroupSize];\n\t}\n\n\t/**\n\t * Resolves dispatch workgroup counts for current frame.\n\t *\n\t * @param ctx - Dispatch context with canvas dimensions and timing.\n\t * @returns Tuple [x, y, z] workgroup counts.\n\t */\n\tresolveDispatch(ctx: ComputeDispatchContext): [number, number, number] {\n\t\tif (this.dispatch === 'auto') {\n\t\t\treturn [\n\t\t\t\tMath.ceil(ctx.width / this.workgroupSize[0]),\n\t\t\t\tMath.ceil(ctx.height / this.workgroupSize[1]),\n\t\t\t\tMath.ceil(1 / this.workgroupSize[2])\n\t\t\t];\n\t\t}\n\n\t\tif (typeof this.dispatch === 'function') {\n\t\t\treturn this.dispatch(ctx);\n\t\t}\n\n\t\tif (Array.isArray(this.dispatch)) {\n\t\t\treturn [this.dispatch[0], this.dispatch[1] ?? 1, this.dispatch[2] ?? 1];\n\t\t}\n\n\t\treturn [1, 1, 1];\n\t}\n\n\t/**\n\t * Releases resources (no-op since GPU resource lifecycle is renderer-managed).\n\t */\n\tdispose(): void {\n\t\t// No-op — GPU resources are managed by the renderer.\n\t}\n}\n"],"mappings":";;;;;;;;;AA6CA,IAAa,cAAb,MAAyB;;;;CAIxB;;;;CAKA,YAAqB;CAErB;CACA;CACA;CAEA,YAAY,SAA6B;AACxC,wBAAsB,QAAQ,QAAQ;EACtC,MAAM,gBAAgB,qBAAqB,QAAQ,QAAQ;AAC3D,OAAK,UAAU,QAAQ;AACvB,OAAK,gBAAgB;AACrB,OAAK,WAAW,QAAQ,YAAY;AACpC,OAAK,UAAU,QAAQ,WAAW;;;;;;;;CASnC,WAAW,SAAuB;AACjC,wBAAsB,QAAQ;EAC9B,MAAM,gBAAgB,qBAAqB,QAAQ;AACnD,OAAK,UAAU;AACf,OAAK,gBAAgB;;;;;CAMtB,YAAY,UAAgD;AAC3D,OAAK,WAAW,YAAY;;;;;CAM7B,aAAqB;AACpB,SAAO,KAAK;;;;;CAMb,mBAA6C;AAC5C,SAAO,CAAC,GAAG,KAAK,cAAc;;;;;;;;CAS/B,gBAAgB,KAAuD;AACtE,MAAI,KAAK,aAAa,OACrB,QAAO;GACN,KAAK,KAAK,IAAI,QAAQ,KAAK,cAAc,GAAG;GAC5C,KAAK,KAAK,IAAI,SAAS,KAAK,cAAc,GAAG;GAC7C,KAAK,KAAK,IAAI,KAAK,cAAc,GAAG;GACpC;AAGF,MAAI,OAAO,KAAK,aAAa,WAC5B,QAAO,KAAK,SAAS,IAAI;AAG1B,MAAI,MAAM,QAAQ,KAAK,SAAS,CAC/B,QAAO;GAAC,KAAK,SAAS;GAAI,KAAK,SAAS,MAAM;GAAG,KAAK,SAAS,MAAM;GAAE;AAGxE,SAAO;GAAC;GAAG;GAAG;GAAE;;;;;CAMjB,UAAgB"}
@@ -0,0 +1,104 @@
1
+ import type { ComputePassOptions, ComputeDispatchContext } from './ComputePass.js';
2
+ /**
3
+ * Options for constructing a `PingPongComputePass`.
4
+ */
5
+ export interface PingPongComputePassOptions {
6
+ /**
7
+ * Compute shader WGSL source code.
8
+ */
9
+ compute: string;
10
+ /**
11
+ * Target texture key from `material.textures`.
12
+ * The engine will auto-generate `{target}A` and `{target}B` bindings.
13
+ */
14
+ target: string;
15
+ /**
16
+ * Number of compute iterations per frame. Default: 1.
17
+ */
18
+ iterations?: number;
19
+ /**
20
+ * Dispatch workgroup counts (same as ComputePass).
21
+ */
22
+ dispatch?: ComputePassOptions['dispatch'];
23
+ /**
24
+ * Enables/disables this pass.
25
+ */
26
+ enabled?: boolean;
27
+ }
28
+ /**
29
+ * Ping-pong compute pass for iterative GPU simulations.
30
+ *
31
+ * Manages two texture buffers (A/B) and alternates between them each iteration,
32
+ * enabling read-from-previous-write patterns commonly used in fluid simulations,
33
+ * reaction-diffusion, and particle systems.
34
+ */
35
+ export declare class PingPongComputePass {
36
+ /**
37
+ * Enables/disables this pass without removing it from graph.
38
+ */
39
+ enabled: boolean;
40
+ /**
41
+ * Discriminant flag for render graph to identify compute passes.
42
+ */
43
+ readonly isCompute: true;
44
+ /**
45
+ * Discriminant flag to identify ping-pong compute passes.
46
+ */
47
+ readonly isPingPong: true;
48
+ private compute;
49
+ private target;
50
+ private iterations;
51
+ private dispatch;
52
+ private workgroupSize;
53
+ private frameCount;
54
+ constructor(options: PingPongComputePassOptions);
55
+ private static assertIterations;
56
+ /**
57
+ * Returns the texture key holding the latest result.
58
+ * Alternates between `{target}A` and `{target}B` based on total iteration parity.
59
+ */
60
+ getCurrentOutput(): string;
61
+ /**
62
+ * Advances the internal frame counter (called by renderer after each frame's iterations).
63
+ */
64
+ advanceFrame(): void;
65
+ /**
66
+ * Replaces compute shader and updates workgroup size.
67
+ */
68
+ setCompute(compute: string): void;
69
+ /**
70
+ * Updates iteration count.
71
+ *
72
+ * @param count - Must be >= 1.
73
+ */
74
+ setIterations(count: number): void;
75
+ /**
76
+ * Updates dispatch strategy.
77
+ */
78
+ setDispatch(dispatch: ComputePassOptions['dispatch']): void;
79
+ /**
80
+ * Returns the target texture key.
81
+ */
82
+ getTarget(): string;
83
+ /**
84
+ * Returns the current iteration count.
85
+ */
86
+ getIterations(): number;
87
+ /**
88
+ * Returns current compute shader source.
89
+ */
90
+ getCompute(): string;
91
+ /**
92
+ * Returns parsed workgroup size.
93
+ */
94
+ getWorkgroupSize(): [number, number, number];
95
+ /**
96
+ * Resolves dispatch workgroup counts for current frame.
97
+ */
98
+ resolveDispatch(ctx: ComputeDispatchContext): [number, number, number];
99
+ /**
100
+ * Releases resources (no-op, GPU lifecycle is renderer-managed).
101
+ */
102
+ dispose(): void;
103
+ }
104
+ //# sourceMappingURL=PingPongComputePass.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PingPongComputePass.d.ts","sourceRoot":"","sources":["../../src/lib/passes/PingPongComputePass.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAEnF;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC;I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+ * Ping-pong compute pass for iterative GPU simulations.
5
+ *
6
+ * Manages two texture buffers (A/B) and alternates between them each iteration,
7
+ * enabling read-from-previous-write patterns commonly used in fluid simulations,
8
+ * reaction-diffusion, and particle systems.
9
+ */
10
+ var PingPongComputePass = class PingPongComputePass {
11
+ /**
12
+ * Enables/disables this pass without removing it from graph.
13
+ */
14
+ enabled;
15
+ /**
16
+ * Discriminant flag for render graph to identify compute passes.
17
+ */
18
+ isCompute = true;
19
+ /**
20
+ * Discriminant flag to identify ping-pong compute passes.
21
+ */
22
+ isPingPong = true;
23
+ compute;
24
+ target;
25
+ iterations;
26
+ dispatch;
27
+ workgroupSize;
28
+ frameCount = 0;
29
+ constructor(options) {
30
+ assertComputeContract(options.compute);
31
+ const workgroupSize = extractWorkgroupSize(options.compute);
32
+ this.compute = options.compute;
33
+ this.target = options.target;
34
+ this.iterations = PingPongComputePass.assertIterations(options.iterations ?? 1);
35
+ this.dispatch = options.dispatch ?? "auto";
36
+ this.enabled = options.enabled ?? true;
37
+ this.workgroupSize = workgroupSize;
38
+ }
39
+ static assertIterations(count) {
40
+ if (!Number.isFinite(count) || count < 1 || !Number.isInteger(count)) throw new Error(`PingPongComputePass iterations must be a positive integer >= 1, got ${count}`);
41
+ return count;
42
+ }
43
+ /**
44
+ * Returns the texture key holding the latest result.
45
+ * Alternates between `{target}A` and `{target}B` based on total iteration parity.
46
+ */
47
+ getCurrentOutput() {
48
+ return this.frameCount * this.iterations % 2 === 0 ? `${this.target}A` : `${this.target}B`;
49
+ }
50
+ /**
51
+ * Advances the internal frame counter (called by renderer after each frame's iterations).
52
+ */
53
+ advanceFrame() {
54
+ this.frameCount += 1;
55
+ }
56
+ /**
57
+ * Replaces compute shader and updates workgroup size.
58
+ */
59
+ setCompute(compute) {
60
+ assertComputeContract(compute);
61
+ const workgroupSize = extractWorkgroupSize(compute);
62
+ this.compute = compute;
63
+ this.workgroupSize = workgroupSize;
64
+ }
65
+ /**
66
+ * Updates iteration count.
67
+ *
68
+ * @param count - Must be >= 1.
69
+ */
70
+ setIterations(count) {
71
+ this.iterations = PingPongComputePass.assertIterations(count);
72
+ }
73
+ /**
74
+ * Updates dispatch strategy.
75
+ */
76
+ setDispatch(dispatch) {
77
+ this.dispatch = dispatch ?? "auto";
78
+ }
79
+ /**
80
+ * Returns the target texture key.
81
+ */
82
+ getTarget() {
83
+ return this.target;
84
+ }
85
+ /**
86
+ * Returns the current iteration count.
87
+ */
88
+ getIterations() {
89
+ return this.iterations;
90
+ }
91
+ /**
92
+ * Returns current compute shader source.
93
+ */
94
+ getCompute() {
95
+ return this.compute;
96
+ }
97
+ /**
98
+ * Returns parsed workgroup size.
99
+ */
100
+ getWorkgroupSize() {
101
+ return [...this.workgroupSize];
102
+ }
103
+ /**
104
+ * Resolves dispatch workgroup counts for current frame.
105
+ */
106
+ resolveDispatch(ctx) {
107
+ if (this.dispatch === "auto") return [
108
+ Math.ceil(ctx.width / this.workgroupSize[0]),
109
+ Math.ceil(ctx.height / this.workgroupSize[1]),
110
+ Math.ceil(1 / this.workgroupSize[2])
111
+ ];
112
+ if (typeof this.dispatch === "function") return this.dispatch(ctx);
113
+ if (Array.isArray(this.dispatch)) return [
114
+ this.dispatch[0],
115
+ this.dispatch[1] ?? 1,
116
+ this.dispatch[2] ?? 1
117
+ ];
118
+ return [
119
+ 1,
120
+ 1,
121
+ 1
122
+ ];
123
+ }
124
+ /**
125
+ * Releases resources (no-op, GPU lifecycle is renderer-managed).
126
+ */
127
+ dispose() {}
128
+ };
129
+ //#endregion
130
+ export { PingPongComputePass };
131
+
132
+ //# sourceMappingURL=PingPongComputePass.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PingPongComputePass.js","names":[],"sources":["../../src/lib/passes/PingPongComputePass.ts"],"sourcesContent":["import { assertComputeContract, extractWorkgroupSize } from '../core/compute-shader.js';\nimport type { ComputePassOptions, ComputeDispatchContext } from './ComputePass.js';\n\n/**\n * Options for constructing a `PingPongComputePass`.\n */\nexport interface PingPongComputePassOptions {\n\t/**\n\t * Compute shader WGSL source code.\n\t */\n\tcompute: string;\n\t/**\n\t * Target texture key from `material.textures`.\n\t * The engine will auto-generate `{target}A` and `{target}B` bindings.\n\t */\n\ttarget: string;\n\t/**\n\t * Number of compute iterations per frame. Default: 1.\n\t */\n\titerations?: number;\n\t/**\n\t * Dispatch workgroup counts (same as ComputePass).\n\t */\n\tdispatch?: ComputePassOptions['dispatch'];\n\t/**\n\t * Enables/disables this pass.\n\t */\n\tenabled?: boolean;\n}\n\n/**\n * Ping-pong compute pass for iterative GPU simulations.\n *\n * Manages two texture buffers (A/B) and alternates between them each iteration,\n * enabling read-from-previous-write patterns commonly used in fluid simulations,\n * reaction-diffusion, and particle systems.\n */\nexport class PingPongComputePass {\n\t/**\n\t * Enables/disables this pass without removing it from graph.\n\t */\n\tenabled: boolean;\n\n\t/**\n\t * Discriminant flag for render graph to identify compute passes.\n\t */\n\treadonly isCompute = true as const;\n\n\t/**\n\t * Discriminant flag to identify ping-pong compute passes.\n\t */\n\treadonly isPingPong = true as const;\n\n\tprivate compute: string;\n\tprivate target: string;\n\tprivate iterations: number;\n\tprivate dispatch: ComputePassOptions['dispatch'];\n\tprivate workgroupSize: [number, number, number];\n\tprivate frameCount: number = 0;\n\n\tconstructor(options: PingPongComputePassOptions) {\n\t\tassertComputeContract(options.compute);\n\t\tconst workgroupSize = extractWorkgroupSize(options.compute);\n\t\tthis.compute = options.compute;\n\t\tthis.target = options.target;\n\t\tthis.iterations = PingPongComputePass.assertIterations(options.iterations ?? 1);\n\t\tthis.dispatch = options.dispatch ?? 'auto';\n\t\tthis.enabled = options.enabled ?? true;\n\t\tthis.workgroupSize = workgroupSize;\n\t}\n\n\tprivate static assertIterations(count: number): number {\n\t\tif (!Number.isFinite(count) || count < 1 || !Number.isInteger(count)) {\n\t\t\tthrow new Error(\n\t\t\t\t`PingPongComputePass iterations must be a positive integer >= 1, got ${count}`\n\t\t\t);\n\t\t}\n\t\treturn count;\n\t}\n\n\t/**\n\t * Returns the texture key holding the latest result.\n\t * Alternates between `{target}A` and `{target}B` based on total iteration parity.\n\t */\n\tgetCurrentOutput(): string {\n\t\tconst totalIterations = this.frameCount * this.iterations;\n\t\treturn totalIterations % 2 === 0 ? `${this.target}A` : `${this.target}B`;\n\t}\n\n\t/**\n\t * Advances the internal frame counter (called by renderer after each frame's iterations).\n\t */\n\tadvanceFrame(): void {\n\t\tthis.frameCount += 1;\n\t}\n\n\t/**\n\t * Replaces compute shader and updates workgroup size.\n\t */\n\tsetCompute(compute: string): void {\n\t\tassertComputeContract(compute);\n\t\tconst workgroupSize = extractWorkgroupSize(compute);\n\t\tthis.compute = compute;\n\t\tthis.workgroupSize = workgroupSize;\n\t}\n\n\t/**\n\t * Updates iteration count.\n\t *\n\t * @param count - Must be >= 1.\n\t */\n\tsetIterations(count: number): void {\n\t\tthis.iterations = PingPongComputePass.assertIterations(count);\n\t}\n\n\t/**\n\t * Updates dispatch strategy.\n\t */\n\tsetDispatch(dispatch: ComputePassOptions['dispatch']): void {\n\t\tthis.dispatch = dispatch ?? 'auto';\n\t}\n\n\t/**\n\t * Returns the target texture key.\n\t */\n\tgetTarget(): string {\n\t\treturn this.target;\n\t}\n\n\t/**\n\t * Returns the current iteration count.\n\t */\n\tgetIterations(): number {\n\t\treturn this.iterations;\n\t}\n\n\t/**\n\t * Returns current compute shader source.\n\t */\n\tgetCompute(): string {\n\t\treturn this.compute;\n\t}\n\n\t/**\n\t * Returns parsed workgroup size.\n\t */\n\tgetWorkgroupSize(): [number, number, number] {\n\t\treturn [...this.workgroupSize];\n\t}\n\n\t/**\n\t * Resolves dispatch workgroup counts for current frame.\n\t */\n\tresolveDispatch(ctx: ComputeDispatchContext): [number, number, number] {\n\t\tif (this.dispatch === 'auto') {\n\t\t\treturn [\n\t\t\t\tMath.ceil(ctx.width / this.workgroupSize[0]),\n\t\t\t\tMath.ceil(ctx.height / this.workgroupSize[1]),\n\t\t\t\tMath.ceil(1 / this.workgroupSize[2])\n\t\t\t];\n\t\t}\n\n\t\tif (typeof this.dispatch === 'function') {\n\t\t\treturn this.dispatch(ctx);\n\t\t}\n\n\t\tif (Array.isArray(this.dispatch)) {\n\t\t\treturn [this.dispatch[0], this.dispatch[1] ?? 1, this.dispatch[2] ?? 1];\n\t\t}\n\n\t\treturn [1, 1, 1];\n\t}\n\n\t/**\n\t * Releases resources (no-op, GPU lifecycle is renderer-managed).\n\t */\n\tdispose(): void {\n\t\t// No-op\n\t}\n}\n"],"mappings":";;;;;;;;;AAqCA,IAAa,sBAAb,MAAa,oBAAoB;;;;CAIhC;;;;CAKA,YAAqB;;;;CAKrB,aAAsB;CAEtB;CACA;CACA;CACA;CACA;CACA,aAA6B;CAE7B,YAAY,SAAqC;AAChD,wBAAsB,QAAQ,QAAQ;EACtC,MAAM,gBAAgB,qBAAqB,QAAQ,QAAQ;AAC3D,OAAK,UAAU,QAAQ;AACvB,OAAK,SAAS,QAAQ;AACtB,OAAK,aAAa,oBAAoB,iBAAiB,QAAQ,cAAc,EAAE;AAC/E,OAAK,WAAW,QAAQ,YAAY;AACpC,OAAK,UAAU,QAAQ,WAAW;AAClC,OAAK,gBAAgB;;CAGtB,OAAe,iBAAiB,OAAuB;AACtD,MAAI,CAAC,OAAO,SAAS,MAAM,IAAI,QAAQ,KAAK,CAAC,OAAO,UAAU,MAAM,CACnE,OAAM,IAAI,MACT,uEAAuE,QACvE;AAEF,SAAO;;;;;;CAOR,mBAA2B;AAE1B,SADwB,KAAK,aAAa,KAAK,aACtB,MAAM,IAAI,GAAG,KAAK,OAAO,KAAK,GAAG,KAAK,OAAO;;;;;CAMvE,eAAqB;AACpB,OAAK,cAAc;;;;;CAMpB,WAAW,SAAuB;AACjC,wBAAsB,QAAQ;EAC9B,MAAM,gBAAgB,qBAAqB,QAAQ;AACnD,OAAK,UAAU;AACf,OAAK,gBAAgB;;;;;;;CAQtB,cAAc,OAAqB;AAClC,OAAK,aAAa,oBAAoB,iBAAiB,MAAM;;;;;CAM9D,YAAY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AqB,IAAI,MAAM;CAGzC"}
1
+ {"version":3,"file":"ShaderPass.d.ts","sourceRoot":"","sources":["../../src/lib/passes/ShaderPass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAKjF,MAAM,WAAW,iBAAkB,SAAQ,qBAAqB;IAC/D,QAAQ,EAAE,MAAM,CAAC;CACjB;AA2CD;;GAEG;AACH,qBAAa,UAAW,SAAQ,cAAc;IAC7C,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE,iBAAiB;IAMtC;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAOnC,WAAW,IAAI,MAAM;IAIrB,SAAS,CAAC,UAAU,IAAI,MAAM;IAI9B,SAAS,CAAC,mBAAmB,IAAI,MAAM;IAIvC,SAAS,CAAC,qBAAqB,IAAI,MAAM;CAGzC"}
@@ -51,8 +51,9 @@ var ShaderPass = class extends FullscreenPass {
51
51
  * Replaces current shader fragment and invalidates pipeline cache.
52
52
  */
53
53
  setFragment(fragment) {
54
+ const nextProgram = buildShaderPassProgram(fragment);
54
55
  this.fragment = fragment;
55
- this.program = buildShaderPassProgram(fragment);
56
+ this.program = nextProgram;
56
57
  this.invalidateFullscreenCache();
57
58
  }
58
59
  getFragment() {
@@ -1 +1 @@
1
- {"version":3,"file":"ShaderPass.js","names":[],"sources":["../../src/lib/passes/ShaderPass.ts"],"sourcesContent":["import { FullscreenPass, type FullscreenPassOptions } from './FullscreenPass.js';\n\nconst SHADER_PASS_CONTRACT =\n\t/\\bfn\\s+shade\\s*\\(\\s*inputColor\\s*:\\s*vec4f\\s*,\\s*uv\\s*:\\s*vec2f\\s*\\)\\s*->\\s*vec4f/;\n\nexport interface ShaderPassOptions extends FullscreenPassOptions {\n\tfragment: string;\n}\n\nfunction buildShaderPassProgram(fragment: string): string {\n\tif (!SHADER_PASS_CONTRACT.test(fragment)) {\n\t\tthrow new Error(\n\t\t\t'ShaderPass fragment must declare `fn shade(inputColor: vec4f, uv: vec2f) -> vec4f`.'\n\t\t);\n\t}\n\n\treturn `\nstruct MotionGPUVertexOut {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n};\n\n@group(0) @binding(0) var motiongpuShaderPassSampler: sampler;\n@group(0) @binding(1) var motiongpuShaderPassTexture: texture_2d<f32>;\n\n@vertex\nfn motiongpuShaderPassVertex(@builtin(vertex_index) index: u32) -> MotionGPUVertexOut {\n\tvar positions = array<vec2f, 3>(\n\t\tvec2f(-1.0, -3.0),\n\t\tvec2f(-1.0, 1.0),\n\t\tvec2f(3.0, 1.0)\n\t);\n\n\tlet position = positions[index];\n\tvar out: MotionGPUVertexOut;\n\tout.position = vec4f(position, 0.0, 1.0);\n\tout.uv = (position + vec2f(1.0, 1.0)) * 0.5;\n\treturn out;\n}\n\n${fragment}\n\n@fragment\nfn motiongpuShaderPassFragment(in: MotionGPUVertexOut) -> @location(0) vec4f {\n\tlet inputColor = textureSample(motiongpuShaderPassTexture, motiongpuShaderPassSampler, in.uv);\n\treturn shade(inputColor, in.uv);\n}\n`;\n}\n\n/**\n * Fullscreen programmable shader pass.\n */\nexport class ShaderPass extends FullscreenPass {\n\tprivate fragment: string;\n\tprivate program: string;\n\n\tconstructor(options: ShaderPassOptions) {\n\t\tsuper(options);\n\t\tthis.fragment = options.fragment;\n\t\tthis.program = buildShaderPassProgram(options.fragment);\n\t}\n\n\t/**\n\t * Replaces current shader fragment and invalidates pipeline cache.\n\t */\n\tsetFragment(fragment: string): void {\n\t\tthis.fragment = fragment;\n\t\tthis.program = buildShaderPassProgram(fragment);\n\t\tthis.invalidateFullscreenCache();\n\t}\n\n\tgetFragment(): string {\n\t\treturn this.fragment;\n\t}\n\n\tprotected getProgram(): string {\n\t\treturn this.program;\n\t}\n\n\tprotected getVertexEntryPoint(): string {\n\t\treturn 'motiongpuShaderPassVertex';\n\t}\n\n\tprotected getFragmentEntryPoint(): string {\n\t\treturn 'motiongpuShaderPassFragment';\n\t}\n}\n"],"mappings":";;AAEA,IAAM,uBACL;AAMD,SAAS,uBAAuB,UAA0B;AACzD,KAAI,CAAC,qBAAqB,KAAK,SAAS,CACvC,OAAM,IAAI,MACT,sFACA;AAGF,QAAO;;;;;;;;;;;;;;;;;;;;;;;;EAwBN,SAAS;;;;;;;;;;;;AAaX,IAAa,aAAb,cAAgC,eAAe;CAC9C;CACA;CAEA,YAAY,SAA4B;AACvC,QAAM,QAAQ;AACd,OAAK,WAAW,QAAQ;AACxB,OAAK,UAAU,uBAAuB,QAAQ,SAAS;;;;;CAMxD,YAAY,UAAwB;AACnC,OAAK,WAAW;AAChB,OAAK,UAAU,uBAAuB,SAAS;AAC/C,OAAK,2BAA2B;;CAGjC,cAAsB;AACrB,SAAO,KAAK;;CAGb,aAA+B;AAC9B,SAAO,KAAK;;CAGb,sBAAwC;AACvC,SAAO;;CAGR,wBAA0C;AACzC,SAAO"}
1
+ {"version":3,"file":"ShaderPass.js","names":[],"sources":["../../src/lib/passes/ShaderPass.ts"],"sourcesContent":["import { FullscreenPass, type FullscreenPassOptions } from './FullscreenPass.js';\n\nconst SHADER_PASS_CONTRACT =\n\t/\\bfn\\s+shade\\s*\\(\\s*inputColor\\s*:\\s*vec4f\\s*,\\s*uv\\s*:\\s*vec2f\\s*\\)\\s*->\\s*vec4f/;\n\nexport interface ShaderPassOptions extends FullscreenPassOptions {\n\tfragment: string;\n}\n\nfunction buildShaderPassProgram(fragment: string): string {\n\tif (!SHADER_PASS_CONTRACT.test(fragment)) {\n\t\tthrow new Error(\n\t\t\t'ShaderPass fragment must declare `fn shade(inputColor: vec4f, uv: vec2f) -> vec4f`.'\n\t\t);\n\t}\n\n\treturn `\nstruct MotionGPUVertexOut {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n};\n\n@group(0) @binding(0) var motiongpuShaderPassSampler: sampler;\n@group(0) @binding(1) var motiongpuShaderPassTexture: texture_2d<f32>;\n\n@vertex\nfn motiongpuShaderPassVertex(@builtin(vertex_index) index: u32) -> MotionGPUVertexOut {\n\tvar positions = array<vec2f, 3>(\n\t\tvec2f(-1.0, -3.0),\n\t\tvec2f(-1.0, 1.0),\n\t\tvec2f(3.0, 1.0)\n\t);\n\n\tlet position = positions[index];\n\tvar out: MotionGPUVertexOut;\n\tout.position = vec4f(position, 0.0, 1.0);\n\tout.uv = (position + vec2f(1.0, 1.0)) * 0.5;\n\treturn out;\n}\n\n${fragment}\n\n@fragment\nfn motiongpuShaderPassFragment(in: MotionGPUVertexOut) -> @location(0) vec4f {\n\tlet inputColor = textureSample(motiongpuShaderPassTexture, motiongpuShaderPassSampler, in.uv);\n\treturn shade(inputColor, in.uv);\n}\n`;\n}\n\n/**\n * Fullscreen programmable shader pass.\n */\nexport class ShaderPass extends FullscreenPass {\n\tprivate fragment: string;\n\tprivate program: string;\n\n\tconstructor(options: ShaderPassOptions) {\n\t\tsuper(options);\n\t\tthis.fragment = options.fragment;\n\t\tthis.program = buildShaderPassProgram(options.fragment);\n\t}\n\n\t/**\n\t * Replaces current shader fragment and invalidates pipeline cache.\n\t */\n\tsetFragment(fragment: string): void {\n\t\tconst nextProgram = buildShaderPassProgram(fragment);\n\t\tthis.fragment = fragment;\n\t\tthis.program = nextProgram;\n\t\tthis.invalidateFullscreenCache();\n\t}\n\n\tgetFragment(): string {\n\t\treturn this.fragment;\n\t}\n\n\tprotected getProgram(): string {\n\t\treturn this.program;\n\t}\n\n\tprotected getVertexEntryPoint(): string {\n\t\treturn 'motiongpuShaderPassVertex';\n\t}\n\n\tprotected getFragmentEntryPoint(): string {\n\t\treturn 'motiongpuShaderPassFragment';\n\t}\n}\n"],"mappings":";;AAEA,IAAM,uBACL;AAMD,SAAS,uBAAuB,UAA0B;AACzD,KAAI,CAAC,qBAAqB,KAAK,SAAS,CACvC,OAAM,IAAI,MACT,sFACA;AAGF,QAAO;;;;;;;;;;;;;;;;;;;;;;;;EAwBN,SAAS;;;;;;;;;;;;AAaX,IAAa,aAAb,cAAgC,eAAe;CAC9C;CACA;CAEA,YAAY,SAA4B;AACvC,QAAM,QAAQ;AACd,OAAK,WAAW,QAAQ;AACxB,OAAK,UAAU,uBAAuB,QAAQ,SAAS;;;;;CAMxD,YAAY,UAAwB;EACnC,MAAM,cAAc,uBAAuB,SAAS;AACpD,OAAK,WAAW;AAChB,OAAK,UAAU;AACf,OAAK,2BAA2B;;CAGjC,cAAsB;AACrB,SAAO,KAAK;;CAGb,aAA+B;AAC9B,SAAO,KAAK;;CAGb,sBAAwC;AACvC,SAAO;;CAGR,wBAA0C;AACzC,SAAO"}
@@ -1,4 +1,6 @@
1
1
  export { BlitPass, type BlitPassOptions } from './BlitPass.js';
2
2
  export { CopyPass, type CopyPassOptions } from './CopyPass.js';
3
3
  export { ShaderPass, type ShaderPassOptions } from './ShaderPass.js';
4
+ export { ComputePass, type ComputePassOptions, type ComputeDispatchContext } from './ComputePass.js';
5
+ export { PingPongComputePass, type PingPongComputePassOptions } from './PingPongComputePass.js';
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/passes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/passes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EACN,WAAW,EACX,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,KAAK,0BAA0B,EAAE,MAAM,0BAA0B,CAAC"}
@@ -1,4 +1,6 @@
1
1
  import { BlitPass } from "./BlitPass.js";
2
2
  import { CopyPass } from "./CopyPass.js";
3
3
  import { ShaderPass } from "./ShaderPass.js";
4
- export { BlitPass, CopyPass, ShaderPass };
4
+ import { ComputePass } from "./ComputePass.js";
5
+ import { PingPongComputePass } from "./PingPongComputePass.js";
6
+ export { BlitPass, ComputePass, CopyPass, PingPongComputePass, ShaderPass };
@@ -1,12 +1,12 @@
1
1
  /// <reference types="@webgpu/types" />
2
2
  import { type MotionGPUErrorReport } from '../core/error-report.js';
3
3
  import type { FragMaterial } from '../core/material.js';
4
- import type { OutputColorSpace, RenderPass, RenderMode, RenderTargetDefinitionMap } from '../core/types.js';
4
+ import type { AnyPass, OutputColorSpace, RenderMode, RenderTargetDefinitionMap } from '../core/types.js';
5
5
  import { type CSSProperties, type ReactNode } from 'react';
6
6
  export interface FragCanvasProps {
7
7
  material: FragMaterial;
8
8
  renderTargets?: RenderTargetDefinitionMap;
9
- passes?: RenderPass[];
9
+ passes?: AnyPass[];
10
10
  clearColor?: [number, number, number, number];
11
11
  outputColorSpace?: OutputColorSpace;
12
12
  renderMode?: RenderMode;
@@ -1 +1 @@
1
- {"version":3,"file":"FragCanvas.d.ts","sourceRoot":"","sources":["../../src/lib/react/FragCanvas.tsx"],"names":[],"mappings":";AACA,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC5F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,KAAK,EACX,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,yBAAyB,EACzB,MAAM,kBAAkB,CAAC;AA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AAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACrB;AA0HD,wBAAgB,UAAU,CAAC,EAC1B,QAAQ,EACR,aAAkB,EAClB,MAAW,EACX,UAAyB,EACzB,gBAAyB,EACzB,UAAqB,EACrB,UAAiB,EACjB,QAAc,EACd,cAA0B,EAC1B,gBAA4B,EAC5B,GAAqB,EACrB,gBAAuB,EACvB,aAAa,EACb,OAAmB,EACnB,iBAAqB,EACrB,cAA0B,EAC1B,SAAc,EACd,KAAK,EACL,QAAQ,EACR,EAAE,eAAe,2CAsKjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"FragCanvas.js","names":[],"sources":["../../src/lib/react/FragCanvas.tsx"],"sourcesContent":["import { createCurrentWritable as currentWritable } from '../core/current-value.js';\nimport { toMotionGPUErrorReport, type MotionGPUErrorReport } from '../core/error-report.js';\nimport type { FragMaterial } from '../core/material.js';\nimport { createFrameRegistry } from '../core/frame-registry.js';\nimport { createMotionGPURuntimeLoop } from '../core/runtime-loop.js';\nimport type {\n\tOutputColorSpace,\n\tRenderPass,\n\tRenderMode,\n\tRenderTargetDefinitionMap\n} from '../core/types.js';\nimport { useEffect, useRef, useState, type CSSProperties, type ReactNode } from 'react';\nimport { FrameRegistryReactContext } from './frame-context.js';\nimport { MotionGPUErrorOverlay } from './MotionGPUErrorOverlay.js';\nimport { MotionGPUReactContext, type MotionGPUContext } from './motiongpu-context.js';\n\nexport interface FragCanvasProps {\n\tmaterial: FragMaterial;\n\trenderTargets?: RenderTargetDefinitionMap;\n\tpasses?: RenderPass[];\n\tclearColor?: [number, number, number, number];\n\toutputColorSpace?: OutputColorSpace;\n\trenderMode?: RenderMode;\n\tautoRender?: boolean;\n\tmaxDelta?: number;\n\tadapterOptions?: GPURequestAdapterOptions;\n\tdeviceDescriptor?: GPUDeviceDescriptor;\n\tdpr?: number;\n\tshowErrorOverlay?: boolean;\n\terrorRenderer?: (report: MotionGPUErrorReport) => ReactNode;\n\tonError?: (report: MotionGPUErrorReport) => void;\n\terrorHistoryLimit?: number;\n\tonErrorHistory?: (history: MotionGPUErrorReport[]) => void;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tchildren?: ReactNode;\n}\n\ninterface RuntimePropsSnapshot {\n\tmaterial: FragMaterial;\n\trenderTargets: RenderTargetDefinitionMap;\n\tpasses: RenderPass[];\n\tclearColor: [number, number, number, number];\n\toutputColorSpace: OutputColorSpace;\n\tadapterOptions: GPURequestAdapterOptions | undefined;\n\tdeviceDescriptor: GPUDeviceDescriptor | undefined;\n\tonError: ((report: MotionGPUErrorReport) => void) | undefined;\n\terrorHistoryLimit: number;\n\tonErrorHistory: ((history: MotionGPUErrorReport[]) => void) | undefined;\n}\n\ninterface FragCanvasRuntimeState {\n\tregistry: ReturnType<typeof createFrameRegistry>;\n\tcontext: MotionGPUContext;\n\tcanvasRef: { current: HTMLCanvasElement | undefined };\n\tsize: ReturnType<typeof currentWritable<{ width: number; height: number }>>;\n\tdprState: ReturnType<typeof currentWritable<number>>;\n\tmaxDeltaState: ReturnType<typeof currentWritable<number>>;\n\trenderModeState: ReturnType<typeof currentWritable<RenderMode>>;\n\tautoRenderState: ReturnType<typeof currentWritable<boolean>>;\n\trequestFrameSignalRef: { current: (() => void) | null };\n\trequestFrame: () => void;\n\tinvalidateFrame: () => void;\n\tadvanceFrame: () => void;\n}\n\nfunction getInitialDpr(): number {\n\tif (typeof window === 'undefined') {\n\t\treturn 1;\n\t}\n\n\treturn window.devicePixelRatio ?? 1;\n}\n\nfunction createRuntimeState(initialDpr: number): FragCanvasRuntimeState {\n\tconst registry = createFrameRegistry({ maxDelta: 0.1 });\n\tconst canvasRef = { current: undefined as HTMLCanvasElement | undefined };\n\tconst requestFrameSignalRef = { current: null as (() => void) | null };\n\tconst requestFrame = (): void => {\n\t\trequestFrameSignalRef.current?.();\n\t};\n\tconst invalidateFrame = (): void => {\n\t\tregistry.invalidate();\n\t\trequestFrame();\n\t};\n\tconst advanceFrame = (): void => {\n\t\tregistry.advance();\n\t\trequestFrame();\n\t};\n\n\tconst size = currentWritable({ width: 0, height: 0 });\n\tconst dprState = currentWritable(initialDpr, requestFrame);\n\tconst maxDeltaState = currentWritable(0.1, (value) => {\n\t\tregistry.setMaxDelta(value);\n\t\trequestFrame();\n\t});\n\tconst renderModeState = currentWritable<RenderMode>('always', (value) => {\n\t\tregistry.setRenderMode(value);\n\t\trequestFrame();\n\t});\n\tconst autoRenderState = currentWritable<boolean>(true, (value) => {\n\t\tregistry.setAutoRender(value);\n\t\trequestFrame();\n\t});\n\tconst userState = currentWritable<Record<string | symbol, unknown>>({});\n\n\tconst context: MotionGPUContext = {\n\t\tget canvas() {\n\t\t\treturn canvasRef.current;\n\t\t},\n\t\tsize,\n\t\tdpr: dprState,\n\t\tmaxDelta: maxDeltaState,\n\t\trenderMode: renderModeState,\n\t\tautoRender: autoRenderState,\n\t\tuser: userState,\n\t\tinvalidate: invalidateFrame,\n\t\tadvance: advanceFrame,\n\t\tscheduler: {\n\t\t\tcreateStage: registry.createStage,\n\t\t\tgetStage: registry.getStage,\n\t\t\tsetDiagnosticsEnabled: registry.setDiagnosticsEnabled,\n\t\t\tgetDiagnosticsEnabled: registry.getDiagnosticsEnabled,\n\t\t\tgetLastRunTimings: registry.getLastRunTimings,\n\t\t\tgetSchedule: registry.getSchedule,\n\t\t\tsetProfilingEnabled: registry.setProfilingEnabled,\n\t\t\tsetProfilingWindow: registry.setProfilingWindow,\n\t\t\tresetProfiling: registry.resetProfiling,\n\t\t\tgetProfilingEnabled: registry.getProfilingEnabled,\n\t\t\tgetProfilingWindow: registry.getProfilingWindow,\n\t\t\tgetProfilingSnapshot: registry.getProfilingSnapshot\n\t\t}\n\t};\n\n\treturn {\n\t\tregistry,\n\t\tcontext,\n\t\tcanvasRef,\n\t\tsize,\n\t\tdprState,\n\t\tmaxDeltaState,\n\t\trenderModeState,\n\t\tautoRenderState,\n\t\trequestFrameSignalRef,\n\t\trequestFrame,\n\t\tinvalidateFrame,\n\t\tadvanceFrame\n\t};\n}\n\nfunction getNormalizedErrorHistoryLimit(value: number): number {\n\tif (!Number.isFinite(value) || value <= 0) {\n\t\treturn 0;\n\t}\n\n\treturn Math.floor(value);\n}\n\nexport function FragCanvas({\n\tmaterial,\n\trenderTargets = {},\n\tpasses = [],\n\tclearColor = [0, 0, 0, 1],\n\toutputColorSpace = 'srgb',\n\trenderMode = 'always',\n\tautoRender = true,\n\tmaxDelta = 0.1,\n\tadapterOptions = undefined,\n\tdeviceDescriptor = undefined,\n\tdpr = getInitialDpr(),\n\tshowErrorOverlay = true,\n\terrorRenderer,\n\tonError = undefined,\n\terrorHistoryLimit = 0,\n\tonErrorHistory = undefined,\n\tclassName = '',\n\tstyle,\n\tchildren\n}: FragCanvasProps) {\n\tconst runtimeRef = useRef<FragCanvasRuntimeState | null>(null);\n\tif (!runtimeRef.current) {\n\t\truntimeRef.current = createRuntimeState(getInitialDpr());\n\t}\n\tconst runtime = runtimeRef.current;\n\n\tconst runtimePropsRef = useRef<RuntimePropsSnapshot>({\n\t\tmaterial,\n\t\trenderTargets,\n\t\tpasses,\n\t\tclearColor,\n\t\toutputColorSpace,\n\t\tadapterOptions,\n\t\tdeviceDescriptor,\n\t\tonError,\n\t\terrorHistoryLimit,\n\t\tonErrorHistory\n\t});\n\truntimePropsRef.current = {\n\t\tmaterial,\n\t\trenderTargets,\n\t\tpasses,\n\t\tclearColor,\n\t\toutputColorSpace,\n\t\tadapterOptions,\n\t\tdeviceDescriptor,\n\t\tonError,\n\t\terrorHistoryLimit,\n\t\tonErrorHistory\n\t};\n\n\tconst [errorReport, setErrorReport] = useState<MotionGPUErrorReport | null>(null);\n\tconst [errorHistory, setErrorHistory] = useState<MotionGPUErrorReport[]>([]);\n\n\tuseEffect(() => {\n\t\truntime.renderModeState.set(renderMode);\n\t}, [renderMode, runtime]);\n\n\tuseEffect(() => {\n\t\truntime.autoRenderState.set(autoRender);\n\t}, [autoRender, runtime]);\n\n\tuseEffect(() => {\n\t\truntime.maxDeltaState.set(maxDelta);\n\t}, [maxDelta, runtime]);\n\n\tuseEffect(() => {\n\t\truntime.dprState.set(dpr);\n\t}, [dpr, runtime]);\n\n\tuseEffect(() => {\n\t\tconst limit = getNormalizedErrorHistoryLimit(errorHistoryLimit);\n\t\tif (limit <= 0) {\n\t\t\tif (errorHistory.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetErrorHistory([]);\n\t\t\tonErrorHistory?.([]);\n\t\t\treturn;\n\t\t}\n\n\t\tif (errorHistory.length <= limit) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst trimmed = errorHistory.slice(errorHistory.length - limit);\n\t\tsetErrorHistory(trimmed);\n\t\tonErrorHistory?.(trimmed);\n\t}, [errorHistory, errorHistoryLimit, onErrorHistory]);\n\n\tuseEffect(() => {\n\t\tconst canvas = runtime.canvasRef.current;\n\t\tif (!canvas) {\n\t\t\tconst report = toMotionGPUErrorReport(\n\t\t\t\tnew Error('Canvas element is not available'),\n\t\t\t\t'initialization'\n\t\t\t);\n\t\t\tsetErrorReport(report);\n\t\t\tconst historyLimit = getNormalizedErrorHistoryLimit(\n\t\t\t\truntimePropsRef.current.errorHistoryLimit\n\t\t\t);\n\t\t\tif (historyLimit > 0) {\n\t\t\t\tconst nextHistory = [report].slice(-historyLimit);\n\t\t\t\tsetErrorHistory(nextHistory);\n\t\t\t\truntimePropsRef.current.onErrorHistory?.(nextHistory);\n\t\t\t}\n\t\t\truntimePropsRef.current.onError?.(report);\n\t\t\treturn () => {\n\t\t\t\truntime.registry.clear();\n\t\t\t};\n\t\t}\n\n\t\tconst runtimeLoop = createMotionGPURuntimeLoop({\n\t\t\tcanvas,\n\t\t\tregistry: runtime.registry,\n\t\t\tsize: runtime.size,\n\t\t\tdpr: runtime.dprState,\n\t\t\tmaxDelta: runtime.maxDeltaState,\n\t\t\tgetMaterial: () => runtimePropsRef.current.material,\n\t\t\tgetRenderTargets: () => runtimePropsRef.current.renderTargets,\n\t\t\tgetPasses: () => runtimePropsRef.current.passes,\n\t\t\tgetClearColor: () => runtimePropsRef.current.clearColor,\n\t\t\tgetOutputColorSpace: () => runtimePropsRef.current.outputColorSpace,\n\t\t\tgetAdapterOptions: () => runtimePropsRef.current.adapterOptions,\n\t\t\tgetDeviceDescriptor: () => runtimePropsRef.current.deviceDescriptor,\n\t\t\tgetOnError: () => runtimePropsRef.current.onError,\n\t\t\tgetErrorHistoryLimit: () => runtimePropsRef.current.errorHistoryLimit,\n\t\t\tgetOnErrorHistory: () => runtimePropsRef.current.onErrorHistory,\n\t\t\treportErrorHistory: (history) => {\n\t\t\t\tsetErrorHistory(history);\n\t\t\t},\n\t\t\treportError: (report) => {\n\t\t\t\tsetErrorReport(report);\n\t\t\t}\n\t\t});\n\t\truntime.requestFrameSignalRef.current = runtimeLoop.requestFrame;\n\n\t\treturn () => {\n\t\t\truntime.requestFrameSignalRef.current = null;\n\t\t\truntimeLoop.destroy();\n\t\t};\n\t}, [runtime]);\n\n\tconst canvasStyle: CSSProperties = {\n\t\tposition: 'absolute',\n\t\tinset: 0,\n\t\tdisplay: 'block',\n\t\twidth: '100%',\n\t\theight: '100%',\n\t\t...style\n\t};\n\n\treturn (\n\t\t<FrameRegistryReactContext.Provider value={runtime.registry}>\n\t\t\t<MotionGPUReactContext.Provider value={runtime.context}>\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"motiongpu-canvas-wrap\"\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tposition: 'relative',\n\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\tminWidth: 0,\n\t\t\t\t\t\tminHeight: 0,\n\t\t\t\t\t\toverflow: 'hidden'\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<canvas\n\t\t\t\t\t\tclassName={className}\n\t\t\t\t\t\tstyle={canvasStyle}\n\t\t\t\t\t\tref={(node) => {\n\t\t\t\t\t\t\truntime.canvasRef.current = node ?? undefined;\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t\t{showErrorOverlay && errorReport ? (\n\t\t\t\t\t\terrorRenderer ? (\n\t\t\t\t\t\t\terrorRenderer(errorReport)\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<MotionGPUErrorOverlay report={errorReport} />\n\t\t\t\t\t\t)\n\t\t\t\t\t) : null}\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t</MotionGPUReactContext.Provider>\n\t\t</FrameRegistryReactContext.Provider>\n\t);\n}\n"],"mappings":";;;;;;;;;;AAkEA,SAAS,gBAAwB;AAChC,KAAI,OAAO,WAAW,YACrB,QAAO;AAGR,QAAO,OAAO,oBAAoB;;AAGnC,SAAS,mBAAmB,YAA4C;CACvE,MAAM,WAAW,oBAAoB,EAAE,UAAU,IAAK,CAAC;CACvD,MAAM,YAAY,EAAE,SAAS,QAA4C;CACzE,MAAM,wBAAwB,EAAE,SAAS,MAA6B;CACtE,MAAM,qBAA2B;AAChC,wBAAsB,WAAW;;CAElC,MAAM,wBAA8B;AACnC,WAAS,YAAY;AACrB,gBAAc;;CAEf,MAAM,qBAA2B;AAChC,WAAS,SAAS;AAClB,gBAAc;;CAGf,MAAM,OAAO,sBAAgB;EAAE,OAAO;EAAG,QAAQ;EAAG,CAAC;CACrD,MAAM,WAAW,sBAAgB,YAAY,aAAa;CAC1D,MAAM,gBAAgB,sBAAgB,KAAM,UAAU;AACrD,WAAS,YAAY,MAAM;AAC3B,gBAAc;GACb;CACF,MAAM,kBAAkB,sBAA4B,WAAW,UAAU;AACxE,WAAS,cAAc,MAAM;AAC7B,gBAAc;GACb;CACF,MAAM,kBAAkB,sBAAyB,OAAO,UAAU;AACjE,WAAS,cAAc,MAAM;AAC7B,gBAAc;GACb;AA+BF,QAAO;EACN;EACA,SA9BiC;GACjC,IAAI,SAAS;AACZ,WAAO,UAAU;;GAElB;GACA,KAAK;GACL,UAAU;GACV,YAAY;GACZ,YAAY;GACZ,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GACnD,yBAAyB,gBAAgB,QAAQ;GACjD,2BAA2B,gBAAgB,QAAQ;GACnD,kBAAkB,gBAAgB,QAAQ;GAC1C,4BAA4B,gBAAgB,QAAQ;GACpD,yBAAyB,gBAAgB,QAAQ;GACjD,qBAAqB,YAAY;AAChC,oBAAgB,QAAQ;;GAEzB,cAAc,WAAW;AACxB,mBAAe,OAAO;;GAEvB,CAAC;AACF,UAAQ,sBAAsB,UAAU,YAAY;AAEpD,eAAa;AACZ,WAAQ,sBAAsB,UAAU;AACxC,eAAY,SAAS;;IAEpB,CAAC,QAAQ,CAAC;CAEb,MAAM,cAA6B;EAClC,UAAU;EACV,OAAO;EACP,SAAS;EACT,OAAO;EACP,QAAQ;EACR,GAAG;EACH;AAED,QACC,oBAAC,0BAA0B,UAA3B;EAAoC,OAAO,QAAQ;YAClD,oBAAC,sBAAsB,UAAvB;GAAgC,OAAO,QAAQ;aAC9C,qBAAC,OAAD;IACC,WAAU;IACV,OAAO;KACN,UAAU;KACV,OAAO;KACP,QAAQ;KACR,UAAU;KACV,WAAW;KACX,UAAU;KACV;cATF;KAWC,oBAAC,UAAD;MACY;MACX,OAAO;MACP,MAAM,SAAS;AACd,eAAQ,UAAU,UAAU,QAAQ;;MAEpC,CAAA;KACD,oBAAoB,cACpB,gBACC,cAAc,YAAY,GAE1B,oBAAC,uBAAD,EAAuB,QAAQ,aAAe,CAAA,GAE5C;KACH;KACI;;GAC0B,CAAA;EACG,CAAA"}
1
+ {"version":3,"file":"FragCanvas.js","names":[],"sources":["../../src/lib/react/FragCanvas.tsx"],"sourcesContent":["import { createCurrentWritable as currentWritable } from '../core/current-value.js';\nimport { toMotionGPUErrorReport, type MotionGPUErrorReport } from '../core/error-report.js';\nimport type { FragMaterial } from '../core/material.js';\nimport { createFrameRegistry } from '../core/frame-registry.js';\nimport { createMotionGPURuntimeLoop } from '../core/runtime-loop.js';\nimport type {\n\tAnyPass,\n\tOutputColorSpace,\n\tRenderMode,\n\tRenderTargetDefinitionMap\n} from '../core/types.js';\nimport { useEffect, useRef, useState, type CSSProperties, type ReactNode } from 'react';\nimport { FrameRegistryReactContext } from './frame-context.js';\nimport { MotionGPUErrorOverlay } from './MotionGPUErrorOverlay.js';\nimport { MotionGPUReactContext, type MotionGPUContext } from './motiongpu-context.js';\n\nexport interface FragCanvasProps {\n\tmaterial: FragMaterial;\n\trenderTargets?: RenderTargetDefinitionMap;\n\tpasses?: AnyPass[];\n\tclearColor?: [number, number, number, number];\n\toutputColorSpace?: OutputColorSpace;\n\trenderMode?: RenderMode;\n\tautoRender?: boolean;\n\tmaxDelta?: number;\n\tadapterOptions?: GPURequestAdapterOptions;\n\tdeviceDescriptor?: GPUDeviceDescriptor;\n\tdpr?: number;\n\tshowErrorOverlay?: boolean;\n\terrorRenderer?: (report: MotionGPUErrorReport) => ReactNode;\n\tonError?: (report: MotionGPUErrorReport) => void;\n\terrorHistoryLimit?: number;\n\tonErrorHistory?: (history: MotionGPUErrorReport[]) => void;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tchildren?: ReactNode;\n}\n\ninterface RuntimePropsSnapshot {\n\tmaterial: FragMaterial;\n\trenderTargets: RenderTargetDefinitionMap;\n\tpasses: AnyPass[];\n\tclearColor: [number, number, number, number];\n\toutputColorSpace: OutputColorSpace;\n\tadapterOptions: GPURequestAdapterOptions | undefined;\n\tdeviceDescriptor: GPUDeviceDescriptor | undefined;\n\tonError: ((report: MotionGPUErrorReport) => void) | undefined;\n\terrorHistoryLimit: number;\n\tonErrorHistory: ((history: MotionGPUErrorReport[]) => void) | undefined;\n}\n\ninterface FragCanvasRuntimeState {\n\tregistry: ReturnType<typeof createFrameRegistry>;\n\tcontext: MotionGPUContext;\n\tcanvasRef: { current: HTMLCanvasElement | undefined };\n\tsize: ReturnType<typeof currentWritable<{ width: number; height: number }>>;\n\tdprState: ReturnType<typeof currentWritable<number>>;\n\tmaxDeltaState: ReturnType<typeof currentWritable<number>>;\n\trenderModeState: ReturnType<typeof currentWritable<RenderMode>>;\n\tautoRenderState: ReturnType<typeof currentWritable<boolean>>;\n\trequestFrameSignalRef: { current: (() => void) | null };\n\trequestFrame: () => void;\n\tinvalidateFrame: () => void;\n\tadvanceFrame: () => void;\n}\n\nfunction getInitialDpr(): number {\n\tif (typeof window === 'undefined') {\n\t\treturn 1;\n\t}\n\n\treturn window.devicePixelRatio ?? 1;\n}\n\nfunction createRuntimeState(initialDpr: number): FragCanvasRuntimeState {\n\tconst registry = createFrameRegistry({ maxDelta: 0.1 });\n\tconst canvasRef = { current: undefined as HTMLCanvasElement | undefined };\n\tconst requestFrameSignalRef = { current: null as (() => void) | null };\n\tconst requestFrame = (): void => {\n\t\trequestFrameSignalRef.current?.();\n\t};\n\tconst invalidateFrame = (): void => {\n\t\tregistry.invalidate();\n\t\trequestFrame();\n\t};\n\tconst advanceFrame = (): void => {\n\t\tregistry.advance();\n\t\trequestFrame();\n\t};\n\n\tconst size = currentWritable({ width: 0, height: 0 });\n\tconst dprState = currentWritable(initialDpr, requestFrame);\n\tconst maxDeltaState = currentWritable(0.1, (value) => {\n\t\tregistry.setMaxDelta(value);\n\t\trequestFrame();\n\t});\n\tconst renderModeState = currentWritable<RenderMode>('always', (value) => {\n\t\tregistry.setRenderMode(value);\n\t\trequestFrame();\n\t});\n\tconst autoRenderState = currentWritable<boolean>(true, (value) => {\n\t\tregistry.setAutoRender(value);\n\t\trequestFrame();\n\t});\n\tconst userState = currentWritable<Record<string | symbol, unknown>>({});\n\n\tconst context: MotionGPUContext = {\n\t\tget canvas() {\n\t\t\treturn canvasRef.current;\n\t\t},\n\t\tsize,\n\t\tdpr: dprState,\n\t\tmaxDelta: maxDeltaState,\n\t\trenderMode: renderModeState,\n\t\tautoRender: autoRenderState,\n\t\tuser: userState,\n\t\tinvalidate: invalidateFrame,\n\t\tadvance: advanceFrame,\n\t\tscheduler: {\n\t\t\tcreateStage: registry.createStage,\n\t\t\tgetStage: registry.getStage,\n\t\t\tsetDiagnosticsEnabled: registry.setDiagnosticsEnabled,\n\t\t\tgetDiagnosticsEnabled: registry.getDiagnosticsEnabled,\n\t\t\tgetLastRunTimings: registry.getLastRunTimings,\n\t\t\tgetSchedule: registry.getSchedule,\n\t\t\tsetProfilingEnabled: registry.setProfilingEnabled,\n\t\t\tsetProfilingWindow: registry.setProfilingWindow,\n\t\t\tresetProfiling: registry.resetProfiling,\n\t\t\tgetProfilingEnabled: registry.getProfilingEnabled,\n\t\t\tgetProfilingWindow: registry.getProfilingWindow,\n\t\t\tgetProfilingSnapshot: registry.getProfilingSnapshot\n\t\t}\n\t};\n\n\treturn {\n\t\tregistry,\n\t\tcontext,\n\t\tcanvasRef,\n\t\tsize,\n\t\tdprState,\n\t\tmaxDeltaState,\n\t\trenderModeState,\n\t\tautoRenderState,\n\t\trequestFrameSignalRef,\n\t\trequestFrame,\n\t\tinvalidateFrame,\n\t\tadvanceFrame\n\t};\n}\n\nfunction getNormalizedErrorHistoryLimit(value: number): number {\n\tif (!Number.isFinite(value) || value <= 0) {\n\t\treturn 0;\n\t}\n\n\treturn Math.floor(value);\n}\n\nexport function FragCanvas({\n\tmaterial,\n\trenderTargets = {},\n\tpasses = [],\n\tclearColor = [0, 0, 0, 1],\n\toutputColorSpace = 'srgb',\n\trenderMode = 'always',\n\tautoRender = true,\n\tmaxDelta = 0.1,\n\tadapterOptions = undefined,\n\tdeviceDescriptor = undefined,\n\tdpr = getInitialDpr(),\n\tshowErrorOverlay = true,\n\terrorRenderer,\n\tonError = undefined,\n\terrorHistoryLimit = 0,\n\tonErrorHistory = undefined,\n\tclassName = '',\n\tstyle,\n\tchildren\n}: FragCanvasProps) {\n\tconst runtimeRef = useRef<FragCanvasRuntimeState | null>(null);\n\tif (!runtimeRef.current) {\n\t\truntimeRef.current = createRuntimeState(getInitialDpr());\n\t}\n\tconst runtime = runtimeRef.current;\n\n\tconst runtimePropsRef = useRef<RuntimePropsSnapshot>({\n\t\tmaterial,\n\t\trenderTargets,\n\t\tpasses,\n\t\tclearColor,\n\t\toutputColorSpace,\n\t\tadapterOptions,\n\t\tdeviceDescriptor,\n\t\tonError,\n\t\terrorHistoryLimit,\n\t\tonErrorHistory\n\t});\n\truntimePropsRef.current = {\n\t\tmaterial,\n\t\trenderTargets,\n\t\tpasses,\n\t\tclearColor,\n\t\toutputColorSpace,\n\t\tadapterOptions,\n\t\tdeviceDescriptor,\n\t\tonError,\n\t\terrorHistoryLimit,\n\t\tonErrorHistory\n\t};\n\n\tconst [errorReport, setErrorReport] = useState<MotionGPUErrorReport | null>(null);\n\tconst [errorHistory, setErrorHistory] = useState<MotionGPUErrorReport[]>([]);\n\n\tuseEffect(() => {\n\t\truntime.renderModeState.set(renderMode);\n\t}, [renderMode, runtime]);\n\n\tuseEffect(() => {\n\t\truntime.autoRenderState.set(autoRender);\n\t}, [autoRender, runtime]);\n\n\tuseEffect(() => {\n\t\truntime.maxDeltaState.set(maxDelta);\n\t}, [maxDelta, runtime]);\n\n\tuseEffect(() => {\n\t\truntime.dprState.set(dpr);\n\t}, [dpr, runtime]);\n\n\tuseEffect(() => {\n\t\tconst limit = getNormalizedErrorHistoryLimit(errorHistoryLimit);\n\t\tif (limit <= 0) {\n\t\t\tif (errorHistory.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetErrorHistory([]);\n\t\t\tonErrorHistory?.([]);\n\t\t\treturn;\n\t\t}\n\n\t\tif (errorHistory.length <= limit) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst trimmed = errorHistory.slice(errorHistory.length - limit);\n\t\tsetErrorHistory(trimmed);\n\t\tonErrorHistory?.(trimmed);\n\t}, [errorHistory, errorHistoryLimit, onErrorHistory]);\n\n\tuseEffect(() => {\n\t\tconst canvas = runtime.canvasRef.current;\n\t\tif (!canvas) {\n\t\t\tconst report = toMotionGPUErrorReport(\n\t\t\t\tnew Error('Canvas element is not available'),\n\t\t\t\t'initialization'\n\t\t\t);\n\t\t\tsetErrorReport(report);\n\t\t\tconst historyLimit = getNormalizedErrorHistoryLimit(\n\t\t\t\truntimePropsRef.current.errorHistoryLimit\n\t\t\t);\n\t\t\tif (historyLimit > 0) {\n\t\t\t\tconst nextHistory = [report].slice(-historyLimit);\n\t\t\t\tsetErrorHistory(nextHistory);\n\t\t\t\truntimePropsRef.current.onErrorHistory?.(nextHistory);\n\t\t\t}\n\t\t\truntimePropsRef.current.onError?.(report);\n\t\t\treturn () => {\n\t\t\t\truntime.registry.clear();\n\t\t\t};\n\t\t}\n\n\t\tconst runtimeLoop = createMotionGPURuntimeLoop({\n\t\t\tcanvas,\n\t\t\tregistry: runtime.registry,\n\t\t\tsize: runtime.size,\n\t\t\tdpr: runtime.dprState,\n\t\t\tmaxDelta: runtime.maxDeltaState,\n\t\t\tgetMaterial: () => runtimePropsRef.current.material,\n\t\t\tgetRenderTargets: () => runtimePropsRef.current.renderTargets,\n\t\t\tgetPasses: () => runtimePropsRef.current.passes,\n\t\t\tgetClearColor: () => runtimePropsRef.current.clearColor,\n\t\t\tgetOutputColorSpace: () => runtimePropsRef.current.outputColorSpace,\n\t\t\tgetAdapterOptions: () => runtimePropsRef.current.adapterOptions,\n\t\t\tgetDeviceDescriptor: () => runtimePropsRef.current.deviceDescriptor,\n\t\t\tgetOnError: () => runtimePropsRef.current.onError,\n\t\t\tgetErrorHistoryLimit: () => runtimePropsRef.current.errorHistoryLimit,\n\t\t\tgetOnErrorHistory: () => runtimePropsRef.current.onErrorHistory,\n\t\t\treportErrorHistory: (history) => {\n\t\t\t\tsetErrorHistory(history);\n\t\t\t},\n\t\t\treportError: (report) => {\n\t\t\t\tsetErrorReport(report);\n\t\t\t}\n\t\t});\n\t\truntime.requestFrameSignalRef.current = runtimeLoop.requestFrame;\n\n\t\treturn () => {\n\t\t\truntime.requestFrameSignalRef.current = null;\n\t\t\truntimeLoop.destroy();\n\t\t};\n\t}, [runtime]);\n\n\tconst canvasStyle: CSSProperties = {\n\t\tposition: 'absolute',\n\t\tinset: 0,\n\t\tdisplay: 'block',\n\t\twidth: '100%',\n\t\theight: '100%',\n\t\t...style\n\t};\n\n\treturn (\n\t\t<FrameRegistryReactContext.Provider value={runtime.registry}>\n\t\t\t<MotionGPUReactContext.Provider value={runtime.context}>\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"motiongpu-canvas-wrap\"\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tposition: 'relative',\n\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\tminWidth: 0,\n\t\t\t\t\t\tminHeight: 0,\n\t\t\t\t\t\toverflow: 'hidden'\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<canvas\n\t\t\t\t\t\tclassName={className}\n\t\t\t\t\t\tstyle={canvasStyle}\n\t\t\t\t\t\tref={(node) => {\n\t\t\t\t\t\t\truntime.canvasRef.current = node ?? undefined;\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t\t{showErrorOverlay && errorReport ? (\n\t\t\t\t\t\terrorRenderer ? (\n\t\t\t\t\t\t\terrorRenderer(errorReport)\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<MotionGPUErrorOverlay report={errorReport} />\n\t\t\t\t\t\t)\n\t\t\t\t\t) : null}\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t</MotionGPUReactContext.Provider>\n\t\t</FrameRegistryReactContext.Provider>\n\t);\n}\n"],"mappings":";;;;;;;;;;AAkEA,SAAS,gBAAwB;AAChC,KAAI,OAAO,WAAW,YACrB,QAAO;AAGR,QAAO,OAAO,oBAAoB;;AAGnC,SAAS,mBAAmB,YAA4C;CACvE,MAAM,WAAW,oBAAoB,EAAE,UAAU,IAAK,CAAC;CACvD,MAAM,YAAY,EAAE,SAAS,QAA4C;CACzE,MAAM,wBAAwB,EAAE,SAAS,MAA6B;CACtE,MAAM,qBAA2B;AAChC,wBAAsB,WAAW;;CAElC,MAAM,wBAA8B;AACnC,WAAS,YAAY;AACrB,gBAAc;;CAEf,MAAM,qBAA2B;AAChC,W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S;AACd,eAAQ,UAAU,UAAU,QAAQ;;MAEpC,CAAA;KACD,oBAAoB,cACpB,gBACC,cAAc,YAAY,GAE1B,oBAAC,uBAAD,EAAuB,QAAQ,aAAe,CAAA,GAE5C;KACH;KACI;;GAC0B,CAAA;EACG,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"MotionGPUErrorOverlay.d.ts","sourceRoot":"","sources":["../../src/lib/react/MotionGPUErrorOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAGpE,UAAU,0BAA0B;IACnC,MAAM,EAAE,oBAAoB,CAAC;CAC7B;AA8SD,wBAAgB,qBAAqB,CAAC,EAAE,MAAM,EAAE,EAAE,0BAA0B,2CAoF3E"}
1
+ {"version":3,"file":"MotionGPUErrorOverlay.d.ts","sourceRoot":"","sources":["../../src/lib/react/MotionGPUErrorOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAGpE,UAAU,0BAA0B;IACnC,MAAM,EAAE,oBAAoB,CAAC;CAC7B;AA8ZD,wBAAgB,qBAAqB,CAAC,EAAE,MAAM,EAAE,EAAE,0BAA0B,2CAwG3E"}