Class ShaderCache
- Namespace
- OmegaEngine.Graphics.Shaders
- Assembly
- OmegaEngine.dll
Caches compiled effect bytecode on disk, so that shaders compiled at runtime do not have to be recompiled after a restart.
public sealed class ShaderCache
- Inheritance
-
objectShaderCache
Remarks
This class is thread-safe.
Constructors
ShaderCache(string)
Caches compiled effect bytecode on disk, so that shaders compiled at runtime do not have to be recompiled after a restart.
public ShaderCache(string directory)
Parameters
directorystringThe directory to store the bytecode in. Created on demand.
Remarks
This class is thread-safe.
- See Also
Properties
Directory
The directory the bytecode is stored in.
public string Directory { get; }
Property Value
Methods
GetOrAdd(string, IReadOnlyDictionary<string, string>, Func<byte[]>)
Returns cached bytecode for a shader, or compiles and caches it if there is none yet.
public byte[] GetOrAdd(string source, IReadOnlyDictionary<string, string> defines, Func<byte[]> compile)
Parameters
sourcestringThe shader source code.
definesIReadOnlyDictionary<string, string>The preprocessor defines the shader is compiled with.
compileFunc<byte[]>Compiles
sourcewithdefines. Called only if there is no usable cache entry.
Returns
- byte[]
The effect bytecode.