diff options
| author | Stenzek <stenzek@gmail.com> | 2017-07-19 20:35:17 +1000 |
|---|---|---|
| committer | Stenzek <stenzek@gmail.com> | 2017-07-20 17:46:59 +1000 |
| commit | d01b0bf60fba2101e45cfac1e5747edcdbab5fc1 (patch) | |
| tree | 2b6d657f96bd62a4c9bf336583590548f19f47f1 /Source/Core/VideoCommon/VideoConfig.cpp | |
| parent | 7c5bbafdd119e3b8975d7b49411dd89e7770baab (diff) | |
VideoCommon: Move shader cache filename generation to common
Diffstat (limited to 'Source/Core/VideoCommon/VideoConfig.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/VideoConfig.cpp | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index 78784c5c9c..86cd38bfd8 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -4,9 +4,12 @@ #include <algorithm> +#include "Common/CommonPaths.h" #include "Common/CommonTypes.h" +#include "Common/FileUtil.h" #include "Common/StringUtil.h" #include "Core/Config/GraphicsSettings.h" +#include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/Movie.h" #include "VideoCommon/OnScreenDisplay.h" @@ -256,8 +259,41 @@ u32 VideoConfig::GetHostConfigBits() const return bits.bits; } -std::string VideoConfig::GetHostConfigFilename() const +std::string VideoConfig::GetDiskCacheFileName(APIType api_type, const char* type, + bool include_gameid, bool include_host_config) const { - u32 bits = GetHostConfigBits(); - return StringFromFormat("%08X", bits); + if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX))) + File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX)); + + std::string filename = File::GetUserPath(D_SHADERCACHE_IDX); + switch (api_type) + { + case APIType::D3D: + filename += "D3D"; + break; + case APIType::OpenGL: + filename += "OpenGL"; + break; + case APIType::Vulkan: + filename += "Vulkan"; + break; + } + + filename += '-'; + filename += type; + + if (include_gameid) + { + filename += '-'; + filename += SConfig::GetInstance().GetGameID(); + } + + if (include_host_config) + { + // We're using 18 bits, so 5 hex characters. + filename += StringFromFormat("-%05X", GetHostConfigBits()); + } + + filename += ".cache"; + return filename; } |
