feat: compile pipeline-specific render pass cohorts

Amp-Thread-ID: https://ampcode.com/threads/T-019f9d91-77c1-7206-a60f-ed6554ce92ab

Co-authored-by: Heaust Azure <heaust.azure@gmail.com>
This commit is contained in:
Amp
2026-07-29 14:49:22 +00:00
co-authored by heaust
parent 27e3dd64ae
commit 780f194be4
16 changed files with 1519 additions and 376 deletions
+4 -2
View File
@@ -11,12 +11,14 @@ import {
} from "../static/render-graph/node-spawn.js";
test("add-node model contains all final catalog types in application groups", () => {
assert.equal(addNodeItems.length, 42);
assert.equal(addNodeItems.length, 44);
assert.deepEqual(
[...new Set(addNodeItems.map((item) => item.group))],
["Source", "Expression", "Render / post", "Frame"],
);
assert.equal(new Set(addNodeItems.map((item) => item.typeId)).size, 42);
assert.equal(new Set(addNodeItems.map((item) => item.typeId)).size, 44);
assert.deepEqual(addNodeItems.filter((item) => ["ground_plane", "gltf_standard", "gltf_standard_double_sided"].includes(item.typeId)).map((item) => item.title), ["Ground Plane", "glTF Standard", "glTF Standard — Double-Sided"]);
assert.ok(!addNodeItems.some((item) => item.typeId === "pipeline" || item.title === "Pipeline"));
assert.ok(addNodeItems.some((item) => item.typeId === "separate_u32_bits" && item.group === "Expression"));
assert.ok(!addNodeItems.some((item) => ["mesh_query", "pipeline_registry"].includes(item.typeId)));
assert.deepEqual(searchAddNodeItems("no such node"), []);
+2 -2
View File
@@ -36,8 +36,8 @@ test("production render graph composition passes fxnode's public validator", asy
result.ok ? undefined : JSON.stringify(result.issues, null, 2),
);
assert.equal(fxNodeComposition.schemaVersion, 2);
assert.equal(fxNodeComposition.version, 11);
assert.equal(Object.keys(fxNodeComposition.nodes).length, 42);
assert.equal(fxNodeComposition.version, 12);
assert.equal(Object.keys(fxNodeComposition.nodes).length, 44);
assert.ok(
Object.values(fxNodeComposition.nodes).every(
(definition) => definition.migrations.length === 0,
+25 -9
View File
@@ -30,15 +30,18 @@ const authoredLink = (id, from, to = "target", muted = false) => ({
toNodeId: to, toSocketId: `${to}:inputs`, muted, extensions: {},
});
test("catalog v11 exposes the final mesh, pipeline, and typed-expression contracts", () => {
assert.equal(CATALOG_VERSION, 11);
test("catalog v12 exposes raster and typed-expression contracts", () => {
assert.equal(CATALOG_VERSION, 12);
assert.deepEqual(semanticCatalog.mesh.outputs, {
mesh: { type: "mesh_data" }, type: { type: "u32x16" }, localAabb: { type: "local_aabb" },
});
assert.equal(semanticCatalog.mesh.version, 2);
assert.equal(nodeDefinitions.mesh.sockets.localAabb.title, "Local AABB");
assert.equal(semanticCatalog.pipeline.version, 4);
assert.deepEqual(semanticCatalog.pipeline.inputs.predicate.cardinality, { minimum: 0, maximum: 1 });
assert.equal(semanticCatalog.pipeline, undefined);
for (const key of ["ground_plane", "gltf_standard", "gltf_standard_double_sided"]) {
assert.equal(semanticCatalog[key].version, 1);
assert.deepEqual(semanticCatalog[key].inputs.predicate.cardinality, { minimum: 0, maximum: 1 });
}
assert.deepEqual(semanticCatalog.and.inputs.inputs.cardinality, { minimum: 0, maximum: 8 });
assert.equal(nodeDefinitions.and.sockets.inputs.maxIncomingLinks, 8);
assert.equal(nodeDefinitions.and.sockets.inputs.value, null);
@@ -52,21 +55,34 @@ test("catalog v11 exposes the final mesh, pipeline, and typed-expression contrac
}
});
test("raster declarations own their defaults and sockets", () => {
const keys = ["ground_plane", "gltf_standard", "gltf_standard_double_sided"];
assert.deepEqual(keys.map((key) => nodeDefinitions[key].title), [
"Ground Plane", "glTF Standard", "glTF Standard — Double-Sided",
]);
assert.notStrictEqual(semanticCatalog.ground_plane.inputs, semanticCatalog.gltf_standard.inputs);
assert.notStrictEqual(nodeDefinitions.ground_plane.sockets, nodeDefinitions.gltf_standard.sockets);
assert.notStrictEqual(nodeDefinitions.ground_plane.parameters, nodeDefinitions.gltf_standard.parameters);
assert.notStrictEqual(nodeDefinitions.ground_plane.parameters.clearColor.default.value,
nodeDefinitions.gltf_standard.parameters.clearColor.default.value);
assert.equal("pipeline" in nodeDefinitions.gltf_standard.parameters, false);
});
test("current culling fixture uses type-bit predicates and final socket versions", () => {
const byId = Object.fromEntries(culling.nodes.map((node) => [node.id, node]));
assert.deepEqual(byId.cull.inputs.localAabb, [{ node: "mesh", socket: "localAabb" }]);
assert.deepEqual(byId.type_words.inputs.value, [{ node: "mesh", socket: "type" }]);
assert.equal(byId.ground.executor.version, 4);
assert.equal(byId.ground.executor.version, 1);
assert.equal(byId.ground.inputs.predicate[0].node, "ground_class");
});
test("compiler texture sockets expose policy metadata without literal widgets", () => {
for (const socket of ["colorTarget", "depthTarget"]) {
assert.equal(semanticCatalog.pipeline.inputs[socket].defaultPolicy, "compiler_texture");
assert.equal(nodeDefinitions.pipeline.sockets[socket].default, undefined);
assert.equal(semanticCatalog.gltf_standard.inputs[socket].defaultPolicy, "compiler_texture");
assert.equal(nodeDefinitions.gltf_standard.sockets[socket].default, undefined);
}
assert.equal(semanticCatalog.pipeline.inputs.predicate.defaultPolicy, "parameter_literal");
assert.notEqual(nodeDefinitions.pipeline.sockets.predicate.default, null);
assert.equal(semanticCatalog.gltf_standard.inputs.predicate.defaultPolicy, "parameter_literal");
assert.notEqual(nodeDefinitions.gltf_standard.sockets.predicate.default, null);
});
test("removed architecture is absent from the authoring catalog", () => {
+18 -12
View File
@@ -6,7 +6,7 @@ import { descriptors } from "../static/render-graph/catalog.js";
test("all presets use current schemas, versions, and one frame output", () => {
assert.equal(Object.keys(presets.renderGraphPresets).length, 13);
for (const [name, graph] of Object.entries(presets.renderGraphPresets)) {
assert.deepEqual([graph.schemaVersion, graph.revision], [3, 2], name);
assert.deepEqual([graph.schemaVersion, graph.revision], [3, 3], name);
assert.equal(new Set(graph.nodes.map((node) => node.id)).size, graph.nodes.length, name);
assert.equal(graph.nodes.filter((node) => node.executor.key === "frame_out").length, 1, name);
for (const node of graph.nodes)
@@ -15,7 +15,7 @@ test("all presets use current schemas, versions, and one frame output", () => {
const authoredX4 = Object.entries(presets.renderGraphPresets).flatMap(([name, graph]) =>
graph.nodes.filter((node) => node.parameters?.texture?.sampleCount === 4)
.map((node) => `${name}:${node.id}`));
assert.deepEqual(authoredX4, ["msaa:msaa_hdr"]);
assert.deepEqual(authoredX4, ["msaa:msaa_hdr", "msaa:scene_depth"]);
assert.equal(typeof presets.msaa.nodes.find((node) => node.id === "msaa_hdr")
.parameters.texture.sampleCount, "number");
});
@@ -30,7 +30,7 @@ test("presets classify demo-owned enable and material bits through type.words[0]
assert.deepEqual(byId.pbr_double.inputs.predicate, [{ node: "double_class", socket: "value" }], name);
for (const pipeline of [byId.ground, byId.pbr, byId.pbr_double]) {
assert.deepEqual(pipeline.inputs.mesh, [{ node: "mesh", socket: "mesh" }]);
assert.equal(pipeline.executor.version, 4);
assert.equal(pipeline.executor.version, 1);
}
}
});
@@ -45,14 +45,20 @@ test("culling adds a local-AABB expression to each material predicate", () => {
assert.equal(byId[id].inputs.inputs.at(-1).node, "not_culled");
});
test("implicit presets start disconnected and then chain both attachments", () => {
for (const name of ["hdr", "culling", "grading"]) {
const byId = Object.fromEntries(presets[name].nodes.map((node) => [node.id, node]));
assert.equal("colorTarget" in byId.ground.inputs, false, name);
assert.equal("depthTarget" in byId.ground.inputs, false, name);
assert.deepEqual(byId.pbr.inputs.colorTarget, [{ node: "ground", socket: "color" }], name);
assert.deepEqual(byId.pbr.inputs.depthTarget, [{ node: "ground", socket: "depth" }], name);
test("scene pipelines directly share matching explicit color and depth targets", () => {
for (const [name, graph] of Object.entries(presets.renderGraphPresets)) {
const byId = Object.fromEntries(graph.nodes.map((node) => [node.id, node]));
const color = byId.ground.inputs.colorTarget;
const depth = byId.ground.inputs.depthTarget;
for (const id of ["ground", "pbr", "pbr_double"]) {
assert.deepEqual(byId[id].inputs.colorTarget, color, `${name}:${id}`);
assert.deepEqual(byId[id].inputs.depthTarget, depth, `${name}:${id}`);
assert.equal(["ground", "pbr", "pbr_double"].includes(color[0].node), false, name);
}
const colorDescriptor = byId[color[0].node].parameters.texture;
const depthDescriptor = byId[depth[0].node].parameters.texture;
assert.equal(depthDescriptor.format, "depth32_float", name);
assert.deepEqual(depthDescriptor.extent, colorDescriptor.extent, name);
assert.equal(depthDescriptor.sampleCount, colorDescriptor.sampleCount, name);
}
const midnight = Object.fromEntries(presets.midnight.nodes.map((node) => [node.id, node]));
assert.deepEqual(midnight.ground.inputs.colorTarget, [{ node: "ldr", socket: "texture" }]);
});