Table of Contents

Class CompiledShader

Namespace
ShadowDusk.Core
Assembly
ShadowDusk.Core.dll

The successful output of CompileAsync(string, CompilerOptions, CancellationToken): the compiled effect bytes together with the platform they were produced for. For MonoGame/KNI targets the bytes are a .mgfx effect; for Fna they are the D3D9 fx_2_0 effects binary (.fxb). Either way they can be written to a file or fed directly to the consumer runtime's Effect constructor.

public sealed record CompiledShader : IEquatable<CompiledShader>
Inheritance
CompiledShader
Implements
Inherited Members

Constructors

CompiledShader(PlatformTarget, byte[])

The successful output of CompileAsync(string, CompilerOptions, CancellationToken): the compiled effect bytes together with the platform they were produced for. For MonoGame/KNI targets the bytes are a .mgfx effect; for Fna they are the D3D9 fx_2_0 effects binary (.fxb). Either way they can be written to a file or fed directly to the consumer runtime's Effect constructor.

public CompiledShader(PlatformTarget Target, byte[] Data)

Parameters

Target PlatformTarget

The platform backend the effect was compiled for.

Data byte[]

The compiled effect bytes, ready to load into the target runtime's Effect.

Properties

Data

The compiled effect bytes, ready to load into the target runtime's Effect.

public byte[] Data { get; init; }

Property Value

byte[]

Parameters

The effect's parameters as the compiled file exposes them to the runtime (Effect.Parameters), in file order: name, shape, type, annotations (MGFX and KNIFX; FNA lists none), and the default value the HLSL declares (DefaultValue, null when unknown), so a tool can show float Scale = 2.0; without loading the effect into a runtime.

public IReadOnlyList<ParameterReflection> Parameters { get; init; }

Property Value

IReadOnlyList<ParameterReflection>

Remarks

Reflection only. On MGFX and KNIFX the defaults are exactly what the effect bytes in Data carry. On FNA the reported default can be larger than what the .fxb file carries: the compiler trims the file's constant table to the registers the shader reads, while the reflection value is read from the source (a float Weights[3] the shader reads only as Weights[1] reflects as 0.75, 1.75, 2.75; the file holds 0.75, 1.75, 0). The list and each default are read-only.

Target

The platform backend the effect was compiled for.

public PlatformTarget Target { get; init; }

Property Value

PlatformTarget

Warnings

Non-fatal diagnostics produced while compiling: the underlying compiler's own warnings (verbatim — never reworded) plus ShadowDusk's GL portability findings (SD0400–SD0499: constructs that compile here but are known to fail or misbehave at runtime on some GL stacks — e.g. WebGL1/KNI Reach loop limits, ANGLE derivative zeroing, a SpriteBatch-incompatible pixel-shader input, a GLSL-1.30+/ES-3.00-only construct in the versionless GL source) and its reflection findings (SD0104: a vertex-input semantic that fell through to the TextureCoordinate default, exactly as mgfxc warns). Empty when there is nothing to report. The effect bytes in Data are valid regardless — warnings never gate output.

public IReadOnlyList<ShaderError> Warnings { get; init; }

Property Value

IReadOnlyList<ShaderError>

Methods

ToXnb()

Returns Data wrapped in an XNB content container, ready to drop into a content directory where Content.Load<Effect>("Foo") will find it — no consumer code change at all (issue #199).

public byte[] ToXnb()

Returns

byte[]

The complete .xnb file bytes.

Remarks

A container only: the payload is Data verbatim, so the effect bytes are identical to what a plain .mgfx / .fxb write would produce. The XNB platform identifier is derived from Target (see PlatformIdentifierFor(PlatformTarget)) and is never something the consumer selects. Write the result to <AssetName>.xnb; the asset name Content.Load uses is the file name, so no companion file is needed. Render-proven through a real ContentManager on MonoGame (WindowsDX and DesktopGL), KNI (4.2.9001 and 4.3.9001, MGFX v10 and KNIFX payloads) and FNA 26.06 (Phase 64); the container carries the XNA-4.0 type-reader name, the only one every runtime resolves.