Prowl.Slang 0.1.1

dotnet add package Prowl.Slang --version 0.1.1
                    
NuGet\Install-Package Prowl.Slang -Version 0.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="Prowl.Slang" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Prowl.Slang" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Prowl.Slang" />
                    
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 Prowl.Slang --version 0.1.1
                    
#r "nuget: Prowl.Slang, 0.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 Prowl.Slang@0.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=Prowl.Slang&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=Prowl.Slang&version=0.1.1
                    
Install as a Cake Tool

Prowl.Slang

A .NET wrapper over the Slang shader compiler. Supports nearly all of Slang's native COM API and all of the shader reflection and type API.

Features

  • Near-Complete Slang Support

    • Nearly all of Slang's API is exposed to C# through a memory-safe and garbage collected proxy.
    • No need to track references or dispose of native Slang objects--the library handles it automatically using COM reference tracking and C# finalizers.
  • C# Language Conventions

    • Native Slang methods which use C++-style parameters or type conventions are replaced.
    • Getters in reflection API have been replaced with C# properties (.GetFoo() → .Foo)
    • No exposed native pointers or custom datatypes--wrapper uses C# datatypes as much as possible.
    • SlangResult has been replaced with C#-style exceptions to allow better use of the try-catch programming paradigm.
    • Compiler error messages in strings can now be parsed into a Diagnostic datatype, to simplify reading error codes, source files, line numbers, and more from C#.
  • Extensive XML Documentation

    • All of the Slang API has been documented, including parts not originally documented in source Slang.
    • Complete XML documentation coverage, with intellisense for every function and type.
  • Cross Platform

    • Supports all 3 major desktop platforms (Windows, Linux, MacOS)
    • Supports 64-bit x86 and ARM instruction sets

Usage

Basic Compilation

using Prowl.Slang;

// Description for a single platform target output
TargetDescription targetDesc = new()
{
  Format = CompileTarget.Spirv, // Emit vulkan-compatible SPIR-V words
  Profile = GlobalSession.FindProfile("spirv_1_5") // Use SPIR-V 1.5 capabilities
};

// Description for a compilation session
SessionDescription sessionDesc = new()
{
  Targets = [targetDesc], // Only targeting SPIR-V - add more targets to automatically compile for multiple different APIs
  SearchPaths = ["./", "./Shaders"], // Search paths are relative to CWD
};

Session session = GlobalSession.CreateSession(sessionDesc);

// Load file called 'shaders.slang'. If warnings appear during loading, they will be written into `diagnostics`
Module module = session.LoadModule("shaders", out DiagnosticInfo diagnostics);

EntryPoint vertex = module.FindEntryPointByName("vertexMain");
EntryPoint fragment = module.FindEntryPointByName("fragmentMain");

// Create a composite program from the entrypoints. If warnings appear, they will be written into `diagnostics`
ComponentType program = session.CreateCompositeComponentType([module, vertex, fragment], out diagnostics);

// Vertex entrypoint at index 0. If warnings appear during compilation, they will be written into `diagnostics`
Memory<byte> compiledVertex = program.GetEntryPointCode(0, 0, out diagnostics);

// Fragment entrypoint at index 1. If warnings appear during compilation, they will be written into `diagnostics`
Memory<byte> compiledFragment = program.GetEntryPointCode(1, 0, out diagnostics);

Advanced compilation

Examples of advanced compilation which may involve specializing shader types and performing advanced linking/reflection can be found under both the Samples/ and Tests/ directories.

Limitations

  • Native Unsafe API is internal and not exposed. Marshaling and safety checks are non-negotiable for those looking to squeeze out faster performance from the library.
  • API is not completely memory safe. Certain combinations of reflection, specialization, and linker options can still corrupt process memory if used incorrectly.

License

This component is part of the Prowl Game Engine and is licensed under the MIT License. See the LICENSE file in the project root for details.

This repository includes software from the Slang shader compiler.

The following third-party component is used under the following license:

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.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
0.1.1 178 6/3/2025