Magnum::ShaderTools::AnyConverter class new in Git master

Any shader converter plugin.

Loads a plugin corresponding to a format either explicitly set using setInputFormat() / setOutputFormat() or detected based on input / output file extension plugin and then tries to either validate or convert the file with it. These formats are detected based on extension:

  • GLSL (*.glsl, *.vert, *.frag, *.geom, *.comp, *.tesc, *.tese, *.rgen, *.rint, *.rahit, *.rchit, *.rmiss, *.rcall, *.mesh, *.task)
  • SPIR-V (*.spv)
  • SPIR-V Assembly (*.spvasm, *.asm.vert, ..., *.asm.task)

Supported validation scenarios:

  • GLSL, validated with any plugin that provides GlslShaderConverter
  • SPIR-V, validated with any plugin that provides SpirvShaderConverter
  • SPIR-V Assembly, validated with any plugin that provides SpirvAssemblyShaderConverter

Supported conversion paths:

  • GLSL to SPIR-V, converted with any plugin that provides GlslToSpirvShaderConverter
  • SPIR-V to SPIR-V, converted with any plugin that provides SpirvShaderConverter
  • SPIR-V to SPIR-V Assembly, converted with any plugin that provides SpirvToSpirvAssemblyShaderConverter
  • SPIR-V Assembly to SPIR-V, converted with any plugin that provides SpirvAssemblyToSpirvShaderConverter
  • SPIR-V Assembly to SPIR-V Assembly, converted with any plugin that provides SpirvAssemblyShaderConverter

There's format detection based on file contents, so the plugin has to either operate on files or setInputFormat() / setOutputFormat() has to be explicitly set.

Usage

This plugin depends on the ShaderTools library and is built if MAGNUM_WITH_ANYSHADERCONVERTER is enabled when building Magnum. To use as a dynamic plugin, load "AnyShaderConverter" via Corrade::PluginManager::Manager.

Additionally, if you're using Magnum as a CMake subproject, do the following:

set(MAGNUM_WITH_ANYSHADERCONVERTER ON CACHE BOOL "" FORCE)
add_subdirectory(magnum EXCLUDE_FROM_ALL)

# So the dynamically loaded plugin gets built implicitly
add_dependencies(your-app Magnum::AnyShaderConverter)

To use as a static plugin or as a dependency of another plugin with CMake, you need to request the AnyShaderConverter component of the Magnum package and link to the Magnum::AnyShaderConverter target:

find_package(Magnum REQUIRED AnyShaderConverter)

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

See Downloading and building, Usage with CMake and Loading and using plugins for more information.

Interface proxying and option propagation

On a call to validateFile() / validateData(), convertFileToFile() / convertFileToData() / convertDataToData(), an input/output file format is detected from either the extensions or taken from the setInputFormat() and setOutputFormat() calls and a corresponding plugin is loaded. After that, everything set via setFlags(), setInputFormat(), setOutputFormat(), setDefinitions(), setDebugInfoLevel(), setOptimizationLevel() is propagated to the concrete implementation, with an error emitted in case the target plugin doesn't support given feature. Options set through configuration() are propagated as well, with just a warning emitted in case given option is not present in the default configuration of the target plugin.

The output of the validateFile() / validateData(), convertFileToFile() / convertFileToData() / convertDataToData() function called on the concrete implementation is then proxied back.

Besides delegating the flags, the AnyConverter itself recognizes ConverterFlag::Verbose, printing info about the concrete plugin being used when the flag is enabled. ConverterFlag::Quiet is recognized as well and causes all warnings to be suppressed.

Base classes

class AbstractConverter new in Git master
Base for shader converter plugins.

Constructors, destructors, conversion operators

AnyConverter(PluginManager::Manager<AbstractConverter>& manager) explicit
Constructor with access to plugin manager.
AnyConverter(PluginManager::AbstractManager& manager, const Containers::StringView& plugin) explicit
Plugin manager constructor.