Skip to content

feliwir/SharpShaderCompiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SharpShaderCompiler

License: MIT Build status

SharpShaderCompiler is a .NET shader compiler for compiling GLSL and HLSL to SPIRV bytecode.

Example

void Compile()
{
    //Create a new compiler and new options
    var c = new ShaderCompiler();
    var o = new CompileOptions();

    //Set our compile options
    o.Language = CompileOptions.InputLanguage.GLSL;
    o.Optimization = CompileOptions.OptimizationLevel.Performance;

    //Specify a minimal vertex shader
    string testShader =  @"#version 450
                            void main()
                            {}";

    //Compile the specified vertex shader and give it a name
    var r = c.Compile(testShader, ShaderCompiler.Stage.Vertex, o,"testShader");

    //Check if we had any compilation errors
    if(r.CompileStatus != CompileResult.Status.Success)
    {
        //Write the error out
        System.Console.WriteLine(r.ErrorMessage);
        return;
    }

    //Get the produced SPV bytecode
    var bc = r.GetBytes();
}

Releases

No releases published

Packages

No packages published

Languages