Class ShaderLibrary¶
Namespace: Apogee.Rendering.Shaders
Assembly: Apogee.Rendering.dll
Where renderers get their shaders. shaders:// (mod://id/…, with their artifacts in mod://id/imported.
The library remembers which files each module it loaded was made from, so that when files change (HotReloader.ShadersChanged or a
public sealed class ShaderLibrary
Inheritance¶
Inherited Members¶
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Constructors¶
ShaderLibrary(VirtualFileSystem, ShaderCompilerOptions?, Func<ShaderCompilerOptions, ShaderCompiler>?, bool?)¶
public ShaderLibrary(VirtualFileSystem files, ShaderCompilerOptions? options = null, Func<ShaderCompilerOptions, ShaderCompiler>? createCompiler = null, bool? canCompile = null)
Parameters¶
files VirtualFileSystem
The file system the shaders are read from.
options ShaderCompilerOptions?
The compiler's options, for shaders that have to be compiled.
createCompiler Func<ShaderCompilerOptions, ShaderCompiler>?
Makes the compiler (tests replace it); the default is
canCompile bool?
Says whether shaders without an artifact can be compiled; by default whether the compiler library loads.
Properties¶
CanCompile¶
True when shaders without an artifact can be compiled: the compiler library is there.
public bool CanCompile { get; }
Property Value¶
Errors¶
The compile errors of the shaders that are being rebuilt and could not be, one message per group of pipelines; empty when everything is as the files say. The dev overlay shows them.
public IReadOnlyList<string> Errors { get; }
Property Value¶
Files¶
public VirtualFileSystem Files { get; }
Property Value¶
Methods¶
Load(string, IReadOnlyDictionary<string, string>?, ShaderBackend)¶
The module at path (shaders://forward.slang), in the variant that defines names, with the code for backend (a device's ShaderBackend).
public CompiledShader Load(string path, IReadOnlyDictionary<string, string>? defines = null, ShaderBackend backend = ShaderBackend.Spirv)
Parameters¶
path string
defines IReadOnlyDictionary<string, string>?
backend ShaderBackend
Returns¶
Exceptions¶
It has no artifact and cannot be compiled, or it does not compile.
MountEngineShaders(VirtualFileSystem, IEnumerable<string>?, bool)¶
Mounts the engine's shaders as shaders://. With directories null that is the Shaders folder next to the program, or, with sources, the folders
of the shaders' own sources when the program runs from the repository, so that editing them is what the running program sees.
public static void MountEngineShaders(VirtualFileSystem files, IEnumerable<string>? directories = null, bool sources = false)
Parameters¶
files VirtualFileSystem
directories IEnumerable<string>?
sources bool
NotifyChanged(IEnumerable<string>)¶
Says that these files changed (virtual paths, as HotReloader.ShadersChanged reports them): the artifact indexes are read again, and
public void NotifyChanged(IEnumerable<string> paths)
Parameters¶
paths IEnumerable<string>
Refresh()¶
Reads the artifact indexes again (after an import).
public void Refresh()
Standard(string?, string?)¶
The engine's shaders: the Shaders folder next to the program, as shaders://.
public static ShaderLibrary Standard(string? cacheDirectory = null, string? shaderDirectory = null)
Parameters¶
cacheDirectory string?
shaderDirectory string?
Returns¶
ModulesChanged¶
Raised, on the thread that called
public event Action<IReadOnlyCollection<string>>? ModulesChanged