|
Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
|
Parser for .esshader unified shader format. More...
#include <ShaderParser.hpp>
Classes | |
| struct | AssembledStage |
| Like assembleStage, but also reports the line count of the assembled prefix (version + variant + sharedCode). More... | |
Static Public Member Functions | |
| static ParsedShader | parse (const std::string &source) |
| Parses shader source into structured format (no include support). | |
| static ParsedShader | parse (const std::string &source, const ShaderIncludeResolver &resolver) |
| Parses shader source with #include "path" expansion. | |
| static std::string | assembleStage (const ParsedShader &parsed, ShaderStage stage, const std::string &platform="", const std::vector< std::string > &features={}, ShaderTargetLanguage target=ShaderTargetLanguage::GLSL_ES300) |
| Assembles final GLSL source for a specific stage. | |
| static std::string | canonicalVaryingsWGSL (const ParsedShader &parsed) |
The WGSL varying struct the engine's vertex stage emits for parsed, or empty when the shader writes its own vertex stage. | |
| static std::string | variantKey (const std::vector< std::string > &features) |
| Stable cache key for a feature set (order-independent), e.g. "GRAYSCALE|TINT". Consumers key their compiled-variant cache on (shader, variantKey(features)). | |
| static std::vector< std::string > | splitFeatures (const std::string &csv) |
| Split a comma-separated feature/switch list into trimmed, non-empty entries — the form the boundary carries a permutation in. | |
| static std::vector< std::string > | featuresRead (const ParsedShader &parsed, const std::vector< std::string > &features, ShaderTargetLanguage target=ShaderTargetLanguage::GLSL_ES300) |
| static void | setLinearColorSpace (bool linear) |
| Process-global color-space mode. When linear, every assembled stage compiles with ES_LINEAR defined (GLSL #define / WGSL assembly-time preprocessor). Set BEFORE the renderer compiles shaders; flipping later requires a reload. Variant caches must fold linearColorSpace() into their keys if they can outlive a flip. | |
| static bool | linearColorSpace () |
| static AssembledStage | assembleStageEx (const ParsedShader &parsed, ShaderStage stage, const std::string &platform="", const std::vector< std::string > &features={}, ShaderTargetLanguage target=ShaderTargetLanguage::GLSL_ES300) |
| static std::string | remapCompilerLog (const std::string &log, const std::vector< SourceLine > &stageMap, u32 headerLineOffset) |
| Rewrites GL compile-log line references back to original files. | |
| static u32 | materialOverflowUnits (const ParsedShader &shader) |
The units below the material base a texture param may take on shader (a mask): the ones it never reads from the engine. | |
Parser for .esshader unified shader format.
Parses shader files that contain multiple stages in a single file. Uses #pragma directives to separate sections.
File format:
Definition at line 296 of file ShaderParser.hpp.
|
static |
Assembles final GLSL source for a specific stage.
| parsed | The parsed shader data |
| stage | The shader stage to assemble |
| platform | Platform variant name (empty for default) |
| features | Feature keywords to enable; each is injected as #define <name> 1 right after #version, so shaders can #ifdef compile-time variants. |
Definition at line 1235 of file ShaderParser.cpp.
References assembleStageEx(), and esengine::resource::ShaderParser::AssembledStage::source.
Referenced by esengine::esshader_cookInfo(), featuresRead(), esengine::ImmediateDraw::init(), esengine::ParticlePlugin::init(), esengine::ShapePlugin::init(), esengine::material_compileEsshader(), esengine::MaterialStore::prepassCoverageProgram(), and esengine::MaterialStore::shadowProgram().
|
static |
Definition at line 3037 of file ShaderParser.cpp.
References esengine::resource::ParsedShader::domain, esengine::resource::ParsedShader::features, esengine::resource::Fragment, esengine::glslMultiDraw(), esengine::resource::ShaderParser::AssembledStage::headerLineCount, esengine::resource::ParsedShader::lightingDirect, esengine::resource::ParsedShader::materialBlockSize, esengine::resource::ParsedShader::properties, esengine::resource::ParsedShader::sharedCode, esengine::resource::ShaderParser::AssembledStage::source, esengine::resource::ParsedShader::stages, esengine::resource::Texture, esengine::resource::ParsedShader::usesLights, esengine::resource::ParsedShader::valid, esengine::resource::ParsedShader::variants, esengine::resource::ParsedShader::version, esengine::resource::Vertex, esengine::resource::ParsedShader::vertexHook, esengine::resource::ParsedShader::vertexIsCanonical, esengine::WATER_SUN_GLSL, and esengine::resource::WGSL.
Referenced by assembleStage().
|
static |
The WGSL varying struct the engine's vertex stage emits for parsed, or empty when the shader writes its own vertex stage.
A fragment twin generated for a shader on the engine's vertex stage reads its inputs at these locations, so every vertex source the engine retargets the material to feeds the same fragment.
Definition at line 3029 of file ShaderParser.cpp.
Referenced by esengine::esshader_cookInfo().
|
static |
Definition at line 1290 of file ShaderParser.cpp.
References assembleStage(), esengine::resource::Fragment, esengine::resource::GLSL_ES300, esengine::resource::ParsedShader::valid, and esengine::resource::Vertex.
|
static |
Definition at line 3035 of file ShaderParser.cpp.
Referenced by esengine::RenderFrame::init().
|
static |
The units below the material base a texture param may take on shader (a mask): the ones it never reads from the engine.
The units below MATERIAL_TEXTURE_UNIT_BASE a material texture may take on shader, as a mask: those the engine binds per draw that this shader never reads. Read are what its domain's injected code takes (Lit: shadow map, reflections, bake, both 2D masks; every mesh: morph deltas) and what its own text names in either language: batch textures (batchUnitsRead), an engine sampler, a tN/sN unit. A fullscreen pass and the UI reach their low units through their own conventions and keep none free.
Definition at line 4854 of file ShaderParser.cpp.
References esengine::ENV_MAP_TEXTURE_UNIT, esengine::LIGHTMAP_TEXTURE_UNIT, esengine::MORPH_DELTA_TEXTURE_UNIT, esengine::SHADOW_2D_TEXTURE_UNIT, esengine::SHADOW_MAP_TEXTURE_UNIT, and esengine::SHAPE_2D_TEXTURE_UNIT.
|
static |
Parses shader source into structured format (no include support).
| source | The complete .esshader file content |
Definition at line 898 of file ShaderParser.cpp.
References parse().
Referenced by esengine::esshader_cookInfo(), esengine::ImmediateDraw::init(), esengine::ParticlePlugin::init(), esengine::ShapePlugin::init(), esengine::material_compileEsshader(), parse(), esengine::MaterialStore::prepassCoverageProgram(), and esengine::MaterialStore::shadowProgram().
|
static |
Parses shader source with #include "path" expansion.
| source | The complete .esshader file content |
| resolver | Callback used to fetch included file contents |
Definition at line 902 of file ShaderParser.cpp.
References esengine::resource::ParsedShader::coverageParam, esengine::resource::ShaderSwitch::defaultOn, esengine::resource::ParsedShader::depthInput, esengine::resource::ParsedShader::domain, esengine::resource::ParsedShader::errorMessage, esengine::resource::ParsedShader::expandedLineMap, esengine::resource::ParsedShader::features, esengine::resource::Fragment, esengine::resource::Global, esengine::resource::ParsedShader::hairShadowParam, esengine::resource::ParsedShader::highPrecision, esengine::resource::ParsedShader::lightingDirect, esengine::resource::ParsedShader::name, esengine::resource::ShaderProperty::name, esengine::resource::ShaderSwitch::name, esengine::resource::Properties, esengine::resource::ParsedShader::properties, esengine::resource::ParsedShader::sharedCode, esengine::resource::ParsedShader::stageLineMaps, esengine::resource::ParsedShader::stages, esengine::resource::ParsedShader::switches, esengine::resource::ParsedShader::tipParam, esengine::resource::ParsedShader::usesGBuffer, esengine::resource::ParsedShader::usesLights, esengine::resource::ParsedShader::valid, esengine::resource::Variant, esengine::resource::ParsedShader::variants, esengine::resource::ParsedShader::version, esengine::resource::Vertex, esengine::resource::ParsedShader::vertexBounds, esengine::resource::VertexHook, esengine::resource::ParsedShader::vertexHook, esengine::resource::ParsedShader::vertexIsCanonical, esengine::resource::ParsedShader::wgslStageFull, esengine::resource::ParsedShader::wgslStageLineMaps, esengine::resource::ParsedShader::wgslStages, esengine::resource::ParsedShader::wgslVertexHook, and esengine::resource::ParsedShader::wgslVertexIsCanonical.
|
static |
Rewrites GL compile-log line references back to original files.
Scans log for 0:N: and 0(N) patterns (the two common vendor prefixes) and rewrites each occurrence to file:origLine:. Lines before headerLineOffset are treated as synthetic header (e.g. #version, sharedCode) and left unchanged.
| log | GL driver log (from glGetShaderInfoLog / glGetProgramInfoLog) |
| stageMap | Per-stage line map from ParsedShader::stageLineMaps |
| headerLineOffset | Line count prepended by assembleStage before the stage body (typically 1 for #version + sharedCode line count) |
Definition at line 4680 of file ShaderParser.cpp.
|
static |
Process-global color-space mode. When linear, every assembled stage compiles with ES_LINEAR defined (GLSL #define / WGSL assembly-time preprocessor). Set BEFORE the renderer compiles shaders; flipping later requires a reload. Variant caches must fold linearColorSpace() into their keys if they can outlive a flip.
Definition at line 3034 of file ShaderParser.cpp.
Referenced by esengine::renderer_setColorSpace(), and esengine::RenderFrame::setColorSpace().
|
static |
Split a comma-separated feature/switch list into trimmed, non-empty entries — the form the boundary carries a permutation in.
Definition at line 1254 of file ShaderParser.cpp.
Referenced by esengine::esshader_cookInfo(), and esengine::material_compileEsshader().
|
static |
Stable cache key for a feature set (order-independent), e.g. "GRAYSCALE|TINT". Consumers key their compiled-variant cache on (shader, variantKey(features)).
Definition at line 1243 of file ShaderParser.cpp.