ShadowDusk.Compiler
0.5.1
See the version list below for details.
dotnet add package ShadowDusk.Compiler --version 0.5.1
NuGet\Install-Package ShadowDusk.Compiler -Version 0.5.1
<PackageReference Include="ShadowDusk.Compiler" Version="0.5.1" />
<PackageVersion Include="ShadowDusk.Compiler" Version="0.5.1" />
<PackageReference Include="ShadowDusk.Compiler" />
paket add ShadowDusk.Compiler --version 0.5.1
#r "nuget: ShadowDusk.Compiler, 0.5.1"
#:package ShadowDusk.Compiler@0.5.1
#addin nuget:?package=ShadowDusk.Compiler&version=0.5.1
#tool nuget:?package=ShadowDusk.Compiler&version=0.5.1
ShadowDusk.Compiler
Cross-platform, in-memory HLSL Effect compiler for MonoGame, KNI, and FNA — a drop-in replacement for mgfxc that compiles .fx source to MonoGame/KNI .mgfx bytes (or FNA .fxb) at runtime, on Linux, macOS, and Windows, with no fxc.exe, no mgfxc, no Wine, and no Windows SDK. Add the package and call the API — every native piece rides inside the package set.
The output loads in a real MonoGame/KNI Effect and renders equivalently to mgfxc's — one faithful pipeline (DXC → SPIR-V → SPIRV-Cross → GLSL, or vkd3d-shader → DXBC/D3D9 bytecode) on every OS, byte-identical output across hosts.
Install
dotnet add package ShadowDusk.Compiler
Use
using ShadowDusk.Core;
using ShadowDusk.Compiler;
IShaderCompiler compiler = new EffectCompiler();
var result = await compiler.CompileAsync(fxSource, new CompilerOptions
{
Target = PlatformTarget.OpenGL, // or DirectX, or Fna
});
if (result.IsFailure)
{
foreach (var e in result.Error)
Console.Error.WriteLine($"{e.File}({e.Line},{e.Column}): {e.Code}: {e.Message}");
return;
}
var effect = new Effect(graphicsDevice, result.Value.Data);
Need to compile from a synchronous call site (e.g. inside Content.Load<Effect>)? Await compiler.InitializeAsync() once at startup, then call the synchronous compiler.Compile(...) anywhere — same pipeline, byte-identical output.
Targets
CompilerOptions.Target |
Output | Runtime |
|---|---|---|
OpenGL |
.mgfx (GLSL) |
MonoGame DesktopGL, KNI (incl. WebGL) |
DirectX |
.mgfx (SM5 DXBC) |
MonoGame WindowsDX, KNI |
Fna |
.fxb (D3D9 fx_2_0) |
FNA |
All three compile on every desktop OS and produce the same bytes on every OS. Errors come back as ShaderError[] with the file, line, column, and compiler message verbatim.
Links
- Documentation: https://kaltinril.github.io/ShadowDusk/
- Source / issues: https://github.com/kaltinril/ShadowDusk
- CLI flavor (
dotnet tool): ShadowDusk.Cli · In-browser (Blazor WASM) flavor: ShadowDusk.Wasm
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- ShadowDusk.Core (>= 0.5.1)
- ShadowDusk.GLSL (>= 0.5.1)
- ShadowDusk.HLSL (>= 0.5.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ShadowDusk.Compiler:
| Package | Downloads |
|---|---|
|
ShadowDusk.Wasm
In-browser (WebAssembly / Blazor net8.0-browser) HLSL Effect compiler for MonoGame, KNI, and FNA. Add the package to a net8.0-browser app, call WasmShaderCompiler.CompileAsync, and feed the .mgfx bytes to new Effect(gd, bytes) — the native DXC + SPIRV-Cross + vkd3d-shader WASM modules ride inside the package as Blazor static web assets (served at _content/ShadowDusk.Wasm/) and self-register; the consumer wires NOTHING. Uses the faithful pinned DXC -> SPIR-V -> SPIRV-Cross -> GLSL pipeline (OpenGL/WebGL) and the pinned vkd3d-shader -> DXBC / D3D9 pipeline (DirectX .mgfx and FNA .fxb as in-browser export targets), byte-identical to the desktop CLI output. |
GitHub repositories
This package is not used by any popular GitHub repositories.