A pipeline is now an object with a build method and a run method. The build method returns the last step's outputs object.

This commit is contained in:
Rezmason
2022-05-03 12:07:48 -07:00
parent b09887ba0f
commit a6c88913f5
2 changed files with 13 additions and 7 deletions

View File

@@ -116,6 +116,14 @@ const makePass = (loaded, build, run) => ({
run: run ?? (() => {}),
});
const makePipeline = (context, steps) => steps.filter((f) => f != null).map((f) => f(context));
const makePipeline = async (context, steps) => {
steps = steps.filter((f) => f != null).map((f) => f(context));
await Promise.all(steps.map(step => step.loaded));
return {
steps,
build: (canvasSize) => steps.reduce((outputs, step) => step.build(canvasSize, outputs), null),
run: (encoder) => steps.forEach((step) => step.run(encoder))
};
}
export { getCanvasSize, makeRenderTarget, makeComputeTarget, make1DTexture, loadTexture, loadShader, makeUniformBuffer, makePass, makePipeline, makeBindGroup };