Namespace ShadowDusk.Core.Reflection
Classes
- AnnotationReflection
A reflected HLSL annotation (a
name = valuepair) on an effect parameter.
- BindingSlotMap
Maps texture and sampler names to their bind slots, used to align reflected resource names with the slots emitted in the compiled shader.
- ConstantBufferReflection
A reflected constant (uniform) buffer: its name, size, bind slot, and variables.
- CtabConstant
One constant from a D3D9 shader's CTAB constant table: the bridge between an HLSL global and the register(s) the SM1–3 bytecode reads it from. Class, Type carry the raw
D3DXPARAMETER_CLASS/D3DXPARAMETER_TYPEvalues — numerically identical to MojoShader's symbol class/type and to the fx_2_0 typedef encoding (seedocs/fx2-binary-format.md§6.1).
- CtabReader
Reads the CTAB constant-table comment out of a legacy D3D9 SM1–3 token stream — the reflection source for the FNA fx_2_0 path. Layout per
docs/fx2-binary-format.md§11 (derived from MojoShader'sparse_constant_table, which is what FNA itself runs on these bytes at load time, and the documentedD3DXSHADER_CONSTANTTABLEstructs).Only the leading comment block(s) directly after the version token are scanned: that is where fxc and vkd3d both place the CTAB, and scanning the instruction stream would risk misreading raw IEEE-float immediates (e.g. from
def) as comment tokens.
- CtabTable
A parsed D3D9 CTAB constant table — the SM1–3 analog of DXIL/SPIR-V reflection. It is what MojoShader itself uses at load time to bind effect parameters to shader registers, which makes it the faithful reflection source for the FNA fx_2_0 path.
- D3DReflectionMaps
The single source of truth for the raw D3D reflection numeric value → ShadowDusk enum lookup tables (
D3D_SHADER_VARIABLE_CLASS,D3D_SHADER_VARIABLE_TYPE, andD3D_SRV_DIMENSION). Both reflection readers consume these so the numeric mappings cannot drift apart: the pure-managed RdefReader passes the raw values it reads from the DXBC container, while the DXIL extractor casts its Vortice/D3D12 reflection enums (whose underlying values are these same D3D constants).These helpers only own the value → enum table. Each caller keeps its own unmapped-value policy: the DXIL extractor throws on an unmapped class/type, whereas RdefReader reports failure (false) — that difference is deliberate and is preserved at the call sites, not unified here.
- ParameterReflection
A flattened effect parameter as exposed to the MonoGame runtime (the user-settable surface, e.g. via
Effect.Parameters["Foo"]), with its name, optional semantic, type shape, and annotations.
- RdefReader
Pure-managed DXBC reflection: parses the
DXBCcontainer'sRDEF(resource definition) andISGN/OSGN(signature) chunks into the same ReflectedEffect shapeD3DReflectproduced — the SM4/SM5 sibling of CtabReader (Phase 18 Track A). This removes the Windows-only d3dcompiler_47 P/Invoke from the DirectX pipeline, so DX11.mgfxcompiles run on Linux/macOS (and, being dependency-free managed code, in WASM).Layout sources: the DXBC container / RDEF format is stable and documented (Wine's d3dcompiler reflection implementation, vkd3d-shader's
tpf/dxbcwriters, and public DXBC container format references). Field semantics were verified byte-level against d3dcompiler_47's own emission andID3D11ShaderReflection's readback; oracle parity is enforced byDxbcReflectionParityTests(managed output deeply equal toD3DReflect's for both d3dcompiler_47 and vkd3d DXBC, on Windows).Behavioral quirks preserved deliberately (the bar is "identical to D3DReflect + the previous extractor", not "looks right"):
- Array variables report a 16-byte-aligned size (the previous extractor rounded
D3DReflect's unpadded trailing element up; seeVariableReflection). - Empty constant buffers are dropped — mgfxc emits no cbuffer record for an empty
$Globals(e.g. a texture-only PS), so the DX.mgfxmust match. D3DReflectfixes up signature system values fxc stores as 0 by semantic name (SV_Target→Target,SV_Depth→Depth, …) — reproduced in FixUpSystemValue(uint, string).
- Array variables report a 16-byte-aligned size (the previous extractor rounded
- ReflectedEffect
The complete reflected metadata for one compiled shader: its constant buffers, texture and sampler bindings, input/output signatures, and flattened effect parameters. Produced by IShaderReflector and consumed when writing the
.mgfxcontainer.
- SamplerReflection
A reflected sampler binding: its name, bind slot, and associated texture.
- SignatureParameterReflection
One entry in a shader stage's input or output signature, describing a semantic-bound attribute (its semantic, register, system-value role, component type, and write mask).
- SpirvReflector
Pure-managed IShaderReflector that derives a ReflectedEffect directly from SPIR-V bytecode — no native DXIL /
ID3D12ShaderReflectionpath, so it runs inside the .NET WASM browser host (Phase 19).It mirrors the field-population semantics of the native DXIL oracle (
ShadowDusk.HLSL.Reflection.DxilReflectionExtractor) for the OpenGL SM3 PS-only corpus: constant-buffer layouts (offsets, sizes, class/type, rows/columns/elements, 16-byte packing) and texture / sampler bind slots.Signatures. InputSignature and OutputSignature are intentionally left EMPTY: SPIR-V discards HLSL semantic strings (
TEXCOORD0,SV_Target, …) — it keeps only numericLocationdecorations — so the original signatures cannot be recovered. The PS-only MonoGame corpus does not need them for.mgfxoutput.
- SpvReflectionVerifier
Cross-checks texture and sampler bind slots against a SPIR-V module, producing a BindingSlotMap. The SPIRV-Cross-backed verification is not yet implemented; the current implementation returns Empty so the reflection pipeline can still run for DXIL-only use cases.
- TextureReflection
A reflected texture binding: its name, bind slot, and dimensionality.
- VariableReflection
A single variable packed inside a ConstantBufferReflection: its name, byte layout within the buffer, type shape, and (for structs) nested members.
Interfaces
- IShaderReflector
Derives a ReflectedEffect from a single compiled shader blob.
Unlike the native DXIL path (
ID3D12ShaderReflection), an implementation of this interface is expected to be pure-managed so it can run inside the .NET WASM browser host (Phase 19), where no native reflection library is available.No stage parameter is taken: the execution model (vertex / pixel / …) is recovered from the blob's own entry-point metadata.
Enums
- CtabRegisterSet
The D3D9 register file a CTAB constant is bound to (
D3DXREGISTER_SET; the values are the on-disk u16).
- EffectParameterClass
The shape class of an effect parameter, mirroring MonoGame's
EffectParameterClassso reflected metadata maps directly onto the runtime.
- EffectParameterType
The element type of an effect parameter, mirroring MonoGame's
EffectParameterTypeso reflected metadata maps directly onto the runtime.
- TextureDimension
The dimensionality of a reflected texture binding.