Table of Contents

Namespace ShadowDusk.HLSL

Classes

FxParseError

A structured diagnostic error produced by the FX9 pre-parser.

FxPreParser

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).

GlobalInitializerDefault

The default value of one global uniform, read off its HLSL initializer (float R = 1;).

GlobalInitializerFailure

A global initializer the reader found but could not turn into a default.

GlobalInitializerReader

Reads the initializers of global (and cbuffer) numeric declarations out of an HLSL effect and evaluates them to the default-value blobs an .mgfx / .knifx carries.

Why this exists. DXC drops the initializer of a global that lands in $Globals (it only warns), and vkd3d's DXBC does not carry it either, so nothing downstream of the compilers knows float R = 1; had a value. fxc (and so mgfxc on DirectX) does keep it. The initializer has to come from the source: this reads the preprocessed text the compilers are given (macros expanded, conditionals evaluated, the compile's own defines honoured), finds declaration-scope numeric declarations, and evaluates the initializer itself.

What it evaluates. Numeric literals (decimal, hex, exponents, f/h/u/l suffixes), true/false, the arithmetic, shift, bitwise, comparison, logical and ternary operators, (type) casts, scalar / vector / matrix constructors (float4(1,0,0,1), float2x2(...), float4(v.xy, 0, 1)), swizzles, constant indexing, brace lists, arrays of any of those, earlier const / static const scalars, and a small set of math intrinsics. Float arithmetic rounds to 32 bits at every step. Anything else (a function call it does not model, a struct, a texture) is reported in Failures, never silently turned into zero.

Blob layout. Exactly what MonoGame's EffectParameter.SetValue would leave in Data: scalars and vectors are their components; a matrix is written column by column (Data[c * Rows + r] = M[r][c], the "HLSL expects matrices to be transposed" layout); int is its 32-bit value, and bool is 0xFFFFFFFF for true, the value D3D reflection hands mgfxc.

GlobalInitializers

What Read(string, string) found.

Sm3StageReservationRewriter

Rewrites D3D9 stage-scoped register reservations for a single-stage SM1–3 compile. D3D9-era HLSL can scope a register bind to one shader stage — float4 Color : register(vs, c0); / : register(ps, c1); / sampler s : register(ps, s0); — but vkd3d 2.1's HLSL compiler fails with E5017 "Reservation shader target" on that stage-scoped form while fully honoring the plain : register(c0) form. The FNA fx_2_0 pipeline therefore rewrites the source PER STAGE before each vkd3d compile (once for vs_3_0, once for ps_3_0).

Enums

FxParseErrorCode

Diagnostic codes emitted by the FX9 pre-parser.

FxSourceMode

How the FX9 pre-parser treats legacy D3D9/SM3 constructs in the shader body.

GlobalInitializerKind

The scalar kind an HLSL numeric declaration is made of.