@motion-core/motion-gpu 0.4.2 → 0.5.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 (111) 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-shader.d.ts +87 -0
  5. package/dist/core/compute-shader.d.ts.map +1 -0
  6. package/dist/core/compute-shader.js +205 -0
  7. package/dist/core/compute-shader.js.map +1 -0
  8. package/dist/core/error-report.d.ts +1 -1
  9. package/dist/core/error-report.d.ts.map +1 -1
  10. package/dist/core/error-report.js +63 -0
  11. package/dist/core/error-report.js.map +1 -1
  12. package/dist/core/frame-registry.d.ts.map +1 -1
  13. package/dist/core/frame-registry.js +1 -1
  14. package/dist/core/frame-registry.js.map +1 -1
  15. package/dist/core/index.d.ts +5 -2
  16. package/dist/core/index.d.ts.map +1 -1
  17. package/dist/core/index.js +3 -1
  18. package/dist/core/material-preprocess.d.ts.map +1 -1
  19. package/dist/core/material-preprocess.js +5 -3
  20. package/dist/core/material-preprocess.js.map +1 -1
  21. package/dist/core/material.d.ts +22 -6
  22. package/dist/core/material.d.ts.map +1 -1
  23. package/dist/core/material.js +30 -3
  24. package/dist/core/material.js.map +1 -1
  25. package/dist/core/render-graph.d.ts +7 -3
  26. package/dist/core/render-graph.d.ts.map +1 -1
  27. package/dist/core/render-graph.js +22 -6
  28. package/dist/core/render-graph.js.map +1 -1
  29. package/dist/core/renderer.d.ts.map +1 -1
  30. package/dist/core/renderer.js +418 -23
  31. package/dist/core/renderer.js.map +1 -1
  32. package/dist/core/runtime-loop.d.ts +2 -2
  33. package/dist/core/runtime-loop.d.ts.map +1 -1
  34. package/dist/core/runtime-loop.js +49 -1
  35. package/dist/core/runtime-loop.js.map +1 -1
  36. package/dist/core/shader.d.ts +9 -1
  37. package/dist/core/shader.d.ts.map +1 -1
  38. package/dist/core/shader.js +21 -2
  39. package/dist/core/shader.js.map +1 -1
  40. package/dist/core/storage-buffers.d.ts +37 -0
  41. package/dist/core/storage-buffers.d.ts.map +1 -0
  42. package/dist/core/storage-buffers.js +95 -0
  43. package/dist/core/storage-buffers.js.map +1 -0
  44. package/dist/core/texture-loader.d.ts.map +1 -1
  45. package/dist/core/texture-loader.js +4 -0
  46. package/dist/core/texture-loader.js.map +1 -1
  47. package/dist/core/textures.d.ts +12 -0
  48. package/dist/core/textures.d.ts.map +1 -1
  49. package/dist/core/textures.js +7 -2
  50. package/dist/core/textures.js.map +1 -1
  51. package/dist/core/types.d.ts +146 -4
  52. package/dist/core/types.d.ts.map +1 -1
  53. package/dist/index.js +3 -1
  54. package/dist/passes/ComputePass.d.ts +83 -0
  55. package/dist/passes/ComputePass.d.ts.map +1 -0
  56. package/dist/passes/ComputePass.js +92 -0
  57. package/dist/passes/ComputePass.js.map +1 -0
  58. package/dist/passes/PingPongComputePass.d.ts +104 -0
  59. package/dist/passes/PingPongComputePass.d.ts.map +1 -0
  60. package/dist/passes/PingPongComputePass.js +132 -0
  61. package/dist/passes/PingPongComputePass.js.map +1 -0
  62. package/dist/passes/ShaderPass.d.ts.map +1 -1
  63. package/dist/passes/ShaderPass.js +2 -1
  64. package/dist/passes/ShaderPass.js.map +1 -1
  65. package/dist/passes/index.d.ts +2 -0
  66. package/dist/passes/index.d.ts.map +1 -1
  67. package/dist/passes/index.js +3 -1
  68. package/dist/react/FragCanvas.d.ts +2 -2
  69. package/dist/react/FragCanvas.d.ts.map +1 -1
  70. package/dist/react/FragCanvas.js.map +1 -1
  71. package/dist/react/MotionGPUErrorOverlay.d.ts.map +1 -1
  72. package/dist/react/MotionGPUErrorOverlay.js +123 -20
  73. package/dist/react/MotionGPUErrorOverlay.js.map +1 -1
  74. package/dist/react/advanced.js +3 -1
  75. package/dist/react/index.d.ts +5 -2
  76. package/dist/react/index.d.ts.map +1 -1
  77. package/dist/react/index.js +3 -1
  78. package/dist/svelte/FragCanvas.svelte +2 -2
  79. package/dist/svelte/FragCanvas.svelte.d.ts +2 -2
  80. package/dist/svelte/FragCanvas.svelte.d.ts.map +1 -1
  81. package/dist/svelte/MotionGPUErrorOverlay.svelte +137 -7
  82. package/dist/svelte/MotionGPUErrorOverlay.svelte.d.ts.map +1 -1
  83. package/dist/svelte/advanced.js +3 -1
  84. package/dist/svelte/index.d.ts +5 -2
  85. package/dist/svelte/index.d.ts.map +1 -1
  86. package/dist/svelte/index.js +3 -1
  87. package/package.json +1 -1
  88. package/src/lib/core/compute-shader.ts +326 -0
  89. package/src/lib/core/error-report.ts +129 -0
  90. package/src/lib/core/frame-registry.ts +2 -1
  91. package/src/lib/core/index.ts +18 -1
  92. package/src/lib/core/material-preprocess.ts +17 -6
  93. package/src/lib/core/material.ts +101 -20
  94. package/src/lib/core/render-graph.ts +39 -9
  95. package/src/lib/core/renderer.ts +655 -41
  96. package/src/lib/core/runtime-loop.ts +82 -3
  97. package/src/lib/core/shader.ts +45 -2
  98. package/src/lib/core/storage-buffers.ts +142 -0
  99. package/src/lib/core/texture-loader.ts +6 -0
  100. package/src/lib/core/textures.ts +24 -2
  101. package/src/lib/core/types.ts +165 -4
  102. package/src/lib/passes/ComputePass.ts +136 -0
  103. package/src/lib/passes/PingPongComputePass.ts +180 -0
  104. package/src/lib/passes/ShaderPass.ts +2 -1
  105. package/src/lib/passes/index.ts +6 -0
  106. package/src/lib/react/FragCanvas.tsx +3 -3
  107. package/src/lib/react/MotionGPUErrorOverlay.tsx +137 -5
  108. package/src/lib/react/index.ts +18 -1
  109. package/src/lib/svelte/FragCanvas.svelte +2 -2
  110. package/src/lib/svelte/MotionGPUErrorOverlay.svelte +137 -7
  111. package/src/lib/svelte/index.ts +18 -1
@@ -16,7 +16,87 @@
16
16
  };
17
17
 
18
18
  const shouldShowErrorMessage = (value: MotionGPUErrorReport): boolean => {
19
- return normalizeErrorText(value.message) !== normalizeErrorText(value.title);
19
+ return resolveDisplayMessage(value).length > 0;
20
+ };
21
+
22
+ const resolveDisplayMessage = (value: MotionGPUErrorReport): string => {
23
+ const rawMessage = value.message.trim();
24
+ if (rawMessage.length === 0) {
25
+ return '';
26
+ }
27
+
28
+ const normalizedMessage = normalizeErrorText(rawMessage);
29
+ const normalizedTitle = normalizeErrorText(value.title);
30
+ if (normalizedMessage === normalizedTitle) {
31
+ return '';
32
+ }
33
+
34
+ const escapedTitle = value.title.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
35
+ const prefixPattern = new RegExp(`^${escapedTitle}\\s*[:\\-|]\\s*`, 'i');
36
+ const stripped = rawMessage.replace(prefixPattern, '').trim();
37
+ return stripped.length > 0 ? stripped : rawMessage;
38
+ };
39
+
40
+ const formatRuntimeContext = (context: MotionGPUErrorReport['context']): string => {
41
+ if (!context) {
42
+ return '';
43
+ }
44
+
45
+ const indentBlock = (value: string, spaces = 2): string => {
46
+ const prefix = ' '.repeat(spaces);
47
+ return value
48
+ .split('\n')
49
+ .map((line) => `${prefix}${line}`)
50
+ .join('\n');
51
+ };
52
+
53
+ const formatMaterialSignature = (value: string): string => {
54
+ const trimmed = value.trim();
55
+ if (trimmed.length === 0) {
56
+ return '<empty>';
57
+ }
58
+ try {
59
+ return JSON.stringify(JSON.parse(trimmed), null, 2);
60
+ } catch {
61
+ return trimmed;
62
+ }
63
+ };
64
+
65
+ const lines: string[] = [];
66
+ if (context.materialSignature) {
67
+ lines.push('materialSignature:');
68
+ lines.push(indentBlock(formatMaterialSignature(context.materialSignature)));
69
+ }
70
+ if (context.passGraph) {
71
+ lines.push('passGraph:');
72
+ lines.push(` passCount: ${context.passGraph.passCount}`);
73
+ lines.push(` enabledPassCount: ${context.passGraph.enabledPassCount}`);
74
+ lines.push(' inputs:');
75
+ if (context.passGraph.inputs.length === 0) {
76
+ lines.push(' - <none>');
77
+ } else {
78
+ for (const input of context.passGraph.inputs) {
79
+ lines.push(` - ${input}`);
80
+ }
81
+ }
82
+ lines.push(' outputs:');
83
+ if (context.passGraph.outputs.length === 0) {
84
+ lines.push(' - <none>');
85
+ } else {
86
+ for (const output of context.passGraph.outputs) {
87
+ lines.push(` - ${output}`);
88
+ }
89
+ }
90
+ }
91
+ lines.push('activeRenderTargets:');
92
+ if (context.activeRenderTargets.length === 0) {
93
+ lines.push(' - <none>');
94
+ } else {
95
+ for (const target of context.activeRenderTargets) {
96
+ lines.push(` - ${target}`);
97
+ }
98
+ }
99
+ return lines.join('\n');
20
100
  };
21
101
  </script>
22
102
 
@@ -30,16 +110,28 @@
30
110
  data-testid="motiongpu-error"
31
111
  >
32
112
  <header class="motiongpu-error-header">
33
- <div class="motiongpu-error-badge-wrap">
34
- <p class="motiongpu-error-phase">
35
- {report.phase}
36
- </p>
113
+ <div class="motiongpu-error-header-top">
114
+ <div class="motiongpu-error-badges">
115
+ <div class="motiongpu-error-badge-wrap">
116
+ <p class="motiongpu-error-badge motiongpu-error-badge-phase">
117
+ {report.phase}
118
+ </p>
119
+ </div>
120
+ <div class="motiongpu-error-badge-wrap">
121
+ <p class="motiongpu-error-badge motiongpu-error-badge-severity">
122
+ {report.severity}
123
+ </p>
124
+ </div>
125
+ </div>
37
126
  </div>
38
127
  <h2 class="motiongpu-error-title">{report.title}</h2>
128
+ <p class="motiongpu-error-recoverable">
129
+ Recoverable: <span>{report.recoverable ? 'yes' : 'no'}</span>
130
+ </p>
39
131
  </header>
40
132
  <div class="motiongpu-error-body">
41
133
  {#if shouldShowErrorMessage(report)}
42
- <p class="motiongpu-error-message">{report.message}</p>
134
+ <p class="motiongpu-error-message">{resolveDisplayMessage(report)}</p>
43
135
  {/if}
44
136
  <p class="motiongpu-error-hint">{report.hint}</p>
45
137
  </div>
@@ -87,6 +179,12 @@
87
179
  <pre>{report.stack.join('\n')}</pre>
88
180
  </details>
89
181
  {/if}
182
+ {#if report.context}
183
+ <details class="motiongpu-error-details">
184
+ <summary>Runtime context</summary>
185
+ <pre>{formatRuntimeContext(report.context)}</pre>
186
+ </details>
187
+ {/if}
90
188
  </div>
91
189
  </section>
92
190
  </div>
@@ -162,6 +260,19 @@
162
260
  border-bottom: 1px solid var(--motiongpu-color-border);
163
261
  }
164
262
 
263
+ .motiongpu-error-header-top {
264
+ display: flex;
265
+ align-items: flex-start;
266
+ gap: 0.75rem;
267
+ }
268
+
269
+ .motiongpu-error-badges {
270
+ display: inline-flex;
271
+ align-items: center;
272
+ gap: 0.4rem;
273
+ flex-wrap: wrap;
274
+ }
275
+
165
276
  .motiongpu-error-badge-wrap {
166
277
  display: inline-flex;
167
278
  align-items: center;
@@ -173,7 +284,7 @@
173
284
  background: var(--motiongpu-color-background-muted);
174
285
  }
175
286
 
176
- .motiongpu-error-phase {
287
+ .motiongpu-error-badge {
177
288
  display: inline-flex;
178
289
  align-items: center;
179
290
  margin: 0;
@@ -193,6 +304,20 @@
193
304
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24);
194
305
  }
195
306
 
307
+ .motiongpu-error-recoverable {
308
+ margin: 0;
309
+ font-size: 0.67rem;
310
+ line-height: 1.2;
311
+ letter-spacing: 0.06em;
312
+ text-transform: uppercase;
313
+ color: var(--motiongpu-color-foreground-muted);
314
+ }
315
+
316
+ .motiongpu-error-recoverable span {
317
+ font-family: var(--motiongpu-font-mono);
318
+ color: var(--motiongpu-color-foreground);
319
+ }
320
+
196
321
  .motiongpu-error-title {
197
322
  margin: 0;
198
323
  font-size: clamp(1.02rem, 1vw + 0.72rem, 1.32rem);
@@ -372,6 +497,11 @@
372
497
  .motiongpu-error-title {
373
498
  font-size: 1.02rem;
374
499
  }
500
+
501
+ .motiongpu-error-header-top {
502
+ flex-direction: column;
503
+ align-items: flex-start;
504
+ }
375
505
  }
376
506
 
377
507
  @media (prefers-reduced-motion: reduce) {
@@ -3,7 +3,13 @@
3
3
  */
4
4
  export { default as FragCanvas } from './FragCanvas.svelte';
5
5
  export { defineMaterial } from '../core/material.js';
6
- export { BlitPass, CopyPass, ShaderPass } from '../passes/index.js';
6
+ export {
7
+ BlitPass,
8
+ CopyPass,
9
+ ShaderPass,
10
+ ComputePass,
11
+ PingPongComputePass
12
+ } from '../passes/index.js';
7
13
  export { useMotionGPU } from './motiongpu-context.js';
8
14
  export { useFrame } from './frame-context.js';
9
15
  export { useTexture } from './use-texture.js';
@@ -11,6 +17,8 @@ export type {
11
17
  FrameInvalidationToken,
12
18
  FrameState,
13
19
  OutputColorSpace,
20
+ AnyPass,
21
+ ComputePassLike,
14
22
  RenderPass,
15
23
  RenderPassContext,
16
24
  RenderPassFlags,
@@ -49,3 +57,12 @@ export type {
49
57
  export type { MotionGPUContext } from './motiongpu-context.js';
50
58
  export type { UseFrameOptions, UseFrameResult } from './frame-context.js';
51
59
  export type { TextureUrlInput, UseTextureResult } from './use-texture.js';
60
+ export type {
61
+ StorageBufferAccess,
62
+ StorageBufferDefinition,
63
+ StorageBufferDefinitionMap,
64
+ StorageBufferType,
65
+ ComputePassContext
66
+ } from '../core/types.js';
67
+ export type { ComputePassOptions, ComputeDispatchContext } from '../passes/ComputePass.js';
68
+ export type { PingPongComputePassOptions } from '../passes/PingPongComputePass.js';