119 lines
3.5 KiB
C++
119 lines
3.5 KiB
C++
#pragma once
|
|
|
|
#include "../ShaderAuthoringParser.h"
|
|
|
|
#include <string>
|
|
#include <unordered_set>
|
|
#include <vector>
|
|
|
|
namespace XCEngine {
|
|
namespace Resources {
|
|
namespace Internal {
|
|
|
|
struct ExtractedProgramBlock {
|
|
enum class Kind {
|
|
SharedInclude,
|
|
PassProgram
|
|
};
|
|
|
|
Kind kind = Kind::PassProgram;
|
|
Containers::String sourceText;
|
|
size_t markerLine = 0;
|
|
};
|
|
|
|
std::string StripAuthoringLineComment(const std::string& line);
|
|
bool StartsWithKeyword(const std::string& line, const char* keyword);
|
|
|
|
void SplitShaderAuthoringLines(
|
|
const std::string& sourceText,
|
|
std::vector<std::string>& outLines);
|
|
|
|
bool TryExtractProgramBlocks(
|
|
const std::string& sourceText,
|
|
std::vector<ExtractedProgramBlock>& outBlocks,
|
|
Containers::String* outError);
|
|
|
|
MaterialRenderState BuildDefaultAuthoringFixedFunctionState();
|
|
void EnsureAuthoringFixedFunctionStateInitialized(
|
|
bool& hasFixedFunctionState,
|
|
MaterialRenderState& fixedFunctionState);
|
|
|
|
bool TryParseAuthoringBoolDirectiveToken(const std::string& token, bool& outValue);
|
|
bool TryParseAuthoringCullMode(const std::string& token, MaterialCullMode& outMode);
|
|
bool TryParseAuthoringComparisonFunc(const std::string& token, MaterialComparisonFunc& outFunc);
|
|
bool TryParseAuthoringBlendFactor(const std::string& token, MaterialBlendFactor& outFactor);
|
|
bool TryParseAuthoringColorMask(const std::string& token, Core::uint8& outMask);
|
|
bool TryParseAuthoringBlendDirective(
|
|
const std::vector<std::string>& tokens,
|
|
MaterialRenderState& outState);
|
|
|
|
void SetOrReplaceAuthoringTag(
|
|
std::vector<ShaderTagIR>& tags,
|
|
const Containers::String& name,
|
|
const Containers::String& value);
|
|
|
|
void AppendAuthoringSourceBlock(
|
|
Containers::String& target,
|
|
const Containers::String& sourceBlock);
|
|
|
|
void CollectQuotedIncludeDependencyPaths(
|
|
const Containers::String& sourcePath,
|
|
const Containers::String& sourceText,
|
|
std::unordered_set<std::string>& seenPaths,
|
|
Containers::Array<Containers::String>& outDependencies);
|
|
|
|
bool IsShaderAuthoringPragmaDirective(const std::string& line);
|
|
|
|
Containers::String StripShaderAuthoringPragmas(const Containers::String& sourceText);
|
|
|
|
std::vector<ShaderKeywordSet> BuildShaderKeywordVariantSets(
|
|
const Containers::Array<ShaderKeywordDeclaration>& declarations);
|
|
|
|
Containers::String BuildKeywordVariantSource(
|
|
const Containers::String& baseSource,
|
|
const ShaderKeywordSet& requiredKeywords);
|
|
|
|
bool TryParseShaderKeywordDeclarationPragma(
|
|
const std::vector<std::string>& pragmaTokens,
|
|
ShaderKeywordDeclaration& outDeclaration);
|
|
|
|
size_t FindMatchingDelimiter(
|
|
const std::string& text,
|
|
size_t openPos,
|
|
char openChar,
|
|
char closeChar);
|
|
|
|
size_t FindFirstTopLevelChar(const std::string& text, char target);
|
|
|
|
bool SplitCommaSeparatedAuthoring(
|
|
const std::string& text,
|
|
std::vector<std::string>& outParts);
|
|
|
|
Containers::String UnquoteAuthoringValue(const std::string& text);
|
|
|
|
bool TryTokenizeQuotedArguments(
|
|
const std::string& line,
|
|
std::vector<std::string>& outTokens);
|
|
|
|
bool TryParseInlineTagAssignments(
|
|
const std::string& line,
|
|
std::vector<ShaderTagIR>& outTags);
|
|
|
|
bool TryParseSemanticAttributes(
|
|
const std::string& attributesText,
|
|
Containers::String& outSemantic);
|
|
|
|
bool TryParseAuthoringPropertyLine(
|
|
const std::string& line,
|
|
ShaderPropertyDesc& outProperty);
|
|
|
|
bool ParseShaderAuthoring(
|
|
const Containers::String& path,
|
|
const std::string& sourceText,
|
|
ShaderIR& outDesc,
|
|
Containers::String* outError);
|
|
|
|
} // namespace Internal
|
|
} // namespace Resources
|
|
} // namespace XCEngine
|