Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Static Public Member Functions | Static Private Member Functions | List of all members
ShaderCompiler Class Reference

Relies on glslang to compile GLSL shaders to SPIR-V and generate reflection data. More...

#include <ShaderCompiler.hpp>

Static Public Member Functions

static void compile (const std::string &prog, ShaderType type, Program::Stage &stage, bool generateModule, std::string &finalLog)
 
static bool init ()
 
static void cleanup ()
 
static void clean (Program::Stage &stage)
 

Static Private Member Functions

static Program::UniformDef::Type convertType (const glslang::TType &type)
 
static uint getSetFromType (const glslang::TType &type)
 
static void reflect (glslang::TProgram &program, Program::Stage &stage)
 

Detailed Description

Relies on glslang to compile GLSL shaders to SPIR-V and generate reflection data.

Member Function Documentation

◆ clean()

void ShaderCompiler::clean ( Program::Stage stage)
static

Destroy a compiled shader

Parameters
stagethe shader to cleanup

◆ cleanup()

void ShaderCompiler::cleanup ( )
static

Close the compiler library.

◆ compile()

void ShaderCompiler::compile ( const std::string &  prog,
ShaderType  type,
Program::Stage stage,
bool  generateModule,
std::string &  finalLog 
)
static

Create a shader of a given type from a string. Extract additional informations from the shader.

Parameters
progthe content of the shader
typethe type of shader (vertex, fragment,...)
stagewill be filled with reflection information: the samplers/buffers present in the shader and their user-defined locations, along with the compiled results
generateModuleshoud a Vulkan module be generated from the SPIR-V code
finalLogwill contain the compilation log of the shader

◆ convertType()

Program::UniformDef::Type ShaderCompiler::convertType ( const glslang::TType &  type)
staticprivate

Convert a uniform compiler type to Rendu internal types.

Parameters
typethe type to convert
Returns
the corresponding Rendu uniform type

◆ getSetFromType()

uint ShaderCompiler::getSetFromType ( const glslang::TType &  type)
staticprivate

Retrieve a set location from its type.

Parameters
typethe type of the set
Returns
the set location

◆ init()

bool ShaderCompiler::init ( )
static

Initialize the compiler library.

Returns
the success status

◆ reflect()

void ShaderCompiler::reflect ( glslang::TProgram &  program,
Program::Stage stage 
)
staticprivate

Perform reflection on a compiled program and populate our reflection structures.

Parameters
programthe compiled SPIR-V program
stagewill contain reflection data

The documentation for this class was generated from the following files: