resources: extract shader authoring parser
This commit is contained in:
@@ -387,6 +387,8 @@ add_library(XCEngine STATIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/Resources/Material/MaterialLoader.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/Resources/Shader/Shader.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/Resources/Shader/ShaderLoader.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/Resources/Shader/ShaderAuthoringParser.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/Resources/Shader/ShaderAuthoringParser.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/Resources/AudioClip/AudioClip.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/Resources/AudioClip/AudioLoader.cpp
|
||||
${XCENGINE_OPTIONAL_UI_RESOURCE_SOURCES}
|
||||
|
||||
2108
engine/src/Resources/Shader/ShaderAuthoringParser.cpp
Normal file
2108
engine/src/Resources/Shader/ShaderAuthoringParser.cpp
Normal file
File diff suppressed because it is too large
Load Diff
99
engine/src/Resources/Shader/ShaderAuthoringParser.h
Normal file
99
engine/src/Resources/Shader/ShaderAuthoringParser.h
Normal file
@@ -0,0 +1,99 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/Core/Containers/Array.h>
|
||||
#include <XCEngine/Core/Containers/String.h>
|
||||
#include <XCEngine/Resources/Shader/Shader.h>
|
||||
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace Resources {
|
||||
|
||||
enum class ShaderAuthoringStyle {
|
||||
NotShaderAuthoring = 0,
|
||||
LegacyBackendSplit,
|
||||
UnityStyleSingleSource
|
||||
};
|
||||
|
||||
struct AuthoringTagEntry {
|
||||
Containers::String name;
|
||||
Containers::String value;
|
||||
};
|
||||
|
||||
struct AuthoringBackendVariantEntry {
|
||||
ShaderBackend backend = ShaderBackend::Generic;
|
||||
ShaderLanguage language = ShaderLanguage::GLSL;
|
||||
Containers::String vertexSourcePath;
|
||||
Containers::String fragmentSourcePath;
|
||||
Containers::String vertexProfile;
|
||||
Containers::String fragmentProfile;
|
||||
};
|
||||
|
||||
struct AuthoringPassEntry {
|
||||
Containers::String name;
|
||||
bool hasFixedFunctionState = false;
|
||||
MaterialRenderState fixedFunctionState = {};
|
||||
std::vector<AuthoringTagEntry> tags;
|
||||
Containers::Array<ShaderResourceBindingDesc> resources;
|
||||
Containers::Array<ShaderKeywordDeclaration> keywordDeclarations;
|
||||
Containers::String vertexEntryPoint;
|
||||
Containers::String fragmentEntryPoint;
|
||||
Containers::String sharedProgramSource;
|
||||
Containers::String programSource;
|
||||
Containers::String targetProfile;
|
||||
std::vector<AuthoringBackendVariantEntry> backendVariants;
|
||||
};
|
||||
|
||||
struct AuthoringSubShaderEntry {
|
||||
bool hasFixedFunctionState = false;
|
||||
MaterialRenderState fixedFunctionState = {};
|
||||
std::vector<AuthoringTagEntry> tags;
|
||||
Containers::String sharedProgramSource;
|
||||
std::vector<AuthoringPassEntry> passes;
|
||||
};
|
||||
|
||||
struct AuthoringShaderDesc {
|
||||
Containers::String name;
|
||||
Containers::String fallback;
|
||||
Containers::String sharedProgramSource;
|
||||
Containers::Array<ShaderPropertyDesc> properties;
|
||||
std::vector<AuthoringSubShaderEntry> subShaders;
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
Containers::String StripUnityStyleAuthoringPragmas(const Containers::String& sourceText);
|
||||
|
||||
std::vector<ShaderKeywordSet> BuildShaderKeywordVariantSets(
|
||||
const Containers::Array<ShaderKeywordDeclaration>& declarations);
|
||||
|
||||
Containers::String BuildKeywordVariantSource(
|
||||
const Containers::String& baseSource,
|
||||
const ShaderKeywordSet& requiredKeywords);
|
||||
|
||||
ShaderAuthoringStyle DetectShaderAuthoringStyle(const std::string& sourceText);
|
||||
|
||||
bool ParseLegacyBackendSplitShaderAuthoring(
|
||||
const Containers::String& path,
|
||||
const std::string& sourceText,
|
||||
AuthoringShaderDesc& outDesc,
|
||||
Containers::String* outError);
|
||||
|
||||
bool ParseUnityStyleSingleSourceShaderAuthoring(
|
||||
const Containers::String& path,
|
||||
const std::string& sourceText,
|
||||
AuthoringShaderDesc& outDesc,
|
||||
Containers::String* outError);
|
||||
|
||||
} // namespace Resources
|
||||
} // namespace XCEngine
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user