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:
parent
51944afa56
commit
21967b1f6e
|
@ -157,14 +157,17 @@ void GeometryShaderCache::Init()
|
||||||
|
|
||||||
Clear();
|
Clear();
|
||||||
|
|
||||||
if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX)))
|
if (g_ActiveConfig.bShaderCache)
|
||||||
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
|
{
|
||||||
|
if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX)))
|
||||||
|
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
|
||||||
|
|
||||||
std::string cache_filename =
|
std::string cache_filename =
|
||||||
StringFromFormat("%sdx11-%s-gs.cache", File::GetUserPath(D_SHADERCACHE_IDX).c_str(),
|
StringFromFormat("%sdx11-%s-gs.cache", File::GetUserPath(D_SHADERCACHE_IDX).c_str(),
|
||||||
SConfig::GetInstance().m_strGameID.c_str());
|
SConfig::GetInstance().m_strGameID.c_str());
|
||||||
GeometryShaderCacheInserter inserter;
|
GeometryShaderCacheInserter inserter;
|
||||||
g_gs_disk_cache.OpenAndRead(cache_filename, inserter);
|
g_gs_disk_cache.OpenAndRead(cache_filename, inserter);
|
||||||
|
}
|
||||||
|
|
||||||
last_entry = nullptr;
|
last_entry = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -494,17 +494,20 @@ void PixelShaderCache::Init()
|
||||||
|
|
||||||
Clear();
|
Clear();
|
||||||
|
|
||||||
if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX)))
|
|
||||||
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
|
|
||||||
|
|
||||||
SETSTAT(stats.numPixelShadersCreated, 0);
|
SETSTAT(stats.numPixelShadersCreated, 0);
|
||||||
SETSTAT(stats.numPixelShadersAlive, 0);
|
SETSTAT(stats.numPixelShadersAlive, 0);
|
||||||
|
|
||||||
std::string cache_filename =
|
if (g_ActiveConfig.bShaderCache)
|
||||||
StringFromFormat("%sdx11-%s-ps.cache", File::GetUserPath(D_SHADERCACHE_IDX).c_str(),
|
{
|
||||||
SConfig::GetInstance().m_strGameID.c_str());
|
if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX)))
|
||||||
PixelShaderCacheInserter inserter;
|
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
|
||||||
g_ps_disk_cache.OpenAndRead(cache_filename, inserter);
|
|
||||||
|
std::string cache_filename =
|
||||||
|
StringFromFormat("%sdx11-%s-ps.cache", File::GetUserPath(D_SHADERCACHE_IDX).c_str(),
|
||||||
|
SConfig::GetInstance().m_strGameID.c_str());
|
||||||
|
PixelShaderCacheInserter inserter;
|
||||||
|
g_ps_disk_cache.OpenAndRead(cache_filename, inserter);
|
||||||
|
}
|
||||||
|
|
||||||
last_entry = nullptr;
|
last_entry = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,17 +155,20 @@ void VertexShaderCache::Init()
|
||||||
|
|
||||||
Clear();
|
Clear();
|
||||||
|
|
||||||
if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX)))
|
|
||||||
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
|
|
||||||
|
|
||||||
SETSTAT(stats.numVertexShadersCreated, 0);
|
SETSTAT(stats.numVertexShadersCreated, 0);
|
||||||
SETSTAT(stats.numVertexShadersAlive, 0);
|
SETSTAT(stats.numVertexShadersAlive, 0);
|
||||||
|
|
||||||
std::string cache_filename =
|
if (g_ActiveConfig.bShaderCache)
|
||||||
StringFromFormat("%sdx11-%s-vs.cache", File::GetUserPath(D_SHADERCACHE_IDX).c_str(),
|
{
|
||||||
SConfig::GetInstance().m_strGameID.c_str());
|
if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX)))
|
||||||
VertexShaderCacheInserter inserter;
|
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
|
||||||
g_vs_disk_cache.OpenAndRead(cache_filename, inserter);
|
|
||||||
|
std::string cache_filename =
|
||||||
|
StringFromFormat("%sdx11-%s-vs.cache", File::GetUserPath(D_SHADERCACHE_IDX).c_str(),
|
||||||
|
SConfig::GetInstance().m_strGameID.c_str());
|
||||||
|
VertexShaderCacheInserter inserter;
|
||||||
|
g_vs_disk_cache.OpenAndRead(cache_filename, inserter);
|
||||||
|
}
|
||||||
|
|
||||||
last_entry = nullptr;
|
last_entry = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,29 +69,32 @@ void ShaderCache::Init()
|
||||||
s_last_pixel_shader_uid = {};
|
s_last_pixel_shader_uid = {};
|
||||||
s_last_vertex_shader_uid = {};
|
s_last_vertex_shader_uid = {};
|
||||||
|
|
||||||
// Ensure shader cache directory exists..
|
if (g_ActiveConfig.bShaderCache)
|
||||||
std::string shader_cache_path = File::GetUserPath(D_SHADERCACHE_IDX);
|
{
|
||||||
|
// Ensure shader cache directory exists..
|
||||||
|
std::string shader_cache_path = File::GetUserPath(D_SHADERCACHE_IDX);
|
||||||
|
|
||||||
if (!File::Exists(shader_cache_path))
|
if (!File::Exists(shader_cache_path))
|
||||||
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
|
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 =
|
std::string gs_cache_filename =
|
||||||
StringFromFormat("%sdx11-%s-gs.cache", shader_cache_path.c_str(), title_game_id.c_str());
|
StringFromFormat("%sdx11-%s-gs.cache", shader_cache_path.c_str(), title_game_id.c_str());
|
||||||
std::string ps_cache_filename =
|
std::string ps_cache_filename =
|
||||||
StringFromFormat("%sdx11-%s-ps.cache", shader_cache_path.c_str(), title_game_id.c_str());
|
StringFromFormat("%sdx11-%s-ps.cache", shader_cache_path.c_str(), title_game_id.c_str());
|
||||||
std::string vs_cache_filename =
|
std::string vs_cache_filename =
|
||||||
StringFromFormat("%sdx11-%s-vs.cache", shader_cache_path.c_str(), title_game_id.c_str());
|
StringFromFormat("%sdx11-%s-vs.cache", shader_cache_path.c_str(), title_game_id.c_str());
|
||||||
|
|
||||||
ShaderCacheInserter<GeometryShaderUid, GsBytecodeCache, &s_gs_bytecode_cache> gs_inserter;
|
ShaderCacheInserter<GeometryShaderUid, GsBytecodeCache, &s_gs_bytecode_cache> gs_inserter;
|
||||||
s_gs_disk_cache.OpenAndRead(gs_cache_filename, gs_inserter);
|
s_gs_disk_cache.OpenAndRead(gs_cache_filename, gs_inserter);
|
||||||
|
|
||||||
ShaderCacheInserter<PixelShaderUid, PsBytecodeCache, &s_ps_bytecode_cache> ps_inserter;
|
ShaderCacheInserter<PixelShaderUid, PsBytecodeCache, &s_ps_bytecode_cache> ps_inserter;
|
||||||
s_ps_disk_cache.OpenAndRead(ps_cache_filename, ps_inserter);
|
s_ps_disk_cache.OpenAndRead(ps_cache_filename, ps_inserter);
|
||||||
|
|
||||||
ShaderCacheInserter<VertexShaderUid, VsBytecodeCache, &s_vs_bytecode_cache> vs_inserter;
|
ShaderCacheInserter<VertexShaderUid, VsBytecodeCache, &s_vs_bytecode_cache> vs_inserter;
|
||||||
s_vs_disk_cache.OpenAndRead(vs_cache_filename, 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.numPixelShadersAlive, static_cast<int>(s_ps_bytecode_cache.size()));
|
||||||
SETSTAT(stats.numPixelShadersCreated, static_cast<int>(s_ps_bytecode_cache.size()));
|
SETSTAT(stats.numPixelShadersCreated, static_cast<int>(s_ps_bytecode_cache.size()));
|
||||||
|
|
|
@ -419,8 +419,8 @@ void ProgramShaderCache::Init()
|
||||||
// Then once more to get bytes
|
// Then once more to get bytes
|
||||||
s_buffer = StreamBuffer::Create(GL_UNIFORM_BUFFER, UBO_LENGTH);
|
s_buffer = StreamBuffer::Create(GL_UNIFORM_BUFFER, UBO_LENGTH);
|
||||||
|
|
||||||
// Read our shader cache, only if supported
|
// Read our shader cache, only if supported and enabled
|
||||||
if (g_ogl_config.bSupportsGLSLCache)
|
if (g_ogl_config.bSupportsGLSLCache && g_ActiveConfig.bShaderCache)
|
||||||
{
|
{
|
||||||
GLint Supported;
|
GLint Supported;
|
||||||
glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &Supported);
|
glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &Supported);
|
||||||
|
|
|
@ -536,21 +536,25 @@ struct ShaderCacheReader : public LinearDiskCacheReader<Uid, u32>
|
||||||
|
|
||||||
void ObjectCache::LoadShaderCaches()
|
void ObjectCache::LoadShaderCaches()
|
||||||
{
|
{
|
||||||
ShaderCacheReader<VertexShaderUid> vs_reader(m_vs_cache.shader_map);
|
if (g_ActiveConfig.bShaderCache)
|
||||||
m_vs_cache.disk_cache.OpenAndRead(GetDiskCacheFileName("vs"), vs_reader);
|
{
|
||||||
SETSTAT(stats.numVertexShadersCreated, static_cast<int>(m_vs_cache.shader_map.size()));
|
ShaderCacheReader<VertexShaderUid> vs_reader(m_vs_cache.shader_map);
|
||||||
SETSTAT(stats.numVertexShadersAlive, static_cast<int>(m_vs_cache.shader_map.size()));
|
m_vs_cache.disk_cache.OpenAndRead(GetDiskCacheFileName("vs"), vs_reader);
|
||||||
|
|
||||||
|
ShaderCacheReader<PixelShaderUid> ps_reader(m_ps_cache.shader_map);
|
||||||
|
m_ps_cache.disk_cache.OpenAndRead(GetDiskCacheFileName("ps"), ps_reader);
|
||||||
|
|
||||||
|
if (g_vulkan_context->SupportsGeometryShaders())
|
||||||
|
{
|
||||||
|
ShaderCacheReader<GeometryShaderUid> gs_reader(m_gs_cache.shader_map);
|
||||||
|
m_gs_cache.disk_cache.OpenAndRead(GetDiskCacheFileName("gs"), gs_reader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ShaderCacheReader<PixelShaderUid> ps_reader(m_ps_cache.shader_map);
|
|
||||||
m_ps_cache.disk_cache.OpenAndRead(GetDiskCacheFileName("ps"), ps_reader);
|
|
||||||
SETSTAT(stats.numPixelShadersCreated, static_cast<int>(m_ps_cache.shader_map.size()));
|
SETSTAT(stats.numPixelShadersCreated, static_cast<int>(m_ps_cache.shader_map.size()));
|
||||||
SETSTAT(stats.numPixelShadersAlive, static_cast<int>(m_ps_cache.shader_map.size()));
|
SETSTAT(stats.numPixelShadersAlive, static_cast<int>(m_ps_cache.shader_map.size()));
|
||||||
|
SETSTAT(stats.numVertexShadersCreated, static_cast<int>(m_vs_cache.shader_map.size()));
|
||||||
if (g_vulkan_context->SupportsGeometryShaders())
|
SETSTAT(stats.numVertexShadersAlive, static_cast<int>(m_vs_cache.shader_map.size()));
|
||||||
{
|
|
||||||
ShaderCacheReader<GeometryShaderUid> gs_reader(m_gs_cache.shader_map);
|
|
||||||
m_gs_cache.disk_cache.OpenAndRead(GetDiskCacheFileName("gs"), gs_reader);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -89,6 +89,7 @@ void VideoConfig::Load(const std::string& ini_file)
|
||||||
settings->Get("EnableValidationLayer", &bEnableValidationLayer, false);
|
settings->Get("EnableValidationLayer", &bEnableValidationLayer, false);
|
||||||
settings->Get("BackendMultithreading", &bBackendMultithreading, true);
|
settings->Get("BackendMultithreading", &bBackendMultithreading, true);
|
||||||
settings->Get("CommandBufferExecuteInterval", &iCommandBufferExecuteInterval, 100);
|
settings->Get("CommandBufferExecuteInterval", &iCommandBufferExecuteInterval, 100);
|
||||||
|
settings->Get("ShaderCache", &bShaderCache, true);
|
||||||
|
|
||||||
settings->Get("SWZComploc", &bZComploc, true);
|
settings->Get("SWZComploc", &bZComploc, true);
|
||||||
settings->Get("SWZFreeze", &bZFreeze, true);
|
settings->Get("SWZFreeze", &bZFreeze, true);
|
||||||
|
@ -307,6 +308,7 @@ void VideoConfig::Save(const std::string& ini_file)
|
||||||
settings->Set("EnableValidationLayer", bEnableValidationLayer);
|
settings->Set("EnableValidationLayer", bEnableValidationLayer);
|
||||||
settings->Set("BackendMultithreading", bBackendMultithreading);
|
settings->Set("BackendMultithreading", bBackendMultithreading);
|
||||||
settings->Set("CommandBufferExecuteInterval", iCommandBufferExecuteInterval);
|
settings->Set("CommandBufferExecuteInterval", iCommandBufferExecuteInterval);
|
||||||
|
settings->Set("ShaderCache", bShaderCache);
|
||||||
|
|
||||||
settings->Set("SWZComploc", bZComploc);
|
settings->Set("SWZComploc", bZComploc);
|
||||||
settings->Set("SWZFreeze", bZFreeze);
|
settings->Set("SWZFreeze", bZFreeze);
|
||||||
|
|
|
@ -69,6 +69,7 @@ struct VideoConfig final
|
||||||
bool bCrop; // Aspect ratio controls.
|
bool bCrop; // Aspect ratio controls.
|
||||||
bool bUseXFB;
|
bool bUseXFB;
|
||||||
bool bUseRealXFB;
|
bool bUseRealXFB;
|
||||||
|
bool bShaderCache;
|
||||||
|
|
||||||
// Enhancements
|
// Enhancements
|
||||||
int iMultisamples;
|
int iMultisamples;
|
||||||
|
|
Loading…
Reference in New Issue