Nameless Engine
Loading...
Searching...
No Matches
ShaderCacheManager.h
1#pragma once
2
3// Standard.
4#include <memory>
5#include <string>
6#include <optional>
7
8// Custom.
9#include "misc/Error.h"
10#include "io/ConfigManager.h"
11
12namespace ne {
13 class Renderer;
14
17 // Only shader manager is expected to create this manager.
18 friend class ShaderManager;
19
20 public:
21 virtual ~ShaderCacheManager() = default;
22
23 ShaderCacheManager() = delete;
25 ShaderCacheManager& operator=(const ShaderCacheManager&) = delete;
26
37 [[nodiscard]] std::optional<Error> refreshShaderCache();
38
39 protected:
46
57 [[nodiscard]] virtual std::optional<std::string>
59
67 [[nodiscard]] virtual std::optional<Error>
69
70 private:
74 static constexpr std::string_view sIsReleaseBuild = "is_release_build";
75
77 static constexpr std::string_view sRenderer = "renderer";
78
80 static constexpr std::string_view sShaderParserVersion = "shader_parser_version";
81 };
82
90 static std::unique_ptr<ShaderCacheManager> create(Renderer* pRenderer);
91
98 [[nodiscard]] std::optional<Error> createNewShaderCache();
99
109 [[nodiscard]] std::optional<std::string>
110 isGlobalShaderCacheOutdated(const ConfigManager& cacheConfig);
111
113 Renderer* const pRenderer = nullptr;
114
122 static constexpr std::string_view sGlobalShaderCacheInfoFileName = ".shader_cache.toml";
123 };
124}
Definition: ConfigManager.h:27
Definition: Renderer.h:43
Definition: ShaderCacheManager.h:16
virtual std::optional< Error > writeLanguageSpecificParameters(ConfigManager &cacheConfig)=0
virtual std::optional< std::string > isLanguageSpecificGlobalCacheOutdated(const ConfigManager &cacheConfig)=0
std::optional< Error > refreshShaderCache()
Definition: ShaderCacheManager.cpp:34
std::optional< Error > createNewShaderCache()
Definition: ShaderCacheManager.cpp:91
static constexpr std::string_view sGlobalShaderCacheInfoFileName
Definition: ShaderCacheManager.h:122
static std::unique_ptr< ShaderCacheManager > create(Renderer *pRenderer)
Definition: ShaderCacheManager.cpp:14
std::optional< std::string > isGlobalShaderCacheOutdated(const ConfigManager &cacheConfig)
Definition: ShaderCacheManager.cpp:142
Renderer *const pRenderer
Definition: ShaderCacheManager.h:113
Definition: ShaderManager.h:25
static constexpr std::string_view sRenderer
Definition: ShaderCacheManager.h:77
static constexpr std::string_view sShaderParserVersion
Definition: ShaderCacheManager.h:80
static constexpr std::string_view sIsReleaseBuild
Definition: ShaderCacheManager.h:74