VideoBackends: Add a developer option to disable the shader cache.

Makes it easier to disable the cache while working on the shaders.
This commit is contained in:
Jules Blok
2017-02-19 12:02:47 +01:00
parent 51944afa56
commit 21967b1f6e
8 changed files with 73 additions and 54 deletions

View File

@ -69,29 +69,32 @@ void ShaderCache::Init()
s_last_pixel_shader_uid = {};
s_last_vertex_shader_uid = {};
// Ensure shader cache directory exists..
std::string shader_cache_path = File::GetUserPath(D_SHADERCACHE_IDX);
if (g_ActiveConfig.bShaderCache)
{
// Ensure shader cache directory exists..
std::string shader_cache_path = File::GetUserPath(D_SHADERCACHE_IDX);
if (!File::Exists(shader_cache_path))
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
if (!File::Exists(shader_cache_path))
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
std::string title_game_id = SConfig::GetInstance().m_strGameID.c_str();
std::string title_game_id = SConfig::GetInstance().m_strGameID.c_str();
std::string gs_cache_filename =
StringFromFormat("%sdx11-%s-gs.cache", shader_cache_path.c_str(), title_game_id.c_str());
std::string ps_cache_filename =
StringFromFormat("%sdx11-%s-ps.cache", shader_cache_path.c_str(), title_game_id.c_str());
std::string vs_cache_filename =
StringFromFormat("%sdx11-%s-vs.cache", shader_cache_path.c_str(), title_game_id.c_str());
std::string gs_cache_filename =
StringFromFormat("%sdx11-%s-gs.cache", shader_cache_path.c_str(), title_game_id.c_str());
std::string ps_cache_filename =
StringFromFormat("%sdx11-%s-ps.cache", shader_cache_path.c_str(), title_game_id.c_str());
std::string vs_cache_filename =
StringFromFormat("%sdx11-%s-vs.cache", shader_cache_path.c_str(), title_game_id.c_str());
ShaderCacheInserter<GeometryShaderUid, GsBytecodeCache, &s_gs_bytecode_cache> gs_inserter;
s_gs_disk_cache.OpenAndRead(gs_cache_filename, gs_inserter);
ShaderCacheInserter<GeometryShaderUid, GsBytecodeCache, &s_gs_bytecode_cache> gs_inserter;
s_gs_disk_cache.OpenAndRead(gs_cache_filename, gs_inserter);
ShaderCacheInserter<PixelShaderUid, PsBytecodeCache, &s_ps_bytecode_cache> ps_inserter;
s_ps_disk_cache.OpenAndRead(ps_cache_filename, ps_inserter);
ShaderCacheInserter<PixelShaderUid, PsBytecodeCache, &s_ps_bytecode_cache> ps_inserter;
s_ps_disk_cache.OpenAndRead(ps_cache_filename, ps_inserter);
ShaderCacheInserter<VertexShaderUid, VsBytecodeCache, &s_vs_bytecode_cache> vs_inserter;
s_vs_disk_cache.OpenAndRead(vs_cache_filename, vs_inserter);
ShaderCacheInserter<VertexShaderUid, VsBytecodeCache, &s_vs_bytecode_cache> vs_inserter;
s_vs_disk_cache.OpenAndRead(vs_cache_filename, vs_inserter);
}
SETSTAT(stats.numPixelShadersAlive, static_cast<int>(s_ps_bytecode_cache.size()));
SETSTAT(stats.numPixelShadersCreated, static_cast<int>(s_ps_bytecode_cache.size()));