Class ShaderBundle¶
Namespace: Apogee.Graphics.Shaders
Assembly: Apogee.Graphics.dll
The artifact of a shader module (.ashader): one or more variants, each the module compiled with one set of preprocessor defines (the default one has none), and for each
variant its reflection and the code of every entry point, per backend. A reader takes the code of the backend it runs on and skips the others, so one file serves Vulkan and Metal. The reflection is that of the first backend written (SPIR-V). Specialization constants need no variant: they stay in the SPIR-V and are listed in the reflection.
public static class ShaderBundle
Inheritance¶
Inherited Members¶
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Fields¶
Extension¶
public const string Extension = ".ashader"
Field Value¶
Methods¶
Read(byte[], string, IReadOnlyList<string>?, bool, ShaderBackend)¶
The code of one variant of a bundle for one backend (SPIR-V by default).
public static CompiledShader Read(byte[] bundle, string variant = "", IReadOnlyList<string>? dependencies = null, bool fromCache = false, ShaderBackend backend = ShaderBackend.Spirv)
Parameters¶
bundle byte[]
variant string
dependencies IReadOnlyList<string>?
fromCache bool
backend ShaderBackend
Returns¶
Exceptions¶
The data is not a bundle, or it has no such variant.
It was made for another shader ABI.
VariantKey(IEnumerable<KeyValuePair<string, string>>)¶
The name of a variant: its defines sorted by name, as A=1;B=2. The default variant, with no defines, is the empty string.
public static string VariantKey(IEnumerable<KeyValuePair<string, string>> defines)
Parameters¶
defines IEnumerable<KeyValuePair<string, string>>
Returns¶
Variants(byte[])¶
The names of the variants in a bundle.
public static IReadOnlyList<string> Variants(byte[] bundle)
Parameters¶
bundle byte[]
Returns¶
Exceptions¶
The data is not a bundle.
It was made for another shader ABI.
Write(string, IReadOnlyList<(string Variant, CompiledShader Shader)>)¶
Writes variants that were compiled for one backend each.
public static byte[] Write(string moduleName, IReadOnlyList<(string Variant, CompiledShader Shader)> variants)
Parameters¶
moduleName string
variants IReadOnlyList<(string Variant, CompiledShader Shader)>
Returns¶
byte[]
Write(string, IReadOnlyList<(string Variant, IReadOnlyList<CompiledShader> Backends)>)¶
Writes variants, each compiled for every backend in its list (the first one's reflection and warnings are kept).
public static byte[] Write(string moduleName, IReadOnlyList<(string Variant, IReadOnlyList<CompiledShader> Backends)> variants)
Parameters¶
moduleName string
variants IReadOnlyList<(string Variant, IReadOnlyList<CompiledShader> Backends)>
Returns¶
byte[]