@motion-core/motion-gpu
Version:
Framework-agnostic WebGPU runtime for fullscreen WGSL shaders with explicit Svelte, React, and Vue adapter entrypoints.
59 lines (58 loc) • 1.99 kB
JavaScript
//#region src/lib/core/scheduler-helpers.ts
var PRESET_CONFIG = {
performance: {
diagnosticsEnabled: false,
profilingEnabled: false,
profilingWindow: 60
},
balanced: {
diagnosticsEnabled: true,
profilingEnabled: true,
profilingWindow: 120
},
debug: {
diagnosticsEnabled: true,
profilingEnabled: true,
profilingWindow: 240
}
};
function assertProfilingWindow(value) {
if (!Number.isFinite(value) || value <= 0) throw new Error("profilingWindow must be a finite number greater than 0");
return Math.floor(value);
}
/**
* Applies a named scheduler preset to the runtime scheduler instance.
*
* Returns resolved values after overrides for easy logging/telemetry.
*/
function applySchedulerPreset(scheduler, preset, options = {}) {
const base = PRESET_CONFIG[preset];
const diagnosticsEnabled = options.diagnosticsEnabled ?? base.diagnosticsEnabled;
const profilingEnabled = options.profilingEnabled ?? base.profilingEnabled;
if (diagnosticsEnabled !== profilingEnabled) throw new Error("MotionGPU scheduler currently shares diagnostics/profiling state; both values must match");
const profilingWindow = assertProfilingWindow(options.profilingWindow ?? base.profilingWindow);
scheduler.setProfilingWindow(profilingWindow);
scheduler.setDiagnosticsEnabled(diagnosticsEnabled);
scheduler.setProfilingEnabled(profilingEnabled);
return {
diagnosticsEnabled,
profilingEnabled,
profilingWindow
};
}
/**
* Captures an aggregate scheduler diagnostics snapshot.
*/
function captureSchedulerDebugSnapshot(scheduler) {
return {
diagnosticsEnabled: scheduler.getDiagnosticsEnabled(),
profilingEnabled: scheduler.getProfilingEnabled(),
profilingWindow: scheduler.getProfilingWindow(),
schedule: scheduler.getSchedule(),
lastRunTimings: scheduler.getLastRunTimings(),
profilingSnapshot: scheduler.getProfilingSnapshot()
};
}
//#endregion
export { applySchedulerPreset, captureSchedulerDebugSnapshot };
//# sourceMappingURL=scheduler-helpers.js.map