Table of Contents

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
object
ShaderCache

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

directory string

The 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

string

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

source string

The shader source code.

defines IReadOnlyDictionary<string, string>

The preprocessor defines the shader is compiled with.

compile Func<byte[]>

Compiles source with defines. Called only if there is no usable cache entry.

Returns

byte[]

The effect bytecode.

See Also