ShaderCompiler::GlslToCpp class

Transpiles lowered fragment GLSL into a C++ software-renderer fragment function.

Public static functions

static auto TranspileFragment(StringView programName, StringView fragmentGlsl, StringView vertexGlsl, const std::vector<SamplerBinding>& samplers, const std::vector<GlslInstanceMember>& instanceMembers) -> GlslToCppResult

Function documentation

static GlslToCppResult ShaderCompiler::GlslToCpp::TranspileFragment(StringView programName, StringView fragmentGlsl, StringView vertexGlsl, const std::vector<SamplerBinding>& samplers, const std::vector<GlslInstanceMember>& instanceMembers)

Transpiles fragmentGlsl (the lowered <Program>_Fs text of one variant) into a void <programName>_Fragment(const nCine::RHI::Software::FragmentShaderInput&) function. samplers maps each sampler uniform to the texture unit it is bound to (from reflection), so texture(sampler, uv) lowers to sw::swTexture(in, <unit>, uv). vertexGlsl is the lowered <Program>_Vs text of the same variant: it is analyzed for per-instance-constant varyings (a varying whose vertex assignment does not depend on the per-vertex input), which the fragment may then read. instanceMembers gives the std140 byte offsets of the instance-block members those varyings read. Returns a result whose GlslToCppResult::Supported flag says whether emission succeeded.