ShaderCompiler/GlslTypedAst.h file

Shared TYPED GLSL AST and front-end parser for the AST-based ShaderCompiler lowerings.

Where GlslAst.h holds only the type-FREE expression node (Expr / ExprKind) plus the stage tokenizer, this header holds the parts that DO carry type information but are nevertheless the same for every non-software target: the translated-subset type system (Ty / TyRef and its helpers), the declaration records (uniform blocks, samplers, attributes, varyings, fragment outputs, global vars, user structs), the statement model (Stmt / StmtKind) and the Parser that grows all of them from the shared lexer/preprocessor. It is consumed by every emitter that re-emits a whole stage from a real AST — the GLSL-to-HLSL emitter (Hlsl.h), the Vulkan-flavored GLSL emitter (Vulkan.h) and the ESSL 100 emitter (Essl100.h) — each of which keeps only its own target spelling / declaration formatting.

The software transpiler (GlslToCpp.h) is NOT a consumer: it folds uint/matrices away and grows its own lighter type-folded AST, so its model stays private to that unit.

This is a HEADER-ONLY unit on purpose: the ESSL 100 emitter is compiled into the engine's OpenGL|ES 2.0 profile (see cmake/ncine_sources.cmake), so the shared parser must not require a new translation unit.

Namespaces

namespace ShaderCompiler

Classes

struct ShaderCompiler::TyRef
A type plus, for Ty::Struct, the user struct name (so struct-typed members resolve their fields).
struct ShaderCompiler::Stmt
struct ShaderCompiler::Param
struct ShaderCompiler::Function
struct ShaderCompiler::Field
struct ShaderCompiler::StructDecl
struct ShaderCompiler::BlockDecl
struct ShaderCompiler::UniformDecl
struct ShaderCompiler::SamplerDecl
struct ShaderCompiler::VaryingDecl
struct ShaderCompiler::AttributeDecl
struct ShaderCompiler::GlobalVarDecl
class ShaderCompiler::Parser
Grows the shared typed AST (declarations + per-function statement trees) from an already-lowered modern-GLSL stage token stream.
struct ShaderCompiler::Parser::FragOutputDecl

Enums

enum class Ty { Void, Float, Int, UInt, Bool, Vec2, Vec3, Vec4, IVec2, IVec3, IVec4, UVec2, UVec3, UVec4, BVec2, BVec3, BVec4, Mat2, Mat3, Mat4, Sampler2D, Sampler3D, SamplerCube, Struct, Unknown }
Scalar/vector/matrix/opaque type of the translated GLSL subset (uint/uvec kept distinct).
enum class StmtKind { Block, VarDecl, ExprStmt, If, For, Return }

Typedefs

using StmtPtr = std::unique_ptr<Stmt>

Functions

auto IsMatrix(Ty t) -> bool
auto IsVector(Ty t) -> bool
auto IsSampler(Ty t) -> bool
auto Comps(Ty t) -> std::int32_t
auto BaseScalar(Ty t) -> Ty
auto MakeVec(Ty scalar, std::int32_t n) -> Ty
auto MatrixColumn(Ty t) -> Ty
auto TryBuiltinType(StringView k, Ty& out) -> bool
auto MakeStmt(StmtKind kind) -> StmtPtr