Class ShaderFormatDetector
- Namespace
- ShadowDusk.Core
- Assembly
- ShadowDusk.Core.dll
Identifies a shader's source language from its text alone, so callers that receive a shader from a stream, a byte buffer, or a package whose files lost their extensions can still route it. It is a cheap structural check on comment- and string-stripped text, never a parse or a compile: the frontend that receives the shader does the real validation and fails loudly if the guess was wrong.
public static class ShaderFormatDetector
- Inheritance
-
ShaderFormatDetector
- Inherited Members
Remarks
Rules, in order:
- A
techniqueblock AND a GLSL entry (mainImage, or a parameterlessvoid main()): ambiguous, unless the name hint's extension picks one side. - A
techniqueblock: FxEffect. This wins over Slang markers, because HLSL-compatible Slang with a technique block compiles as an effect. - A
[shader("...")]attribute, or a line-leadingimport x;/module x;: Slang. - A GLSL entry: Glsl.
- No signal: the name hint's extension if it names a format, else Unknown.
The name hint never overrides a content signal; it only settles rules 1 and 5.
Recognized hint extensions: .fx; .slang; .glsl, .frag,
.fs, .glslf.
Methods
Detect(string, string?)
Detects the source language of source. Never throws for any input
text; a null source throws ArgumentNullException.
public static ShaderFormatDetection Detect(string source, string? nameHint = null)
Parameters
sourcestringThe shader source text.
nameHintstringOptional file name or path. Only its extension is read, and only to settle ambiguous content or content with no signal at all.