Namespace ShadowDusk.Compiler.Slang
Classes
- SlangFrontend
The Slang input frontend (issue #197's sibling, issue #198): accepts a
.slangsource and produces ordinary.fxeffect text for ShadowDusk's unchanged faithful pipeline. ShadowDusk is a multi-input, multi-output shader compiler — input languages (.fx, ShaderToy GLSL, Slang) are thin text frontends over ONE pipeline that fans out to every supported runtime (MonoGame, KNI, FNA), OS (Windows, macOS, Linux), and graphics backend (OpenGL, DX11, DX12, Vulkan) — and this frontend follows that shape exactly.How it works — no Slang toolchain, anywhere, ever (owner direction 2026-08-13, superseding an earlier slangc-based route): Slang is a near-superset of HLSL — it keeps HLSL's types, semantics,
cbuffer/register, and function syntax — so the supported input is HLSL-compatible Slang, and the shader body compiles through the same DXC every.fxuses, with nothing new to ship. The frontend is pure managed text transformation, so.slanginput works everywhere the pipeline works, the browser/WASM host included. Slang-only language features (moduleimports, generics,interfaceconformances,extensions) are rejected loudly by name (SD0600) — never silently miscompiled — which is the trade the project chose, and matches the request as filed ("write slang, but still go through the normal compilation pipe… features not supported in HLSL are likely also not supported in MonoGame").The technique block is synthesized. Slang has no
technique/passconcept, so entry points are declared the Slang way —[shader("vertex")]/[shader("fragment")]attributes — and the frontend generates a one-pass technique from them (both stages when both are present; pixel-only, the SpriteBatch shape, when only a fragment entry exists). The attributes themselves are stripped from the body before compile (fxc-lineage compilers reject them outside library targets). Shader-model selection follows the ShaderToy frontend's measured convention:#if SM4→vs/ps_4_0_level_9_1(mgfxc's DirectX_11 floor), elsevs/ps_3_0.No route through this frontend is `mgfxc`-equivalent — `mgfxc` cannot read Slang at all. The claim is simpler and stronger: the generated
.fxcompiles through the same faithful pipeline as any other, to the same proven targets.
- SlangFxConversion
The successful product of the Slang frontend:
.fxtext for the unchanged pipeline.