refactor: consolidate render graph architecture
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:
@@ -71,7 +71,6 @@ function publish(telemetry) {
|
||||
activeCompiledGraph: telemetry.activeCompiledGraph,
|
||||
activeCompiledRevision: telemetry.activeCompiledRevision,
|
||||
activeCompiledSchemaVersion: telemetry.activeCompiledSchemaVersion,
|
||||
graphPasses: telemetry.graphPasses,
|
||||
graphExecutions: telemetry.graphExecutions,
|
||||
graphTextureSlots: telemetry.graphTextureSlots,
|
||||
draws: telemetry.draws,
|
||||
|
||||
@@ -345,76 +345,3 @@ export function adaptFxNodeSnapshot(raw, revision = 1) {
|
||||
fail("AUTHORING_SHAPE");
|
||||
}
|
||||
}
|
||||
export const adaptGraphSnapshot = adaptFxNodeSnapshot;
|
||||
|
||||
/** Compatibility helper retained for V1 presets. */
|
||||
export function semanticProjectionToV1(p, revision = 1) {
|
||||
const extent = {
|
||||
kind: "surface_relative",
|
||||
width: { numerator: 1, denominator: 1 },
|
||||
height: { numerator: 1, denominator: 1 },
|
||||
depthOrArrayLayers: 1,
|
||||
};
|
||||
return {
|
||||
schemaVersion: 1,
|
||||
graphId: p.graphId,
|
||||
revision,
|
||||
resources: [
|
||||
{
|
||||
id: "surface",
|
||||
version: 0,
|
||||
residency: { kind: "external", source: "surface_color" },
|
||||
texture: {
|
||||
dimension: "d2",
|
||||
format: "surface",
|
||||
extent,
|
||||
mipLevelCount: 1,
|
||||
sampleCount: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "depth",
|
||||
version: 0,
|
||||
residency: { kind: "transient" },
|
||||
texture: {
|
||||
dimension: "d2",
|
||||
format: "depth32_float",
|
||||
extent,
|
||||
mipLevelCount: 1,
|
||||
sampleCount: 1,
|
||||
},
|
||||
},
|
||||
],
|
||||
passes: [
|
||||
{
|
||||
id: "forward",
|
||||
state: p.passState,
|
||||
executor: { key: "scene_forward", version: 1 },
|
||||
parameters: {},
|
||||
reads: [],
|
||||
writes: [
|
||||
{
|
||||
binding: "color",
|
||||
resource: { id: "surface", version: 0 },
|
||||
access: {
|
||||
kind: "color_attachment",
|
||||
location: 0,
|
||||
load: { op: "clear", value: p.clearColor },
|
||||
store: "store",
|
||||
},
|
||||
},
|
||||
{
|
||||
binding: "depth",
|
||||
resource: { id: "depth", version: 0 },
|
||||
access: {
|
||||
kind: "depth_attachment",
|
||||
load: { op: "clear", value: p.clearDepth },
|
||||
store: "store",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
outputs: [{ name: "present", resource: { id: "surface", version: 0 } }],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,13 +1,3 @@
|
||||
import { semanticProjectionToV1 } from "./adapter.js";
|
||||
const make = (graphId, clearColor) =>
|
||||
Object.freeze(
|
||||
semanticProjectionToV1(
|
||||
{ graphId, clearColor, clearDepth: 1, passState: "enabled" },
|
||||
1,
|
||||
),
|
||||
);
|
||||
export const midnight = make("preset_midnight", [0.015, 0.06, 0.18, 1]);
|
||||
export const ember = make("preset_ember", [0.18, 0.035, 0.012, 1]);
|
||||
const input = (node, socket) => ({ node, socket });
|
||||
const node = (id, key, parameters = {}, inputs = {}) => ({
|
||||
id,
|
||||
@@ -32,6 +22,38 @@ const texture = (format) => ({
|
||||
},
|
||||
residency: "transient",
|
||||
});
|
||||
const direct = (graphId, clearColor) => Object.freeze({
|
||||
schemaVersion: 2,
|
||||
graphId,
|
||||
revision: 1,
|
||||
nodes: [
|
||||
node("surface", "surface_target"),
|
||||
node("depth", "texture_spec", texture("depth32_float")),
|
||||
node("scene", "scene_table"),
|
||||
node("visible", "visibility_flags", {}, { scene: input("scene", "scene") }),
|
||||
node("query", "mesh_query", {
|
||||
filters: [
|
||||
{ flag: "isVisible", predicate: "required_true" },
|
||||
{ flag: "isFrustumCulled", predicate: "any" },
|
||||
],
|
||||
}, { scene: input("scene", "scene"), isVisible: input("visible", "flags") }),
|
||||
node("depth_config", "depth_stencil_config", {
|
||||
depthCompare: "less_equal",
|
||||
depthWriteEnabled: true,
|
||||
clearDepth: 1,
|
||||
}),
|
||||
node("forward", "legacy_forward", { clearColor }, {
|
||||
scene: input("scene", "scene"),
|
||||
draws: input("query", "draws"),
|
||||
colorTarget: input("surface", "surface"),
|
||||
depthTarget: input("depth", "spec"),
|
||||
depthStencil: input("depth_config", "config"),
|
||||
}),
|
||||
node("present", "present", {}, { surface: input("forward", "color") }),
|
||||
],
|
||||
});
|
||||
export const midnight = direct("preset_midnight", [0.015, 0.06, 0.18, 1]);
|
||||
export const ember = direct("preset_ember", [0.18, 0.035, 0.012, 1]);
|
||||
export const hdr = Object.freeze({
|
||||
schemaVersion: 2,
|
||||
graphId: "preset_hdr_fullscreen",
|
||||
|
||||
Reference in New Issue
Block a user