27#include <unordered_map>
151 std::unordered_map<ShaderStage, std::string>
stages;
152 std::unordered_map<std::string, std::string>
variants;
325 const std::string& platform =
"",
326 const std::vector<std::string>& features = {},
342 static std::string
variantKey(
const std::vector<std::string>& features);
348 static std::vector<std::string>
splitFeatures(
const std::string& csv);
351 const std::vector<std::string>& features,
379 const std::string& platform =
"",
380 const std::vector<std::string>& features = {},
399 const std::vector<SourceLine>& stageMap,
400 u32 headerLineOffset);
403 static void parseDirective(
const std::string& line,
404 std::string& directive,
405 std::string& argument);
408 static ShaderProperty parseParamDirective(
const std::string& argument);
412 static void computeMaterialLayout(
ParsedShader& shader);
420 static i32 takeOverflowUnit(
u32& free);
422 static ShaderProperty parsePropertyAnnotation(
const std::string& line);
426 static std::string trim(
const std::string& str);
429 static bool s_linearColor;
Core type definitions and utilities for ESEngine.
2D texture for GPU rendering
Parser for .esshader unified shader format.
static void setLinearColorSpace(bool linear)
Process-global color-space mode. When linear, every assembled stage compiles with ES_LINEAR defined (...
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 c...
static ParsedShader parse(const std::string &source)
Parses shader source into structured format (no include support).
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 i...
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 co...
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 read...
static bool linearColorSpace()
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::vector< std::string > featuresRead(const ParsedShader &parsed, const std::vector< std::string > &features, ShaderTargetLanguage target=ShaderTargetLanguage::GLSL_ES300)
static AssembledStage assembleStageEx(const ParsedShader &parsed, ShaderStage stage, const std::string &platform="", const std::vector< std::string > &features={}, ShaderTargetLanguage target=ShaderTargetLanguage::GLSL_ES300)
std::function< std::optional< std::string >(const std::string &)> ShaderIncludeResolver
Resolves an include path to its file contents.
ShaderTargetLanguage
Target language for stage assembly (REARCH_WGSL dual emission).
std::int32_t i32
Signed 32-bit integer.
std::int8_t i8
Signed 8-bit integer.
std::uint32_t u32
Unsigned 32-bit integer.
std::uint8_t u8
Unsigned 8-bit integer.
float f32
32-bit floating point
Result of parsing an .esshader file.
std::string version
GLSL version.
std::string errorMessage
Parse error if any.
std::unordered_map< ShaderStage, std::vector< SourceLine > > wgslStageLineMaps
Line maps for wgslStages, same convention as stageLineMaps.
std::unordered_map< ShaderStage, std::vector< SourceLine > > stageLineMaps
Per-stage line maps, parallel to stages[].
std::unordered_map< ShaderStage, std::string > stages
Stage source code.
std::unordered_map< ShaderStage, std::string > wgslStages
WGSL twin stage bodies (#pragma vertex wgsl / #pragma fragment wgsl sections), keyed like stages[].
bool valid
True if parsing succeeded.
std::vector< SourceLine > expandedLineMap
Line map for the expanded pre-parse source.
std::vector< std::string > features
std::string sharedCode
Code shared by all stages.
std::string hairShadowParam
std::string coverageParam
std::string name
Shader name.
std::unordered_map< ShaderStage, bool > wgslStageFull
Stages whose WGSL twin is a SELF-CONTAINED program (#pragma vertex wgsl full / #pragma fragment wgsl ...
bool wgslVertexIsCanonical
True when the WGSL vertex stage is the injected canonical one. The WGSL fragment assembly then also i...
bool vertexIsCanonical
True when the GLSL vertex stage is the injected canonical one.
std::vector< ShaderSwitch > switches
Material-controlled pragma switch toggles (name + default).
std::string wgslVertexHook
std::unordered_map< std::string, std::string > variants
Platform variants.
std::vector< ShaderProperty > properties
Exposed material params (pragma param / properties block).
Like assembleStage, but also reports the line count of the assembled prefix (version + variant + shar...
i32 textureUnit
Sampler unit for a texture param (>= MATERIAL_TEXTURE_UNIT_BASE), or -1 otherwise.
std::string defaultValue
Default value as string (comma-separated for vectors).
std::string name
Uniform name.
std::string displayName
Display name for editor.
ShaderPropertyType type
Property type.
A material-controlled static switch (pragma switch): a boolean the material sets, selecting a compile...
A (file, line) pair identifying an original source location.