diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 7759ea6a21..665143900a 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -97,6 +97,8 @@ add_library( memory_detect.h multi_level_page_table.cpp multi_level_page_table.h + nvidia_flags.cpp + nvidia_flags.h overflow.h page_table.cpp page_table.h diff --git a/src/common/nvidia_flags.cpp b/src/common/nvidia_flags.cpp new file mode 100644 index 0000000000..baca31b0ac --- /dev/null +++ b/src/common/nvidia_flags.cpp @@ -0,0 +1,32 @@ +// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include + +#include + +#include "common/fs/fs.h" +#include "common/fs/path_util.h" +#include "common/nvidia_flags.h" + +namespace Common { + +void ConfigureNvidiaEnvironmentFlags() { +#ifdef _WIN32 + const auto nvidia_shader_dir = + Common::FS::GetEdenPath(Common::FS::EdenPath::ShaderDir) / "nvidia"; + + if (!Common::FS::CreateDirs(nvidia_shader_dir)) { + return; + } + + const auto windows_path_string = + Common::FS::PathToUTF8String(nvidia_shader_dir.lexically_normal()); + + void(_putenv(fmt::format("__GL_SHADER_DISK_CACHE_PATH={}", windows_path_string).c_str())); + void(_putenv("__GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1")); + void(_putenv("__GL_THREADED_OPTIMIZATIONS=1")); +#endif +} + +} // namespace Common diff --git a/src/common/nvidia_flags.h b/src/common/nvidia_flags.h new file mode 100644 index 0000000000..8c3b1bfb92 --- /dev/null +++ b/src/common/nvidia_flags.h @@ -0,0 +1,11 @@ +// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +namespace Common { + +/// Configure platform specific flags for Nvidia's driver +void ConfigureNvidiaEnvironmentFlags(); + +} // namespace Common diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index d2c12c9d40..19162a4ab7 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -35,6 +35,7 @@ #include "applets/qt_profile_select.h" #include "applets/qt_software_keyboard.h" #include "applets/qt_web_browser.h" +#include "common/nvidia_flags.h" #include "common/settings_enums.h" #include "configuration/configure_input.h" #include "configuration/configure_per_game.h" @@ -4916,6 +4917,7 @@ int main(int argc, char* argv[]) { #endif Common::DetachedTasks detached_tasks; + Common::ConfigureNvidiaEnvironmentFlags(); // Init settings params QCoreApplication::setOrganizationName(QStringLiteral("eden")); diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 4a99f34861..599582aba9 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -16,6 +16,7 @@ #include "common/detached_tasks.h" #include "common/logging/backend.h" #include "common/logging/log.h" +#include "common/nvidia_flags.h" #include "common/scm_rev.h" #include "common/scope_exit.h" #include "common/settings.h" @@ -333,6 +334,8 @@ int main(int argc, char** argv) { LocalFree(argv_w); #endif + Common::ConfigureNvidiaEnvironmentFlags(); + if (filepath.empty()) { LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified"); return -1;