public abstract class NodeGraphCompiler<TArtefact> where TArtefact : classA graph, walked in order, with every node's ports resolved and bound. What is done with each one is the subclass's.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
What is shared and what is not. Walking a graph in dependency order, deciding what a dynamic port resolved to, naming the variable an output writes, converting a value that arrives at a port of a different width, and reporting all of it against the node it came from — none of that differs between a shader graph and a VFX graph. What differs is the language the literals and conversions are spelled in, and what a bound node does. Those three are abstract and nothing else is.
Names are derived from identity, not from a counter. An output's variable is n{id}_{port}, so compiling the same graph twice produces the same source — which is what a golden test needs, and what makes a diff between two saved versions of a graph mean something.
It keeps going after an error. A graph with a missing node type and a badly typed edge should report both, because an author fixing one at a time is an author compiling five times. The artefact is withheld at the end rather than the walk abandoned at the first problem.
Fields and properties (3)
protected NodeTypeRegistry RegistryThe node types the graph may contain.
public ISubGraphSource? SubGraphSourceWhere sub-graphs are found, or null when this compiler does not support them.
protected bool HasErrorsWhether anything has gone wrong so far.
Methods (9)
protected NodeGraphCompiler(NodeTypeRegistry registry)Starts a compiler over a node library.
public NodeGraphCompilation<TArtefact> Compile(NodeGraphModel graph)Compiles a graph.
protected virtual void Begin(NodeGraphModel graph)Called before the walk, to reset whatever the subclass accumulates.
protected abstract void Visit(GraphNode node, NodeTypeDefinition definition, Node instance, NodeBinding binding)Called once per node, in dependency order, with its ports already filled.
protected abstract TArtefact? Finish(NodeGraphModel graph)Called after the walk, when nothing went wrong, to produce the artefact.
protected abstract string Constant(ReadOnlySpan<float> value, PortKind kind)How a constant is spelled in the target language.
protected abstract string Convert(string expression, PortKind from, PortKind target)How a value of one kind is read as another.
protected void Report(NodeDiagnostic diagnostic)Says something about a node.
protected static string Variable(GraphNode node, string port)The variable one output writes to.
Used by (14)
- CompositorCompilerTestsVixen.Editor.AssetEditors.Tests
- CompositorDocumentVixen.Editor.AssetEditors
- CompositorGraphCompilerVixen.Editor.AssetEditors
- ListingCompilerVixen.Editor.NodeGraph.Tests
- NodeTypingTestsVixen.Editor.NodeGraph.Tests
- RecordingVixen.Editor.NodeGraph.Tests
- ShaderGraphCompilerVixen.Editor.ShaderGraph
- ShaderGraphCompilerTestsVixen.Editor.ShaderGraph.Tests
- ShaderGraphDocumentVixen.Editor.AssetEditors
- SubGraphTestsVixen.Editor.NodeGraph.Tests
- VfxDocumentVixen.Editor.AssetEditors
- VfxGraphCompilerVixen.Editor.VfxGraph
- VfxGraphCompilerTestsVixen.Editor.VfxGraph.Tests
- VfxImporterVixen.Editor.Assets