Magnum::ShaderTools namespace new in Git master

Shader tools.

Shader validation, conversion, compilation and reflection.

This library is built if MAGNUM_WITH_SHADERTOOLS is enabled when building Magnum. To use this library with CMake, request the ShaderTools component of the Magnum package and link to the Magnum::ShaderTools target:

find_package(Magnum REQUIRED ShaderTools)

# ...
target_link_libraries(your-app PRIVATE Magnum::ShaderTools)

Additional plugins and utilities are built separately. See particular *Converter class documentation, the magnum-shaderconverter utility documentation, Downloading and building, Downloading and building plugins, Usage with CMake, Plugin usage with CMake and Loading and using plugins for more information.

Classes

class AbstractConverter new in Git master
Base for shader converter plugins.
class AnyConverter new in Git master
Any shader converter plugin.
class GlslangConverter new in Git master
Glslang shader converter plugin.
class SpirvToolsConverter new in Git master
SPIRV-Tools shader converter plugin.

Enums

enum class ConverterFeature: UnsignedInt { ValidateFile = 1 << 0, ValidateData = ValidateFile|(1 << 1), ConvertFile = 1 << 2, ConvertData = ConvertFile|(1 << 3), LinkFile = 1 << 4, LinkData = LinkFile|(1 << 5), InputFileCallback = 1 << 6, Preprocess = 1 << 7, Optimize = 1 << 8, DebugInfo = 1 << 9 } new in Git master
Features supported by a shader converter.
enum class ConverterFlag: UnsignedInt { Quiet = 1 << 0, Verbose = 1 << 1, WarningAsError = 1 << 2, PreprocessOnly = 1 << 3 } new in Git master
Shader converter flag.
enum class Format: UnsignedInt { Unspecified = 0, Glsl, Spirv, SpirvAssembly, Hlsl, Msl, Wgsl, Dxil } new in Git master
Shader format.
enum class Stage: UnsignedInt { Unspecified = 0, Vertex, Fragment, Geometry, TessellationControl, TessellationEvaluation, Compute, RayGeneration, RayAnyHit, RayClosestHit, RayMiss, RayIntersection, RayCallable, MeshTask, Mesh, Kernel } new in Git master
Shader stage.

Typedefs

using ConverterFeatures = Containers::EnumSet<ConverterFeature> new in Git master
Features supported by a shader converter.
using ConverterFlags = Containers::EnumSet<ConverterFlag> new in Git master
Shader converter flags.

Functions

auto operator<<(Debug& debug, ConverterFeature value) -> Debug& new in Git master
Debug output operator.
auto operator<<(Debug& debug, ConverterFeatures value) -> Debug& new in Git master
Debug output operator.
auto operator<<(Debug& debug, ConverterFlag value) -> Debug& new in Git master
Debug output operator.
auto operator<<(Debug& debug, ConverterFlags value) -> Debug& new in Git master
Debug output operator.
auto operator<<(Debug& debug, Format value) -> Debug& new in Git master
Debug output operator.
auto operator<<(Debug& debug, Stage value) -> Debug& new in Git master
Debug output operator.

Enum documentation

enum class Magnum::ShaderTools::ConverterFeature: UnsignedInt new in Git master

Features supported by a shader converter.

Enumerators
ValidateFile

Validate shader file with AbstractConverter::validateFile()

ValidateData

Validate shader data with AbstractConverter::validateData(). Implies ConverterFeature::ValidateData.

ConvertFile

Convert shader file to a file with AbstractConverter::convertFileToFile()

ConvertData

Convert shader data to data with AbstractConverter::convertDataToData() or any of the other AbstractConverter::convertDataToFile(), AbstractConverter::convertFileToData() combinations. Implies ConverterFeature::ConvertFile.

LinkFile

Link shader files together and output a file with AbstractConverter::linkFilesToFile()

LinkData

Link shader data together and output a data with AbstractConverter::linkDataToData() or any of the other AbstractConverter::linkDataToFile(), AbstractConverter::linkFilesToData() combinations. Implies ConverterFeature::LinkFile.

InputFileCallback

Specifying input file callbacks for additional files referenced from the main file using AbstractConverter::setInputFileCallback(). If the converter doesn't expose this feature, the format is either single-file or input file callbacks are not supported.

See Loading shaders from memory, using file callbacks and particular converter documentation for more information.

Preprocess

Set preprocess definitions using AbstractConverter::setDefinitions() and the ConverterFlag::PreprocessOnly flag.

Optimize

Control code optimization using AbstractConverter::setOptimizationLevel()

DebugInfo

Control amount of debug info present in the output using AbstractConverter::setDebugInfoLevel()

enum class Magnum::ShaderTools::ConverterFlag: UnsignedInt new in Git master

Shader converter flag.

Enumerators
Quiet

Suppress warnings, print just errors. By default the converter prints both warnings and errors. Corresponds to the -q / --quiet option in magnum-shaderconverter.

Verbose

Print verbose diagnostic. By default the converter only prints warnings and errors. Corresponds to the -v / --verbose option in magnum-shaderconverter.

WarningAsError

Treat warnings as error. By default, if a warning occurs, validation or conversion succeeds. With this flag set, it fails. Corresponds to the --warning-as-error option in magnum-shaderconverter.

PreprocessOnly

Only run the preprocessor. Available only if the converter supports ConverterFeature::Preprocess, not allowed in combination with AbstractConverter::linkDataToData(), AbstractConverter::linkDataToFile(), AbstractConverter::linkFilesToFile() or AbstractConverter::linkFilesToData(). Corresponds to the -E / --preprocess-only option in magnum-shaderconverter.

enum class Magnum::ShaderTools::Format: UnsignedInt new in Git master

Shader format.

Describes input and output shader format.

Enumerators
Unspecified

Either leaves format detection up to the implementation or describes a format not fitting into any other categories. This includes various application-specific languages and language flavors, compressed or encrypted data and other.

This value is guaranteed to be 0, which means you're encouraged to simply use {} in function calls and elsewhere.

Glsl

GLSL

Spirv

SPIR-V

SpirvAssembly

Textual representation of SPIR-V.

Hlsl

HLSL (High-Level Shading Language), used in D3D

Msl

MSL (Metal Shading Language)

Wgsl

WGSL (WebGPU Shading Language)

Dxil

DXIL (DirectX Intermediate Language), produced by DirectX Shader Compiler

enum class Magnum::ShaderTools::Stage: UnsignedInt new in Git master

Shader stage.

Enumerators
Unspecified

Unspecified stage. When used in the AbstractConverter::validateFile(), convertFileToFile(), convertFileToData(), linkFilesToFile() or linkFilesToData() APIs, particular plugins may attempt to detect the stage from filename, the shader stage might also be encoded directly in certain Formats. Leaving the stage unspecified might limit validation and conversion capabilities, see documentation of a particular converter for concrete behavior.

This value is guaranteed to be 0, which means you're encouraged to simply use {} in function calls and elsewhere.

Vertex

Vertex stage

Fragment

Fragment stage

Geometry

Geometry stage

TessellationControl

Tessellation control stage

TessellationEvaluation

Tessellation evaluation stage

Compute

Compute stage

RayGeneration

Ray generation stage

RayAnyHit

Ray any hit stage

RayClosestHit

Ray closest hit stage

RayMiss

Ray miss stage

RayIntersection

Ray intersection stage

RayCallable

Ray callable stage

MeshTask

Mesh task stage

Mesh

Mesh stage

Kernel

Compute kernel.

Compared to Stage::Compute, which is used by graphics APIs such as Vulkan or OpenGL, this one is for use by OpenCL.

Typedef documentation

typedef Containers::EnumSet<ConverterFeature> Magnum::ShaderTools::ConverterFeatures new in Git master

Features supported by a shader converter.

Function documentation

Debug& Magnum::ShaderTools::operator<<(Debug& debug, ConverterFeature value) new in Git master

Debug output operator.

Debug& Magnum::ShaderTools::operator<<(Debug& debug, ConverterFeatures value) new in Git master

Debug output operator.

Debug& Magnum::ShaderTools::operator<<(Debug& debug, ConverterFlag value) new in Git master

Debug output operator.

Debug& Magnum::ShaderTools::operator<<(Debug& debug, ConverterFlags value) new in Git master

Debug output operator.

Debug& Magnum::ShaderTools::operator<<(Debug& debug, Format value) new in Git master

Debug output operator.

Debug& Magnum::ShaderTools::operator<<(Debug& debug, Stage value) new in Git master

Debug output operator.