Nameless Engine
Loading...
Searching...
No Matches
ne::ShaderCacheManager Class Referenceabstract

#include <ShaderCacheManager.h>

Inheritance diagram for ne::ShaderCacheManager:
ne::GlslShaderCacheManager ne::HlslShaderCacheManager

Classes

struct  GlobalShaderCacheParameterNames
 

Public Member Functions

 ShaderCacheManager (const ShaderCacheManager &)=delete
 
ShaderCacheManageroperator= (const ShaderCacheManager &)=delete
 
std::optional< ErrorrefreshShaderCache ()
 

Protected Member Functions

 ShaderCacheManager (Renderer *pRenderer)
 
virtual std::optional< std::string > isLanguageSpecificGlobalCacheOutdated (const ConfigManager &cacheConfig)=0
 
virtual std::optional< ErrorwriteLanguageSpecificParameters (ConfigManager &cacheConfig)=0
 

Private Member Functions

std::optional< ErrorcreateNewShaderCache ()
 
std::optional< std::string > isGlobalShaderCacheOutdated (const ConfigManager &cacheConfig)
 

Static Private Member Functions

static std::unique_ptr< ShaderCacheManagercreate (Renderer *pRenderer)
 

Private Attributes

Renderer *const pRenderer = nullptr
 

Static Private Attributes

static constexpr std::string_view sGlobalShaderCacheInfoFileName = ".shader_cache.toml"
 

Friends

class ShaderManager
 

Detailed Description

Responsible for validating shader cache, reading and updating the cache.

Constructor & Destructor Documentation

◆ ShaderCacheManager()

ne::ShaderCacheManager::ShaderCacheManager ( Renderer pRenderer)
protected

Only used internally, use create to create objects of this type.

Parameters
pRendererUsed renderer.

Member Function Documentation

◆ create()

std::unique_ptr< ShaderCacheManager > ne::ShaderCacheManager::create ( Renderer pRenderer)
staticprivate

Creates a new render-specific cache manager.

Parameters
pRendererUsed renderer.
Returns
Cache manager.

◆ createNewShaderCache()

std::optional< Error > ne::ShaderCacheManager::createNewShaderCache ( )
private

Deletes the current shader cache directory (if exists) and creates a new one with a new config that stores renderer's parameters.

Returns
Error if something went wrong.

◆ isGlobalShaderCacheOutdated()

std::optional< std::string > ne::ShaderCacheManager::isGlobalShaderCacheOutdated ( const ConfigManager cacheConfig)
private

Makes sure that the cache was generated using the same parameters as the current renderer's state and that the cache can be safely used.

Parameters
cacheConfigConfig that stores global cache parameters.
Returns
Empty if cache can be safely used, otherwise reason why it's outdated and cache can't be used.

◆ isLanguageSpecificGlobalCacheOutdated()

virtual std::optional< std::string > ne::ShaderCacheManager::isLanguageSpecificGlobalCacheOutdated ( const ConfigManager cacheConfig)
protectedpure virtual

Makes sure that the cache was generated using the same parameters as the current renderer's state and that the cache can be safely used. This function checks shader language specific parameters that might have changed.

Parameters
cacheConfigConfig that stores global cache parameters.
Returns
Empty if cache can be safely used, otherwise reason why it's outdated and cache can't be used.

Implemented in ne::GlslShaderCacheManager, and ne::HlslShaderCacheManager.

◆ refreshShaderCache()

std::optional< Error > ne::ShaderCacheManager::refreshShaderCache ( )

Checks if any of the global shader cache parameters changed (such as build mode, shader model, etc.). If changed deletes the whole shader cache directory (including caches of previously compiled shaders) and creates a fresh new shader cache directory with up to date global parameters file.

Remarks
If no global shader cache metadata file existed it will create it.
Returns
An error if something went wrong.

◆ writeLanguageSpecificParameters()

virtual std::optional< Error > ne::ShaderCacheManager::writeLanguageSpecificParameters ( ConfigManager cacheConfig)
protectedpure virtual

Writes shader language specific parameters that affect shader cache into the specified config.

Parameters
cacheConfigConfig that stores global cache parameters.
Returns
Error if something went wrong.

Implemented in ne::GlslShaderCacheManager, and ne::HlslShaderCacheManager.

Member Data Documentation

◆ pRenderer

Renderer* const ne::ShaderCacheManager::pRenderer = nullptr
private

Used renderer.

◆ sGlobalShaderCacheInfoFileName

constexpr std::string_view ne::ShaderCacheManager::sGlobalShaderCacheInfoFileName = ".shader_cache.toml"
staticconstexprprivate

Name of the file used to store global shader cache information. Global shader cache information is used to determine if the shader cache is valid or not (needs to be recompiled or not).

Starts with a dot on purpose (because no shader can start with a dot - reserved for internal use).


The documentation for this class was generated from the following files: