aboutsummaryrefslogtreecommitdiff
path: root/src/yuzu/main.cpp
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2021-07-11 14:39:13 -0400
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-22 21:51:40 -0400
commit4e4b8775b56a7f596e509aab597067815d005507 (patch)
tree4ea01de80e4ee59e0164645a880987a6c4714651 /src/yuzu/main.cpp
parent41493fbe89200a4a8321dec7b313872435c57df7 (diff)
main: Update Shader Cache menu options
This change adds two new context menu items to remove either the OpenGL or the Vulkan shader caches individually, and the provides the option to remove all caches for the selected title. This also changes the behavior of the open shader cache option. Now it creates the shader cache directory for the title if it does not yet exist.
Diffstat (limited to 'src/yuzu/main.cpp')
-rw-r--r--src/yuzu/main.cpp59
1 files changed, 47 insertions, 12 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 562dfa6201..a5159a1ee1 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -1655,9 +1655,9 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target
void GMainWindow::OnTransferableShaderCacheOpenFile(u64 program_id) {
const auto shader_cache_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ShaderDir);
const auto shader_cache_folder_path{shader_cache_dir / fmt::format("{:016x}", program_id)};
- if (!Common::FS::Exists(shader_cache_folder_path)) {
+ if (!Common::FS::CreateDirs(shader_cache_folder_path)) {
QMessageBox::warning(this, tr("Error Opening Transferable Shader Cache"),
- tr("A shader cache for this title does not exist."));
+ tr("Filed to create the shader cache directory for this title."));
return;
}
const auto shader_path_string{Common::FS::PathToUTF8String(shader_cache_folder_path)};
@@ -1805,8 +1805,12 @@ void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget targ
const std::string& game_path) {
const QString question = [this, target] {
switch (target) {
- case GameListRemoveTarget::ShaderCache:
- return tr("Delete Transferable Shader Cache?");
+ case GameListRemoveTarget::GlShaderCache:
+ return tr("Delete OpenGL Transferable Shader Cache?");
+ case GameListRemoveTarget::VkShaderCache:
+ return tr("Delete Vulkan Transferable Shader Cache?");
+ case GameListRemoveTarget::AllShaderCache:
+ return tr("Delete All Transferable Shader Caches?");
case GameListRemoveTarget::CustomConfiguration:
return tr("Remove Custom Game Configuration?");
default:
@@ -1820,8 +1824,12 @@ void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget targ
}
switch (target) {
- case GameListRemoveTarget::ShaderCache:
- RemoveTransferableShaderCache(program_id);
+ case GameListRemoveTarget::GlShaderCache:
+ case GameListRemoveTarget::VkShaderCache:
+ RemoveTransferableShaderCache(program_id, target);
+ break;
+ case GameListRemoveTarget::AllShaderCache:
+ RemoveAllTransferableShaderCaches(program_id);
break;
case GameListRemoveTarget::CustomConfiguration:
RemoveCustomConfiguration(program_id, game_path);
@@ -1829,18 +1837,27 @@ void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget targ
}
}
-void GMainWindow::RemoveTransferableShaderCache(u64 program_id) {
+void GMainWindow::RemoveTransferableShaderCache(u64 program_id, GameListRemoveTarget target) {
+ const auto target_file_name = [target] {
+ switch (target) {
+ case GameListRemoveTarget::GlShaderCache:
+ return "opengl.bin";
+ case GameListRemoveTarget::VkShaderCache:
+ return "vulkan.bin";
+ default:
+ return "";
+ }
+ }();
const auto shader_cache_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ShaderDir);
- const auto transferable_shader_cache_file_path =
- shader_cache_dir / "opengl" / "transferable" / fmt::format("{:016X}.bin", program_id);
+ const auto shader_cache_folder_path = shader_cache_dir / fmt::format("{:016x}", program_id);
+ const auto target_file = shader_cache_folder_path / target_file_name;
- if (!Common::FS::Exists(transferable_shader_cache_file_path)) {
+ if (!Common::FS::Exists(target_file)) {
QMessageBox::warning(this, tr("Error Removing Transferable Shader Cache"),
tr("A shader cache for this title does not exist."));
return;
}
-
- if (Common::FS::RemoveFile(transferable_shader_cache_file_path)) {
+ if (Common::FS::RemoveFile(target_file)) {
QMessageBox::information(this, tr("Successfully Removed"),
tr("Successfully removed the transferable shader cache."));
} else {
@@ -1849,6 +1866,24 @@ void GMainWindow::RemoveTransferableShaderCache(u64 program_id) {
}
}
+void GMainWindow::RemoveAllTransferableShaderCaches(u64 program_id) {
+ const auto shader_cache_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ShaderDir);
+ const auto program_shader_cache_dir = shader_cache_dir / fmt::format("{:016x}", program_id);
+
+ if (!Common::FS::Exists(program_shader_cache_dir)) {
+ QMessageBox::warning(this, tr("Error Removing Transferable Shader Caches"),
+ tr("A shader cache for this title does not exist."));
+ return;
+ }
+ if (Common::FS::RemoveDirRecursively(program_shader_cache_dir)) {
+ QMessageBox::information(this, tr("Successfully Removed"),
+ tr("Successfully removed the transferable shader caches."));
+ } else {
+ QMessageBox::warning(this, tr("Error Removing Transferable Shader Caches"),
+ tr("Failed to remove the transferable shader cache directory."));
+ }
+}
+
void GMainWindow::RemoveCustomConfiguration(u64 program_id, const std::string& game_path) {
const auto file_path = std::filesystem::path(Common::FS::ToU8String(game_path));
const auto config_file_name =