Class KnifxWriter
- Namespace
- ShadowDusk.Core
- Assembly
- ShadowDusk.Core.dll
Serializes a ShadowDusk ShaderIR into KNI's KNIFX v11 effect
container, the additive newer format KNI v4.02+ loads (signature "KNIF"). This
is the KNIFX analogue of MgfxWriter: it carries the same
MojoShader-dialect GLSL body ShadowDusk already produces for MGFX v10 (KNIFX is a
container over a still-MojoShader body), re-serialized into KNIFX's binary layout.
Byte format reverse-engineered from KNI's own KNIFXWriter11 + the runtime
Effect reader (full spec: plan/PHASE-35-appendix/knifx-format-spec.md).
The headline deltas vs MGFX v10:
- A multi-backend directory header (one
.knifxcan carry several backend bodies; the runtime picks the match). This writer emits one backend. - Counts and most indices are written as packed ints (zigzag + 7-bit).
- New fields: a per-shader
ShaderVersion, aStagebyte (with a compute slot), and acolumnsActualbyte on parameters.
public sealed class KnifxWriter
- Inheritance
-
KnifxWriter
- Inherited Members
Fields
KnifxSignature
KNIFX 4-byte signature (ASCII "KNIF"), per KNI's KNIFXWriter11.
public const string KnifxSignature = "KNIF"
Field Value
KnifxVersion
The only KNIFX container version KNI defines today.
public const short KnifxVersion = 11
Field Value
Methods
Write(ShaderIR, KnifxWriterOptions)
Serializes ir into the binary KNIFX (v11) container bytes for the
backend named in options.
public Result<byte[], ShaderError> Write(ShaderIR ir, KnifxWriterOptions options)
Parameters
irShaderIRThe fully assembled effect IR to serialize.
optionsKnifxWriterOptionsThe KNIFX backend (and thus integer-as-float decoding) to emit for.
Returns
- Result<byte[], ShaderError>
The KNIFX bytes on success, or a ShaderError on failure.