refactor: order raster cohorts by authored nodes
Amp-Thread-ID: https://ampcode.com/threads/T-019ff1fa-611d-71c8-aefd-86659bff2075 Co-authored-by: Akash Shakdwipeea <ashakdwipeea@gmail.com>
This commit is contained in:
@@ -334,6 +334,7 @@ export function adaptFxNodeSnapshot(raw, revision = 1) {
|
||||
sockets.set(s.id, {
|
||||
node: n.id,
|
||||
key: s.key,
|
||||
semanticName: (input ?? descriptor.outputs[s.key]).semanticName ?? s.key,
|
||||
direction,
|
||||
semanticType: input
|
||||
? input.accepted.types[0]
|
||||
@@ -350,7 +351,7 @@ export function adaptFxNodeSnapshot(raw, revision = 1) {
|
||||
for (const key of Object.keys(descriptor.inputs)) {
|
||||
const authoredDefault = sockets.get(`${n.id}:${key}`).defaultValue;
|
||||
if (authoredDefault)
|
||||
parameters[`${key}Default`] = parameterValue(
|
||||
parameters[`${descriptor.inputs[key].semanticName ?? key}Default`] = parameterValue(
|
||||
authoredDefault,
|
||||
definition.sockets[key].value,
|
||||
n.id,
|
||||
@@ -446,9 +447,9 @@ export function adaptFxNodeSnapshot(raw, revision = 1) {
|
||||
linkSources.set(link.id, linkSource);
|
||||
if (!link.muted) {
|
||||
incoming.set(link.toSocketId, (incoming.get(link.toSocketId) ?? 0) + 1);
|
||||
(nodes.get(to.node).value.inputs[to.key] ??= []).push({
|
||||
(nodes.get(to.node).value.inputs[to.semanticName] ??= []).push({
|
||||
node: from.node,
|
||||
socket: from.key,
|
||||
socket: from.semanticName,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -463,8 +464,9 @@ export function adaptFxNodeSnapshot(raw, revision = 1) {
|
||||
const item = ordered[wireOrdinal];
|
||||
item.value.inputs = Object.fromEntries(
|
||||
Object.keys(descriptors[item.value.executor.key].inputs)
|
||||
.filter((key) => Object.hasOwn(item.value.inputs, key))
|
||||
.map((key) => [key, item.value.inputs[key]]),
|
||||
.map((key) => descriptors[item.value.executor.key].inputs[key].semanticName ?? key)
|
||||
.filter((semanticName) => Object.hasOwn(item.value.inputs, semanticName))
|
||||
.map((semanticName) => [semanticName, item.value.inputs[semanticName]]),
|
||||
);
|
||||
const base = `nodes[${wireOrdinal}]`;
|
||||
const nodeSource = { kind: "node", nodeId: item.value.id };
|
||||
@@ -561,12 +563,13 @@ export function adaptFxNodeSnapshot(raw, revision = 1) {
|
||||
socketId: `${item.value.id}:${key}`,
|
||||
unconnected: true,
|
||||
};
|
||||
paths[`${base}.inputs.${key}`] = source;
|
||||
const semanticName = descriptors[item.value.executor.key].inputs[key].semanticName ?? key;
|
||||
paths[`${base}.inputs.${semanticName}`] = source;
|
||||
for (const [index, link] of links.entries()) {
|
||||
const linkSource = linkSources.get(link.id);
|
||||
paths[`${base}.inputs.${key}[${index}]`] = linkSource;
|
||||
paths[`${base}.inputs.${key}[${index}].node`] = linkSource;
|
||||
paths[`${base}.inputs.${key}[${index}].socket`] = {
|
||||
paths[`${base}.inputs.${semanticName}[${index}]`] = linkSource;
|
||||
paths[`${base}.inputs.${semanticName}[${index}].node`] = linkSource;
|
||||
paths[`${base}.inputs.${semanticName}[${index}].socket`] = {
|
||||
kind: "socket",
|
||||
nodeId: link.fromNodeId,
|
||||
socketId: link.fromSocketId,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export const GRAPH_ID = "authored_gpu_culling";
|
||||
export const CATALOG_VERSION = 12;
|
||||
export const CATALOG_VERSION = 13;
|
||||
const exact = (type) => ({ kind: "exact", types: [type] });
|
||||
const i = (type, minimum = 1, authoringType, defaultPolicy = minimum ? "none" : "parameter_literal", maximum = 1) => ({
|
||||
accepted: typeof type === "string" ? exact(type) : type,
|
||||
@@ -7,7 +7,7 @@ const i = (type, minimum = 1, authoringType, defaultPolicy = minimum ? "none" :
|
||||
...(authoringType ? { authoringType } : {}),
|
||||
defaultPolicy,
|
||||
});
|
||||
const o = (type) => ({ type });
|
||||
const o = (type, semanticName) => ({ type, ...(semanticName ? { semanticName } : {}) });
|
||||
const expression = (inputs, outputs) => ({
|
||||
version: 1,
|
||||
execution: "expression",
|
||||
@@ -66,12 +66,12 @@ const texture = {
|
||||
const rasterInputs = () => ({
|
||||
mesh: i("mesh_data"),
|
||||
predicate: i("bool", 0),
|
||||
colorTarget: i("texture", 0, undefined, "compiler_texture"),
|
||||
depthTarget: i("texture", 0, undefined, "compiler_texture"),
|
||||
"input.color": { ...i("texture", 0, undefined, "compiler_texture"), semanticName: "color" },
|
||||
"input.depth": { ...i("texture", 0, undefined, "compiler_texture"), semanticName: "depth" },
|
||||
});
|
||||
const rasterOutputs = () => ({ color: o("texture"), depth: o("texture") });
|
||||
const rasterParameters = () => ({ drawOrder: 0, depthCompare: "less_equal", depthWriteEnabled: true, clearDepth: 1, clearColor: [0.015, 0.02, 0.03, 1] });
|
||||
const raster = () => ({ version: 1, execution: "render", inputs: rasterInputs(), outputs: rasterOutputs(), parameters: rasterParameters() });
|
||||
const rasterOutputs = () => ({ "output.color": o("texture", "color"), "output.depth": o("texture", "depth") });
|
||||
const rasterParameters = () => ({ depthCompare: "less_equal", depthWriteEnabled: true, clearDepth: 1, clearColor: [0.015, 0.02, 0.03, 1] });
|
||||
const raster = () => ({ version: 2, execution: "render", inputs: rasterInputs(), outputs: rasterOutputs(), parameters: rasterParameters() });
|
||||
export const NODE_TITLE_OVERRIDES = Object.freeze({
|
||||
ground_plane: "Ground Plane",
|
||||
gltf_standard: "glTF Standard",
|
||||
@@ -379,7 +379,6 @@ const parameterSchemas = {
|
||||
mesh: {},
|
||||
frustum_cull: { cameraSelection: enumeration("active", ["active"]) },
|
||||
ground_plane: {
|
||||
drawOrder: { ...number(0, -2147483648, 2147483647), integer: true },
|
||||
depthCompare: enumeration("less_equal", [
|
||||
"never",
|
||||
"less",
|
||||
@@ -431,7 +430,7 @@ export const nodeDefinitions = Object.fromEntries(
|
||||
Object.entries(c.inputs).map(([n, v]) => [
|
||||
n,
|
||||
socket(
|
||||
n,
|
||||
v.semanticName ?? n,
|
||||
"input",
|
||||
v.authoringType ?? v.accepted.types[0],
|
||||
v.defaultPolicy === "parameter_literal" ? socketDefault(v.accepted.types[0], defaultForInput(key, n, v.accepted.types[0])) : null,
|
||||
@@ -442,7 +441,7 @@ export const nodeDefinitions = Object.fromEntries(
|
||||
...Object.fromEntries(
|
||||
Object.entries(c.outputs).map(([n, v]) => [
|
||||
n,
|
||||
socket(n, "output", v.authoringType ?? v.type),
|
||||
socket(v.semanticName ?? n, "output", v.authoringType ?? v.type),
|
||||
]),
|
||||
),
|
||||
},
|
||||
@@ -483,7 +482,6 @@ export const nodeDefinitions = Object.fromEntries(
|
||||
nodeDefinitions.mesh.sockets.localAabb.title = "Local AABB";
|
||||
for (const key of Object.keys(NODE_TITLE_OVERRIDES)) {
|
||||
for (const item of nodeDefinitions[key].ui) {
|
||||
if (item.parameter === "drawOrder") item.title = "Draw Order";
|
||||
if (item.parameter === "clearColor") item.title = "Initial Color";
|
||||
if (item.parameter === "clearDepth") item.title = "Initial Depth";
|
||||
}
|
||||
|
||||
@@ -39,12 +39,12 @@ const scene = (colorTarget, clearColor = [0.015, 0.02, 0.03, 1], heightScale = 1
|
||||
node("scene_depth", "texture", texture("depth32_float", 1, heightScale, sampleCount)),
|
||||
node("mesh", "mesh"),
|
||||
...classification.nodes,
|
||||
node("ground", "ground_plane", { drawOrder: 0, depthCompare: "less_equal", depthWriteEnabled: true, clearDepth: 1, clearColor, predicateDefault: true }, { mesh: input("mesh", "mesh"), predicate: input(classification.classes.ground, "value"), colorTarget: input(target, "texture"), depthTarget: input("scene_depth", "texture") }),
|
||||
node("pbr", "gltf_standard", { drawOrder: 1, depthCompare: "less_equal", depthWriteEnabled: true, clearDepth: 1, clearColor, predicateDefault: true }, { mesh: input("mesh", "mesh"), predicate: input(classification.classes.pbr, "value"), colorTarget: input(target, "texture"), depthTarget: input("scene_depth", "texture") }),
|
||||
node("pbr_double", "gltf_standard_double_sided", { drawOrder: 2, depthCompare: "less_equal", depthWriteEnabled: true, clearDepth: 1, clearColor, predicateDefault: true }, { mesh: input("mesh", "mesh"), predicate: input(classification.classes.pbr_double, "value"), colorTarget: input(target, "texture"), depthTarget: input("scene_depth", "texture") }),
|
||||
node("ground", "ground_plane", { depthCompare: "less_equal", depthWriteEnabled: true, clearDepth: 1, clearColor, predicateDefault: true }, { mesh: input("mesh", "mesh"), predicate: input(classification.classes.ground, "value"), color: input(target, "texture"), depth: input("scene_depth", "texture") }),
|
||||
node("pbr", "gltf_standard", { depthCompare: "less_equal", depthWriteEnabled: true, clearDepth: 1, clearColor, predicateDefault: true }, { mesh: input("mesh", "mesh"), predicate: input(classification.classes.pbr, "value"), color: input(target, "texture"), depth: input("scene_depth", "texture") }),
|
||||
node("pbr_double", "gltf_standard_double_sided", { depthCompare: "less_equal", depthWriteEnabled: true, clearDepth: 1, clearColor, predicateDefault: true }, { mesh: input("mesh", "mesh"), predicate: input(classification.classes.pbr_double, "value"), color: input(target, "texture"), depth: input("scene_depth", "texture") }),
|
||||
];
|
||||
};
|
||||
const graph = (graphId, nodes) => Object.freeze({ schemaVersion: 3, graphId, revision: 3, nodes });
|
||||
const graph = (graphId, nodes) => Object.freeze({ schemaVersion: 3, graphId, revision: 4, nodes });
|
||||
const direct = (graphId, clearColor) => graph(graphId, [
|
||||
node("ldr", "texture", texture("rgba8_unorm")),
|
||||
...scene("ldr", clearColor),
|
||||
|
||||
Reference in New Issue
Block a user