Vixen
dd8b0a81
csharp
public sealed class TextureGraphCompiler

A texture graph, as a TexturePlan.

Read the guide page for this →

Remarks

Pure, and doc 48 § D5 is explicit about why. Nothing here opens a device, allocates a texture or dispatches anything: compiling a graph is a walk over nodes that appends records to two lists, so it is testable with no provider, cheap enough to run on every edit, and the thing a background bake is handed rather than the thing a background bake is. Every assertion about what a graph means is therefore an assertion about a value, and the one test that needs a GPU is the differential that proves the value is the one the evaluator already draws correctly.

Images are allocated per output port and freed by the pool. A node asks for the image it writes and gets a fresh index; nothing here reuses one, because TexturePoolSchedule already reads the op order as a liveness and does it better than a compiler could — an image is written exactly once, which is the invariant that makes that possible and the reason a two-pass filter asks for a scratch rather than writing its output twice.

⚠ Grey against colour is decided here and nowhere else. Accepts passes every image-to-image wire, deliberately — a PortKind carries no format — so doc 48 § Part 4's promotion rule is this class's: a node resolves to the widest thing arriving at its image inputs, a grey feeding one that resolved to colour is splatted by an inserted ChannelShuffle, and a colour arriving at a port that measures is a type error naming that port. It is Dynamic's widening rule reused rather than a second type system.

Fields and properties (14)

  • public int BaseWidth

    The width the graph was authored at, in texels, when the graph says nothing.

  • public int BaseHeight

    The height the graph was authored at.

  • public int BakeLevelOffset

    How much bigger this bake is than the resolution the graph was authored at.

  • public uint Seed

    The plan's seed, from which every op's is derived.

  • public ImmutableArray<TextureGraphOutput> Outputs

    What each output the last compilation produced is for.

  • public List<TextureGraphParameter> Parameters

    The exposed parameters a host declares, for a graph that declares none of its own.

  • public IReadOnlyDictionary<string, string>? Arguments

    What an author or a .vxsmartmat overrode a parameter to, by name.

  • public IReadOnlyDictionary<string, float> ParameterValues

    What each parameter was worth in the last compilation.

  • public bool PreviewEveryNode

    Whether every node's output is kept, so each can be looked at.

  • public ImmutableArray<TextureGraphNodeImage> NodeImages

    Which image each node's output port wrote in the last compilation.

  • public ImmutableArray<TextureGraphKernel> Kernels

    The kernels the last compilation's own nodes authored.

  • public ImmutableArray<TextureGraphExternal> Externals

    What fills each external image the last compilation asked for.

  • public int ExpressionCompilations

    How many times the last compilation asked Raven to compile an expression source.

  • protected override ISubGraphValues SubGraphValues

Methods (8)

  • public TextureGraphCompiler(NodeTypeRegistry registry)

    Starts a compiler over a node library.

  • protected override void Prepare(NodeGraphModel graph)
  • protected override void Begin(NodeGraphModel graph)

    Called before the walk, to reset whatever the subclass accumulates.

  • protected override string Setting(GraphNode node, string name, string value)
  • protected override void Visit(GraphNode node, NodeTypeDefinition definition, Node instance, NodeBinding binding)

    Called once per node, in dependency order, with its ports already filled.

  • protected override TexturePlan? Finish(NodeGraphModel graph)

    Called after the walk, when nothing went wrong, to produce the artefact.

  • protected override string Constant(ReadOnlySpan<float> value, PortKind kind)
  • protected override string Convert(string expression, PortKind from, PortKind target)

Used by (32)

  • BakedMaterialImageTestsVixen.Graphics.Golden.Tests
  • LayerStackCompilerVixen.Editor.Texturing
  • MeshMapGeneratorBindingTestsVixen.Editor.App.Tests
  • TextureCompoundBakeDeviceTestsVixen.Editor.TextureGraph.Tests
  • TextureCompoundLibraryTestsVixen.Editor.TextureGraph.Tests
  • TextureDiagnosticIdTestsVixen.Editor.TextureGraph.Tests
  • TextureEmitterVixen.Editor.TextureGraph
  • TextureExpressionCostTestsVixen.Editor.TextureGraph.Tests
  • TextureExternalGraphDeviceTestsVixen.Editor.TextureGraph.Tests
  • TextureGraphCompilerTestsVixen.Editor.TextureGraph.Tests
  • TextureGraphDeclarationTestsVixen.Editor.TextureGraph.Tests
  • TextureGraphDeviceTestsVixen.Editor.TextureGraph.Tests
  • TextureGraphDocumentVixen.Editor.Texturing
  • TextureGraphNameKnobTestsVixen.Editor.TextureGraph.Tests
  • TextureGraphParameterTestsVixen.Editor.TextureGraph.Tests
  • TextureGraphPreviewDeviceTestsVixen.Editor.TextureGraph.Tests
  • TextureGraphPreviewsVixen.Editor.TextureGraph
  • TextureGraphRunnerVixen.Cli
  • TextureGraphSubGraphTestsVixen.Editor.TextureGraph.Tests
  • TextureLevelDeviceTestsVixen.Editor.TextureGraph.Tests
  • TextureMeshMapNodeTestsVixen.Editor.TextureGraph.Tests
  • TextureNodeLibraryTestsVixen.Editor.TextureGraph.Tests
  • TextureNodeResolutionTestsVixen.Editor.TextureGraph.Tests
  • TextureOutputLevelTestsVixen.Editor.TextureGraph.Tests
  • TexturePixelProcessorTestsVixen.Editor.TextureGraph.Tests
  • TexturePlanKernelDeviceTestsVixen.Editor.TextureGraph.Tests
  • TexturePlanKernelTestsVixen.Editor.TextureGraph.Tests
  • TexturePlanSeedTestsVixen.Editor.TextureGraph.Tests
  • TextureResampleFilterTestsVixen.Editor.TextureGraph.Tests
  • TextureSettingChoiceTestsVixen.Editor.TextureGraph.Tests
  • TextureVariantCacheTestsVixen.Editor.TextureGraph.Tests
  • TexturingModuleVixen.Editor.Texturing