Vixen
dd8b0a81
csharp
public static class TextureKernelPrelude

The shader-library sources every kernel is compiled beside, so that a kernel can import rather than transcribe.

Read the guide page for this →

Remarks

⚠ A kernel could always have imported; what it could not do was be compiled alone. #635 reads as though an import in a texture-graph kernel is refused by the compiler and offers two answers — a compiled .rvnlib handed to referencePaths, or a prelude this assembly writes and prepends. Both are wrong about the cause. FromSources takes a set of texts and makes them one compilation, and a package's declarations are visible across one compilation; the evaluator was passing one text. So the fix is neither a build artefact nor a second copy of the arithmetic: it is the library's own .rvn files, embedded verbatim, in the same list.

Which sources, and why exactly these four. Material/ComputeColor.rvn is what doc 48 § 4.2's colour kernels want — the YIQ hue rotation, the blend modes. It imports Vixen.Shaders.Core, and Core/Random.rvn in turn spells Math.SphericalToCartesian and Const.TwoPi, so Core/Math.rvn comes with it. ⚠ That last edge is the one worth writing down: a set that stops at Random.rvn fails with RVN2010: The name 'Math' does not exist on every kernel at once, because the library file is bound whether the kernel calls into that part of it or not.

⚠ Core/ColorSpaces.rvn is the fourth, and adding it is what closed #1093. Three kernels wrote Rec. 709 out as a dot against a literal triple under headers saying the library had no Luminance(linear: float3): float to call. It has had one all along — the obstacle was never a signature, a package or an import, it was this list. ⚠ The lesson generalises past luminance: "the library does not have it" is a claim about these entries written as though it were a claim about Raven/Library, and the two are different sets. ColorSpaces.rvn imports nothing and spells Const.Epsilon, which Core/Math.rvn already supplies, so the closure does not grow past it.

⚠ Embedded from the library's own path, not copied into this assembly. The EmbeddedResource entries in the .csproj point at Raven/Library/** and give the resource a LogicalName under a prefix TextureKernels does not read — so there is exactly one copy of these functions in the repository, editing the library edits what a kernel compiles against, and the folder that is the kernel list stays the folder it was.

What it costs. Every variant parses four more files. That is four parses against a lowering, a code generation and a pipeline creation, and it is paid once per (kernel, format) because TexturePlanEvaluator caches the variant. What it does not cost is module size: a library function no kernel calls is unreferenced and does not reach the emitted module.

Fields and properties (1)

  • public static ImmutableArray<(string Name, string Text)> Sources

    The library sources, in the order a compilation is handed them.

Methods (1)

  • public static RavenEffectCompiler Compile(string name, string source)

    Compiles one kernel source against the library.

Used by (15)

  • TextureAnalysisKernelTestsVixen.Editor.TextureGraph.Tests
  • TextureColourKernelTestsVixen.Editor.TextureGraph.Tests
  • TextureFilterKernelTestsVixen.Editor.TextureGraph.Tests
  • TextureGraphCompilerTestsVixen.Editor.TextureGraph.Tests
  • TextureKernelLanguageSeamTestsVixen.Editor.TextureGraph.Tests
  • TextureKernelSabotageTestsVixen.Editor.TextureGraph.Tests
  • TextureKernelTestsVixen.Editor.TextureGraph.Tests
  • TextureNodeLibraryTestsVixen.Editor.TextureGraph.Tests
  • TexturePixelProcessorTestsVixen.Editor.TextureGraph.Tests
  • TexturePlacementKernelTestsVixen.Editor.TextureGraph.Tests
  • TexturePlanEvaluatorVixen.Editor.TextureGraph
  • TexturePlanKernelTestsVixen.Editor.TextureGraph.Tests
  • TexturePreludeManifestTestsVixen.Editor.TextureGraph.Tests
  • TextureSourceKernelTestsVixen.Editor.TextureGraph.Tests
  • TextureSurfaceKernelTestsVixen.Editor.TextureGraph.Tests