@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.65 kB
JavaScript
import { BlitPass } from "./BlitPass.js";
//#region src/lib/passes/CopyPass.ts
/**
* Texture copy pass with fullscreen-blit fallback.
*/
var CopyPass = class {
enabled;
needsSwap;
input;
output;
clear;
clearColor;
preserve;
fallbackBlit;
constructor(options = {}) {
this.enabled = options.enabled ?? true;
this.needsSwap = options.needsSwap ?? true;
this.input = options.input ?? "source";
this.output = options.output ?? (this.needsSwap ? "target" : "source");
this.clear = options.clear ?? false;
this.clearColor = options.clearColor ?? [
0,
0,
0,
1
];
this.preserve = options.preserve ?? true;
this.fallbackBlit = new BlitPass({
enabled: true,
needsSwap: false,
input: this.input,
output: this.output,
...options.filter !== void 0 ? { filter: options.filter } : {}
});
}
setSize(width, height) {
this.fallbackBlit.setSize(width, height);
}
render(context) {
const source = context.input;
const target = context.output;
if (context.clear === false && context.preserve === true && source.texture !== target.texture && source.texture !== context.canvas.texture && target.texture !== context.canvas.texture && source.width === target.width && source.height === target.height && source.format === target.format) {
context.commandEncoder.copyTextureToTexture({ texture: source.texture }, { texture: target.texture }, {
width: source.width,
height: source.height,
depthOrArrayLayers: 1
});
return;
}
this.fallbackBlit.render(context);
}
dispose() {
this.fallbackBlit.dispose();
}
};
//#endregion
export { CopyPass };
//# sourceMappingURL=CopyPass.js.map