VideoCommon: Move shader cache filename generation to common

This commit is contained in:
Stenzek
2017-07-19 20:35:17 +10:00
parent 7c5bbafdd1
commit d01b0bf60f
9 changed files with 61 additions and 51 deletions

View File

@ -446,16 +446,6 @@ void ObjectCache::ClearPipelineCache()
m_compute_pipeline_objects.clear();
}
std::string ObjectCache::GetDiskCacheFileName(const char* type, bool include_gameid,
bool include_host_config)
{
return StringFromFormat(
"%svulkan-%s%s%s%s%s.cache", File::GetUserPath(D_SHADERCACHE_IDX).c_str(), type,
include_gameid ? "-" : "", include_gameid ? SConfig::GetInstance().GetGameID().c_str() : "",
include_host_config ? "-" : "",
include_host_config ? g_ActiveConfig.GetHostConfigFilename().c_str() : "");
}
class PipelineCacheReadCallback : public LinearDiskCacheReader<u32, u8>
{
public:
@ -482,7 +472,8 @@ bool ObjectCache::CreatePipelineCache()
// Vulkan pipeline caches can be shared between games for shader compile time reduction.
// This assumes that drivers don't create all pipelines in the cache on load time, only
// when a lookup occurs that matches a pipeline (or pipeline data) in the cache.
m_pipeline_cache_filename = GetDiskCacheFileName("pipeline", false, true);
m_pipeline_cache_filename =
g_ActiveConfig.GetDiskCacheFileName(APIType::Vulkan, "Pipeline", false, true);
VkPipelineCacheCreateInfo info = {
VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO, // VkStructureType sType
@ -505,7 +496,8 @@ bool ObjectCache::LoadPipelineCache()
{
// We have to keep the pipeline cache file name around since when we save it
// we delete the old one, by which time the game's unique ID is already cleared.
m_pipeline_cache_filename = GetDiskCacheFileName("pipeline", false, true);
m_pipeline_cache_filename =
g_ActiveConfig.GetDiskCacheFileName(APIType::Vulkan, "Pipeline", false, true);
std::vector<u8> disk_data;
LinearDiskCache<u32, u8> disk_cache;
@ -671,15 +663,18 @@ struct ShaderCacheReader : public LinearDiskCacheReader<Uid, u32>
void ObjectCache::LoadShaderCaches()
{
ShaderCacheReader<VertexShaderUid> vs_reader(m_vs_cache.shader_map);
m_vs_cache.disk_cache.OpenAndRead(GetDiskCacheFileName("vs", true, true), vs_reader);
m_vs_cache.disk_cache.OpenAndRead(
g_ActiveConfig.GetDiskCacheFileName(APIType::Vulkan, "VS", true, true), vs_reader);
ShaderCacheReader<PixelShaderUid> ps_reader(m_ps_cache.shader_map);
m_ps_cache.disk_cache.OpenAndRead(GetDiskCacheFileName("ps", true, true), ps_reader);
m_ps_cache.disk_cache.OpenAndRead(
g_ActiveConfig.GetDiskCacheFileName(APIType::Vulkan, "PS", true, true), ps_reader);
if (g_vulkan_context->SupportsGeometryShaders())
{
ShaderCacheReader<GeometryShaderUid> gs_reader(m_gs_cache.shader_map);
m_gs_cache.disk_cache.OpenAndRead(GetDiskCacheFileName("gs", true, true), gs_reader);
m_gs_cache.disk_cache.OpenAndRead(
g_ActiveConfig.GetDiskCacheFileName(APIType::Vulkan, "GS", true, true), gs_reader);
}
SETSTAT(stats.numPixelShadersCreated, static_cast<int>(m_ps_cache.shader_map.size()));