SlangShaderSharp 2026.1.1

dotnet add package SlangShaderSharp --version 2026.1.1
                    
NuGet\Install-Package SlangShaderSharp -Version 2026.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SlangShaderSharp" Version="2026.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SlangShaderSharp" Version="2026.1.1" />
                    
Directory.Packages.props
<PackageReference Include="SlangShaderSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SlangShaderSharp --version 2026.1.1
                    
#r "nuget: SlangShaderSharp, 2026.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SlangShaderSharp@2026.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SlangShaderSharp&version=2026.1.1
                    
Install as a Cake Addin
#tool nuget:?package=SlangShaderSharp&version=2026.1.1
                    
Install as a Cake Tool

SlangShaderSharp

A very rough in development C# binding for the Slang shading language that target .NET 8+.

Bindings written against 2026.1.1.

Not all bindings have been implemented yet! Notably missing are the ones for reflection.

  • Some types may also be incorrect (especially around Slang types and things like size_t)
  • Test works but must be run one at a time due to global state in Slang.

Missing Bindings

  • SlangTerminatedChars
  • ICompileRequest
  • IByteCodeRunner
  • Attribute/UserAttribute
  • Reflection APIs
  • IModulePrecompileService_Experimental
  • slang_createByteCodeRunner

Versioning

The versioning of this library follows the versioning of the underlying Slang library where the Revision part is used to indicate changes in the bindings.

For Example:

SlangShaderSharp 2025.21.2.0 corresponds to Slang library version 2025.21.2. SlangShaderSharp 2025.21.2.1 corresponds to Slang library version 2025.21.2 with changes in the bindings only.

Usage

Loading a Module and Getting WGSL Code for a Compute Shader

// 1. Create Global Session

Slang.CreateGlobalSession(Slang.ApiVersion, out var globalSession).Succeeded.ShouldBeTrue();

// 2. Create Session

var sessionDesc = new SessionDesc
{
    Targets = [new TargetDesc { Format = SlangCompileTarget.Wgsl }],

    // Slang supports using the preprocessor.
    PreprocessorMacros = [
        new PreprocessorMacroDesc("BIAS_VALUE", "1138"),
        new PreprocessorMacroDesc("OTHER_MACRO", "float")
    ],
};

globalSession.CreateSession(sessionDesc, out var session).Succeeded.ShouldBeTrue();

// 3. Load module

var module = session.LoadModuleFromSource("test", "test.slang", Slang.CreateBlob("""
    StructuredBuffer<float> buffer0;
    StructuredBuffer<float> buffer1;
    RWStructuredBuffer<float> result;

    [shader("compute")]
    [numthreads(1,1,1)]
    void computeMain(uint3 threadId : SV_DispatchThreadID)
    {
        uint index = threadId.x;
        result[index] = buffer0[index] + buffer1[index];
    }
    """u8), out var moduleLoadError);

module.ShouldNotBeNull(moduleLoadError?.AsString ?? "Unknown Error");

// 4. Query Entry Points

module.FindEntryPointByName("computeMain", out var entryPoint).Succeeded.ShouldBeTrue();

// 5. Compose Modules + Entry Points

session.CreateCompositeComponentType([module, entryPoint], out var composedProgram, out _).Succeeded.ShouldBeTrue();

// 6. Link

composedProgram.Link(out _, out var linkError).Succeeded.ShouldBeTrue(linkError?.AsString ?? "Unknown Error");

// 7. Get Target Kernel Code

composedProgram.GetEntryPointCode(0, 0, out var wgslCode, out _).Succeeded.ShouldBeTrue();

// Output

_ = wgslCode.AsString;

// Done

Slang.Shutdown();

Updating Bindings

Eventually this should be moved to a GitHub Action.

  1. Update update_slang.ps1 to point towards the desired Slang version.
  2. Run update_slang.ps1.
  3. Adjust any bindings as needed to incorporate any changes in the header files (diff compare the header files to make this easy!)
Product 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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • 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.

Version Downloads Last Updated
2026.1.1 30 1/28/2026