Class Preprocessor
- Namespace
- ShadowDusk.Core.Preprocessor
- Assembly
- ShadowDusk.Core.dll
Flattens an HLSL source tree by expanding all #include directives (honoring
#pragma once and detecting circular includes) and prepending the platform macros,
producing a single self-contained PreprocessedSource for the compiler.
public sealed class Preprocessor
- Inheritance
-
Preprocessor
- Inherited Members
Constructors
Preprocessor()
Creates a preprocessor that asks the real file system how it spells resolved include paths.
public Preprocessor()
Preprocessor(IIncludePathCanonicalizer)
Creates a preprocessor with an explicit IIncludePathCanonicalizer.
public Preprocessor(IIncludePathCanonicalizer pathCanonicalizer)
Parameters
pathCanonicalizerIIncludePathCanonicalizerDecides whether two case-only path variants name the same file, and supplies the on-disk spelling the
SD0008portability warning reports. Injectable so both file-system behaviours (case-sensitive, as on Android and Linux and case-sensitive APFS; and case-insensitive, as on a default Windows or macOS volume) can be driven from a pure unit test on any host.
Methods
Flatten(string, string, MacroSet, IIncludeResolver, IReadOnlyList<string>)
Expands all includes in the source and prepends the platform macros.
public Result<PreprocessedSource, ShaderError> Flatten(string cleanedHlsl, string originalFilePath, MacroSet macros, IIncludeResolver includeResolver, IReadOnlyList<string> additionalPaths)
Parameters
cleanedHlslstringThe HLSL entry source (comments may still be present; the include scanner is comment-aware and ignores directives inside them).
originalFilePathstringThe entry source's path, used for diagnostics and relative includes.
macrosMacroSetThe platform macros to prepend.
includeResolverIIncludeResolverThe resolver used to fetch
#includetargets.additionalPathsIReadOnlyList<string>Extra include search directories.
Returns
- Result<PreprocessedSource, ShaderError>
The flattened source on success (carrying any non-fatal Warnings), or a ShaderError on a missing or circular include.