DirectXShaderCompiler.NET
1.2.0
The binary releases of DXC used in this package are unstable and can lead to unexpected memory access violations and segmentation faults on different platforms or by being given breaking compilation combinations. Avoid using this package outside of testing or experimental purposes, or in critical systems.
See the version list below for details.
dotnet add package DirectXShaderCompiler.NET --version 1.2.0
NuGet\Install-Package DirectXShaderCompiler.NET -Version 1.2.0
<PackageReference Include="DirectXShaderCompiler.NET" Version="1.2.0" />
paket add DirectXShaderCompiler.NET --version 1.2.0
#r "nuget: DirectXShaderCompiler.NET, 1.2.0"
// Install DirectXShaderCompiler.NET as a Cake Addin #addin nuget:?package=DirectXShaderCompiler.NET&version=1.2.0 // Install DirectXShaderCompiler.NET as a Cake Tool #tool nuget:?package=DirectXShaderCompiler.NET&version=1.2.0
DirectXShaderCompiler.NET: cross-platform C# wrapper for DirectXShaderCompiler
A cross-platform .NET 8.0 wrapper for Microsoft's DirectX Shader Compiler, written in C#.
Usage
This project wraps functionality from DXC into a static DirectXShaderCompiler class, which can be used to easily compile shader code with various options, and get parsed and formatted outputs from the compilation process. For an example of how to compile a basic shader, refer to Example.cs. There is no proper documentation for this wrapper, but most functionality is reasonably well-documented with typical XML comments.
Note on CompilerOptions
While CompilerOptions does a generally good job of passing in command-line arguments to DXC in the correct format and providing only working options, specific combinations of options can cause a segmentation fault in native code. It is best to test out combinations of more obscure or under-utilized options in an isolated environment beforehand, as they can potentially cause a program crash.
Native Details
Due to the nature of the official DirectXShaderCompiler repository's build system, it is difficult to easily acquire or build binaries of DXC that meets the following criteria:
- Exposes a cross-platform c-style interface for DXC.
- Runs on all major desktop operating systems.
- Can be compiled for all major desktop operating systems from any system.
As such, DirectXShaderCompiler.NET uses a fork of DXC, built with zig instead of CMake. As Zig's compiler supports cross-compilation out of the box, it allows DXC to build easily from most desktop platforms, for most platforms. The libraries produced by building this repository are what DirectXShaderCompiler.NET uses in its releases.
Building Native Libraries
To build native libraries, run the BuildNative.cs
file inside the Native folder, specicying your target architecture [x64, arm64, all] with -A and your target platform [windows, linux, macos, all] with -P.
Native build requirements:
- Zig compiler version present on your
PATH
of at least version 0.14.0
Pre-built binaries are bundled in the NuGet package for the following operating systems:
- Windows x64
- Windows arm64
- OSX x64
- OSX arm64 (Apple silicon)
- Linux x64
- Linux arm64
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. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.