diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-01-14 03:22:15 +0100 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-02-07 02:20:57 +0100 |
commit | 98be5a49289ca17b9470669ae94162dfa28eb2fb (patch) | |
tree | f69c8e66525b4c9c5fa4ef28a6a7565e0830deb4 /src/video_core/renderer_opengl/gl_shader_disk_cache.cpp | |
parent | gl_shader_disk_cache: Add file and move BaseBindings declaration (diff) | |
download | yuzu-98be5a49289ca17b9470669ae94162dfa28eb2fb.tar yuzu-98be5a49289ca17b9470669ae94162dfa28eb2fb.tar.gz yuzu-98be5a49289ca17b9470669ae94162dfa28eb2fb.tar.bz2 yuzu-98be5a49289ca17b9470669ae94162dfa28eb2fb.tar.lz yuzu-98be5a49289ca17b9470669ae94162dfa28eb2fb.tar.xz yuzu-98be5a49289ca17b9470669ae94162dfa28eb2fb.tar.zst yuzu-98be5a49289ca17b9470669ae94162dfa28eb2fb.zip |
Diffstat (limited to 'src/video_core/renderer_opengl/gl_shader_disk_cache.cpp')
-rw-r--r-- | src/video_core/renderer_opengl/gl_shader_disk_cache.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp index b7876c3a7..de890676e 100644 --- a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp @@ -4,6 +4,18 @@ #pragma once +#include <fmt/format.h> + +#include "common/assert.h" +#include "common/common_paths.h" +#include "common/common_types.h" +#include "common/file_util.h" +#include "common/logging/log.h" + +#include "core/core.h" +#include "core/hle/kernel/process.h" + +#include "video_core/renderer_opengl/gl_shader_cache.h" #include "video_core/renderer_opengl/gl_shader_disk_cache.h" namespace OpenGL { @@ -11,4 +23,44 @@ namespace OpenGL { // Making sure sizes doesn't change by accident static_assert(sizeof(BaseBindings) == 12); +namespace { +std::string GetTitleID() { + return fmt::format("{:016X}", Core::CurrentProcess()->GetTitleID()); +} +} // namespace + +bool ShaderDiskCacheOpenGL::EnsureDirectories() const { + const auto CreateDir = [](const std::string& dir) { + if (!FileUtil::CreateDir(dir)) { + LOG_ERROR(Render_OpenGL, "Failed to create directory={}", dir); + return false; + } + return true; + }; + + return CreateDir(FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir)) && + CreateDir(GetBaseDir()) && CreateDir(GetTransferableDir()) && + CreateDir(GetPrecompiledDir()); +} + +std::string ShaderDiskCacheOpenGL::GetTransferablePath() const { + return FileUtil::SanitizePath(GetTransferableDir() + DIR_SEP_CHR + GetTitleID() + ".bin"); +} + +std::string ShaderDiskCacheOpenGL::GetPrecompiledPath() const { + return FileUtil::SanitizePath(GetPrecompiledDir() + DIR_SEP_CHR + GetTitleID() + ".bin"); +} + +std::string ShaderDiskCacheOpenGL::GetTransferableDir() const { + return GetBaseDir() + DIR_SEP "transferable"; +} + +std::string ShaderDiskCacheOpenGL::GetPrecompiledDir() const { + return GetBaseDir() + DIR_SEP "precompiled"; +} + +std::string ShaderDiskCacheOpenGL::GetBaseDir() const { + return FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir) + DIR_SEP "opengl"; +} + } // namespace OpenGL
\ No newline at end of file |