GlslReflect.h file
GLSL-subset declaration parser and std140 layout calculator for ShaderCompiler.
Operates on the preprocessed declaration stream produced by Preprocessor (comments stripped, inactive conditional branches removed, macros expanded). Only global-scope declarations are parsed — function bodies are skipped by brace counting:
- struct <Name> { <members> };
- layout (std140) uniform <BlockName> { <members> } [instanceName];
- uniform <type> <name>[N]; (sampler types become texture bindings)
- in <type> <name>; (vertex stage only — vertex attributes)
Supported types: float, int, uint, bool, vec2/3/4, ivec2/3/4, uvec2/3/4, bvec2/3/4, mat2, mat3, mat4, sampler2D, sampler3D, samplerCube and previously declared user structs. Arrays may be sized by a decimal integer literal or by the symbolic BATCH_SIZE constant (uniform block members only) — symbolic arrays record their std140 element stride so the runtime can compute the batch size as maxUniformBlockSize / stride.
std140 rules used (per OpenGL spec):
- scalars 4/4 (bool = 4), vec2 8/8, vec3 12 with align 16, vec4 16/16;
- matN = N columns with vec4 stride: mat2 32, mat3 48, mat4 64, align 16;
- array base alignment = element alignment rounded up to 16, element stride = element size rounded up to that alignment;
- struct base alignment = max member alignment rounded up to 16, struct size = end offset rounded up to the struct alignment.
Namespaces
- namespace ShaderCompiler
Classes
- struct ShaderCompiler::MemberInfo
- Member of a struct or std140 uniform block.
- struct ShaderCompiler::StructInfo
- User struct declaration with its computed std140 layout.
- struct ShaderCompiler::UniformInfo
- Loose (non-block, non-sampler) uniform.
- struct ShaderCompiler::BlockInfo
- std140 uniform block
- struct ShaderCompiler::TextureInfo
- Sampler uniform with its optional "texture_unit(N)" hint unit assignment.
- struct ShaderCompiler::AttributeInfo
- Vertex attribute ("in" declaration in the vertex stage).
- struct ShaderCompiler::StageReflection
- Reflection data collected from one stage (or merged for a whole program).
- class ShaderCompiler::GlslReflector
- Parses global-scope GLSL declarations and computes std140 layouts.