Class FxPreParser
- Namespace
- ShadowDusk.HLSL
- Assembly
- ShadowDusk.HLSL.dll
FX9 pre-parser: strips technique, pass, and sampler_state blocks from .fx source and extracts all FX9 metadata needed by the compilation pipeline. DXC rejects these constructs, so they must be removed before invoking DXC. Stripped output preserves original line numbers by replacing removed lines with blank lines. FxSourceMode selects how legacy D3D9 constructs in the shader body are treated: rewritten forward to SM4 for DXC (the default), or preserved verbatim for an SM1–3 backend (the FNA fx_2_0 target, compiled by vkd3d).
public sealed class FxPreParser
- Inheritance
-
FxPreParser
- Inherited Members
Methods
IsDirectX11Profile(string)
Returns true when profile (a recognized profile, already
lowercased) is one MonoGame's DirectX_11 shader profile accepts. Anything
else is below that target's floor and is rejected by mgfxc with
"must be SM 4.0 level 9.1 or higher!"; ShadowDusk reports the same condition
as SD0015. See the empirical note on the backing set.
public static bool IsDirectX11Profile(string profile)
Parameters
profilestring
Returns
IsKnownProfile(string)
Returns true when the given profile string (already lowercased) is a recognized shader profile.
public static bool IsKnownProfile(string profile)
Parameters
profilestring
Returns
LooksLikeProfile(string)
Returns true when token is SHAPED like a shader profile
(a vs_/ps_/gs_/hs_/ds_/cs_ stage prefix
immediately followed by a digit) REGARDLESS of whether it is a recognized profile.
This distinguishes a typo'd real-shaped profile (ps_9_9) — which is
unconditionally invalid and can be rejected without any macro expansion — from a
macro NAME (PS_SHADERMODEL), which may still expand to a valid profile. It is
NOT a substitute for IsKnownProfile(string): a profile-shaped token is not
necessarily a real profile.
public static bool LooksLikeProfile(string token)
Parameters
tokenstring
Returns
Parse(string, string)
Parses an FX9 .fx source file, strips FX9-specific blocks, and extracts metadata, rewriting legacy D3D9 constructs forward to SM4 (RewriteToSm4).
public static Result<FxParseResult, FxParseError> Parse(string source, string sourceFile)
Parameters
sourcestringFull text of the .fx file.
sourceFilestringDisplay name used in diagnostics (file path or virtual name).
Returns
Parse(string, string, FxSourceMode)
Parses an FX9 .fx source file, strips FX9-specific blocks, and extracts metadata.
public static Result<FxParseResult, FxParseError> Parse(string source, string sourceFile, FxSourceMode mode)
Parameters
sourcestringFull text of the .fx file.
sourceFilestringDisplay name used in diagnostics (file path or virtual name).
modeFxSourceModeHow legacy D3D9/SM3 constructs in the shader body are treated (rewritten forward for DXC, or preserved verbatim for an SM1–3 backend).