@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.
- package/README.md +99 -0
- package/dist/advanced.js +3 -1
- package/dist/core/advanced.js +3 -1
- package/dist/core/compute-shader.d.ts +87 -0
- package/dist/core/compute-shader.d.ts.map +1 -0
- package/dist/core/compute-shader.js +205 -0
- package/dist/core/compute-shader.js.map +1 -0
- package/dist/core/error-report.d.ts +1 -1
- package/dist/core/error-report.d.ts.map +1 -1
- package/dist/core/error-report.js +63 -0
- package/dist/core/error-report.js.map +1 -1
- package/dist/core/frame-registry.d.ts.map +1 -1
- package/dist/core/frame-registry.js +1 -1
- package/dist/core/frame-registry.js.map +1 -1
- package/dist/core/index.d.ts +5 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -1
- package/dist/core/material-preprocess.d.ts.map +1 -1
- package/dist/core/material-preprocess.js +5 -3
- package/dist/core/material-preprocess.js.map +1 -1
- package/dist/core/material.d.ts +22 -6
- package/dist/core/material.d.ts.map +1 -1
- package/dist/core/material.js +30 -3
- package/dist/core/material.js.map +1 -1
- package/dist/core/render-graph.d.ts +7 -3
- package/dist/core/render-graph.d.ts.map +1 -1
- package/dist/core/render-graph.js +22 -6
- package/dist/core/render-graph.js.map +1 -1
- package/dist/core/renderer.d.ts.map +1 -1
- package/dist/core/renderer.js +418 -23
- package/dist/core/renderer.js.map +1 -1
- package/dist/core/runtime-loop.d.ts +2 -2
- package/dist/core/runtime-loop.d.ts.map +1 -1
- package/dist/core/runtime-loop.js +49 -1
- package/dist/core/runtime-loop.js.map +1 -1
- package/dist/core/shader.d.ts +9 -1
- package/dist/core/shader.d.ts.map +1 -1
- package/dist/core/shader.js +21 -2
- package/dist/core/shader.js.map +1 -1
- package/dist/core/storage-buffers.d.ts +37 -0
- package/dist/core/storage-buffers.d.ts.map +1 -0
- package/dist/core/storage-buffers.js +95 -0
- package/dist/core/storage-buffers.js.map +1 -0
- package/dist/core/texture-loader.d.ts.map +1 -1
- package/dist/core/texture-loader.js +4 -0
- package/dist/core/texture-loader.js.map +1 -1
- package/dist/core/textures.d.ts +12 -0
- package/dist/core/textures.d.ts.map +1 -1
- package/dist/core/textures.js +7 -2
- package/dist/core/textures.js.map +1 -1
- package/dist/core/types.d.ts +146 -4
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/passes/ComputePass.d.ts +83 -0
- package/dist/passes/ComputePass.d.ts.map +1 -0
- package/dist/passes/ComputePass.js +92 -0
- package/dist/passes/ComputePass.js.map +1 -0
- package/dist/passes/PingPongComputePass.d.ts +104 -0
- package/dist/passes/PingPongComputePass.d.ts.map +1 -0
- package/dist/passes/PingPongComputePass.js +132 -0
- package/dist/passes/PingPongComputePass.js.map +1 -0
- package/dist/passes/ShaderPass.d.ts.map +1 -1
- package/dist/passes/ShaderPass.js +2 -1
- package/dist/passes/ShaderPass.js.map +1 -1
- package/dist/passes/index.d.ts +2 -0
- package/dist/passes/index.d.ts.map +1 -1
- package/dist/passes/index.js +3 -1
- package/dist/react/FragCanvas.d.ts +2 -2
- package/dist/react/FragCanvas.d.ts.map +1 -1
- package/dist/react/FragCanvas.js.map +1 -1
- package/dist/react/MotionGPUErrorOverlay.d.ts.map +1 -1
- package/dist/react/MotionGPUErrorOverlay.js +123 -20
- package/dist/react/MotionGPUErrorOverlay.js.map +1 -1
- package/dist/react/advanced.js +3 -1
- package/dist/react/index.d.ts +5 -2
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +3 -1
- package/dist/svelte/FragCanvas.svelte +2 -2
- package/dist/svelte/FragCanvas.svelte.d.ts +2 -2
- package/dist/svelte/FragCanvas.svelte.d.ts.map +1 -1
- package/dist/svelte/MotionGPUErrorOverlay.svelte +137 -7
- package/dist/svelte/MotionGPUErrorOverlay.svelte.d.ts.map +1 -1
- package/dist/svelte/advanced.js +3 -1
- package/dist/svelte/index.d.ts +5 -2
- package/dist/svelte/index.d.ts.map +1 -1
- package/dist/svelte/index.js +3 -1
- package/package.json +1 -1
- package/src/lib/core/compute-shader.ts +326 -0
- package/src/lib/core/error-report.ts +129 -0
- package/src/lib/core/frame-registry.ts +2 -1
- package/src/lib/core/index.ts +18 -1
- package/src/lib/core/material-preprocess.ts +17 -6
- package/src/lib/core/material.ts +101 -20
- package/src/lib/core/render-graph.ts +39 -9
- package/src/lib/core/renderer.ts +655 -41
- package/src/lib/core/runtime-loop.ts +82 -3
- package/src/lib/core/shader.ts +45 -2
- package/src/lib/core/storage-buffers.ts +142 -0
- package/src/lib/core/texture-loader.ts +6 -0
- package/src/lib/core/textures.ts +24 -2
- package/src/lib/core/types.ts +165 -4
- package/src/lib/passes/ComputePass.ts +136 -0
- package/src/lib/passes/PingPongComputePass.ts +180 -0
- package/src/lib/passes/ShaderPass.ts +2 -1
- package/src/lib/passes/index.ts +6 -0
- package/src/lib/react/FragCanvas.tsx +3 -3
- package/src/lib/react/MotionGPUErrorOverlay.tsx +137 -5
- package/src/lib/react/index.ts +18 -1
- package/src/lib/svelte/FragCanvas.svelte +2 -2
- package/src/lib/svelte/MotionGPUErrorOverlay.svelte +137 -7
- 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
|
|
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-
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
|
|
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
|
|
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-
|
|
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) {
|
package/src/lib/svelte/index.ts
CHANGED
|
@@ -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 {
|
|
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';
|