Class ShadercShaderCompiler
- Namespace
- BSGameLib.Game.ShaderCompiler
- Assembly
- BSGameLib.Game.ShaderCompiler.dll
An IShaderCompiler over shaderc, which ships with this package, so it works on a player's machine. It compiles exactly as the build step does, and keeps what it compiles on disk so a shader is compiled once, not once per launch.
public sealed class ShadercShaderCompiler : IShaderCompiler, IDisposable
- Inheritance
-
ShadercShaderCompiler
- Implements
- Inherited Members
Constructors
ShadercShaderCompiler(ShaderCompilerOptions, ILogger<ShadercShaderCompiler>)
Creates a compiler with options, or the defaults when it is null.
public ShadercShaderCompiler(ShaderCompilerOptions options = null, ILogger<ShadercShaderCompiler> logger = null)
Parameters
optionsShaderCompilerOptionsloggerILogger<ShadercShaderCompiler>
Remarks
logger is told when the disk cache cannot be written. Without one,
nothing is logged.
Methods
Dispose()
Frees the native shaderc compiler, if one was created.
public void Dispose()
TryCompile(string, ShaderStage, out byte[], out string)
Compiles source for stage to SPIR-V. A result already
in the disk cache is returned without compiling. Returns false, with the compiler's messages
in diagnostics, when the source does not compile.
public bool TryCompile(string source, ShaderStage stage, out byte[] spirv, out string diagnostics)
Parameters
sourcestringstageShaderStagespirvbyte[]diagnosticsstring