Table of Contents

Interface IShaderCompiler

Namespace
BSGameLib.Game.Rendering
Assembly
BSGameLib.Game.dll

Compiles GLSL to SPIR-V for the Vulkan backend at runtime.

public interface IShaderCompiler

Remarks

Register one in the service collection (Game.Configure) to compile shaders that were not precompiled at build. Compilers are asked in registration order, after the precompiled lookup, and the first that succeeds wins. With none registered, a shader with no precompiled SPIR-V fails to compile rather than looking for a tool on the machine.

The source TryCompile(string, ShaderStage, out byte[], out string) is given has already been through the engine's Vulkan source preparation (#version 450, explicit bindings, loose uniforms gathered into a uniform block), so every compiler, and the build step, compiles identical text.

Methods

TryCompile(string, ShaderStage, out byte[], out string)

Compiles prepared GLSL for stage. On failure, diagnostics carries the compiler's messages.

bool TryCompile(string source, ShaderStage stage, out byte[] spirv, out string diagnostics)

Parameters

source string
stage ShaderStage
spirv byte[]
diagnostics string

Returns

bool