class IShaderCompiler

Interface used for compilers that transform a source file written in a higher level shading language into a Shader and shader variations usable by the engine.

Public

Methods

~IShaderCompiler

virtual ~IShaderCompiler() = default

Compile

virtual ShaderCompilerResult Compile(const String &name, const String &source, const UnorderedMap<String, String> &defines, ShadingLanguageFlags languages, bool compileVariations, SPtr<Shader> &outShader) = 0

Compiles the shader from BSL and outputs a Shader object.

Depending on the parameter the shader variations will be compiled as well, or the shader will be empty and requires variations to be compiled on demand.

name
Name used to identify the shader.
source
BSL source to compile.
defines
An optional set of defines to set during compilation.
languages
Low-level languages to compile individual variations for. Each language will result in another set of variations.
compileVariations
If true all shader variations will be compiled. If false, you must compile the variations on demand before use.
outShader
Shader if the compilation is successful, null otherwise.

Returns: A result object containing an error message if not successful.

Compile

virtual ShaderCompilerResult Compile(const String &name, const String &source, const UnorderedMap<String, String> &defines, ShadingLanguageFlags languages, bool compileVariations, SPtr<render::Shader> &outShader) = 0

CompileVariation

virtual ShaderCompilerResult CompileVariation(const Shader &shader, const ShaderVariationParameters &variationParameters, ShadingLanguageFlag language, Variation &inOutVariation) = 0

Compiles a particular shader variation.

shader
Shader for which to compile the variation.
variationParameters
Specific variation to compile.
language
Language to compile the variation for. Must be a single language, rather than a mask of multiple languages.
inOutVariation
Variation on which to set the compiled data if successful.

Returns: A result object containing an error message if not successful.

CompileVariation

virtual ShaderCompilerResult CompileVariation(const render::Shader &shader, const ShaderVariationParameters &variationParameters, ShadingLanguageFlag language, render::Variation &inOutVariation) = 0