#include <ShaderDescription.h>
◆ ShaderDescription() [1/3]
ne::ShaderDescription::ShaderDescription |
( |
std::string_view |
sShaderName, |
|
|
const std::filesystem::path & |
pathToShaderFile, |
|
|
ShaderType |
shaderType, |
|
|
std::optional< VertexFormat > |
vertexFormat, |
|
|
const std::string & |
sShaderEntryFunctionName, |
|
|
const std::unordered_map< std::string, std::string > & |
definedShaderMacros |
|
) |
| |
Constructor.
- Parameters
-
sShaderName | Globally unique shader name. |
pathToShaderFile | Path to the shader file. |
shaderType | Type of the shader. |
vertexFormat | Vertex format that the shader uses (can be empty if not applicable, for example if this shader is a compute shader). |
sShaderEntryFunctionName | Name of the shader's entry function name. For example: if the shader type is vertex shader, then this value should contain name of the function used for vertex processing (from shader's file, "VS" for example). |
definedShaderMacros | Map of defined macros for shader, stores pairs of "macro name" - "value" (no value if empty). |
◆ ShaderDescription() [2/3]
Copy constructor.
- Parameters
-
◆ ShaderDescription() [3/3]
Move constructor.
- Parameters
-
◆ calculateShaderIncludeTreeHashes()
void ne::ShaderDescription::calculateShaderIncludeTreeHashes |
( |
| ) |
|
|
private |
◆ deserializeShaderIncludeTreeHashes()
std::unordered_map< std::string, std::unordered_map< std::string, std::string > > ne::ShaderDescription::deserializeShaderIncludeTreeHashes |
( |
const toml::value & |
data | ) |
|
|
staticprivate |
Converts TOML table into shader include tree hash map.
- Parameters
-
data | TOML data formatted as table. |
- Returns
- Map [include chain (i.e. current shader), [relative include path, include file hash]].
◆ from_toml()
void ne::ShaderDescription::from_toml |
( |
const toml::value & |
data | ) |
|
Used to deserialize struct from .toml file.
- Parameters
-
◆ getConfigurationFileSectionName()
static const char * ne::ShaderDescription::getConfigurationFileSectionName |
( |
| ) |
|
|
inlinestatic |
Returns name of the section that is used to store ShaderDescription in configuration (on disk).
- Returns
- Section name.
◆ getFileHash()
std::string ne::ShaderDescription::getFileHash |
( |
const std::filesystem::path & |
pathToFile, |
|
|
const std::string & |
sShaderName |
|
) |
| |
|
static |
Calculates hash of a file and returns it.
- Parameters
-
pathToFile | Path to a file. Assumes that this path exists. |
sShaderName | Unique name of this shader (used for logging). |
- Returns
- Empty string if something went wrong, source file hash otherwise.
◆ into_toml()
toml::value ne::ShaderDescription::into_toml |
( |
| ) |
const |
Used to serialize struct to .toml file.
- Returns
- Toml value.
◆ isSerializableDataEqual()
std::optional< ShaderCacheInvalidationReason > ne::ShaderDescription::isSerializableDataEqual |
( |
ShaderDescription & |
other | ) |
|
Compares this shader description with other to see if the serializable fields are equal. This is usually done to check if shader cache is valid or not (needs to be recompiled or not).
- Parameters
-
other | Other shader description to compare with. If this "other" shader description was retrieved from the cache it will not be changed, otherwise if it has path to the shader source file specified it will be updated with hashes of the source shader file and its includes. |
- Returns
- Whether the data is equal or not. If the data is not equal, has a value that contains a reason.
◆ operator=() [1/2]
Copy assignment.
- Parameters
-
- Returns
- Result of copy assignment.
◆ operator=() [2/2]
Move assignment.
- Parameters
-
- Returns
- Result of move assignment.
◆ serializeShaderIncludeTree()
void ne::ShaderDescription::serializeShaderIncludeTree |
( |
const std::filesystem::path & |
pathToShaderFile, |
|
|
std::string & |
sCurrentIncludeChain, |
|
|
toml::value & |
data |
|
) |
| |
|
staticprivate |
Scans shader file for "#include" entries and recursively adds included files hashes.
- Parameters
-
pathToShaderFile | Path to shader source file. |
sCurrentIncludeChain | Current section (in TOML) text. |
data | TOML structure to write to. |
◆ definedShaderMacros
std::unordered_map<std::string, std::string> ne::ShaderDescription::definedShaderMacros |
Map of defined macros for shader, stores pairs of "macro name" - "value" (no value if empty).
◆ pathToShaderFile
std::filesystem::path ne::ShaderDescription::pathToShaderFile |
◆ sConfigurationFileSectionName
auto ne::ShaderDescription::sConfigurationFileSectionName = "shader_description" |
|
inlinestaticprivate |
Name of the section that is used to store ShaderDescription in configuration (on disk).
◆ shaderIncludeTreeHashes
std::unordered_map< std::string , std:: unordered_map<std::string , std::string > > ne::ShaderDescription::shaderIncludeTreeHashes |
|
private |
Shader include tree hashes, contains relative include paths for each "#include" entry in shader with included source file hash. May be empty (not calculated yet).
◆ shaderType
ShaderType ne::ShaderDescription::shaderType = ShaderType::VERTEX_SHADER |
◆ sInitialIncludeChainText
std::string_view ne::ShaderDescription::sInitialIncludeChainText = "includes" |
|
inlinestaticprivate |
Used as the initial text for "include chain" string (starting text in serialized form). After serializing data in the TOML file, it might look like this:
"includes.default.post_process"
^------ [includes] initial text (this variable)
^------ [post_process] shader file name B that shader A includes
Definition: ShaderDescription.h:74
◆ sShaderEntryFunctionName
std::string ne::ShaderDescription::sShaderEntryFunctionName |
Name of the shader's entry function name.
◆ sShaderName
std::string ne::ShaderDescription::sShaderName |
Globally unique shader name.
◆ sSourceFileHash
std::string ne::ShaderDescription::sSourceFileHash |
|
private |
Shader source file hash, may be empty (not calculated yet).
◆ vertexFormat
std::optional<VertexFormat> ne::ShaderDescription::vertexFormat |
The documentation for this struct was generated from the following files:
- src/engine_lib/public/shader/ShaderDescription.h
- src/engine_lib/private/shader/general/ShaderDescription.cpp