Nameless Engine
Loading...
Searching...
No Matches
ShaderMacro.h
1#pragma once
2
3// Standard.
4#include <string>
5#include <vector>
6#include <set>
7#include <unordered_map>
8
9namespace ne {
10 class Renderer;
11
30 enum class ShaderMacro : int {
31 PS_USE_DIFFUSE_TEXTURE,
32 PS_USE_MATERIAL_TRANSPARENCY,
33 VS_SHADOW_MAPPING_PASS,
34
35 // ... add new entries here...
36
37 // !! also add new entries to convertShaderMacrosToText !!
38 // !! also add new entries to valid configuration combinations below !!
39 };
40
48 std::vector<std::string> convertShaderMacrosToText(const std::set<ShaderMacro>& macros);
49
57 std::string formatShaderMacros(const std::vector<std::string>& macros);
58
61 private:
102 static std::set<std::set<ShaderMacro>> combineConfigurations(
103 const std::set<std::set<ShaderMacro>>& constantSets,
104 const std::set<std::set<ShaderMacro>>& macroSets,
105 const std::set<ShaderMacro>& appendToEachSet,
106 bool bIncludeEmptyConfiguration);
107
118 static std::set<std::set<ShaderMacro>> duplicateAndAppendConfiguration(
119 const std::set<std::set<ShaderMacro>>& toDuplicateSets,
120 const std::set<ShaderMacro>& toAppendToDuplicated);
121
135 static inline const std::unordered_map<ShaderMacro, ShaderMacro> dependentMacros = {};
136
137 public:
145 static unsigned long long convertConfigurationToHash(const std::set<ShaderMacro>& configuration);
146
155 static std::string convertConfigurationToText(const std::set<ShaderMacro>& configuration);
156
169 ShaderMacro macro, const std::set<ShaderMacro>& configuration);
170
176 static inline const std::set<std::set<ShaderMacro>> validVertexShaderMacroConfigurations = {
177 {}, {ShaderMacro::VS_SHADOW_MAPPING_PASS}};
178
184 static inline const std::set<std::set<ShaderMacro>> validPixelShaderMacroConfigurations =
186 {{ShaderMacro::PS_USE_DIFFUSE_TEXTURE},
187 {ShaderMacro::PS_USE_MATERIAL_TRANSPARENCY},
188 {ShaderMacro::PS_USE_DIFFUSE_TEXTURE, ShaderMacro::PS_USE_MATERIAL_TRANSPARENCY}},
189 {},
190 {},
191 true);
192
194 static inline const std::set<std::set<ShaderMacro>> validComputeShaderMacroConfigurations = {{}};
195 };
196
206 size_t operator()(std::set<ShaderMacro> const& item) const {
208 }
209 };
210} // namespace ne
Definition: ShaderMacro.h:60
static std::set< std::set< ShaderMacro > > combineConfigurations(const std::set< std::set< ShaderMacro > > &constantSets, const std::set< std::set< ShaderMacro > > &macroSets, const std::set< ShaderMacro > &appendToEachSet, bool bIncludeEmptyConfiguration)
Definition: ShaderMacro.cpp:29
static std::set< std::set< ShaderMacro > > duplicateAndAppendConfiguration(const std::set< std::set< ShaderMacro > > &toDuplicateSets, const std::set< ShaderMacro > &toAppendToDuplicated)
Definition: ShaderMacro.cpp:59
static const std::set< std::set< ShaderMacro > > validComputeShaderMacroConfigurations
Definition: ShaderMacro.h:194
static const std::unordered_map< ShaderMacro, ShaderMacro > dependentMacros
Definition: ShaderMacro.h:135
static unsigned long long convertConfigurationToHash(const std::set< ShaderMacro > &configuration)
Definition: ShaderMacro.cpp:80
static bool isMacroShouldBeConsideredInConfiguration(ShaderMacro macro, const std::set< ShaderMacro > &configuration)
Definition: ShaderMacro.cpp:104
static const std::set< std::set< ShaderMacro > > validVertexShaderMacroConfigurations
Definition: ShaderMacro.h:176
static std::string convertConfigurationToText(const std::set< ShaderMacro > &configuration)
Definition: ShaderMacro.cpp:95
static const std::set< std::set< ShaderMacro > > validPixelShaderMacroConfigurations
Definition: ShaderMacro.h:184
Definition: ShaderMacro.h:198
size_t operator()(std::set< ShaderMacro > const &item) const
Definition: ShaderMacro.h:206