Grindstone Game Engine v0.2.0
An open source game engine and toolkit.
Loading...
Searching...
No Matches
ParseTree.hpp
1#pragma once
2
3#include <filesystem>
4#include <string_view>
5#include <array>
6#include <map>
7#include <optional>
8
9#include <Common/Graphics/Formats.hpp>
10#include "ParameterType.hpp"
11
12enum class ShaderCodeType {
13 Unset,
14 Glsl,
15 Hlsl
16};
17
18struct ParseTree {
19 struct RenderState {
20 std::optional<Grindstone::GraphicsAPI::GeometryType> geometryType;
21 std::optional<Grindstone::GraphicsAPI::PolygonFillMode> polygonFillMode;
22 std::optional<Grindstone::GraphicsAPI::CullMode> cullMode;
23
25 std::optional<Grindstone::GraphicsAPI::ColorMask> colorMask;
26
27 std::optional<Grindstone::GraphicsAPI::BlendOperation> blendColorOperation;
28 std::optional<Grindstone::GraphicsAPI::BlendFactor> blendColorFactorSrc;
29 std::optional<Grindstone::GraphicsAPI::BlendFactor> blendColorFactorDst;
30
31 std::optional<Grindstone::GraphicsAPI::BlendOperation> blendAlphaOperation;
32 std::optional<Grindstone::GraphicsAPI::BlendFactor> blendAlphaFactorSrc;
33 std::optional<Grindstone::GraphicsAPI::BlendFactor> blendAlphaFactorDst;
34 };
35
36 std::vector<AttachmentData> attachmentData;
37 bool shouldCopyFirstAttachment = false;
38
39 std::optional<Grindstone::GraphicsAPI::CompareOperation> depthCompareOp;
40 std::optional<bool> isStencilEnabled;
41 std::optional<bool> isDepthTestEnabled;
42 std::optional<bool> isDepthWriteEnabled;
43 std::optional<bool> isDepthBiasEnabled;
44 std::optional<bool> isDepthClampEnabled;
45
46 std::optional<float> depthBiasConstantFactor;
47 std::optional<float> depthBiasSlopeFactor;
48 std::optional<float> depthBiasClamp;
49 };
50
51 enum class ParentType : uint8_t {
52 None,
53 Inherit,
54 Clone
55 };
56
57 struct ParentData {
58 std::string parent;
59 ParentType parentType = ParentType::None;
60 };
61
62 struct ShaderBlock {
63 std::filesystem::path sourceFilepath;
64 ShaderCodeType type = ShaderCodeType::Unset;
65 std::vector<std::string> requiredShaderBlocks;
66 std::string code;
67 ParentData parentData;
68 std::array<std::string, Grindstone::GraphicsAPI::numShaderTotalStage> stageEntryPoints;
69 };
70
71 struct Pass {
72 std::filesystem::path sourceFilepath;
73 bool isAbstract;
74 std::string renderQueue;
75 ParentData parentData;
76 RenderState renderState;
77 ShaderBlock shaderBlock;
78 };
79
81 bool isAbstract;
82 std::filesystem::path sourceFilepath;
83 ParentData parentData;
84 std::vector<std::string_view> tags;
85 std::map<std::string, Pass> passes;
86 };
87
89 ParameterType parameterType;
90 std::string name;
91 std::string defaultValue;
92 };
93
94 struct PipelineSet {
95 std::filesystem::path sourceFilepath;
96 bool isAbstract;
97 ParentData parentData;
98 std::vector<std::string_view> tags;
99 std::vector<MaterialParameter> parameters;
100 std::map<std::string, Configuration> configurations;
101 };
102
103 struct ComputeSet {
104 std::filesystem::path sourceFilepath;
105 ShaderBlock shaderBlock;
106 };
107
108 std::map<std::string, PipelineSet> pipelineSets;
109 std::map<std::string, ComputeSet> computeSets;
110 std::map<std::string, Configuration> genericConfigurations;
111 std::map<std::string, Pass> genericPasses;
112 std::map<std::string, ShaderBlock> genericShaderBlocks;
113};
Definition ParseTree.hpp:103
Definition ParseTree.hpp:80
Definition ParseTree.hpp:88
Definition ParseTree.hpp:57
Definition ParseTree.hpp:71
Definition ParseTree.hpp:94
Definition ParseTree.hpp:24
Definition ParseTree.hpp:19
Definition ParseTree.hpp:62
Definition ParseTree.hpp:18