diff options
Diffstat (limited to 'src')
72 files changed, 1171 insertions, 245 deletions
diff --git a/src/common/common_sizes.h b/src/common/common_sizes.h index 7e9fd968b..d07b7ee5a 100644 --- a/src/common/common_sizes.h +++ b/src/common/common_sizes.h | |||
| @@ -24,6 +24,7 @@ enum : u64 { | |||
| 24 | Size_128_MB = 128ULL * Size_1_MB, | 24 | Size_128_MB = 128ULL * Size_1_MB, |
| 25 | Size_448_MB = 448ULL * Size_1_MB, | 25 | Size_448_MB = 448ULL * Size_1_MB, |
| 26 | Size_507_MB = 507ULL * Size_1_MB, | 26 | Size_507_MB = 507ULL * Size_1_MB, |
| 27 | Size_512_MB = 512ULL * Size_1_MB, | ||
| 27 | Size_562_MB = 562ULL * Size_1_MB, | 28 | Size_562_MB = 562ULL * Size_1_MB, |
| 28 | Size_1554_MB = 1554ULL * Size_1_MB, | 29 | Size_1554_MB = 1554ULL * Size_1_MB, |
| 29 | Size_2048_MB = 2048ULL * Size_1_MB, | 30 | Size_2048_MB = 2048ULL * Size_1_MB, |
diff --git a/src/common/detached_tasks.cpp b/src/common/detached_tasks.cpp index f2b4939df..c1362631e 100644 --- a/src/common/detached_tasks.cpp +++ b/src/common/detached_tasks.cpp | |||
| @@ -21,6 +21,8 @@ void DetachedTasks::WaitForAllTasks() { | |||
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | DetachedTasks::~DetachedTasks() { | 23 | DetachedTasks::~DetachedTasks() { |
| 24 | WaitForAllTasks(); | ||
| 25 | |||
| 24 | std::unique_lock lock{mutex}; | 26 | std::unique_lock lock{mutex}; |
| 25 | ASSERT(count == 0); | 27 | ASSERT(count == 0); |
| 26 | instance = nullptr; | 28 | instance = nullptr; |
diff --git a/src/common/fs/file.cpp b/src/common/fs/file.cpp index 710e88b39..077f34995 100644 --- a/src/common/fs/file.cpp +++ b/src/common/fs/file.cpp | |||
| @@ -172,7 +172,7 @@ std::string ReadStringFromFile(const std::filesystem::path& path, FileType type) | |||
| 172 | 172 | ||
| 173 | size_t WriteStringToFile(const std::filesystem::path& path, FileType type, | 173 | size_t WriteStringToFile(const std::filesystem::path& path, FileType type, |
| 174 | std::string_view string) { | 174 | std::string_view string) { |
| 175 | if (!IsFile(path)) { | 175 | if (Exists(path) && !IsFile(path)) { |
| 176 | return 0; | 176 | return 0; |
| 177 | } | 177 | } |
| 178 | 178 | ||
| @@ -183,7 +183,7 @@ size_t WriteStringToFile(const std::filesystem::path& path, FileType type, | |||
| 183 | 183 | ||
| 184 | size_t AppendStringToFile(const std::filesystem::path& path, FileType type, | 184 | size_t AppendStringToFile(const std::filesystem::path& path, FileType type, |
| 185 | std::string_view string) { | 185 | std::string_view string) { |
| 186 | if (!IsFile(path)) { | 186 | if (Exists(path) && !IsFile(path)) { |
| 187 | return 0; | 187 | return 0; |
| 188 | } | 188 | } |
| 189 | 189 | ||
diff --git a/src/common/fs/file.h b/src/common/fs/file.h index 0f10b6003..588fe619d 100644 --- a/src/common/fs/file.h +++ b/src/common/fs/file.h | |||
| @@ -49,7 +49,7 @@ void OpenFileStream(FileStream& file_stream, const Path& path, std::ios_base::op | |||
| 49 | 49 | ||
| 50 | /** | 50 | /** |
| 51 | * Reads an entire file at path and returns a string of the contents read from the file. | 51 | * Reads an entire file at path and returns a string of the contents read from the file. |
| 52 | * If the filesystem object at path is not a file, this function returns an empty string. | 52 | * If the filesystem object at path is not a regular file, this function returns an empty string. |
| 53 | * | 53 | * |
| 54 | * @param path Filesystem path | 54 | * @param path Filesystem path |
| 55 | * @param type File type | 55 | * @param type File type |
| @@ -72,7 +72,8 @@ template <typename Path> | |||
| 72 | /** | 72 | /** |
| 73 | * Writes a string to a file at path and returns the number of characters successfully written. | 73 | * Writes a string to a file at path and returns the number of characters successfully written. |
| 74 | * If a file already exists at path, its contents will be erased. | 74 | * If a file already exists at path, its contents will be erased. |
| 75 | * If the filesystem object at path is not a file, this function returns 0. | 75 | * If a file does not exist at path, it creates and opens a new empty file for writing. |
| 76 | * If the filesystem object at path exists and is not a regular file, this function returns 0. | ||
| 76 | * | 77 | * |
| 77 | * @param path Filesystem path | 78 | * @param path Filesystem path |
| 78 | * @param type File type | 79 | * @param type File type |
| @@ -95,7 +96,8 @@ template <typename Path> | |||
| 95 | 96 | ||
| 96 | /** | 97 | /** |
| 97 | * Appends a string to a file at path and returns the number of characters successfully written. | 98 | * Appends a string to a file at path and returns the number of characters successfully written. |
| 98 | * If the filesystem object at path is not a file, this function returns 0. | 99 | * If a file does not exist at path, it creates and opens a new empty file for appending. |
| 100 | * If the filesystem object at path exists and is not a regular file, this function returns 0. | ||
| 99 | * | 101 | * |
| 100 | * @param path Filesystem path | 102 | * @param path Filesystem path |
| 101 | * @param type File type | 103 | * @param type File type |
| @@ -394,11 +396,11 @@ public: | |||
| 394 | [[nodiscard]] size_t WriteString(std::span<const char> string) const; | 396 | [[nodiscard]] size_t WriteString(std::span<const char> string) const; |
| 395 | 397 | ||
| 396 | /** | 398 | /** |
| 397 | * Flushes any unwritten buffered data into the file. | 399 | * Attempts to flush any unwritten buffered data into the file and flush the file into the disk. |
| 398 | * | 400 | * |
| 399 | * @returns True if the flush was successful, false otherwise. | 401 | * @returns True if the flush was successful, false otherwise. |
| 400 | */ | 402 | */ |
| 401 | [[nodiscard]] bool Flush() const; | 403 | bool Flush() const; |
| 402 | 404 | ||
| 403 | /** | 405 | /** |
| 404 | * Resizes the file to a given size. | 406 | * Resizes the file to a given size. |
diff --git a/src/common/fs/fs.cpp b/src/common/fs/fs.cpp index d3159e908..9089cad67 100644 --- a/src/common/fs/fs.cpp +++ b/src/common/fs/fs.cpp | |||
| @@ -135,8 +135,9 @@ std::shared_ptr<IOFile> FileOpen(const fs::path& path, FileAccessMode mode, File | |||
| 135 | return nullptr; | 135 | return nullptr; |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | if (!IsFile(path)) { | 138 | if (Exists(path) && !IsFile(path)) { |
| 139 | LOG_ERROR(Common_Filesystem, "Filesystem object at path={} is not a file", | 139 | LOG_ERROR(Common_Filesystem, |
| 140 | "Filesystem object at path={} exists and is not a regular file", | ||
| 140 | PathToUTF8String(path)); | 141 | PathToUTF8String(path)); |
| 141 | return nullptr; | 142 | return nullptr; |
| 142 | } | 143 | } |
diff --git a/src/common/fs/fs.h b/src/common/fs/fs.h index f6f256349..183126de3 100644 --- a/src/common/fs/fs.h +++ b/src/common/fs/fs.h | |||
| @@ -48,18 +48,18 @@ template <typename Path> | |||
| 48 | * | 48 | * |
| 49 | * Failures occur when: | 49 | * Failures occur when: |
| 50 | * - Input path is not valid | 50 | * - Input path is not valid |
| 51 | * - Filesystem object at path is not a file | 51 | * - Filesystem object at path is not a regular file |
| 52 | * - Filesystem at path is read only | 52 | * - Filesystem at path is read only |
| 53 | * | 53 | * |
| 54 | * @param path Filesystem path | 54 | * @param path Filesystem path |
| 55 | * | 55 | * |
| 56 | * @returns True if file removal succeeds or file does not exist, false otherwise. | 56 | * @returns True if file removal succeeds or file does not exist, false otherwise. |
| 57 | */ | 57 | */ |
| 58 | [[nodiscard]] bool RemoveFile(const std::filesystem::path& path); | 58 | bool RemoveFile(const std::filesystem::path& path); |
| 59 | 59 | ||
| 60 | #ifdef _WIN32 | 60 | #ifdef _WIN32 |
| 61 | template <typename Path> | 61 | template <typename Path> |
| 62 | [[nodiscard]] bool RemoveFile(const Path& path) { | 62 | bool RemoveFile(const Path& path) { |
| 63 | if constexpr (IsChar<typename Path::value_type>) { | 63 | if constexpr (IsChar<typename Path::value_type>) { |
| 64 | return RemoveFile(ToU8String(path)); | 64 | return RemoveFile(ToU8String(path)); |
| 65 | } else { | 65 | } else { |
| @@ -74,7 +74,7 @@ template <typename Path> | |||
| 74 | * Failures occur when: | 74 | * Failures occur when: |
| 75 | * - One or both input path(s) is not valid | 75 | * - One or both input path(s) is not valid |
| 76 | * - Filesystem object at old_path does not exist | 76 | * - Filesystem object at old_path does not exist |
| 77 | * - Filesystem object at old_path is not a file | 77 | * - Filesystem object at old_path is not a regular file |
| 78 | * - Filesystem object at new_path exists | 78 | * - Filesystem object at new_path exists |
| 79 | * - Filesystem at either path is read only | 79 | * - Filesystem at either path is read only |
| 80 | * | 80 | * |
| @@ -110,8 +110,8 @@ template <typename Path1, typename Path2> | |||
| 110 | * | 110 | * |
| 111 | * Failures occur when: | 111 | * Failures occur when: |
| 112 | * - Input path is not valid | 112 | * - Input path is not valid |
| 113 | * - Filesystem object at path is not a file | 113 | * - Filesystem object at path exists and is not a regular file |
| 114 | * - The file is not opened | 114 | * - The file is not open |
| 115 | * | 115 | * |
| 116 | * @param path Filesystem path | 116 | * @param path Filesystem path |
| 117 | * @param mode File access mode | 117 | * @param mode File access mode |
| @@ -251,11 +251,11 @@ template <typename Path> | |||
| 251 | * | 251 | * |
| 252 | * @returns True if directory removal succeeds or directory does not exist, false otherwise. | 252 | * @returns True if directory removal succeeds or directory does not exist, false otherwise. |
| 253 | */ | 253 | */ |
| 254 | [[nodiscard]] bool RemoveDir(const std::filesystem::path& path); | 254 | bool RemoveDir(const std::filesystem::path& path); |
| 255 | 255 | ||
| 256 | #ifdef _WIN32 | 256 | #ifdef _WIN32 |
| 257 | template <typename Path> | 257 | template <typename Path> |
| 258 | [[nodiscard]] bool RemoveDir(const Path& path) { | 258 | bool RemoveDir(const Path& path) { |
| 259 | if constexpr (IsChar<typename Path::value_type>) { | 259 | if constexpr (IsChar<typename Path::value_type>) { |
| 260 | return RemoveDir(ToU8String(path)); | 260 | return RemoveDir(ToU8String(path)); |
| 261 | } else { | 261 | } else { |
| @@ -276,11 +276,11 @@ template <typename Path> | |||
| 276 | * | 276 | * |
| 277 | * @returns True if the directory and all of its contents are removed successfully, false otherwise. | 277 | * @returns True if the directory and all of its contents are removed successfully, false otherwise. |
| 278 | */ | 278 | */ |
| 279 | [[nodiscard]] bool RemoveDirRecursively(const std::filesystem::path& path); | 279 | bool RemoveDirRecursively(const std::filesystem::path& path); |
| 280 | 280 | ||
| 281 | #ifdef _WIN32 | 281 | #ifdef _WIN32 |
| 282 | template <typename Path> | 282 | template <typename Path> |
| 283 | [[nodiscard]] bool RemoveDirRecursively(const Path& path) { | 283 | bool RemoveDirRecursively(const Path& path) { |
| 284 | if constexpr (IsChar<typename Path::value_type>) { | 284 | if constexpr (IsChar<typename Path::value_type>) { |
| 285 | return RemoveDirRecursively(ToU8String(path)); | 285 | return RemoveDirRecursively(ToU8String(path)); |
| 286 | } else { | 286 | } else { |
| @@ -301,11 +301,11 @@ template <typename Path> | |||
| 301 | * | 301 | * |
| 302 | * @returns True if all of the directory's contents are removed successfully, false otherwise. | 302 | * @returns True if all of the directory's contents are removed successfully, false otherwise. |
| 303 | */ | 303 | */ |
| 304 | [[nodiscard]] bool RemoveDirContentsRecursively(const std::filesystem::path& path); | 304 | bool RemoveDirContentsRecursively(const std::filesystem::path& path); |
| 305 | 305 | ||
| 306 | #ifdef _WIN32 | 306 | #ifdef _WIN32 |
| 307 | template <typename Path> | 307 | template <typename Path> |
| 308 | [[nodiscard]] bool RemoveDirContentsRecursively(const Path& path) { | 308 | bool RemoveDirContentsRecursively(const Path& path) { |
| 309 | if constexpr (IsChar<typename Path::value_type>) { | 309 | if constexpr (IsChar<typename Path::value_type>) { |
| 310 | return RemoveDirContentsRecursively(ToU8String(path)); | 310 | return RemoveDirContentsRecursively(ToU8String(path)); |
| 311 | } else { | 311 | } else { |
| @@ -435,11 +435,13 @@ template <typename Path> | |||
| 435 | #endif | 435 | #endif |
| 436 | 436 | ||
| 437 | /** | 437 | /** |
| 438 | * Returns whether a filesystem object at path is a file. | 438 | * Returns whether a filesystem object at path is a regular file. |
| 439 | * A regular file is a file that stores text or binary data. | ||
| 440 | * It is not a directory, symlink, FIFO, socket, block device, or character device. | ||
| 439 | * | 441 | * |
| 440 | * @param path Filesystem path | 442 | * @param path Filesystem path |
| 441 | * | 443 | * |
| 442 | * @returns True if a filesystem object at path is a file, false otherwise. | 444 | * @returns True if a filesystem object at path is a regular file, false otherwise. |
| 443 | */ | 445 | */ |
| 444 | [[nodiscard]] bool IsFile(const std::filesystem::path& path); | 446 | [[nodiscard]] bool IsFile(const std::filesystem::path& path); |
| 445 | 447 | ||
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index d5cff400f..47ce06478 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp | |||
| @@ -159,7 +159,7 @@ FileBackend::FileBackend(const std::filesystem::path& filename) { | |||
| 159 | 159 | ||
| 160 | // Existence checks are done within the functions themselves. | 160 | // Existence checks are done within the functions themselves. |
| 161 | // We don't particularly care if these succeed or not. | 161 | // We don't particularly care if these succeed or not. |
| 162 | void(FS::RemoveFile(old_filename)); | 162 | FS::RemoveFile(old_filename); |
| 163 | void(FS::RenameFile(filename, old_filename)); | 163 | void(FS::RenameFile(filename, old_filename)); |
| 164 | 164 | ||
| 165 | file = | 165 | file = |
| @@ -186,7 +186,7 @@ void FileBackend::Write(const Entry& entry) { | |||
| 186 | 186 | ||
| 187 | bytes_written += file->WriteString(FormatLogMessage(entry).append(1, '\n')); | 187 | bytes_written += file->WriteString(FormatLogMessage(entry).append(1, '\n')); |
| 188 | if (entry.log_level >= Level::Error) { | 188 | if (entry.log_level >= Level::Error) { |
| 189 | void(file->Flush()); | 189 | file->Flush(); |
| 190 | } | 190 | } |
| 191 | } | 191 | } |
| 192 | 192 | ||
diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 9ec71eced..e1bb4b7ff 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp | |||
| @@ -59,6 +59,7 @@ void LogSettings() { | |||
| 59 | log_setting("Renderer_UseVsync", values.use_vsync.GetValue()); | 59 | log_setting("Renderer_UseVsync", values.use_vsync.GetValue()); |
| 60 | log_setting("Renderer_UseAssemblyShaders", values.use_assembly_shaders.GetValue()); | 60 | log_setting("Renderer_UseAssemblyShaders", values.use_assembly_shaders.GetValue()); |
| 61 | log_setting("Renderer_UseAsynchronousShaders", values.use_asynchronous_shaders.GetValue()); | 61 | log_setting("Renderer_UseAsynchronousShaders", values.use_asynchronous_shaders.GetValue()); |
| 62 | log_setting("Renderer_UseGarbageCollection", values.use_caches_gc.GetValue()); | ||
| 62 | log_setting("Renderer_AnisotropicFilteringLevel", values.max_anisotropy.GetValue()); | 63 | log_setting("Renderer_AnisotropicFilteringLevel", values.max_anisotropy.GetValue()); |
| 63 | log_setting("Audio_OutputEngine", values.sink_id); | 64 | log_setting("Audio_OutputEngine", values.sink_id); |
| 64 | log_setting("Audio_EnableAudioStretching", values.enable_audio_stretching.GetValue()); | 65 | log_setting("Audio_EnableAudioStretching", values.enable_audio_stretching.GetValue()); |
| @@ -122,6 +123,7 @@ void RestoreGlobalState(bool is_powered_on) { | |||
| 122 | values.cpu_accuracy.SetGlobal(true); | 123 | values.cpu_accuracy.SetGlobal(true); |
| 123 | values.cpuopt_unsafe_unfuse_fma.SetGlobal(true); | 124 | values.cpuopt_unsafe_unfuse_fma.SetGlobal(true); |
| 124 | values.cpuopt_unsafe_reduce_fp_error.SetGlobal(true); | 125 | values.cpuopt_unsafe_reduce_fp_error.SetGlobal(true); |
| 126 | values.cpuopt_unsafe_ignore_standard_fpcr.SetGlobal(true); | ||
| 125 | values.cpuopt_unsafe_inaccurate_nan.SetGlobal(true); | 127 | values.cpuopt_unsafe_inaccurate_nan.SetGlobal(true); |
| 126 | values.cpuopt_unsafe_fastmem_check.SetGlobal(true); | 128 | values.cpuopt_unsafe_fastmem_check.SetGlobal(true); |
| 127 | 129 | ||
| @@ -141,6 +143,7 @@ void RestoreGlobalState(bool is_powered_on) { | |||
| 141 | values.use_assembly_shaders.SetGlobal(true); | 143 | values.use_assembly_shaders.SetGlobal(true); |
| 142 | values.use_asynchronous_shaders.SetGlobal(true); | 144 | values.use_asynchronous_shaders.SetGlobal(true); |
| 143 | values.use_fast_gpu_time.SetGlobal(true); | 145 | values.use_fast_gpu_time.SetGlobal(true); |
| 146 | values.use_caches_gc.SetGlobal(true); | ||
| 144 | values.bg_red.SetGlobal(true); | 147 | values.bg_red.SetGlobal(true); |
| 145 | values.bg_green.SetGlobal(true); | 148 | values.bg_green.SetGlobal(true); |
| 146 | values.bg_blue.SetGlobal(true); | 149 | values.bg_blue.SetGlobal(true); |
diff --git a/src/common/settings.h b/src/common/settings.h index 6198f2d9f..82ec18e27 100644 --- a/src/common/settings.h +++ b/src/common/settings.h | |||
| @@ -129,6 +129,7 @@ struct Values { | |||
| 129 | 129 | ||
| 130 | Setting<bool> cpuopt_unsafe_unfuse_fma; | 130 | Setting<bool> cpuopt_unsafe_unfuse_fma; |
| 131 | Setting<bool> cpuopt_unsafe_reduce_fp_error; | 131 | Setting<bool> cpuopt_unsafe_reduce_fp_error; |
| 132 | Setting<bool> cpuopt_unsafe_ignore_standard_fpcr; | ||
| 132 | Setting<bool> cpuopt_unsafe_inaccurate_nan; | 133 | Setting<bool> cpuopt_unsafe_inaccurate_nan; |
| 133 | Setting<bool> cpuopt_unsafe_fastmem_check; | 134 | Setting<bool> cpuopt_unsafe_fastmem_check; |
| 134 | 135 | ||
| @@ -149,9 +150,11 @@ struct Values { | |||
| 149 | Setting<bool> use_nvdec_emulation; | 150 | Setting<bool> use_nvdec_emulation; |
| 150 | Setting<bool> accelerate_astc; | 151 | Setting<bool> accelerate_astc; |
| 151 | Setting<bool> use_vsync; | 152 | Setting<bool> use_vsync; |
| 153 | Setting<bool> disable_fps_limit; | ||
| 152 | Setting<bool> use_assembly_shaders; | 154 | Setting<bool> use_assembly_shaders; |
| 153 | Setting<bool> use_asynchronous_shaders; | 155 | Setting<bool> use_asynchronous_shaders; |
| 154 | Setting<bool> use_fast_gpu_time; | 156 | Setting<bool> use_fast_gpu_time; |
| 157 | Setting<bool> use_caches_gc; | ||
| 155 | 158 | ||
| 156 | Setting<float> bg_red; | 159 | Setting<float> bg_red; |
| 157 | Setting<float> bg_green; | 160 | Setting<float> bg_green; |
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index efb851f5a..83b5b7676 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -139,6 +139,7 @@ add_library(core STATIC | |||
| 139 | frontend/input.h | 139 | frontend/input.h |
| 140 | hardware_interrupt_manager.cpp | 140 | hardware_interrupt_manager.cpp |
| 141 | hardware_interrupt_manager.h | 141 | hardware_interrupt_manager.h |
| 142 | hle/api_version.h | ||
| 142 | hle/ipc.h | 143 | hle/ipc.h |
| 143 | hle/ipc_helpers.h | 144 | hle/ipc_helpers.h |
| 144 | hle/kernel/board/nintendo/nx/k_system_control.cpp | 145 | hle/kernel/board/nintendo/nx/k_system_control.cpp |
| @@ -550,6 +551,8 @@ add_library(core STATIC | |||
| 550 | hle/service/spl/module.h | 551 | hle/service/spl/module.h |
| 551 | hle/service/spl/spl.cpp | 552 | hle/service/spl/spl.cpp |
| 552 | hle/service/spl/spl.h | 553 | hle/service/spl/spl.h |
| 554 | hle/service/spl/spl_results.h | ||
| 555 | hle/service/spl/spl_types.h | ||
| 553 | hle/service/ssl/ssl.cpp | 556 | hle/service/ssl/ssl.cpp |
| 554 | hle/service/ssl/ssl.h | 557 | hle/service/ssl/ssl.h |
| 555 | hle/service/time/clock_types.h | 558 | hle/service/time/clock_types.h |
diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp index c8f6dc765..f871f7bf4 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp | |||
| @@ -186,6 +186,9 @@ std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable* | |||
| 186 | if (Settings::values.cpuopt_unsafe_reduce_fp_error.GetValue()) { | 186 | if (Settings::values.cpuopt_unsafe_reduce_fp_error.GetValue()) { |
| 187 | config.optimizations |= Dynarmic::OptimizationFlag::Unsafe_ReducedErrorFP; | 187 | config.optimizations |= Dynarmic::OptimizationFlag::Unsafe_ReducedErrorFP; |
| 188 | } | 188 | } |
| 189 | if (Settings::values.cpuopt_unsafe_ignore_standard_fpcr.GetValue()) { | ||
| 190 | config.optimizations |= Dynarmic::OptimizationFlag::Unsafe_IgnoreStandardFPCRValue; | ||
| 191 | } | ||
| 189 | if (Settings::values.cpuopt_unsafe_inaccurate_nan.GetValue()) { | 192 | if (Settings::values.cpuopt_unsafe_inaccurate_nan.GetValue()) { |
| 190 | config.optimizations |= Dynarmic::OptimizationFlag::Unsafe_InaccurateNaN; | 193 | config.optimizations |= Dynarmic::OptimizationFlag::Unsafe_InaccurateNaN; |
| 191 | } | 194 | } |
diff --git a/src/core/core.cpp b/src/core/core.cpp index c5004b7b4..e6f1aa0e7 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <array> | 5 | #include <array> |
| 6 | #include <atomic> | ||
| 6 | #include <memory> | 7 | #include <memory> |
| 7 | #include <utility> | 8 | #include <utility> |
| 8 | 9 | ||
| @@ -377,7 +378,7 @@ struct System::Impl { | |||
| 377 | std::unique_ptr<Core::DeviceMemory> device_memory; | 378 | std::unique_ptr<Core::DeviceMemory> device_memory; |
| 378 | Core::Memory::Memory memory; | 379 | Core::Memory::Memory memory; |
| 379 | CpuManager cpu_manager; | 380 | CpuManager cpu_manager; |
| 380 | bool is_powered_on = false; | 381 | std::atomic_bool is_powered_on{}; |
| 381 | bool exit_lock = false; | 382 | bool exit_lock = false; |
| 382 | 383 | ||
| 383 | Reporter reporter; | 384 | Reporter reporter; |
| @@ -463,7 +464,7 @@ System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::st | |||
| 463 | } | 464 | } |
| 464 | 465 | ||
| 465 | bool System::IsPoweredOn() const { | 466 | bool System::IsPoweredOn() const { |
| 466 | return impl->is_powered_on; | 467 | return impl->is_powered_on.load(std::memory_order::relaxed); |
| 467 | } | 468 | } |
| 468 | 469 | ||
| 469 | void System::PrepareReschedule() { | 470 | void System::PrepareReschedule() { |
diff --git a/src/core/file_sys/system_archive/system_version.cpp b/src/core/file_sys/system_archive/system_version.cpp index 54704105b..9b76d007e 100644 --- a/src/core/file_sys/system_archive/system_version.cpp +++ b/src/core/file_sys/system_archive/system_version.cpp | |||
| @@ -4,47 +4,29 @@ | |||
| 4 | 4 | ||
| 5 | #include "core/file_sys/system_archive/system_version.h" | 5 | #include "core/file_sys/system_archive/system_version.h" |
| 6 | #include "core/file_sys/vfs_vector.h" | 6 | #include "core/file_sys/vfs_vector.h" |
| 7 | #include "core/hle/api_version.h" | ||
| 7 | 8 | ||
| 8 | namespace FileSys::SystemArchive { | 9 | namespace FileSys::SystemArchive { |
| 9 | 10 | ||
| 10 | namespace SystemVersionData { | ||
| 11 | |||
| 12 | // This section should reflect the best system version to describe yuzu's HLE api. | ||
| 13 | // TODO(DarkLordZach): Update when HLE gets better. | ||
| 14 | |||
| 15 | constexpr u8 VERSION_MAJOR = 11; | ||
| 16 | constexpr u8 VERSION_MINOR = 0; | ||
| 17 | constexpr u8 VERSION_MICRO = 1; | ||
| 18 | |||
| 19 | constexpr u8 REVISION_MAJOR = 1; | ||
| 20 | constexpr u8 REVISION_MINOR = 0; | ||
| 21 | |||
| 22 | constexpr char PLATFORM_STRING[] = "NX"; | ||
| 23 | constexpr char VERSION_HASH[] = "69103fcb2004dace877094c2f8c29e6113be5dbf"; | ||
| 24 | constexpr char DISPLAY_VERSION[] = "11.0.1"; | ||
| 25 | constexpr char DISPLAY_TITLE[] = "NintendoSDK Firmware for NX 11.0.1-1.0"; | ||
| 26 | |||
| 27 | } // namespace SystemVersionData | ||
| 28 | |||
| 29 | std::string GetLongDisplayVersion() { | 11 | std::string GetLongDisplayVersion() { |
| 30 | return SystemVersionData::DISPLAY_TITLE; | 12 | return HLE::ApiVersion::DISPLAY_TITLE; |
| 31 | } | 13 | } |
| 32 | 14 | ||
| 33 | VirtualDir SystemVersion() { | 15 | VirtualDir SystemVersion() { |
| 34 | VirtualFile file = std::make_shared<VectorVfsFile>(std::vector<u8>(0x100), "file"); | 16 | VirtualFile file = std::make_shared<VectorVfsFile>(std::vector<u8>(0x100), "file"); |
| 35 | file->WriteObject(SystemVersionData::VERSION_MAJOR, 0); | 17 | file->WriteObject(HLE::ApiVersion::HOS_VERSION_MAJOR, 0); |
| 36 | file->WriteObject(SystemVersionData::VERSION_MINOR, 1); | 18 | file->WriteObject(HLE::ApiVersion::HOS_VERSION_MINOR, 1); |
| 37 | file->WriteObject(SystemVersionData::VERSION_MICRO, 2); | 19 | file->WriteObject(HLE::ApiVersion::HOS_VERSION_MICRO, 2); |
| 38 | file->WriteObject(SystemVersionData::REVISION_MAJOR, 4); | 20 | file->WriteObject(HLE::ApiVersion::SDK_REVISION_MAJOR, 4); |
| 39 | file->WriteObject(SystemVersionData::REVISION_MINOR, 5); | 21 | file->WriteObject(HLE::ApiVersion::SDK_REVISION_MINOR, 5); |
| 40 | file->WriteArray(SystemVersionData::PLATFORM_STRING, | 22 | file->WriteArray(HLE::ApiVersion::PLATFORM_STRING, |
| 41 | std::min<u64>(sizeof(SystemVersionData::PLATFORM_STRING), 0x20ULL), 0x8); | 23 | std::min<u64>(sizeof(HLE::ApiVersion::PLATFORM_STRING), 0x20ULL), 0x8); |
| 42 | file->WriteArray(SystemVersionData::VERSION_HASH, | 24 | file->WriteArray(HLE::ApiVersion::VERSION_HASH, |
| 43 | std::min<u64>(sizeof(SystemVersionData::VERSION_HASH), 0x40ULL), 0x28); | 25 | std::min<u64>(sizeof(HLE::ApiVersion::VERSION_HASH), 0x40ULL), 0x28); |
| 44 | file->WriteArray(SystemVersionData::DISPLAY_VERSION, | 26 | file->WriteArray(HLE::ApiVersion::DISPLAY_VERSION, |
| 45 | std::min<u64>(sizeof(SystemVersionData::DISPLAY_VERSION), 0x18ULL), 0x68); | 27 | std::min<u64>(sizeof(HLE::ApiVersion::DISPLAY_VERSION), 0x18ULL), 0x68); |
| 46 | file->WriteArray(SystemVersionData::DISPLAY_TITLE, | 28 | file->WriteArray(HLE::ApiVersion::DISPLAY_TITLE, |
| 47 | std::min<u64>(sizeof(SystemVersionData::DISPLAY_TITLE), 0x80ULL), 0x80); | 29 | std::min<u64>(sizeof(HLE::ApiVersion::DISPLAY_TITLE), 0x80ULL), 0x80); |
| 48 | return std::make_shared<VectorVfsDirectory>(std::vector<VirtualFile>{file}, | 30 | return std::make_shared<VectorVfsDirectory>(std::vector<VirtualFile>{file}, |
| 49 | std::vector<VirtualDir>{}, "data"); | 31 | std::vector<VirtualDir>{}, "data"); |
| 50 | } | 32 | } |
diff --git a/src/core/file_sys/vfs_real.cpp b/src/core/file_sys/vfs_real.cpp index d0b8fd046..3dad54f49 100644 --- a/src/core/file_sys/vfs_real.cpp +++ b/src/core/file_sys/vfs_real.cpp | |||
| @@ -24,17 +24,12 @@ constexpr FS::FileAccessMode ModeFlagsToFileAccessMode(Mode mode) { | |||
| 24 | case Mode::Read: | 24 | case Mode::Read: |
| 25 | return FS::FileAccessMode::Read; | 25 | return FS::FileAccessMode::Read; |
| 26 | case Mode::Write: | 26 | case Mode::Write: |
| 27 | return FS::FileAccessMode::Write; | ||
| 28 | case Mode::ReadWrite: | 27 | case Mode::ReadWrite: |
| 29 | return FS::FileAccessMode::ReadWrite; | ||
| 30 | case Mode::Append: | 28 | case Mode::Append: |
| 31 | return FS::FileAccessMode::Append; | ||
| 32 | case Mode::ReadAppend: | 29 | case Mode::ReadAppend: |
| 33 | return FS::FileAccessMode::ReadAppend; | ||
| 34 | case Mode::WriteAppend: | 30 | case Mode::WriteAppend: |
| 35 | return FS::FileAccessMode::Append; | ||
| 36 | case Mode::All: | 31 | case Mode::All: |
| 37 | return FS::FileAccessMode::ReadAppend; | 32 | return FS::FileAccessMode::ReadWrite; |
| 38 | default: | 33 | default: |
| 39 | return {}; | 34 | return {}; |
| 40 | } | 35 | } |
diff --git a/src/core/hle/api_version.h b/src/core/hle/api_version.h new file mode 100644 index 000000000..811732179 --- /dev/null +++ b/src/core/hle/api_version.h | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/common_types.h" | ||
| 6 | |||
| 7 | // This file contains yuzu's HLE API version constants. | ||
| 8 | |||
| 9 | namespace HLE::ApiVersion { | ||
| 10 | |||
| 11 | // Horizon OS version constants. | ||
| 12 | |||
| 13 | constexpr u8 HOS_VERSION_MAJOR = 11; | ||
| 14 | constexpr u8 HOS_VERSION_MINOR = 0; | ||
| 15 | constexpr u8 HOS_VERSION_MICRO = 1; | ||
| 16 | |||
| 17 | // NintendoSDK version constants. | ||
| 18 | |||
| 19 | constexpr u8 SDK_REVISION_MAJOR = 1; | ||
| 20 | constexpr u8 SDK_REVISION_MINOR = 0; | ||
| 21 | |||
| 22 | constexpr char PLATFORM_STRING[] = "NX"; | ||
| 23 | constexpr char VERSION_HASH[] = "69103fcb2004dace877094c2f8c29e6113be5dbf"; | ||
| 24 | constexpr char DISPLAY_VERSION[] = "11.0.1"; | ||
| 25 | constexpr char DISPLAY_TITLE[] = "NintendoSDK Firmware for NX 11.0.1-1.0"; | ||
| 26 | |||
| 27 | // Atmosphere version constants. | ||
| 28 | |||
| 29 | constexpr u8 ATMOSPHERE_RELEASE_VERSION_MAJOR = 0; | ||
| 30 | constexpr u8 ATMOSPHERE_RELEASE_VERSION_MINOR = 19; | ||
| 31 | constexpr u8 ATMOSPHERE_RELEASE_VERSION_MICRO = 4; | ||
| 32 | |||
| 33 | constexpr u32 GetTargetFirmware() { | ||
| 34 | return u32{HOS_VERSION_MAJOR} << 24 | u32{HOS_VERSION_MINOR} << 16 | | ||
| 35 | u32{HOS_VERSION_MICRO} << 8 | 0U; | ||
| 36 | } | ||
| 37 | |||
| 38 | } // namespace HLE::ApiVersion | ||
diff --git a/src/core/hle/kernel/k_resource_limit.cpp b/src/core/hle/kernel/k_resource_limit.cpp index da88f35bc..0c4bba66b 100644 --- a/src/core/hle/kernel/k_resource_limit.cpp +++ b/src/core/hle/kernel/k_resource_limit.cpp | |||
| @@ -79,6 +79,7 @@ ResultCode KResourceLimit::SetLimitValue(LimitableResource which, s64 value) { | |||
| 79 | R_UNLESS(current_values[index] <= value, ResultInvalidState); | 79 | R_UNLESS(current_values[index] <= value, ResultInvalidState); |
| 80 | 80 | ||
| 81 | limit_values[index] = value; | 81 | limit_values[index] = value; |
| 82 | peak_values[index] = current_values[index]; | ||
| 82 | 83 | ||
| 83 | return ResultSuccess; | 84 | return ResultSuccess; |
| 84 | } | 85 | } |
diff --git a/src/core/hle/service/bcat/backend/boxcat.cpp b/src/core/hle/service/bcat/backend/boxcat.cpp index a2844ea8c..dc15cf58b 100644 --- a/src/core/hle/service/bcat/backend/boxcat.cpp +++ b/src/core/hle/service/bcat/backend/boxcat.cpp | |||
| @@ -313,7 +313,7 @@ void SynchronizeInternal(AM::Applets::AppletManager& applet_manager, DirectoryGe | |||
| 313 | LOG_ERROR(Service_BCAT, "Boxcat synchronization failed with error '{}'!", res); | 313 | LOG_ERROR(Service_BCAT, "Boxcat synchronization failed with error '{}'!", res); |
| 314 | 314 | ||
| 315 | if (res == DownloadResult::NoMatchBuildId || res == DownloadResult::NoMatchTitleId) { | 315 | if (res == DownloadResult::NoMatchBuildId || res == DownloadResult::NoMatchTitleId) { |
| 316 | void(Common::FS::RemoveFile(zip_path)); | 316 | Common::FS::RemoveFile(zip_path); |
| 317 | } | 317 | } |
| 318 | 318 | ||
| 319 | HandleDownloadDisplayResult(applet_manager, res); | 319 | HandleDownloadDisplayResult(applet_manager, res); |
| @@ -445,7 +445,7 @@ std::optional<std::vector<u8>> Boxcat::GetLaunchParameter(TitleIDVersion title) | |||
| 445 | LOG_ERROR(Service_BCAT, "Boxcat synchronization failed with error '{}'!", res); | 445 | LOG_ERROR(Service_BCAT, "Boxcat synchronization failed with error '{}'!", res); |
| 446 | 446 | ||
| 447 | if (res == DownloadResult::NoMatchBuildId || res == DownloadResult::NoMatchTitleId) { | 447 | if (res == DownloadResult::NoMatchBuildId || res == DownloadResult::NoMatchTitleId) { |
| 448 | void(Common::FS::RemoveFile(bin_file_path)); | 448 | Common::FS::RemoveFile(bin_file_path); |
| 449 | } | 449 | } |
| 450 | 450 | ||
| 451 | HandleDownloadDisplayResult(applet_manager, res); | 451 | HandleDownloadDisplayResult(applet_manager, res); |
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 7acad3798..1eb02aee2 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -314,6 +314,8 @@ void Controller_NPad::OnInit() { | |||
| 314 | 314 | ||
| 315 | void Controller_NPad::OnLoadInputDevices() { | 315 | void Controller_NPad::OnLoadInputDevices() { |
| 316 | const auto& players = Settings::values.players.GetValue(); | 316 | const auto& players = Settings::values.players.GetValue(); |
| 317 | |||
| 318 | std::lock_guard lock{mutex}; | ||
| 317 | for (std::size_t i = 0; i < players.size(); ++i) { | 319 | for (std::size_t i = 0; i < players.size(); ++i) { |
| 318 | std::transform(players[i].buttons.begin() + Settings::NativeButton::BUTTON_HID_BEGIN, | 320 | std::transform(players[i].buttons.begin() + Settings::NativeButton::BUTTON_HID_BEGIN, |
| 319 | players[i].buttons.begin() + Settings::NativeButton::BUTTON_HID_END, | 321 | players[i].buttons.begin() + Settings::NativeButton::BUTTON_HID_END, |
| @@ -348,6 +350,8 @@ void Controller_NPad::OnRelease() { | |||
| 348 | } | 350 | } |
| 349 | 351 | ||
| 350 | void Controller_NPad::RequestPadStateUpdate(u32 npad_id) { | 352 | void Controller_NPad::RequestPadStateUpdate(u32 npad_id) { |
| 353 | std::lock_guard lock{mutex}; | ||
| 354 | |||
| 351 | const auto controller_idx = NPadIdToIndex(npad_id); | 355 | const auto controller_idx = NPadIdToIndex(npad_id); |
| 352 | const auto controller_type = connected_controllers[controller_idx].type; | 356 | const auto controller_type = connected_controllers[controller_idx].type; |
| 353 | if (!connected_controllers[controller_idx].is_connected) { | 357 | if (!connected_controllers[controller_idx].is_connected) { |
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index c050c9a44..1409d82a2 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h | |||
| @@ -6,6 +6,8 @@ | |||
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <atomic> | 8 | #include <atomic> |
| 9 | #include <mutex> | ||
| 10 | |||
| 9 | #include "common/bit_field.h" | 11 | #include "common/bit_field.h" |
| 10 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 11 | #include "common/quaternion.h" | 13 | #include "common/quaternion.h" |
| @@ -563,6 +565,8 @@ private: | |||
| 563 | using MotionArray = std::array< | 565 | using MotionArray = std::array< |
| 564 | std::array<std::unique_ptr<Input::MotionDevice>, Settings::NativeMotion::NUM_MOTIONS_HID>, | 566 | std::array<std::unique_ptr<Input::MotionDevice>, Settings::NativeMotion::NUM_MOTIONS_HID>, |
| 565 | 10>; | 567 | 10>; |
| 568 | |||
| 569 | std::mutex mutex; | ||
| 566 | ButtonArray buttons; | 570 | ButtonArray buttons; |
| 567 | StickArray sticks; | 571 | StickArray sticks; |
| 568 | VibrationArray vibrations; | 572 | VibrationArray vibrations; |
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index d1dbc659b..1d810562f 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp | |||
| @@ -307,6 +307,9 @@ void NVFlinger::Compose() { | |||
| 307 | } | 307 | } |
| 308 | 308 | ||
| 309 | s64 NVFlinger::GetNextTicks() const { | 309 | s64 NVFlinger::GetNextTicks() const { |
| 310 | if (Settings::values.disable_fps_limit.GetValue()) { | ||
| 311 | return 0; | ||
| 312 | } | ||
| 310 | constexpr s64 max_hertz = 120LL; | 313 | constexpr s64 max_hertz = 120LL; |
| 311 | return (1000000000 * (1LL << swap_interval)) / max_hertz; | 314 | return (1000000000 * (1LL << swap_interval)) / max_hertz; |
| 312 | } | 315 | } |
diff --git a/src/core/hle/service/spl/csrng.cpp b/src/core/hle/service/spl/csrng.cpp index 1beca417c..9c7f89475 100644 --- a/src/core/hle/service/spl/csrng.cpp +++ b/src/core/hle/service/spl/csrng.cpp | |||
| @@ -9,7 +9,7 @@ namespace Service::SPL { | |||
| 9 | CSRNG::CSRNG(Core::System& system_, std::shared_ptr<Module> module_) | 9 | CSRNG::CSRNG(Core::System& system_, std::shared_ptr<Module> module_) |
| 10 | : Interface(system_, std::move(module_), "csrng") { | 10 | : Interface(system_, std::move(module_), "csrng") { |
| 11 | static const FunctionInfo functions[] = { | 11 | static const FunctionInfo functions[] = { |
| 12 | {0, &CSRNG::GetRandomBytes, "GetRandomBytes"}, | 12 | {0, &CSRNG::GenerateRandomBytes, "GenerateRandomBytes"}, |
| 13 | }; | 13 | }; |
| 14 | RegisterHandlers(functions); | 14 | RegisterHandlers(functions); |
| 15 | } | 15 | } |
diff --git a/src/core/hle/service/spl/module.cpp b/src/core/hle/service/spl/module.cpp index 0b5e2b7c3..ebb179aa8 100644 --- a/src/core/hle/service/spl/module.cpp +++ b/src/core/hle/service/spl/module.cpp | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include <vector> | 10 | #include <vector> |
| 11 | #include "common/logging/log.h" | 11 | #include "common/logging/log.h" |
| 12 | #include "common/settings.h" | 12 | #include "common/settings.h" |
| 13 | #include "core/hle/api_version.h" | ||
| 13 | #include "core/hle/ipc_helpers.h" | 14 | #include "core/hle/ipc_helpers.h" |
| 14 | #include "core/hle/service/spl/csrng.h" | 15 | #include "core/hle/service/spl/csrng.h" |
| 15 | #include "core/hle/service/spl/module.h" | 16 | #include "core/hle/service/spl/module.h" |
| @@ -24,7 +25,46 @@ Module::Interface::Interface(Core::System& system_, std::shared_ptr<Module> modu | |||
| 24 | 25 | ||
| 25 | Module::Interface::~Interface() = default; | 26 | Module::Interface::~Interface() = default; |
| 26 | 27 | ||
| 27 | void Module::Interface::GetRandomBytes(Kernel::HLERequestContext& ctx) { | 28 | void Module::Interface::GetConfig(Kernel::HLERequestContext& ctx) { |
| 29 | IPC::RequestParser rp{ctx}; | ||
| 30 | const auto config_item = rp.PopEnum<ConfigItem>(); | ||
| 31 | |||
| 32 | // This should call svcCallSecureMonitor with the appropriate args. | ||
| 33 | // Since we do not have it implemented yet, we will use this for now. | ||
| 34 | const auto smc_result = GetConfigImpl(config_item); | ||
| 35 | const auto result_code = smc_result.Code(); | ||
| 36 | |||
| 37 | if (smc_result.Failed()) { | ||
| 38 | LOG_ERROR(Service_SPL, "called, config_item={}, result_code={}", config_item, | ||
| 39 | result_code.raw); | ||
| 40 | |||
| 41 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 42 | rb.Push(result_code); | ||
| 43 | } | ||
| 44 | |||
| 45 | LOG_DEBUG(Service_SPL, "called, config_item={}, result_code={}, smc_result={}", config_item, | ||
| 46 | result_code.raw, *smc_result); | ||
| 47 | |||
| 48 | IPC::ResponseBuilder rb{ctx, 4}; | ||
| 49 | rb.Push(result_code); | ||
| 50 | rb.Push(*smc_result); | ||
| 51 | } | ||
| 52 | |||
| 53 | void Module::Interface::ModularExponentiate(Kernel::HLERequestContext& ctx) { | ||
| 54 | UNIMPLEMENTED_MSG("ModularExponentiate is not implemented!"); | ||
| 55 | |||
| 56 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 57 | rb.Push(ResultSecureMonitorNotImplemented); | ||
| 58 | } | ||
| 59 | |||
| 60 | void Module::Interface::SetConfig(Kernel::HLERequestContext& ctx) { | ||
| 61 | UNIMPLEMENTED_MSG("SetConfig is not implemented!"); | ||
| 62 | |||
| 63 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 64 | rb.Push(ResultSecureMonitorNotImplemented); | ||
| 65 | } | ||
| 66 | |||
| 67 | void Module::Interface::GenerateRandomBytes(Kernel::HLERequestContext& ctx) { | ||
| 28 | LOG_DEBUG(Service_SPL, "called"); | 68 | LOG_DEBUG(Service_SPL, "called"); |
| 29 | 69 | ||
| 30 | const std::size_t size = ctx.GetWriteBufferSize(); | 70 | const std::size_t size = ctx.GetWriteBufferSize(); |
| @@ -39,6 +79,88 @@ void Module::Interface::GetRandomBytes(Kernel::HLERequestContext& ctx) { | |||
| 39 | rb.Push(ResultSuccess); | 79 | rb.Push(ResultSuccess); |
| 40 | } | 80 | } |
| 41 | 81 | ||
| 82 | void Module::Interface::IsDevelopment(Kernel::HLERequestContext& ctx) { | ||
| 83 | UNIMPLEMENTED_MSG("IsDevelopment is not implemented!"); | ||
| 84 | |||
| 85 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 86 | rb.Push(ResultSecureMonitorNotImplemented); | ||
| 87 | } | ||
| 88 | |||
| 89 | void Module::Interface::SetBootReason(Kernel::HLERequestContext& ctx) { | ||
| 90 | UNIMPLEMENTED_MSG("SetBootReason is not implemented!"); | ||
| 91 | |||
| 92 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 93 | rb.Push(ResultSecureMonitorNotImplemented); | ||
| 94 | } | ||
| 95 | |||
| 96 | void Module::Interface::GetBootReason(Kernel::HLERequestContext& ctx) { | ||
| 97 | UNIMPLEMENTED_MSG("GetBootReason is not implemented!"); | ||
| 98 | |||
| 99 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 100 | rb.Push(ResultSecureMonitorNotImplemented); | ||
| 101 | } | ||
| 102 | |||
| 103 | ResultVal<u64> Module::Interface::GetConfigImpl(ConfigItem config_item) const { | ||
| 104 | switch (config_item) { | ||
| 105 | case ConfigItem::DisableProgramVerification: | ||
| 106 | case ConfigItem::DramId: | ||
| 107 | case ConfigItem::SecurityEngineInterruptNumber: | ||
| 108 | case ConfigItem::FuseVersion: | ||
| 109 | case ConfigItem::HardwareType: | ||
| 110 | case ConfigItem::HardwareState: | ||
| 111 | case ConfigItem::IsRecoveryBoot: | ||
| 112 | case ConfigItem::DeviceId: | ||
| 113 | case ConfigItem::BootReason: | ||
| 114 | case ConfigItem::MemoryMode: | ||
| 115 | case ConfigItem::IsDevelopmentFunctionEnabled: | ||
| 116 | case ConfigItem::KernelConfiguration: | ||
| 117 | case ConfigItem::IsChargerHiZModeEnabled: | ||
| 118 | case ConfigItem::QuestState: | ||
| 119 | case ConfigItem::RegulatorType: | ||
| 120 | case ConfigItem::DeviceUniqueKeyGeneration: | ||
| 121 | case ConfigItem::Package2Hash: | ||
| 122 | return ResultSecureMonitorNotImplemented; | ||
| 123 | case ConfigItem::ExosphereApiVersion: | ||
| 124 | // Get information about the current exosphere version. | ||
| 125 | return MakeResult((u64{HLE::ApiVersion::ATMOSPHERE_RELEASE_VERSION_MAJOR} << 56) | | ||
| 126 | (u64{HLE::ApiVersion::ATMOSPHERE_RELEASE_VERSION_MINOR} << 48) | | ||
| 127 | (u64{HLE::ApiVersion::ATMOSPHERE_RELEASE_VERSION_MICRO} << 40) | | ||
| 128 | (static_cast<u64>(HLE::ApiVersion::GetTargetFirmware()))); | ||
| 129 | case ConfigItem::ExosphereNeedsReboot: | ||
| 130 | // We are executing, so we aren't in the process of rebooting. | ||
| 131 | return MakeResult(u64{0}); | ||
| 132 | case ConfigItem::ExosphereNeedsShutdown: | ||
| 133 | // We are executing, so we aren't in the process of shutting down. | ||
| 134 | return MakeResult(u64{0}); | ||
| 135 | case ConfigItem::ExosphereGitCommitHash: | ||
| 136 | // Get information about the current exosphere git commit hash. | ||
| 137 | return MakeResult(u64{0}); | ||
| 138 | case ConfigItem::ExosphereHasRcmBugPatch: | ||
| 139 | // Get information about whether this unit has the RCM bug patched. | ||
| 140 | return MakeResult(u64{0}); | ||
| 141 | case ConfigItem::ExosphereBlankProdInfo: | ||
| 142 | // Get whether this unit should simulate a "blanked" PRODINFO. | ||
| 143 | return MakeResult(u64{0}); | ||
| 144 | case ConfigItem::ExosphereAllowCalWrites: | ||
| 145 | // Get whether this unit should allow writing to the calibration partition. | ||
| 146 | return MakeResult(u64{0}); | ||
| 147 | case ConfigItem::ExosphereEmummcType: | ||
| 148 | // Get what kind of emummc this unit has active. | ||
| 149 | return MakeResult(u64{0}); | ||
| 150 | case ConfigItem::ExospherePayloadAddress: | ||
| 151 | // Gets the physical address of the reboot payload buffer, if one exists. | ||
| 152 | return ResultSecureMonitorNotInitialized; | ||
| 153 | case ConfigItem::ExosphereLogConfiguration: | ||
| 154 | // Get the log configuration. | ||
| 155 | return MakeResult(u64{0}); | ||
| 156 | case ConfigItem::ExosphereForceEnableUsb30: | ||
| 157 | // Get whether usb 3.0 should be force-enabled. | ||
| 158 | return MakeResult(u64{0}); | ||
| 159 | default: | ||
| 160 | return ResultSecureMonitorInvalidArgument; | ||
| 161 | } | ||
| 162 | } | ||
| 163 | |||
| 42 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { | 164 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { |
| 43 | auto module = std::make_shared<Module>(); | 165 | auto module = std::make_shared<Module>(); |
| 44 | std::make_shared<CSRNG>(system, module)->InstallAsService(service_manager); | 166 | std::make_shared<CSRNG>(system, module)->InstallAsService(service_manager); |
diff --git a/src/core/hle/service/spl/module.h b/src/core/hle/service/spl/module.h index 71855c1bf..61630df80 100644 --- a/src/core/hle/service/spl/module.h +++ b/src/core/hle/service/spl/module.h | |||
| @@ -6,6 +6,8 @@ | |||
| 6 | 6 | ||
| 7 | #include <random> | 7 | #include <random> |
| 8 | #include "core/hle/service/service.h" | 8 | #include "core/hle/service/service.h" |
| 9 | #include "core/hle/service/spl/spl_results.h" | ||
| 10 | #include "core/hle/service/spl/spl_types.h" | ||
| 9 | 11 | ||
| 10 | namespace Core { | 12 | namespace Core { |
| 11 | class System; | 13 | class System; |
| @@ -21,12 +23,21 @@ public: | |||
| 21 | const char* name); | 23 | const char* name); |
| 22 | ~Interface() override; | 24 | ~Interface() override; |
| 23 | 25 | ||
| 24 | void GetRandomBytes(Kernel::HLERequestContext& ctx); | 26 | // General |
| 27 | void GetConfig(Kernel::HLERequestContext& ctx); | ||
| 28 | void ModularExponentiate(Kernel::HLERequestContext& ctx); | ||
| 29 | void SetConfig(Kernel::HLERequestContext& ctx); | ||
| 30 | void GenerateRandomBytes(Kernel::HLERequestContext& ctx); | ||
| 31 | void IsDevelopment(Kernel::HLERequestContext& ctx); | ||
| 32 | void SetBootReason(Kernel::HLERequestContext& ctx); | ||
| 33 | void GetBootReason(Kernel::HLERequestContext& ctx); | ||
| 25 | 34 | ||
| 26 | protected: | 35 | protected: |
| 27 | std::shared_ptr<Module> module; | 36 | std::shared_ptr<Module> module; |
| 28 | 37 | ||
| 29 | private: | 38 | private: |
| 39 | ResultVal<u64> GetConfigImpl(ConfigItem config_item) const; | ||
| 40 | |||
| 30 | std::mt19937 rng; | 41 | std::mt19937 rng; |
| 31 | }; | 42 | }; |
| 32 | }; | 43 | }; |
diff --git a/src/core/hle/service/spl/spl.cpp b/src/core/hle/service/spl/spl.cpp index fff3f3c42..20384042f 100644 --- a/src/core/hle/service/spl/spl.cpp +++ b/src/core/hle/service/spl/spl.cpp | |||
| @@ -10,13 +10,13 @@ SPL::SPL(Core::System& system_, std::shared_ptr<Module> module_) | |||
| 10 | : Interface(system_, std::move(module_), "spl:") { | 10 | : Interface(system_, std::move(module_), "spl:") { |
| 11 | // clang-format off | 11 | // clang-format off |
| 12 | static const FunctionInfo functions[] = { | 12 | static const FunctionInfo functions[] = { |
| 13 | {0, nullptr, "GetConfig"}, | 13 | {0, &SPL::GetConfig, "GetConfig"}, |
| 14 | {1, nullptr, "ModularExponentiate"}, | 14 | {1, &SPL::ModularExponentiate, "ModularExponentiate"}, |
| 15 | {5, nullptr, "SetConfig"}, | 15 | {5, &SPL::SetConfig, "SetConfig"}, |
| 16 | {7, &SPL::GetRandomBytes, "GetRandomBytes"}, | 16 | {7, &SPL::GenerateRandomBytes, "GenerateRandomBytes"}, |
| 17 | {11, nullptr, "IsDevelopment"}, | 17 | {11, &SPL::IsDevelopment, "IsDevelopment"}, |
| 18 | {24, nullptr, "SetBootReason"}, | 18 | {24, &SPL::SetBootReason, "SetBootReason"}, |
| 19 | {25, nullptr, "GetBootReason"}, | 19 | {25, &SPL::GetBootReason, "GetBootReason"}, |
| 20 | }; | 20 | }; |
| 21 | // clang-format on | 21 | // clang-format on |
| 22 | 22 | ||
| @@ -27,22 +27,22 @@ SPL_MIG::SPL_MIG(Core::System& system_, std::shared_ptr<Module> module_) | |||
| 27 | : Interface(system_, std::move(module_), "spl:mig") { | 27 | : Interface(system_, std::move(module_), "spl:mig") { |
| 28 | // clang-format off | 28 | // clang-format off |
| 29 | static const FunctionInfo functions[] = { | 29 | static const FunctionInfo functions[] = { |
| 30 | {0, nullptr, "GetConfig"}, | 30 | {0, &SPL::GetConfig, "GetConfig"}, |
| 31 | {1, nullptr, "ModularExponentiate"}, | 31 | {1, &SPL::ModularExponentiate, "ModularExponentiate"}, |
| 32 | {2, nullptr, "GenerateAesKek"}, | 32 | {2, nullptr, "GenerateAesKek"}, |
| 33 | {3, nullptr, "LoadAesKey"}, | 33 | {3, nullptr, "LoadAesKey"}, |
| 34 | {4, nullptr, "GenerateAesKey"}, | 34 | {4, nullptr, "GenerateAesKey"}, |
| 35 | {5, nullptr, "SetConfig"}, | 35 | {5, &SPL::SetConfig, "SetConfig"}, |
| 36 | {7, &SPL::GetRandomBytes, "GenerateRandomBytes"}, | 36 | {7, &SPL::GenerateRandomBytes, "GenerateRandomBytes"}, |
| 37 | {11, nullptr, "IsDevelopment"}, | 37 | {11, &SPL::IsDevelopment, "IsDevelopment"}, |
| 38 | {14, nullptr, "DecryptAesKey"}, | 38 | {14, nullptr, "DecryptAesKey"}, |
| 39 | {15, nullptr, "CryptAesCtr"}, | 39 | {15, nullptr, "CryptAesCtr"}, |
| 40 | {16, nullptr, "ComputeCmac"}, | 40 | {16, nullptr, "ComputeCmac"}, |
| 41 | {21, nullptr, "AllocateAesKeyslot"}, | 41 | {21, nullptr, "AllocateAesKeyslot"}, |
| 42 | {22, nullptr, "DeallocateAesKeySlot"}, | 42 | {22, nullptr, "DeallocateAesKeySlot"}, |
| 43 | {23, nullptr, "GetAesKeyslotAvailableEvent"}, | 43 | {23, nullptr, "GetAesKeyslotAvailableEvent"}, |
| 44 | {24, nullptr, "SetBootReason"}, | 44 | {24, &SPL::SetBootReason, "SetBootReason"}, |
| 45 | {25, nullptr, "GetBootReason"}, | 45 | {25, &SPL::GetBootReason, "GetBootReason"}, |
| 46 | }; | 46 | }; |
| 47 | // clang-format on | 47 | // clang-format on |
| 48 | 48 | ||
| @@ -53,16 +53,16 @@ SPL_FS::SPL_FS(Core::System& system_, std::shared_ptr<Module> module_) | |||
| 53 | : Interface(system_, std::move(module_), "spl:fs") { | 53 | : Interface(system_, std::move(module_), "spl:fs") { |
| 54 | // clang-format off | 54 | // clang-format off |
| 55 | static const FunctionInfo functions[] = { | 55 | static const FunctionInfo functions[] = { |
| 56 | {0, nullptr, "GetConfig"}, | 56 | {0, &SPL::GetConfig, "GetConfig"}, |
| 57 | {1, nullptr, "ModularExponentiate"}, | 57 | {1, &SPL::ModularExponentiate, "ModularExponentiate"}, |
| 58 | {2, nullptr, "GenerateAesKek"}, | 58 | {2, nullptr, "GenerateAesKek"}, |
| 59 | {3, nullptr, "LoadAesKey"}, | 59 | {3, nullptr, "LoadAesKey"}, |
| 60 | {4, nullptr, "GenerateAesKey"}, | 60 | {4, nullptr, "GenerateAesKey"}, |
| 61 | {5, nullptr, "SetConfig"}, | 61 | {5, &SPL::SetConfig, "SetConfig"}, |
| 62 | {7, &SPL::GetRandomBytes, "GenerateRandomBytes"}, | 62 | {7, &SPL::GenerateRandomBytes, "GenerateRandomBytes"}, |
| 63 | {9, nullptr, "ImportLotusKey"}, | 63 | {9, nullptr, "ImportLotusKey"}, |
| 64 | {10, nullptr, "DecryptLotusMessage"}, | 64 | {10, nullptr, "DecryptLotusMessage"}, |
| 65 | {11, nullptr, "IsDevelopment"}, | 65 | {11, &SPL::IsDevelopment, "IsDevelopment"}, |
| 66 | {12, nullptr, "GenerateSpecificAesKey"}, | 66 | {12, nullptr, "GenerateSpecificAesKey"}, |
| 67 | {14, nullptr, "DecryptAesKey"}, | 67 | {14, nullptr, "DecryptAesKey"}, |
| 68 | {15, nullptr, "CryptAesCtr"}, | 68 | {15, nullptr, "CryptAesCtr"}, |
| @@ -71,8 +71,8 @@ SPL_FS::SPL_FS(Core::System& system_, std::shared_ptr<Module> module_) | |||
| 71 | {21, nullptr, "AllocateAesKeyslot"}, | 71 | {21, nullptr, "AllocateAesKeyslot"}, |
| 72 | {22, nullptr, "DeallocateAesKeySlot"}, | 72 | {22, nullptr, "DeallocateAesKeySlot"}, |
| 73 | {23, nullptr, "GetAesKeyslotAvailableEvent"}, | 73 | {23, nullptr, "GetAesKeyslotAvailableEvent"}, |
| 74 | {24, nullptr, "SetBootReason"}, | 74 | {24, &SPL::SetBootReason, "SetBootReason"}, |
| 75 | {25, nullptr, "GetBootReason"}, | 75 | {25, &SPL::GetBootReason, "GetBootReason"}, |
| 76 | {31, nullptr, "GetPackage2Hash"}, | 76 | {31, nullptr, "GetPackage2Hash"}, |
| 77 | }; | 77 | }; |
| 78 | // clang-format on | 78 | // clang-format on |
| @@ -84,14 +84,14 @@ SPL_SSL::SPL_SSL(Core::System& system_, std::shared_ptr<Module> module_) | |||
| 84 | : Interface(system_, std::move(module_), "spl:ssl") { | 84 | : Interface(system_, std::move(module_), "spl:ssl") { |
| 85 | // clang-format off | 85 | // clang-format off |
| 86 | static const FunctionInfo functions[] = { | 86 | static const FunctionInfo functions[] = { |
| 87 | {0, nullptr, "GetConfig"}, | 87 | {0, &SPL::GetConfig, "GetConfig"}, |
| 88 | {1, nullptr, "ModularExponentiate"}, | 88 | {1, &SPL::ModularExponentiate, "ModularExponentiate"}, |
| 89 | {2, nullptr, "GenerateAesKek"}, | 89 | {2, nullptr, "GenerateAesKek"}, |
| 90 | {3, nullptr, "LoadAesKey"}, | 90 | {3, nullptr, "LoadAesKey"}, |
| 91 | {4, nullptr, "GenerateAesKey"}, | 91 | {4, nullptr, "GenerateAesKey"}, |
| 92 | {5, nullptr, "SetConfig"}, | 92 | {5, &SPL::SetConfig, "SetConfig"}, |
| 93 | {7, &SPL::GetRandomBytes, "GetRandomBytes"}, | 93 | {7, &SPL::GenerateRandomBytes, "GenerateRandomBytes"}, |
| 94 | {11, nullptr, "IsDevelopment"}, | 94 | {11, &SPL::IsDevelopment, "IsDevelopment"}, |
| 95 | {13, nullptr, "DecryptDeviceUniqueData"}, | 95 | {13, nullptr, "DecryptDeviceUniqueData"}, |
| 96 | {14, nullptr, "DecryptAesKey"}, | 96 | {14, nullptr, "DecryptAesKey"}, |
| 97 | {15, nullptr, "CryptAesCtr"}, | 97 | {15, nullptr, "CryptAesCtr"}, |
| @@ -99,8 +99,8 @@ SPL_SSL::SPL_SSL(Core::System& system_, std::shared_ptr<Module> module_) | |||
| 99 | {21, nullptr, "AllocateAesKeyslot"}, | 99 | {21, nullptr, "AllocateAesKeyslot"}, |
| 100 | {22, nullptr, "DeallocateAesKeySlot"}, | 100 | {22, nullptr, "DeallocateAesKeySlot"}, |
| 101 | {23, nullptr, "GetAesKeyslotAvailableEvent"}, | 101 | {23, nullptr, "GetAesKeyslotAvailableEvent"}, |
| 102 | {24, nullptr, "SetBootReason"}, | 102 | {24, &SPL::SetBootReason, "SetBootReason"}, |
| 103 | {25, nullptr, "GetBootReason"}, | 103 | {25, &SPL::GetBootReason, "GetBootReason"}, |
| 104 | {26, nullptr, "DecryptAndStoreSslClientCertKey"}, | 104 | {26, nullptr, "DecryptAndStoreSslClientCertKey"}, |
| 105 | {27, nullptr, "ModularExponentiateWithSslClientCertKey"}, | 105 | {27, nullptr, "ModularExponentiateWithSslClientCertKey"}, |
| 106 | }; | 106 | }; |
| @@ -113,14 +113,14 @@ SPL_ES::SPL_ES(Core::System& system_, std::shared_ptr<Module> module_) | |||
| 113 | : Interface(system_, std::move(module_), "spl:es") { | 113 | : Interface(system_, std::move(module_), "spl:es") { |
| 114 | // clang-format off | 114 | // clang-format off |
| 115 | static const FunctionInfo functions[] = { | 115 | static const FunctionInfo functions[] = { |
| 116 | {0, nullptr, "GetConfig"}, | 116 | {0, &SPL::GetConfig, "GetConfig"}, |
| 117 | {1, nullptr, "ModularExponentiate"}, | 117 | {1, &SPL::ModularExponentiate, "ModularExponentiate"}, |
| 118 | {2, nullptr, "GenerateAesKek"}, | 118 | {2, nullptr, "GenerateAesKek"}, |
| 119 | {3, nullptr, "LoadAesKey"}, | 119 | {3, nullptr, "LoadAesKey"}, |
| 120 | {4, nullptr, "GenerateAesKey"}, | 120 | {4, nullptr, "GenerateAesKey"}, |
| 121 | {5, nullptr, "SetConfig"}, | 121 | {5, &SPL::SetConfig, "SetConfig"}, |
| 122 | {7, &SPL::GetRandomBytes, "GenerateRandomBytes"}, | 122 | {7, &SPL::GenerateRandomBytes, "GenerateRandomBytes"}, |
| 123 | {11, nullptr, "IsDevelopment"}, | 123 | {11, &SPL::IsDevelopment, "IsDevelopment"}, |
| 124 | {13, nullptr, "DecryptDeviceUniqueData"}, | 124 | {13, nullptr, "DecryptDeviceUniqueData"}, |
| 125 | {14, nullptr, "DecryptAesKey"}, | 125 | {14, nullptr, "DecryptAesKey"}, |
| 126 | {15, nullptr, "CryptAesCtr"}, | 126 | {15, nullptr, "CryptAesCtr"}, |
| @@ -131,8 +131,8 @@ SPL_ES::SPL_ES(Core::System& system_, std::shared_ptr<Module> module_) | |||
| 131 | {21, nullptr, "AllocateAesKeyslot"}, | 131 | {21, nullptr, "AllocateAesKeyslot"}, |
| 132 | {22, nullptr, "DeallocateAesKeySlot"}, | 132 | {22, nullptr, "DeallocateAesKeySlot"}, |
| 133 | {23, nullptr, "GetAesKeyslotAvailableEvent"}, | 133 | {23, nullptr, "GetAesKeyslotAvailableEvent"}, |
| 134 | {24, nullptr, "SetBootReason"}, | 134 | {24, &SPL::SetBootReason, "SetBootReason"}, |
| 135 | {25, nullptr, "GetBootReason"}, | 135 | {25, &SPL::GetBootReason, "GetBootReason"}, |
| 136 | {28, nullptr, "DecryptAndStoreDrmDeviceCertKey"}, | 136 | {28, nullptr, "DecryptAndStoreDrmDeviceCertKey"}, |
| 137 | {29, nullptr, "ModularExponentiateWithDrmDeviceCertKey"}, | 137 | {29, nullptr, "ModularExponentiateWithDrmDeviceCertKey"}, |
| 138 | {31, nullptr, "PrepareEsArchiveKey"}, | 138 | {31, nullptr, "PrepareEsArchiveKey"}, |
| @@ -147,14 +147,14 @@ SPL_MANU::SPL_MANU(Core::System& system_, std::shared_ptr<Module> module_) | |||
| 147 | : Interface(system_, std::move(module_), "spl:manu") { | 147 | : Interface(system_, std::move(module_), "spl:manu") { |
| 148 | // clang-format off | 148 | // clang-format off |
| 149 | static const FunctionInfo functions[] = { | 149 | static const FunctionInfo functions[] = { |
| 150 | {0, nullptr, "GetConfig"}, | 150 | {0, &SPL::GetConfig, "GetConfig"}, |
| 151 | {1, nullptr, "ModularExponentiate"}, | 151 | {1, &SPL::ModularExponentiate, "ModularExponentiate"}, |
| 152 | {2, nullptr, "GenerateAesKek"}, | 152 | {2, nullptr, "GenerateAesKek"}, |
| 153 | {3, nullptr, "LoadAesKey"}, | 153 | {3, nullptr, "LoadAesKey"}, |
| 154 | {4, nullptr, "GenerateAesKey"}, | 154 | {4, nullptr, "GenerateAesKey"}, |
| 155 | {5, nullptr, "SetConfig"}, | 155 | {5, &SPL::SetConfig, "SetConfig"}, |
| 156 | {7, &SPL::GetRandomBytes, "GetRandomBytes"}, | 156 | {7, &SPL::GenerateRandomBytes, "GenerateRandomBytes"}, |
| 157 | {11, nullptr, "IsDevelopment"}, | 157 | {11, &SPL::IsDevelopment, "IsDevelopment"}, |
| 158 | {13, nullptr, "DecryptDeviceUniqueData"}, | 158 | {13, nullptr, "DecryptDeviceUniqueData"}, |
| 159 | {14, nullptr, "DecryptAesKey"}, | 159 | {14, nullptr, "DecryptAesKey"}, |
| 160 | {15, nullptr, "CryptAesCtr"}, | 160 | {15, nullptr, "CryptAesCtr"}, |
| @@ -162,8 +162,8 @@ SPL_MANU::SPL_MANU(Core::System& system_, std::shared_ptr<Module> module_) | |||
| 162 | {21, nullptr, "AllocateAesKeyslot"}, | 162 | {21, nullptr, "AllocateAesKeyslot"}, |
| 163 | {22, nullptr, "DeallocateAesKeySlot"}, | 163 | {22, nullptr, "DeallocateAesKeySlot"}, |
| 164 | {23, nullptr, "GetAesKeyslotAvailableEvent"}, | 164 | {23, nullptr, "GetAesKeyslotAvailableEvent"}, |
| 165 | {24, nullptr, "SetBootReason"}, | 165 | {24, &SPL::SetBootReason, "SetBootReason"}, |
| 166 | {25, nullptr, "GetBootReason"}, | 166 | {25, &SPL::GetBootReason, "GetBootReason"}, |
| 167 | {30, nullptr, "ReencryptDeviceUniqueData"}, | 167 | {30, nullptr, "ReencryptDeviceUniqueData"}, |
| 168 | }; | 168 | }; |
| 169 | // clang-format on | 169 | // clang-format on |
diff --git a/src/core/hle/service/spl/spl_results.h b/src/core/hle/service/spl/spl_results.h new file mode 100644 index 000000000..878fa91b7 --- /dev/null +++ b/src/core/hle/service/spl/spl_results.h | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "core/hle/result.h" | ||
| 6 | |||
| 7 | namespace Service::SPL { | ||
| 8 | |||
| 9 | // Description 0 - 99 | ||
| 10 | constexpr ResultCode ResultSecureMonitorError{ErrorModule::SPL, 0}; | ||
| 11 | constexpr ResultCode ResultSecureMonitorNotImplemented{ErrorModule::SPL, 1}; | ||
| 12 | constexpr ResultCode ResultSecureMonitorInvalidArgument{ErrorModule::SPL, 2}; | ||
| 13 | constexpr ResultCode ResultSecureMonitorBusy{ErrorModule::SPL, 3}; | ||
| 14 | constexpr ResultCode ResultSecureMonitorNoAsyncOperation{ErrorModule::SPL, 4}; | ||
| 15 | constexpr ResultCode ResultSecureMonitorInvalidAsyncOperation{ErrorModule::SPL, 5}; | ||
| 16 | constexpr ResultCode ResultSecureMonitorNotPermitted{ErrorModule::SPL, 6}; | ||
| 17 | constexpr ResultCode ResultSecureMonitorNotInitialized{ErrorModule::SPL, 7}; | ||
| 18 | |||
| 19 | constexpr ResultCode ResultInvalidSize{ErrorModule::SPL, 100}; | ||
| 20 | constexpr ResultCode ResultUnknownSecureMonitorError{ErrorModule::SPL, 101}; | ||
| 21 | constexpr ResultCode ResultDecryptionFailed{ErrorModule::SPL, 102}; | ||
| 22 | |||
| 23 | constexpr ResultCode ResultOutOfKeySlots{ErrorModule::SPL, 104}; | ||
| 24 | constexpr ResultCode ResultInvalidKeySlot{ErrorModule::SPL, 105}; | ||
| 25 | constexpr ResultCode ResultBootReasonAlreadySet{ErrorModule::SPL, 106}; | ||
| 26 | constexpr ResultCode ResultBootReasonNotSet{ErrorModule::SPL, 107}; | ||
| 27 | constexpr ResultCode ResultInvalidArgument{ErrorModule::SPL, 108}; | ||
| 28 | |||
| 29 | } // namespace Service::SPL | ||
diff --git a/src/core/hle/service/spl/spl_types.h b/src/core/hle/service/spl/spl_types.h new file mode 100644 index 000000000..23c39f7ed --- /dev/null +++ b/src/core/hle/service/spl/spl_types.h | |||
| @@ -0,0 +1,230 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <span> | ||
| 6 | |||
| 7 | #include "common/bit_field.h" | ||
| 8 | #include "common/common_types.h" | ||
| 9 | |||
| 10 | namespace Service::SPL { | ||
| 11 | |||
| 12 | constexpr size_t AES_128_KEY_SIZE = 0x10; | ||
| 13 | |||
| 14 | namespace Smc { | ||
| 15 | |||
| 16 | enum class FunctionId : u32 { | ||
| 17 | SetConfig = 0xC3000401, | ||
| 18 | GetConfig = 0xC3000002, | ||
| 19 | GetResult = 0xC3000003, | ||
| 20 | GetResultData = 0xC3000404, | ||
| 21 | ModularExponentiate = 0xC3000E05, | ||
| 22 | GenerateRandomBytes = 0xC3000006, | ||
| 23 | GenerateAesKek = 0xC3000007, | ||
| 24 | LoadAesKey = 0xC3000008, | ||
| 25 | ComputeAes = 0xC3000009, | ||
| 26 | GenerateSpecificAesKey = 0xC300000A, | ||
| 27 | ComputeCmac = 0xC300040B, | ||
| 28 | ReencryptDeviceUniqueData = 0xC300D60C, | ||
| 29 | DecryptDeviceUniqueData = 0xC300100D, | ||
| 30 | |||
| 31 | ModularExponentiateWithStorageKey = 0xC300060F, | ||
| 32 | PrepareEsDeviceUniqueKey = 0xC3000610, | ||
| 33 | LoadPreparedAesKey = 0xC3000011, | ||
| 34 | PrepareCommonEsTitleKey = 0xC3000012, | ||
| 35 | |||
| 36 | // Deprecated functions. | ||
| 37 | LoadEsDeviceKey = 0xC300100C, | ||
| 38 | DecryptAndStoreGcKey = 0xC300100E, | ||
| 39 | |||
| 40 | // Atmosphere functions. | ||
| 41 | AtmosphereIramCopy = 0xF0000201, | ||
| 42 | AtmosphereReadWriteRegister = 0xF0000002, | ||
| 43 | |||
| 44 | AtmosphereGetEmummcConfig = 0xF0000404, | ||
| 45 | }; | ||
| 46 | |||
| 47 | enum class CipherMode { | ||
| 48 | CbcEncrypt = 0, | ||
| 49 | CbcDecrypt = 1, | ||
| 50 | Ctr = 2, | ||
| 51 | }; | ||
| 52 | |||
| 53 | enum class DeviceUniqueDataMode { | ||
| 54 | DecryptDeviceUniqueData = 0, | ||
| 55 | DecryptAndStoreGcKey = 1, | ||
| 56 | DecryptAndStoreEsDeviceKey = 2, | ||
| 57 | DecryptAndStoreSslKey = 3, | ||
| 58 | DecryptAndStoreDrmDeviceCertKey = 4, | ||
| 59 | }; | ||
| 60 | |||
| 61 | enum class ModularExponentiateWithStorageKeyMode { | ||
| 62 | Gc = 0, | ||
| 63 | Ssl = 1, | ||
| 64 | DrmDeviceCert = 2, | ||
| 65 | }; | ||
| 66 | |||
| 67 | enum class EsCommonKeyType { | ||
| 68 | TitleKey = 0, | ||
| 69 | ArchiveKey = 1, | ||
| 70 | }; | ||
| 71 | |||
| 72 | struct AsyncOperationKey { | ||
| 73 | u64 value; | ||
| 74 | }; | ||
| 75 | |||
| 76 | } // namespace Smc | ||
| 77 | |||
| 78 | enum class HardwareType { | ||
| 79 | Icosa = 0, | ||
| 80 | Copper = 1, | ||
| 81 | Hoag = 2, | ||
| 82 | Iowa = 3, | ||
| 83 | Calcio = 4, | ||
| 84 | Aula = 5, | ||
| 85 | }; | ||
| 86 | |||
| 87 | enum class SocType { | ||
| 88 | Erista = 0, | ||
| 89 | Mariko = 1, | ||
| 90 | }; | ||
| 91 | |||
| 92 | enum class HardwareState { | ||
| 93 | Development = 0, | ||
| 94 | Production = 1, | ||
| 95 | }; | ||
| 96 | |||
| 97 | enum class MemoryArrangement { | ||
| 98 | Standard = 0, | ||
| 99 | StandardForAppletDev = 1, | ||
| 100 | StandardForSystemDev = 2, | ||
| 101 | Expanded = 3, | ||
| 102 | ExpandedForAppletDev = 4, | ||
| 103 | |||
| 104 | // Note: Dynamic is not official. | ||
| 105 | // Atmosphere uses it to maintain compatibility with firmwares prior to 6.0.0, | ||
| 106 | // which removed the explicit retrieval of memory arrangement from PM. | ||
| 107 | Dynamic = 5, | ||
| 108 | Count, | ||
| 109 | }; | ||
| 110 | |||
| 111 | enum class BootReason { | ||
| 112 | Unknown = 0, | ||
| 113 | AcOk = 1, | ||
| 114 | OnKey = 2, | ||
| 115 | RtcAlarm1 = 3, | ||
| 116 | RtcAlarm2 = 4, | ||
| 117 | }; | ||
| 118 | |||
| 119 | struct BootReasonValue { | ||
| 120 | union { | ||
| 121 | u32 value{}; | ||
| 122 | |||
| 123 | BitField<0, 8, u32> power_intr; | ||
| 124 | BitField<8, 8, u32> rtc_intr; | ||
| 125 | BitField<16, 8, u32> nv_erc; | ||
| 126 | BitField<24, 8, u32> boot_reason; | ||
| 127 | }; | ||
| 128 | }; | ||
| 129 | static_assert(sizeof(BootReasonValue) == sizeof(u32), "BootReasonValue definition!"); | ||
| 130 | |||
| 131 | struct AesKey { | ||
| 132 | std::array<u64, AES_128_KEY_SIZE / sizeof(u64)> data64{}; | ||
| 133 | |||
| 134 | std::span<u8> AsBytes() { | ||
| 135 | return std::span{reinterpret_cast<u8*>(data64.data()), AES_128_KEY_SIZE}; | ||
| 136 | } | ||
| 137 | |||
| 138 | std::span<const u8> AsBytes() const { | ||
| 139 | return std::span{reinterpret_cast<const u8*>(data64.data()), AES_128_KEY_SIZE}; | ||
| 140 | } | ||
| 141 | }; | ||
| 142 | static_assert(sizeof(AesKey) == AES_128_KEY_SIZE, "AesKey definition!"); | ||
| 143 | |||
| 144 | struct IvCtr { | ||
| 145 | std::array<u64, AES_128_KEY_SIZE / sizeof(u64)> data64{}; | ||
| 146 | |||
| 147 | std::span<u8> AsBytes() { | ||
| 148 | return std::span{reinterpret_cast<u8*>(data64.data()), AES_128_KEY_SIZE}; | ||
| 149 | } | ||
| 150 | |||
| 151 | std::span<const u8> AsBytes() const { | ||
| 152 | return std::span{reinterpret_cast<const u8*>(data64.data()), AES_128_KEY_SIZE}; | ||
| 153 | } | ||
| 154 | }; | ||
| 155 | static_assert(sizeof(AesKey) == AES_128_KEY_SIZE, "IvCtr definition!"); | ||
| 156 | |||
| 157 | struct Cmac { | ||
| 158 | std::array<u64, AES_128_KEY_SIZE / sizeof(u64)> data64{}; | ||
| 159 | |||
| 160 | std::span<u8> AsBytes() { | ||
| 161 | return std::span{reinterpret_cast<u8*>(data64.data()), AES_128_KEY_SIZE}; | ||
| 162 | } | ||
| 163 | |||
| 164 | std::span<const u8> AsBytes() const { | ||
| 165 | return std::span{reinterpret_cast<const u8*>(data64.data()), AES_128_KEY_SIZE}; | ||
| 166 | } | ||
| 167 | }; | ||
| 168 | static_assert(sizeof(AesKey) == AES_128_KEY_SIZE, "Cmac definition!"); | ||
| 169 | |||
| 170 | struct AccessKey { | ||
| 171 | std::array<u64, AES_128_KEY_SIZE / sizeof(u64)> data64{}; | ||
| 172 | |||
| 173 | std::span<u8> AsBytes() { | ||
| 174 | return std::span{reinterpret_cast<u8*>(data64.data()), AES_128_KEY_SIZE}; | ||
| 175 | } | ||
| 176 | |||
| 177 | std::span<const u8> AsBytes() const { | ||
| 178 | return std::span{reinterpret_cast<const u8*>(data64.data()), AES_128_KEY_SIZE}; | ||
| 179 | } | ||
| 180 | }; | ||
| 181 | static_assert(sizeof(AesKey) == AES_128_KEY_SIZE, "AccessKey definition!"); | ||
| 182 | |||
| 183 | struct KeySource { | ||
| 184 | std::array<u64, AES_128_KEY_SIZE / sizeof(u64)> data64{}; | ||
| 185 | |||
| 186 | std::span<u8> AsBytes() { | ||
| 187 | return std::span{reinterpret_cast<u8*>(data64.data()), AES_128_KEY_SIZE}; | ||
| 188 | } | ||
| 189 | |||
| 190 | std::span<const u8> AsBytes() const { | ||
| 191 | return std::span{reinterpret_cast<const u8*>(data64.data()), AES_128_KEY_SIZE}; | ||
| 192 | } | ||
| 193 | }; | ||
| 194 | static_assert(sizeof(AesKey) == AES_128_KEY_SIZE, "KeySource definition!"); | ||
| 195 | |||
| 196 | enum class ConfigItem : u32 { | ||
| 197 | // Standard config items. | ||
| 198 | DisableProgramVerification = 1, | ||
| 199 | DramId = 2, | ||
| 200 | SecurityEngineInterruptNumber = 3, | ||
| 201 | FuseVersion = 4, | ||
| 202 | HardwareType = 5, | ||
| 203 | HardwareState = 6, | ||
| 204 | IsRecoveryBoot = 7, | ||
| 205 | DeviceId = 8, | ||
| 206 | BootReason = 9, | ||
| 207 | MemoryMode = 10, | ||
| 208 | IsDevelopmentFunctionEnabled = 11, | ||
| 209 | KernelConfiguration = 12, | ||
| 210 | IsChargerHiZModeEnabled = 13, | ||
| 211 | QuestState = 14, | ||
| 212 | RegulatorType = 15, | ||
| 213 | DeviceUniqueKeyGeneration = 16, | ||
| 214 | Package2Hash = 17, | ||
| 215 | |||
| 216 | // Extension config items for exosphere. | ||
| 217 | ExosphereApiVersion = 65000, | ||
| 218 | ExosphereNeedsReboot = 65001, | ||
| 219 | ExosphereNeedsShutdown = 65002, | ||
| 220 | ExosphereGitCommitHash = 65003, | ||
| 221 | ExosphereHasRcmBugPatch = 65004, | ||
| 222 | ExosphereBlankProdInfo = 65005, | ||
| 223 | ExosphereAllowCalWrites = 65006, | ||
| 224 | ExosphereEmummcType = 65007, | ||
| 225 | ExospherePayloadAddress = 65008, | ||
| 226 | ExosphereLogConfiguration = 65009, | ||
| 227 | ExosphereForceEnableUsb30 = 65010, | ||
| 228 | }; | ||
| 229 | |||
| 230 | } // namespace Service::SPL | ||
diff --git a/src/core/hle/service/time/time_zone_content_manager.cpp b/src/core/hle/service/time/time_zone_content_manager.cpp index bf4402308..c634b6abd 100644 --- a/src/core/hle/service/time/time_zone_content_manager.cpp +++ b/src/core/hle/service/time/time_zone_content_manager.cpp | |||
| @@ -125,7 +125,7 @@ ResultCode TimeZoneContentManager::GetTimeZoneInfoFile(const std::string& locati | |||
| 125 | return ERROR_TIME_NOT_FOUND; | 125 | return ERROR_TIME_NOT_FOUND; |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | vfs_file = zoneinfo_dir->GetFile(location_name); | 128 | vfs_file = zoneinfo_dir->GetFileRelative(location_name); |
| 129 | if (!vfs_file) { | 129 | if (!vfs_file) { |
| 130 | LOG_ERROR(Service_Time, "{:016X} has no file \"{}\"! Using default timezone.", | 130 | LOG_ERROR(Service_Time, "{:016X} has no file \"{}\"! Using default timezone.", |
| 131 | time_zone_binary_titleid, location_name); | 131 | time_zone_binary_titleid, location_name); |
diff --git a/src/input_common/mouse/mouse_input.cpp b/src/input_common/mouse/mouse_input.cpp index a335e6da1..3b052ffb2 100644 --- a/src/input_common/mouse/mouse_input.cpp +++ b/src/input_common/mouse/mouse_input.cpp | |||
| @@ -2,25 +2,23 @@ | |||
| 2 | // Licensed under GPLv2+ | 2 | // Licensed under GPLv2+ |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <stop_token> | ||
| 6 | #include <thread> | ||
| 7 | |||
| 5 | #include "common/settings.h" | 8 | #include "common/settings.h" |
| 6 | #include "input_common/mouse/mouse_input.h" | 9 | #include "input_common/mouse/mouse_input.h" |
| 7 | 10 | ||
| 8 | namespace MouseInput { | 11 | namespace MouseInput { |
| 9 | 12 | ||
| 10 | Mouse::Mouse() { | 13 | Mouse::Mouse() { |
| 11 | update_thread = std::thread(&Mouse::UpdateThread, this); | 14 | update_thread = std::jthread([this](std::stop_token stop_token) { UpdateThread(stop_token); }); |
| 12 | } | 15 | } |
| 13 | 16 | ||
| 14 | Mouse::~Mouse() { | 17 | Mouse::~Mouse() = default; |
| 15 | update_thread_running = false; | ||
| 16 | if (update_thread.joinable()) { | ||
| 17 | update_thread.join(); | ||
| 18 | } | ||
| 19 | } | ||
| 20 | 18 | ||
| 21 | void Mouse::UpdateThread() { | 19 | void Mouse::UpdateThread(std::stop_token stop_token) { |
| 22 | constexpr int update_time = 10; | 20 | constexpr int update_time = 10; |
| 23 | while (update_thread_running) { | 21 | while (!stop_token.stop_requested()) { |
| 24 | for (MouseInfo& info : mouse_info) { | 22 | for (MouseInfo& info : mouse_info) { |
| 25 | const Common::Vec3f angular_direction{ | 23 | const Common::Vec3f angular_direction{ |
| 26 | -info.tilt_direction.y, | 24 | -info.tilt_direction.y, |
diff --git a/src/input_common/mouse/mouse_input.h b/src/input_common/mouse/mouse_input.h index 5a971ad67..c8bae99c1 100644 --- a/src/input_common/mouse/mouse_input.h +++ b/src/input_common/mouse/mouse_input.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <mutex> | 8 | #include <mutex> |
| 9 | #include <stop_token> | ||
| 9 | #include <thread> | 10 | #include <thread> |
| 10 | 11 | ||
| 11 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| @@ -85,7 +86,7 @@ public: | |||
| 85 | [[nodiscard]] const MouseData& GetMouseState(std::size_t button) const; | 86 | [[nodiscard]] const MouseData& GetMouseState(std::size_t button) const; |
| 86 | 87 | ||
| 87 | private: | 88 | private: |
| 88 | void UpdateThread(); | 89 | void UpdateThread(std::stop_token stop_token); |
| 89 | void UpdateYuzuSettings(); | 90 | void UpdateYuzuSettings(); |
| 90 | void StopPanning(); | 91 | void StopPanning(); |
| 91 | 92 | ||
| @@ -105,12 +106,11 @@ private: | |||
| 105 | u16 buttons{}; | 106 | u16 buttons{}; |
| 106 | u16 toggle_buttons{}; | 107 | u16 toggle_buttons{}; |
| 107 | u16 lock_buttons{}; | 108 | u16 lock_buttons{}; |
| 108 | std::thread update_thread; | 109 | std::jthread update_thread; |
| 109 | MouseButton last_button{MouseButton::Undefined}; | 110 | MouseButton last_button{MouseButton::Undefined}; |
| 110 | std::array<MouseInfo, 7> mouse_info; | 111 | std::array<MouseInfo, 7> mouse_info; |
| 111 | Common::SPSCQueue<MouseStatus> mouse_queue; | 112 | Common::SPSCQueue<MouseStatus> mouse_queue; |
| 112 | bool configuring{false}; | 113 | bool configuring{false}; |
| 113 | bool update_thread_running{true}; | ||
| 114 | int mouse_panning_timout{}; | 114 | int mouse_panning_timout{}; |
| 115 | }; | 115 | }; |
| 116 | } // namespace MouseInput | 116 | } // namespace MouseInput |
diff --git a/src/video_core/buffer_cache/buffer_base.h b/src/video_core/buffer_cache/buffer_base.h index a39505903..b121d36a3 100644 --- a/src/video_core/buffer_cache/buffer_base.h +++ b/src/video_core/buffer_cache/buffer_base.h | |||
| @@ -256,6 +256,16 @@ public: | |||
| 256 | stream_score += score; | 256 | stream_score += score; |
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | /// Sets the new frame tick | ||
| 260 | void SetFrameTick(u64 new_frame_tick) noexcept { | ||
| 261 | frame_tick = new_frame_tick; | ||
| 262 | } | ||
| 263 | |||
| 264 | /// Returns the new frame tick | ||
| 265 | [[nodiscard]] u64 FrameTick() const noexcept { | ||
| 266 | return frame_tick; | ||
| 267 | } | ||
| 268 | |||
| 259 | /// Returns the likeliness of this being a stream buffer | 269 | /// Returns the likeliness of this being a stream buffer |
| 260 | [[nodiscard]] int StreamScore() const noexcept { | 270 | [[nodiscard]] int StreamScore() const noexcept { |
| 261 | return stream_score; | 271 | return stream_score; |
| @@ -586,6 +596,7 @@ private: | |||
| 586 | RasterizerInterface* rasterizer = nullptr; | 596 | RasterizerInterface* rasterizer = nullptr; |
| 587 | VAddr cpu_addr = 0; | 597 | VAddr cpu_addr = 0; |
| 588 | Words words; | 598 | Words words; |
| 599 | u64 frame_tick = 0; | ||
| 589 | BufferFlagBits flags{}; | 600 | BufferFlagBits flags{}; |
| 590 | int stream_score = 0; | 601 | int stream_score = 0; |
| 591 | }; | 602 | }; |
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index d371b842f..6d04d00da 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | 16 | ||
| 17 | #include <boost/container/small_vector.hpp> | 17 | #include <boost/container/small_vector.hpp> |
| 18 | 18 | ||
| 19 | #include "common/common_sizes.h" | ||
| 19 | #include "common/common_types.h" | 20 | #include "common/common_types.h" |
| 20 | #include "common/div_ceil.h" | 21 | #include "common/div_ceil.h" |
| 21 | #include "common/microprofile.h" | 22 | #include "common/microprofile.h" |
| @@ -65,6 +66,9 @@ class BufferCache { | |||
| 65 | 66 | ||
| 66 | static constexpr BufferId NULL_BUFFER_ID{0}; | 67 | static constexpr BufferId NULL_BUFFER_ID{0}; |
| 67 | 68 | ||
| 69 | static constexpr u64 EXPECTED_MEMORY = Common::Size_512_MB; | ||
| 70 | static constexpr u64 CRITICAL_MEMORY = Common::Size_1_GB; | ||
| 71 | |||
| 68 | using Maxwell = Tegra::Engines::Maxwell3D::Regs; | 72 | using Maxwell = Tegra::Engines::Maxwell3D::Regs; |
| 69 | 73 | ||
| 70 | using Runtime = typename P::Runtime; | 74 | using Runtime = typename P::Runtime; |
| @@ -102,6 +106,8 @@ public: | |||
| 102 | 106 | ||
| 103 | void TickFrame(); | 107 | void TickFrame(); |
| 104 | 108 | ||
| 109 | void RunGarbageCollector(); | ||
| 110 | |||
| 105 | void WriteMemory(VAddr cpu_addr, u64 size); | 111 | void WriteMemory(VAddr cpu_addr, u64 size); |
| 106 | 112 | ||
| 107 | void CachedWriteMemory(VAddr cpu_addr, u64 size); | 113 | void CachedWriteMemory(VAddr cpu_addr, u64 size); |
| @@ -243,6 +249,8 @@ private: | |||
| 243 | template <bool insert> | 249 | template <bool insert> |
| 244 | void ChangeRegister(BufferId buffer_id); | 250 | void ChangeRegister(BufferId buffer_id); |
| 245 | 251 | ||
| 252 | void TouchBuffer(Buffer& buffer) const noexcept; | ||
| 253 | |||
| 246 | bool SynchronizeBuffer(Buffer& buffer, VAddr cpu_addr, u32 size); | 254 | bool SynchronizeBuffer(Buffer& buffer, VAddr cpu_addr, u32 size); |
| 247 | 255 | ||
| 248 | bool SynchronizeBufferImpl(Buffer& buffer, VAddr cpu_addr, u32 size); | 256 | bool SynchronizeBufferImpl(Buffer& buffer, VAddr cpu_addr, u32 size); |
| @@ -255,6 +263,10 @@ private: | |||
| 255 | 263 | ||
| 256 | void MappedUploadMemory(Buffer& buffer, u64 total_size_bytes, std::span<BufferCopy> copies); | 264 | void MappedUploadMemory(Buffer& buffer, u64 total_size_bytes, std::span<BufferCopy> copies); |
| 257 | 265 | ||
| 266 | void DownloadBufferMemory(Buffer& buffer_id); | ||
| 267 | |||
| 268 | void DownloadBufferMemory(Buffer& buffer_id, VAddr cpu_addr, u64 size); | ||
| 269 | |||
| 258 | void DeleteBuffer(BufferId buffer_id); | 270 | void DeleteBuffer(BufferId buffer_id); |
| 259 | 271 | ||
| 260 | void ReplaceBufferDownloads(BufferId old_buffer_id, BufferId new_buffer_id); | 272 | void ReplaceBufferDownloads(BufferId old_buffer_id, BufferId new_buffer_id); |
| @@ -319,6 +331,10 @@ private: | |||
| 319 | size_t immediate_buffer_capacity = 0; | 331 | size_t immediate_buffer_capacity = 0; |
| 320 | std::unique_ptr<u8[]> immediate_buffer_alloc; | 332 | std::unique_ptr<u8[]> immediate_buffer_alloc; |
| 321 | 333 | ||
| 334 | typename SlotVector<Buffer>::Iterator deletion_iterator; | ||
| 335 | u64 frame_tick = 0; | ||
| 336 | u64 total_used_memory = 0; | ||
| 337 | |||
| 322 | std::array<BufferId, ((1ULL << 39) >> PAGE_BITS)> page_table; | 338 | std::array<BufferId, ((1ULL << 39) >> PAGE_BITS)> page_table; |
| 323 | }; | 339 | }; |
| 324 | 340 | ||
| @@ -332,6 +348,28 @@ BufferCache<P>::BufferCache(VideoCore::RasterizerInterface& rasterizer_, | |||
| 332 | gpu_memory{gpu_memory_}, cpu_memory{cpu_memory_}, runtime{runtime_} { | 348 | gpu_memory{gpu_memory_}, cpu_memory{cpu_memory_}, runtime{runtime_} { |
| 333 | // Ensure the first slot is used for the null buffer | 349 | // Ensure the first slot is used for the null buffer |
| 334 | void(slot_buffers.insert(runtime, NullBufferParams{})); | 350 | void(slot_buffers.insert(runtime, NullBufferParams{})); |
| 351 | deletion_iterator = slot_buffers.end(); | ||
| 352 | } | ||
| 353 | |||
| 354 | template <class P> | ||
| 355 | void BufferCache<P>::RunGarbageCollector() { | ||
| 356 | const bool aggressive_gc = total_used_memory >= CRITICAL_MEMORY; | ||
| 357 | const u64 ticks_to_destroy = aggressive_gc ? 60 : 120; | ||
| 358 | int num_iterations = aggressive_gc ? 64 : 32; | ||
| 359 | for (; num_iterations > 0; --num_iterations) { | ||
| 360 | if (deletion_iterator == slot_buffers.end()) { | ||
| 361 | deletion_iterator = slot_buffers.begin(); | ||
| 362 | } | ||
| 363 | ++deletion_iterator; | ||
| 364 | if (deletion_iterator == slot_buffers.end()) { | ||
| 365 | break; | ||
| 366 | } | ||
| 367 | const auto [buffer_id, buffer] = *deletion_iterator; | ||
| 368 | if (buffer->FrameTick() + ticks_to_destroy < frame_tick) { | ||
| 369 | DownloadBufferMemory(*buffer); | ||
| 370 | DeleteBuffer(buffer_id); | ||
| 371 | } | ||
| 372 | } | ||
| 335 | } | 373 | } |
| 336 | 374 | ||
| 337 | template <class P> | 375 | template <class P> |
| @@ -349,6 +387,10 @@ void BufferCache<P>::TickFrame() { | |||
| 349 | const bool skip_preferred = hits * 256 < shots * 251; | 387 | const bool skip_preferred = hits * 256 < shots * 251; |
| 350 | uniform_buffer_skip_cache_size = skip_preferred ? DEFAULT_SKIP_CACHE_SIZE : 0; | 388 | uniform_buffer_skip_cache_size = skip_preferred ? DEFAULT_SKIP_CACHE_SIZE : 0; |
| 351 | 389 | ||
| 390 | if (Settings::values.use_caches_gc.GetValue() && total_used_memory >= EXPECTED_MEMORY) { | ||
| 391 | RunGarbageCollector(); | ||
| 392 | } | ||
| 393 | ++frame_tick; | ||
| 352 | delayed_destruction_ring.Tick(); | 394 | delayed_destruction_ring.Tick(); |
| 353 | } | 395 | } |
| 354 | 396 | ||
| @@ -371,50 +413,8 @@ void BufferCache<P>::CachedWriteMemory(VAddr cpu_addr, u64 size) { | |||
| 371 | 413 | ||
| 372 | template <class P> | 414 | template <class P> |
| 373 | void BufferCache<P>::DownloadMemory(VAddr cpu_addr, u64 size) { | 415 | void BufferCache<P>::DownloadMemory(VAddr cpu_addr, u64 size) { |
| 374 | ForEachBufferInRange(cpu_addr, size, [&](BufferId, Buffer& buffer) { | 416 | ForEachBufferInRange(cpu_addr, size, |
| 375 | boost::container::small_vector<BufferCopy, 1> copies; | 417 | [&](BufferId, Buffer& buffer) { DownloadBufferMemory(buffer); }); |
| 376 | u64 total_size_bytes = 0; | ||
| 377 | u64 largest_copy = 0; | ||
| 378 | buffer.ForEachDownloadRange(cpu_addr, size, [&](u64 range_offset, u64 range_size) { | ||
| 379 | copies.push_back(BufferCopy{ | ||
| 380 | .src_offset = range_offset, | ||
| 381 | .dst_offset = total_size_bytes, | ||
| 382 | .size = range_size, | ||
| 383 | }); | ||
| 384 | total_size_bytes += range_size; | ||
| 385 | largest_copy = std::max(largest_copy, range_size); | ||
| 386 | }); | ||
| 387 | if (total_size_bytes == 0) { | ||
| 388 | return; | ||
| 389 | } | ||
| 390 | MICROPROFILE_SCOPE(GPU_DownloadMemory); | ||
| 391 | |||
| 392 | if constexpr (USE_MEMORY_MAPS) { | ||
| 393 | auto download_staging = runtime.DownloadStagingBuffer(total_size_bytes); | ||
| 394 | const u8* const mapped_memory = download_staging.mapped_span.data(); | ||
| 395 | const std::span<BufferCopy> copies_span(copies.data(), copies.data() + copies.size()); | ||
| 396 | for (BufferCopy& copy : copies) { | ||
| 397 | // Modify copies to have the staging offset in mind | ||
| 398 | copy.dst_offset += download_staging.offset; | ||
| 399 | } | ||
| 400 | runtime.CopyBuffer(download_staging.buffer, buffer, copies_span); | ||
| 401 | runtime.Finish(); | ||
| 402 | for (const BufferCopy& copy : copies) { | ||
| 403 | const VAddr copy_cpu_addr = buffer.CpuAddr() + copy.src_offset; | ||
| 404 | // Undo the modified offset | ||
| 405 | const u64 dst_offset = copy.dst_offset - download_staging.offset; | ||
| 406 | const u8* copy_mapped_memory = mapped_memory + dst_offset; | ||
| 407 | cpu_memory.WriteBlockUnsafe(copy_cpu_addr, copy_mapped_memory, copy.size); | ||
| 408 | } | ||
| 409 | } else { | ||
| 410 | const std::span<u8> immediate_buffer = ImmediateBuffer(largest_copy); | ||
| 411 | for (const BufferCopy& copy : copies) { | ||
| 412 | buffer.ImmediateDownload(copy.src_offset, immediate_buffer.subspan(0, copy.size)); | ||
| 413 | const VAddr copy_cpu_addr = buffer.CpuAddr() + copy.src_offset; | ||
| 414 | cpu_memory.WriteBlockUnsafe(copy_cpu_addr, immediate_buffer.data(), copy.size); | ||
| 415 | } | ||
| 416 | } | ||
| 417 | }); | ||
| 418 | } | 418 | } |
| 419 | 419 | ||
| 420 | template <class P> | 420 | template <class P> |
| @@ -640,6 +640,7 @@ bool BufferCache<P>::IsRegionGpuModified(VAddr addr, size_t size) { | |||
| 640 | template <class P> | 640 | template <class P> |
| 641 | void BufferCache<P>::BindHostIndexBuffer() { | 641 | void BufferCache<P>::BindHostIndexBuffer() { |
| 642 | Buffer& buffer = slot_buffers[index_buffer.buffer_id]; | 642 | Buffer& buffer = slot_buffers[index_buffer.buffer_id]; |
| 643 | TouchBuffer(buffer); | ||
| 643 | const u32 offset = buffer.Offset(index_buffer.cpu_addr); | 644 | const u32 offset = buffer.Offset(index_buffer.cpu_addr); |
| 644 | const u32 size = index_buffer.size; | 645 | const u32 size = index_buffer.size; |
| 645 | SynchronizeBuffer(buffer, index_buffer.cpu_addr, size); | 646 | SynchronizeBuffer(buffer, index_buffer.cpu_addr, size); |
| @@ -658,6 +659,7 @@ void BufferCache<P>::BindHostVertexBuffers() { | |||
| 658 | for (u32 index = 0; index < NUM_VERTEX_BUFFERS; ++index) { | 659 | for (u32 index = 0; index < NUM_VERTEX_BUFFERS; ++index) { |
| 659 | const Binding& binding = vertex_buffers[index]; | 660 | const Binding& binding = vertex_buffers[index]; |
| 660 | Buffer& buffer = slot_buffers[binding.buffer_id]; | 661 | Buffer& buffer = slot_buffers[binding.buffer_id]; |
| 662 | TouchBuffer(buffer); | ||
| 661 | SynchronizeBuffer(buffer, binding.cpu_addr, binding.size); | 663 | SynchronizeBuffer(buffer, binding.cpu_addr, binding.size); |
| 662 | if (!flags[Dirty::VertexBuffer0 + index]) { | 664 | if (!flags[Dirty::VertexBuffer0 + index]) { |
| 663 | continue; | 665 | continue; |
| @@ -693,6 +695,7 @@ void BufferCache<P>::BindHostGraphicsUniformBuffer(size_t stage, u32 index, u32 | |||
| 693 | const VAddr cpu_addr = binding.cpu_addr; | 695 | const VAddr cpu_addr = binding.cpu_addr; |
| 694 | const u32 size = binding.size; | 696 | const u32 size = binding.size; |
| 695 | Buffer& buffer = slot_buffers[binding.buffer_id]; | 697 | Buffer& buffer = slot_buffers[binding.buffer_id]; |
| 698 | TouchBuffer(buffer); | ||
| 696 | const bool use_fast_buffer = binding.buffer_id != NULL_BUFFER_ID && | 699 | const bool use_fast_buffer = binding.buffer_id != NULL_BUFFER_ID && |
| 697 | size <= uniform_buffer_skip_cache_size && | 700 | size <= uniform_buffer_skip_cache_size && |
| 698 | !buffer.IsRegionGpuModified(cpu_addr, size); | 701 | !buffer.IsRegionGpuModified(cpu_addr, size); |
| @@ -744,6 +747,7 @@ void BufferCache<P>::BindHostGraphicsStorageBuffers(size_t stage) { | |||
| 744 | ForEachEnabledBit(enabled_storage_buffers[stage], [&](u32 index) { | 747 | ForEachEnabledBit(enabled_storage_buffers[stage], [&](u32 index) { |
| 745 | const Binding& binding = storage_buffers[stage][index]; | 748 | const Binding& binding = storage_buffers[stage][index]; |
| 746 | Buffer& buffer = slot_buffers[binding.buffer_id]; | 749 | Buffer& buffer = slot_buffers[binding.buffer_id]; |
| 750 | TouchBuffer(buffer); | ||
| 747 | const u32 size = binding.size; | 751 | const u32 size = binding.size; |
| 748 | SynchronizeBuffer(buffer, binding.cpu_addr, size); | 752 | SynchronizeBuffer(buffer, binding.cpu_addr, size); |
| 749 | 753 | ||
| @@ -766,6 +770,7 @@ void BufferCache<P>::BindHostTransformFeedbackBuffers() { | |||
| 766 | for (u32 index = 0; index < NUM_TRANSFORM_FEEDBACK_BUFFERS; ++index) { | 770 | for (u32 index = 0; index < NUM_TRANSFORM_FEEDBACK_BUFFERS; ++index) { |
| 767 | const Binding& binding = transform_feedback_buffers[index]; | 771 | const Binding& binding = transform_feedback_buffers[index]; |
| 768 | Buffer& buffer = slot_buffers[binding.buffer_id]; | 772 | Buffer& buffer = slot_buffers[binding.buffer_id]; |
| 773 | TouchBuffer(buffer); | ||
| 769 | const u32 size = binding.size; | 774 | const u32 size = binding.size; |
| 770 | SynchronizeBuffer(buffer, binding.cpu_addr, size); | 775 | SynchronizeBuffer(buffer, binding.cpu_addr, size); |
| 771 | 776 | ||
| @@ -784,6 +789,7 @@ void BufferCache<P>::BindHostComputeUniformBuffers() { | |||
| 784 | ForEachEnabledBit(enabled_compute_uniform_buffers, [&](u32 index) { | 789 | ForEachEnabledBit(enabled_compute_uniform_buffers, [&](u32 index) { |
| 785 | const Binding& binding = compute_uniform_buffers[index]; | 790 | const Binding& binding = compute_uniform_buffers[index]; |
| 786 | Buffer& buffer = slot_buffers[binding.buffer_id]; | 791 | Buffer& buffer = slot_buffers[binding.buffer_id]; |
| 792 | TouchBuffer(buffer); | ||
| 787 | const u32 size = binding.size; | 793 | const u32 size = binding.size; |
| 788 | SynchronizeBuffer(buffer, binding.cpu_addr, size); | 794 | SynchronizeBuffer(buffer, binding.cpu_addr, size); |
| 789 | 795 | ||
| @@ -803,6 +809,7 @@ void BufferCache<P>::BindHostComputeStorageBuffers() { | |||
| 803 | ForEachEnabledBit(enabled_compute_storage_buffers, [&](u32 index) { | 809 | ForEachEnabledBit(enabled_compute_storage_buffers, [&](u32 index) { |
| 804 | const Binding& binding = compute_storage_buffers[index]; | 810 | const Binding& binding = compute_storage_buffers[index]; |
| 805 | Buffer& buffer = slot_buffers[binding.buffer_id]; | 811 | Buffer& buffer = slot_buffers[binding.buffer_id]; |
| 812 | TouchBuffer(buffer); | ||
| 806 | const u32 size = binding.size; | 813 | const u32 size = binding.size; |
| 807 | SynchronizeBuffer(buffer, binding.cpu_addr, size); | 814 | SynchronizeBuffer(buffer, binding.cpu_addr, size); |
| 808 | 815 | ||
| @@ -1101,6 +1108,7 @@ BufferId BufferCache<P>::CreateBuffer(VAddr cpu_addr, u32 wanted_size) { | |||
| 1101 | const OverlapResult overlap = ResolveOverlaps(cpu_addr, wanted_size); | 1108 | const OverlapResult overlap = ResolveOverlaps(cpu_addr, wanted_size); |
| 1102 | const u32 size = static_cast<u32>(overlap.end - overlap.begin); | 1109 | const u32 size = static_cast<u32>(overlap.end - overlap.begin); |
| 1103 | const BufferId new_buffer_id = slot_buffers.insert(runtime, rasterizer, overlap.begin, size); | 1110 | const BufferId new_buffer_id = slot_buffers.insert(runtime, rasterizer, overlap.begin, size); |
| 1111 | TouchBuffer(slot_buffers[new_buffer_id]); | ||
| 1104 | for (const BufferId overlap_id : overlap.ids) { | 1112 | for (const BufferId overlap_id : overlap.ids) { |
| 1105 | JoinOverlap(new_buffer_id, overlap_id, !overlap.has_stream_leap); | 1113 | JoinOverlap(new_buffer_id, overlap_id, !overlap.has_stream_leap); |
| 1106 | } | 1114 | } |
| @@ -1122,8 +1130,14 @@ template <class P> | |||
| 1122 | template <bool insert> | 1130 | template <bool insert> |
| 1123 | void BufferCache<P>::ChangeRegister(BufferId buffer_id) { | 1131 | void BufferCache<P>::ChangeRegister(BufferId buffer_id) { |
| 1124 | const Buffer& buffer = slot_buffers[buffer_id]; | 1132 | const Buffer& buffer = slot_buffers[buffer_id]; |
| 1133 | const auto size = buffer.SizeBytes(); | ||
| 1134 | if (insert) { | ||
| 1135 | total_used_memory += Common::AlignUp(size, 1024); | ||
| 1136 | } else { | ||
| 1137 | total_used_memory -= Common::AlignUp(size, 1024); | ||
| 1138 | } | ||
| 1125 | const VAddr cpu_addr_begin = buffer.CpuAddr(); | 1139 | const VAddr cpu_addr_begin = buffer.CpuAddr(); |
| 1126 | const VAddr cpu_addr_end = cpu_addr_begin + buffer.SizeBytes(); | 1140 | const VAddr cpu_addr_end = cpu_addr_begin + size; |
| 1127 | const u64 page_begin = cpu_addr_begin / PAGE_SIZE; | 1141 | const u64 page_begin = cpu_addr_begin / PAGE_SIZE; |
| 1128 | const u64 page_end = Common::DivCeil(cpu_addr_end, PAGE_SIZE); | 1142 | const u64 page_end = Common::DivCeil(cpu_addr_end, PAGE_SIZE); |
| 1129 | for (u64 page = page_begin; page != page_end; ++page) { | 1143 | for (u64 page = page_begin; page != page_end; ++page) { |
| @@ -1136,6 +1150,11 @@ void BufferCache<P>::ChangeRegister(BufferId buffer_id) { | |||
| 1136 | } | 1150 | } |
| 1137 | 1151 | ||
| 1138 | template <class P> | 1152 | template <class P> |
| 1153 | void BufferCache<P>::TouchBuffer(Buffer& buffer) const noexcept { | ||
| 1154 | buffer.SetFrameTick(frame_tick); | ||
| 1155 | } | ||
| 1156 | |||
| 1157 | template <class P> | ||
| 1139 | bool BufferCache<P>::SynchronizeBuffer(Buffer& buffer, VAddr cpu_addr, u32 size) { | 1158 | bool BufferCache<P>::SynchronizeBuffer(Buffer& buffer, VAddr cpu_addr, u32 size) { |
| 1140 | if (buffer.CpuAddr() == 0) { | 1159 | if (buffer.CpuAddr() == 0) { |
| 1141 | return true; | 1160 | return true; |
| @@ -1212,6 +1231,57 @@ void BufferCache<P>::MappedUploadMemory(Buffer& buffer, u64 total_size_bytes, | |||
| 1212 | } | 1231 | } |
| 1213 | 1232 | ||
| 1214 | template <class P> | 1233 | template <class P> |
| 1234 | void BufferCache<P>::DownloadBufferMemory(Buffer& buffer) { | ||
| 1235 | DownloadBufferMemory(buffer, buffer.CpuAddr(), buffer.SizeBytes()); | ||
| 1236 | } | ||
| 1237 | |||
| 1238 | template <class P> | ||
| 1239 | void BufferCache<P>::DownloadBufferMemory(Buffer& buffer, VAddr cpu_addr, u64 size) { | ||
| 1240 | boost::container::small_vector<BufferCopy, 1> copies; | ||
| 1241 | u64 total_size_bytes = 0; | ||
| 1242 | u64 largest_copy = 0; | ||
| 1243 | buffer.ForEachDownloadRange(cpu_addr, size, [&](u64 range_offset, u64 range_size) { | ||
| 1244 | copies.push_back(BufferCopy{ | ||
| 1245 | .src_offset = range_offset, | ||
| 1246 | .dst_offset = total_size_bytes, | ||
| 1247 | .size = range_size, | ||
| 1248 | }); | ||
| 1249 | total_size_bytes += range_size; | ||
| 1250 | largest_copy = std::max(largest_copy, range_size); | ||
| 1251 | }); | ||
| 1252 | if (total_size_bytes == 0) { | ||
| 1253 | return; | ||
| 1254 | } | ||
| 1255 | MICROPROFILE_SCOPE(GPU_DownloadMemory); | ||
| 1256 | |||
| 1257 | if constexpr (USE_MEMORY_MAPS) { | ||
| 1258 | auto download_staging = runtime.DownloadStagingBuffer(total_size_bytes); | ||
| 1259 | const u8* const mapped_memory = download_staging.mapped_span.data(); | ||
| 1260 | const std::span<BufferCopy> copies_span(copies.data(), copies.data() + copies.size()); | ||
| 1261 | for (BufferCopy& copy : copies) { | ||
| 1262 | // Modify copies to have the staging offset in mind | ||
| 1263 | copy.dst_offset += download_staging.offset; | ||
| 1264 | } | ||
| 1265 | runtime.CopyBuffer(download_staging.buffer, buffer, copies_span); | ||
| 1266 | runtime.Finish(); | ||
| 1267 | for (const BufferCopy& copy : copies) { | ||
| 1268 | const VAddr copy_cpu_addr = buffer.CpuAddr() + copy.src_offset; | ||
| 1269 | // Undo the modified offset | ||
| 1270 | const u64 dst_offset = copy.dst_offset - download_staging.offset; | ||
| 1271 | const u8* copy_mapped_memory = mapped_memory + dst_offset; | ||
| 1272 | cpu_memory.WriteBlockUnsafe(copy_cpu_addr, copy_mapped_memory, copy.size); | ||
| 1273 | } | ||
| 1274 | } else { | ||
| 1275 | const std::span<u8> immediate_buffer = ImmediateBuffer(largest_copy); | ||
| 1276 | for (const BufferCopy& copy : copies) { | ||
| 1277 | buffer.ImmediateDownload(copy.src_offset, immediate_buffer.subspan(0, copy.size)); | ||
| 1278 | const VAddr copy_cpu_addr = buffer.CpuAddr() + copy.src_offset; | ||
| 1279 | cpu_memory.WriteBlockUnsafe(copy_cpu_addr, immediate_buffer.data(), copy.size); | ||
| 1280 | } | ||
| 1281 | } | ||
| 1282 | } | ||
| 1283 | |||
| 1284 | template <class P> | ||
| 1215 | void BufferCache<P>::DeleteBuffer(BufferId buffer_id) { | 1285 | void BufferCache<P>::DeleteBuffer(BufferId buffer_id) { |
| 1216 | const auto scalar_replace = [buffer_id](Binding& binding) { | 1286 | const auto scalar_replace = [buffer_id](Binding& binding) { |
| 1217 | if (binding.buffer_id == buffer_id) { | 1287 | if (binding.buffer_id == buffer_id) { |
| @@ -1236,6 +1306,7 @@ void BufferCache<P>::DeleteBuffer(BufferId buffer_id) { | |||
| 1236 | 1306 | ||
| 1237 | Unregister(buffer_id); | 1307 | Unregister(buffer_id); |
| 1238 | delayed_destruction_ring.Push(std::move(slot_buffers[buffer_id])); | 1308 | delayed_destruction_ring.Push(std::move(slot_buffers[buffer_id])); |
| 1309 | slot_buffers.erase(buffer_id); | ||
| 1239 | 1310 | ||
| 1240 | NotifyBufferDeletion(); | 1311 | NotifyBufferDeletion(); |
| 1241 | } | 1312 | } |
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index ffed42a29..335383955 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -242,6 +242,7 @@ public: | |||
| 242 | return 4; | 242 | return 4; |
| 243 | default: | 243 | default: |
| 244 | UNREACHABLE(); | 244 | UNREACHABLE(); |
| 245 | return 1; | ||
| 245 | } | 246 | } |
| 246 | } | 247 | } |
| 247 | 248 | ||
diff --git a/src/video_core/rasterizer_interface.h b/src/video_core/rasterizer_interface.h index f968b5b16..07939432f 100644 --- a/src/video_core/rasterizer_interface.h +++ b/src/video_core/rasterizer_interface.h | |||
| @@ -4,10 +4,10 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <atomic> | ||
| 8 | #include <functional> | 7 | #include <functional> |
| 9 | #include <optional> | 8 | #include <optional> |
| 10 | #include <span> | 9 | #include <span> |
| 10 | #include <stop_token> | ||
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "video_core/engines/fermi_2d.h" | 12 | #include "video_core/engines/fermi_2d.h" |
| 13 | #include "video_core/gpu.h" | 13 | #include "video_core/gpu.h" |
| @@ -123,7 +123,7 @@ public: | |||
| 123 | virtual void UpdatePagesCachedCount(VAddr addr, u64 size, int delta) {} | 123 | virtual void UpdatePagesCachedCount(VAddr addr, u64 size, int delta) {} |
| 124 | 124 | ||
| 125 | /// Initialize disk cached resources for the game being emulated | 125 | /// Initialize disk cached resources for the game being emulated |
| 126 | virtual void LoadDiskResources(u64 title_id, const std::atomic_bool& stop_loading, | 126 | virtual void LoadDiskResources(u64 title_id, std::stop_token stop_loading, |
| 127 | const DiskResourceLoadCallback& callback) {} | 127 | const DiskResourceLoadCallback& callback) {} |
| 128 | 128 | ||
| 129 | /// Grant access to the Guest Driver Profile for recording/obtaining info on the guest driver. | 129 | /// Grant access to the Guest Driver Profile for recording/obtaining info on the guest driver. |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index f87bb269b..eb8bdaa85 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -351,7 +351,7 @@ void RasterizerOpenGL::SetupShaders(bool is_indexed) { | |||
| 351 | } | 351 | } |
| 352 | } | 352 | } |
| 353 | 353 | ||
| 354 | void RasterizerOpenGL::LoadDiskResources(u64 title_id, const std::atomic_bool& stop_loading, | 354 | void RasterizerOpenGL::LoadDiskResources(u64 title_id, std::stop_token stop_loading, |
| 355 | const VideoCore::DiskResourceLoadCallback& callback) { | 355 | const VideoCore::DiskResourceLoadCallback& callback) { |
| 356 | shader_cache.LoadDiskCache(title_id, stop_loading, callback); | 356 | shader_cache.LoadDiskCache(title_id, stop_loading, callback); |
| 357 | } | 357 | } |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 76298517f..9995a563b 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -94,7 +94,7 @@ public: | |||
| 94 | const Tegra::Engines::Fermi2D::Config& copy_config) override; | 94 | const Tegra::Engines::Fermi2D::Config& copy_config) override; |
| 95 | bool AccelerateDisplay(const Tegra::FramebufferConfig& config, VAddr framebuffer_addr, | 95 | bool AccelerateDisplay(const Tegra::FramebufferConfig& config, VAddr framebuffer_addr, |
| 96 | u32 pixel_stride) override; | 96 | u32 pixel_stride) override; |
| 97 | void LoadDiskResources(u64 title_id, const std::atomic_bool& stop_loading, | 97 | void LoadDiskResources(u64 title_id, std::stop_token stop_loading, |
| 98 | const VideoCore::DiskResourceLoadCallback& callback) override; | 98 | const VideoCore::DiskResourceLoadCallback& callback) override; |
| 99 | 99 | ||
| 100 | /// Returns true when there are commands queued to the OpenGL server. | 100 | /// Returns true when there are commands queued to the OpenGL server. |
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp index 5cf7cd151..5a01c59ec 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp | |||
| @@ -331,7 +331,7 @@ ShaderCacheOpenGL::ShaderCacheOpenGL(RasterizerOpenGL& rasterizer_, | |||
| 331 | 331 | ||
| 332 | ShaderCacheOpenGL::~ShaderCacheOpenGL() = default; | 332 | ShaderCacheOpenGL::~ShaderCacheOpenGL() = default; |
| 333 | 333 | ||
| 334 | void ShaderCacheOpenGL::LoadDiskCache(u64 title_id, const std::atomic_bool& stop_loading, | 334 | void ShaderCacheOpenGL::LoadDiskCache(u64 title_id, std::stop_token stop_loading, |
| 335 | const VideoCore::DiskResourceLoadCallback& callback) { | 335 | const VideoCore::DiskResourceLoadCallback& callback) { |
| 336 | disk_cache.BindTitleID(title_id); | 336 | disk_cache.BindTitleID(title_id); |
| 337 | const std::optional transferable = disk_cache.LoadTransferable(); | 337 | const std::optional transferable = disk_cache.LoadTransferable(); |
| @@ -372,7 +372,7 @@ void ShaderCacheOpenGL::LoadDiskCache(u64 title_id, const std::atomic_bool& stop | |||
| 372 | const auto scope = context->Acquire(); | 372 | const auto scope = context->Acquire(); |
| 373 | 373 | ||
| 374 | for (std::size_t i = begin; i < end; ++i) { | 374 | for (std::size_t i = begin; i < end; ++i) { |
| 375 | if (stop_loading) { | 375 | if (stop_loading.stop_requested()) { |
| 376 | return; | 376 | return; |
| 377 | } | 377 | } |
| 378 | const auto& entry = (*transferable)[i]; | 378 | const auto& entry = (*transferable)[i]; |
| @@ -435,7 +435,7 @@ void ShaderCacheOpenGL::LoadDiskCache(u64 title_id, const std::atomic_bool& stop | |||
| 435 | precompiled_cache_altered = true; | 435 | precompiled_cache_altered = true; |
| 436 | return; | 436 | return; |
| 437 | } | 437 | } |
| 438 | if (stop_loading) { | 438 | if (stop_loading.stop_requested()) { |
| 439 | return; | 439 | return; |
| 440 | } | 440 | } |
| 441 | 441 | ||
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.h b/src/video_core/renderer_opengl/gl_shader_cache.h index 2aed0697e..b30308b6f 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.h +++ b/src/video_core/renderer_opengl/gl_shader_cache.h | |||
| @@ -127,7 +127,7 @@ public: | |||
| 127 | ~ShaderCacheOpenGL() override; | 127 | ~ShaderCacheOpenGL() override; |
| 128 | 128 | ||
| 129 | /// Loads disk cache for the current game | 129 | /// Loads disk cache for the current game |
| 130 | void LoadDiskCache(u64 title_id, const std::atomic_bool& stop_loading, | 130 | void LoadDiskCache(u64 title_id, std::stop_token stop_loading, |
| 131 | const VideoCore::DiskResourceLoadCallback& callback); | 131 | const VideoCore::DiskResourceLoadCallback& callback); |
| 132 | 132 | ||
| 133 | /// Gets the current specified shader stage program | 133 | /// Gets the current specified shader stage program |
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index 9b4038615..23948feed 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp | |||
| @@ -737,6 +737,8 @@ Image::Image(TextureCacheRuntime& runtime, const VideoCommon::ImageInfo& info_, | |||
| 737 | } | 737 | } |
| 738 | } | 738 | } |
| 739 | 739 | ||
| 740 | Image::~Image() = default; | ||
| 741 | |||
| 740 | void Image::UploadMemory(const ImageBufferMap& map, | 742 | void Image::UploadMemory(const ImageBufferMap& map, |
| 741 | std::span<const VideoCommon::BufferImageCopy> copies) { | 743 | std::span<const VideoCommon::BufferImageCopy> copies) { |
| 742 | glBindBuffer(GL_PIXEL_UNPACK_BUFFER, map.buffer); | 744 | glBindBuffer(GL_PIXEL_UNPACK_BUFFER, map.buffer); |
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h index df8be12ff..25fe61566 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.h +++ b/src/video_core/renderer_opengl/gl_texture_cache.h | |||
| @@ -143,6 +143,14 @@ public: | |||
| 143 | explicit Image(TextureCacheRuntime&, const VideoCommon::ImageInfo& info, GPUVAddr gpu_addr, | 143 | explicit Image(TextureCacheRuntime&, const VideoCommon::ImageInfo& info, GPUVAddr gpu_addr, |
| 144 | VAddr cpu_addr); | 144 | VAddr cpu_addr); |
| 145 | 145 | ||
| 146 | ~Image(); | ||
| 147 | |||
| 148 | Image(const Image&) = delete; | ||
| 149 | Image& operator=(const Image&) = delete; | ||
| 150 | |||
| 151 | Image(Image&&) = default; | ||
| 152 | Image& operator=(Image&&) = default; | ||
| 153 | |||
| 146 | void UploadMemory(const ImageBufferMap& map, | 154 | void UploadMemory(const ImageBufferMap& map, |
| 147 | std::span<const VideoCommon::BufferImageCopy> copies); | 155 | std::span<const VideoCommon::BufferImageCopy> copies); |
| 148 | 156 | ||
| @@ -235,6 +243,7 @@ struct TextureCacheParams { | |||
| 235 | static constexpr bool ENABLE_VALIDATION = true; | 243 | static constexpr bool ENABLE_VALIDATION = true; |
| 236 | static constexpr bool FRAMEBUFFER_BLITS = true; | 244 | static constexpr bool FRAMEBUFFER_BLITS = true; |
| 237 | static constexpr bool HAS_EMULATED_COPIES = true; | 245 | static constexpr bool HAS_EMULATED_COPIES = true; |
| 246 | static constexpr bool HAS_DEVICE_MEMORY_INFO = false; | ||
| 238 | 247 | ||
| 239 | using Runtime = OpenGL::TextureCacheRuntime; | 248 | using Runtime = OpenGL::TextureCacheRuntime; |
| 240 | using Image = OpenGL::Image; | 249 | using Image = OpenGL::Image; |
diff --git a/src/video_core/renderer_vulkan/vk_master_semaphore.cpp b/src/video_core/renderer_vulkan/vk_master_semaphore.cpp index db78ce3d9..6852c11b0 100644 --- a/src/video_core/renderer_vulkan/vk_master_semaphore.cpp +++ b/src/video_core/renderer_vulkan/vk_master_semaphore.cpp | |||
| @@ -2,8 +2,7 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <atomic> | 5 | #include <thread> |
| 6 | #include <chrono> | ||
| 7 | 6 | ||
| 8 | #include "common/settings.h" | 7 | #include "common/settings.h" |
| 9 | #include "video_core/renderer_vulkan/vk_master_semaphore.h" | 8 | #include "video_core/renderer_vulkan/vk_master_semaphore.h" |
| @@ -12,8 +11,6 @@ | |||
| 12 | 11 | ||
| 13 | namespace Vulkan { | 12 | namespace Vulkan { |
| 14 | 13 | ||
| 15 | using namespace std::chrono_literals; | ||
| 16 | |||
| 17 | MasterSemaphore::MasterSemaphore(const Device& device) { | 14 | MasterSemaphore::MasterSemaphore(const Device& device) { |
| 18 | static constexpr VkSemaphoreTypeCreateInfoKHR semaphore_type_ci{ | 15 | static constexpr VkSemaphoreTypeCreateInfoKHR semaphore_type_ci{ |
| 19 | .sType = VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO_KHR, | 16 | .sType = VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO_KHR, |
| @@ -34,9 +31,9 @@ MasterSemaphore::MasterSemaphore(const Device& device) { | |||
| 34 | // Validation layers have a bug where they fail to track resource usage when using timeline | 31 | // Validation layers have a bug where they fail to track resource usage when using timeline |
| 35 | // semaphores and synchronizing with GetSemaphoreCounterValueKHR. To workaround this issue, have | 32 | // semaphores and synchronizing with GetSemaphoreCounterValueKHR. To workaround this issue, have |
| 36 | // a separate thread waiting for each timeline semaphore value. | 33 | // a separate thread waiting for each timeline semaphore value. |
| 37 | debug_thread = std::thread([this] { | 34 | debug_thread = std::jthread([this](std::stop_token stop_token) { |
| 38 | u64 counter = 0; | 35 | u64 counter = 0; |
| 39 | while (!shutdown) { | 36 | while (!stop_token.stop_requested()) { |
| 40 | if (semaphore.Wait(counter, 10'000'000)) { | 37 | if (semaphore.Wait(counter, 10'000'000)) { |
| 41 | ++counter; | 38 | ++counter; |
| 42 | } | 39 | } |
| @@ -44,13 +41,6 @@ MasterSemaphore::MasterSemaphore(const Device& device) { | |||
| 44 | }); | 41 | }); |
| 45 | } | 42 | } |
| 46 | 43 | ||
| 47 | MasterSemaphore::~MasterSemaphore() { | 44 | MasterSemaphore::~MasterSemaphore() = default; |
| 48 | shutdown = true; | ||
| 49 | |||
| 50 | // This thread might not be started | ||
| 51 | if (debug_thread.joinable()) { | ||
| 52 | debug_thread.join(); | ||
| 53 | } | ||
| 54 | } | ||
| 55 | 45 | ||
| 56 | } // namespace Vulkan | 46 | } // namespace Vulkan |
diff --git a/src/video_core/renderer_vulkan/vk_master_semaphore.h b/src/video_core/renderer_vulkan/vk_master_semaphore.h index 4b6d64daa..ee3cd35d0 100644 --- a/src/video_core/renderer_vulkan/vk_master_semaphore.h +++ b/src/video_core/renderer_vulkan/vk_master_semaphore.h | |||
| @@ -65,11 +65,10 @@ public: | |||
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | private: | 67 | private: |
| 68 | vk::Semaphore semaphore; ///< Timeline semaphore. | 68 | vk::Semaphore semaphore; ///< Timeline semaphore. |
| 69 | std::atomic<u64> gpu_tick{0}; ///< Current known GPU tick. | 69 | std::atomic<u64> gpu_tick{0}; ///< Current known GPU tick. |
| 70 | std::atomic<u64> current_tick{1}; ///< Current logical tick. | 70 | std::atomic<u64> current_tick{1}; ///< Current logical tick. |
| 71 | std::atomic<bool> shutdown{false}; ///< True when the object is being destroyed. | 71 | std::jthread debug_thread; ///< Debug thread to workaround validation layer bugs. |
| 72 | std::thread debug_thread; ///< Debug thread to workaround validation layer bugs. | ||
| 73 | }; | 72 | }; |
| 74 | 73 | ||
| 75 | } // namespace Vulkan | 74 | } // namespace Vulkan |
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 52860b4cf..a2ab4d1ee 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp | |||
| @@ -818,6 +818,10 @@ void TextureCacheRuntime::CopyImage(Image& dst, Image& src, | |||
| 818 | }); | 818 | }); |
| 819 | } | 819 | } |
| 820 | 820 | ||
| 821 | u64 TextureCacheRuntime::GetDeviceLocalMemory() const { | ||
| 822 | return device.GetDeviceLocalMemory(); | ||
| 823 | } | ||
| 824 | |||
| 821 | Image::Image(TextureCacheRuntime& runtime, const ImageInfo& info_, GPUVAddr gpu_addr_, | 825 | Image::Image(TextureCacheRuntime& runtime, const ImageInfo& info_, GPUVAddr gpu_addr_, |
| 822 | VAddr cpu_addr_) | 826 | VAddr cpu_addr_) |
| 823 | : VideoCommon::ImageBase(info_, gpu_addr_, cpu_addr_), scheduler{&runtime.scheduler}, | 827 | : VideoCommon::ImageBase(info_, gpu_addr_, cpu_addr_), scheduler{&runtime.scheduler}, |
| @@ -876,6 +880,8 @@ Image::Image(TextureCacheRuntime& runtime, const ImageInfo& info_, GPUVAddr gpu_ | |||
| 876 | } | 880 | } |
| 877 | } | 881 | } |
| 878 | 882 | ||
| 883 | Image::~Image() = default; | ||
| 884 | |||
| 879 | void Image::UploadMemory(const StagingBufferRef& map, std::span<const BufferImageCopy> copies) { | 885 | void Image::UploadMemory(const StagingBufferRef& map, std::span<const BufferImageCopy> copies) { |
| 880 | // TODO: Move this to another API | 886 | // TODO: Move this to another API |
| 881 | scheduler->RequestOutsideRenderPassOperationContext(); | 887 | scheduler->RequestOutsideRenderPassOperationContext(); |
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h index 4a57d378b..172bcdf98 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.h +++ b/src/video_core/renderer_vulkan/vk_texture_cache.h | |||
| @@ -97,6 +97,8 @@ struct TextureCacheRuntime { | |||
| 97 | // All known Vulkan drivers can natively handle BGR textures | 97 | // All known Vulkan drivers can natively handle BGR textures |
| 98 | return true; | 98 | return true; |
| 99 | } | 99 | } |
| 100 | |||
| 101 | u64 GetDeviceLocalMemory() const; | ||
| 100 | }; | 102 | }; |
| 101 | 103 | ||
| 102 | class Image : public VideoCommon::ImageBase { | 104 | class Image : public VideoCommon::ImageBase { |
| @@ -104,6 +106,14 @@ public: | |||
| 104 | explicit Image(TextureCacheRuntime&, const VideoCommon::ImageInfo& info, GPUVAddr gpu_addr, | 106 | explicit Image(TextureCacheRuntime&, const VideoCommon::ImageInfo& info, GPUVAddr gpu_addr, |
| 105 | VAddr cpu_addr); | 107 | VAddr cpu_addr); |
| 106 | 108 | ||
| 109 | ~Image(); | ||
| 110 | |||
| 111 | Image(const Image&) = delete; | ||
| 112 | Image& operator=(const Image&) = delete; | ||
| 113 | |||
| 114 | Image(Image&&) = default; | ||
| 115 | Image& operator=(Image&&) = default; | ||
| 116 | |||
| 107 | void UploadMemory(const StagingBufferRef& map, | 117 | void UploadMemory(const StagingBufferRef& map, |
| 108 | std::span<const VideoCommon::BufferImageCopy> copies); | 118 | std::span<const VideoCommon::BufferImageCopy> copies); |
| 109 | 119 | ||
| @@ -257,6 +267,7 @@ struct TextureCacheParams { | |||
| 257 | static constexpr bool ENABLE_VALIDATION = true; | 267 | static constexpr bool ENABLE_VALIDATION = true; |
| 258 | static constexpr bool FRAMEBUFFER_BLITS = false; | 268 | static constexpr bool FRAMEBUFFER_BLITS = false; |
| 259 | static constexpr bool HAS_EMULATED_COPIES = false; | 269 | static constexpr bool HAS_EMULATED_COPIES = false; |
| 270 | static constexpr bool HAS_DEVICE_MEMORY_INFO = true; | ||
| 260 | 271 | ||
| 261 | using Runtime = Vulkan::TextureCacheRuntime; | 272 | using Runtime = Vulkan::TextureCacheRuntime; |
| 262 | using Image = Vulkan::Image; | 273 | using Image = Vulkan::Image; |
diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp index 6308aef94..eb1746265 100644 --- a/src/video_core/surface.cpp +++ b/src/video_core/surface.cpp | |||
| @@ -283,4 +283,11 @@ std::pair<u32, u32> GetASTCBlockSize(PixelFormat format) { | |||
| 283 | return {DefaultBlockWidth(format), DefaultBlockHeight(format)}; | 283 | return {DefaultBlockWidth(format), DefaultBlockHeight(format)}; |
| 284 | } | 284 | } |
| 285 | 285 | ||
| 286 | u64 EstimatedDecompressedSize(u64 base_size, PixelFormat format) { | ||
| 287 | constexpr u64 RGBA8_PIXEL_SIZE = 4; | ||
| 288 | const u64 base_block_size = static_cast<u64>(DefaultBlockWidth(format)) * | ||
| 289 | static_cast<u64>(DefaultBlockHeight(format)) * RGBA8_PIXEL_SIZE; | ||
| 290 | return (base_size * base_block_size) / BytesPerBlock(format); | ||
| 291 | } | ||
| 292 | |||
| 286 | } // namespace VideoCore::Surface | 293 | } // namespace VideoCore::Surface |
diff --git a/src/video_core/surface.h b/src/video_core/surface.h index c40ab89d0..1503db81f 100644 --- a/src/video_core/surface.h +++ b/src/video_core/surface.h | |||
| @@ -462,4 +462,6 @@ bool IsPixelFormatSRGB(PixelFormat format); | |||
| 462 | 462 | ||
| 463 | std::pair<u32, u32> GetASTCBlockSize(PixelFormat format); | 463 | std::pair<u32, u32> GetASTCBlockSize(PixelFormat format); |
| 464 | 464 | ||
| 465 | u64 EstimatedDecompressedSize(u64 base_size, PixelFormat format); | ||
| 466 | |||
| 465 | } // namespace VideoCore::Surface | 467 | } // namespace VideoCore::Surface |
diff --git a/src/video_core/texture_cache/image_base.cpp b/src/video_core/texture_cache/image_base.cpp index 9914926b3..ad69d32d1 100644 --- a/src/video_core/texture_cache/image_base.cpp +++ b/src/video_core/texture_cache/image_base.cpp | |||
| @@ -113,6 +113,43 @@ void ImageBase::InsertView(const ImageViewInfo& view_info, ImageViewId image_vie | |||
| 113 | image_view_ids.push_back(image_view_id); | 113 | image_view_ids.push_back(image_view_id); |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | bool ImageBase::IsSafeDownload() const noexcept { | ||
| 117 | // Skip images that were not modified from the GPU | ||
| 118 | if (False(flags & ImageFlagBits::GpuModified)) { | ||
| 119 | return false; | ||
| 120 | } | ||
| 121 | // Skip images that .are. modified from the CPU | ||
| 122 | // We don't want to write sensitive data from the guest | ||
| 123 | if (True(flags & ImageFlagBits::CpuModified)) { | ||
| 124 | return false; | ||
| 125 | } | ||
| 126 | if (info.num_samples > 1) { | ||
| 127 | LOG_WARNING(HW_GPU, "MSAA image downloads are not implemented"); | ||
| 128 | return false; | ||
| 129 | } | ||
| 130 | return true; | ||
| 131 | } | ||
| 132 | |||
| 133 | void ImageBase::CheckBadOverlapState() { | ||
| 134 | if (False(flags & ImageFlagBits::BadOverlap)) { | ||
| 135 | return; | ||
| 136 | } | ||
| 137 | if (!overlapping_images.empty()) { | ||
| 138 | return; | ||
| 139 | } | ||
| 140 | flags &= ~ImageFlagBits::BadOverlap; | ||
| 141 | } | ||
| 142 | |||
| 143 | void ImageBase::CheckAliasState() { | ||
| 144 | if (False(flags & ImageFlagBits::Alias)) { | ||
| 145 | return; | ||
| 146 | } | ||
| 147 | if (!aliased_images.empty()) { | ||
| 148 | return; | ||
| 149 | } | ||
| 150 | flags &= ~ImageFlagBits::Alias; | ||
| 151 | } | ||
| 152 | |||
| 116 | void AddImageAlias(ImageBase& lhs, ImageBase& rhs, ImageId lhs_id, ImageId rhs_id) { | 153 | void AddImageAlias(ImageBase& lhs, ImageBase& rhs, ImageId lhs_id, ImageId rhs_id) { |
| 117 | static constexpr auto OPTIONS = RelaxedOptions::Size | RelaxedOptions::Format; | 154 | static constexpr auto OPTIONS = RelaxedOptions::Size | RelaxedOptions::Format; |
| 118 | ASSERT(lhs.info.type == rhs.info.type); | 155 | ASSERT(lhs.info.type == rhs.info.type); |
diff --git a/src/video_core/texture_cache/image_base.h b/src/video_core/texture_cache/image_base.h index b7f3b7e43..e326cab71 100644 --- a/src/video_core/texture_cache/image_base.h +++ b/src/video_core/texture_cache/image_base.h | |||
| @@ -25,6 +25,12 @@ enum class ImageFlagBits : u32 { | |||
| 25 | Strong = 1 << 5, ///< Exists in the image table, the dimensions are can be trusted | 25 | Strong = 1 << 5, ///< Exists in the image table, the dimensions are can be trusted |
| 26 | Registered = 1 << 6, ///< True when the image is registered | 26 | Registered = 1 << 6, ///< True when the image is registered |
| 27 | Picked = 1 << 7, ///< Temporary flag to mark the image as picked | 27 | Picked = 1 << 7, ///< Temporary flag to mark the image as picked |
| 28 | |||
| 29 | // Garbage Collection Flags | ||
| 30 | BadOverlap = 1 << 8, ///< This image overlaps other but doesn't fit, has higher | ||
| 31 | ///< garbage collection priority | ||
| 32 | Alias = 1 << 9, ///< This image has aliases and has priority on garbage | ||
| 33 | ///< collection | ||
| 28 | }; | 34 | }; |
| 29 | DECLARE_ENUM_FLAG_OPERATORS(ImageFlagBits) | 35 | DECLARE_ENUM_FLAG_OPERATORS(ImageFlagBits) |
| 30 | 36 | ||
| @@ -44,11 +50,16 @@ struct ImageBase { | |||
| 44 | 50 | ||
| 45 | void InsertView(const ImageViewInfo& view_info, ImageViewId image_view_id); | 51 | void InsertView(const ImageViewInfo& view_info, ImageViewId image_view_id); |
| 46 | 52 | ||
| 53 | [[nodiscard]] bool IsSafeDownload() const noexcept; | ||
| 54 | |||
| 47 | [[nodiscard]] bool Overlaps(VAddr overlap_cpu_addr, size_t overlap_size) const noexcept { | 55 | [[nodiscard]] bool Overlaps(VAddr overlap_cpu_addr, size_t overlap_size) const noexcept { |
| 48 | const VAddr overlap_end = overlap_cpu_addr + overlap_size; | 56 | const VAddr overlap_end = overlap_cpu_addr + overlap_size; |
| 49 | return cpu_addr < overlap_end && overlap_cpu_addr < cpu_addr_end; | 57 | return cpu_addr < overlap_end && overlap_cpu_addr < cpu_addr_end; |
| 50 | } | 58 | } |
| 51 | 59 | ||
| 60 | void CheckBadOverlapState(); | ||
| 61 | void CheckAliasState(); | ||
| 62 | |||
| 52 | ImageInfo info; | 63 | ImageInfo info; |
| 53 | 64 | ||
| 54 | u32 guest_size_bytes = 0; | 65 | u32 guest_size_bytes = 0; |
| @@ -72,6 +83,7 @@ struct ImageBase { | |||
| 72 | std::vector<SubresourceBase> slice_subresources; | 83 | std::vector<SubresourceBase> slice_subresources; |
| 73 | 84 | ||
| 74 | std::vector<AliasedImage> aliased_images; | 85 | std::vector<AliasedImage> aliased_images; |
| 86 | std::vector<ImageId> overlapping_images; | ||
| 75 | }; | 87 | }; |
| 76 | 88 | ||
| 77 | struct ImageAllocBase { | 89 | struct ImageAllocBase { |
diff --git a/src/video_core/texture_cache/slot_vector.h b/src/video_core/texture_cache/slot_vector.h index eae3be6ea..6180b8c0e 100644 --- a/src/video_core/texture_cache/slot_vector.h +++ b/src/video_core/texture_cache/slot_vector.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <bit> | ||
| 8 | #include <concepts> | 9 | #include <concepts> |
| 9 | #include <numeric> | 10 | #include <numeric> |
| 10 | #include <type_traits> | 11 | #include <type_traits> |
| @@ -32,6 +33,60 @@ template <class T> | |||
| 32 | requires std::is_nothrow_move_assignable_v<T>&& | 33 | requires std::is_nothrow_move_assignable_v<T>&& |
| 33 | std::is_nothrow_move_constructible_v<T> class SlotVector { | 34 | std::is_nothrow_move_constructible_v<T> class SlotVector { |
| 34 | public: | 35 | public: |
| 36 | class Iterator { | ||
| 37 | friend SlotVector<T>; | ||
| 38 | |||
| 39 | public: | ||
| 40 | constexpr Iterator() = default; | ||
| 41 | |||
| 42 | Iterator& operator++() noexcept { | ||
| 43 | const u64* const bitset = slot_vector->stored_bitset.data(); | ||
| 44 | const u32 size = static_cast<u32>(slot_vector->stored_bitset.size()) * 64; | ||
| 45 | if (id.index < size) { | ||
| 46 | do { | ||
| 47 | ++id.index; | ||
| 48 | } while (id.index < size && !IsValid(bitset)); | ||
| 49 | if (id.index == size) { | ||
| 50 | id.index = SlotId::INVALID_INDEX; | ||
| 51 | } | ||
| 52 | } | ||
| 53 | return *this; | ||
| 54 | } | ||
| 55 | |||
| 56 | Iterator operator++(int) noexcept { | ||
| 57 | const Iterator copy{*this}; | ||
| 58 | ++*this; | ||
| 59 | return copy; | ||
| 60 | } | ||
| 61 | |||
| 62 | bool operator==(const Iterator& other) const noexcept { | ||
| 63 | return id.index == other.id.index; | ||
| 64 | } | ||
| 65 | |||
| 66 | bool operator!=(const Iterator& other) const noexcept { | ||
| 67 | return id.index != other.id.index; | ||
| 68 | } | ||
| 69 | |||
| 70 | std::pair<SlotId, T*> operator*() const noexcept { | ||
| 71 | return {id, std::addressof((*slot_vector)[id])}; | ||
| 72 | } | ||
| 73 | |||
| 74 | T* operator->() const noexcept { | ||
| 75 | return std::addressof((*slot_vector)[id]); | ||
| 76 | } | ||
| 77 | |||
| 78 | private: | ||
| 79 | Iterator(SlotVector<T>* slot_vector_, SlotId id_) noexcept | ||
| 80 | : slot_vector{slot_vector_}, id{id_} {} | ||
| 81 | |||
| 82 | bool IsValid(const u64* bitset) const noexcept { | ||
| 83 | return ((bitset[id.index / 64] >> (id.index % 64)) & 1) != 0; | ||
| 84 | } | ||
| 85 | |||
| 86 | SlotVector<T>* slot_vector; | ||
| 87 | SlotId id; | ||
| 88 | }; | ||
| 89 | |||
| 35 | ~SlotVector() noexcept { | 90 | ~SlotVector() noexcept { |
| 36 | size_t index = 0; | 91 | size_t index = 0; |
| 37 | for (u64 bits : stored_bitset) { | 92 | for (u64 bits : stored_bitset) { |
| @@ -70,6 +125,20 @@ public: | |||
| 70 | ResetStorageBit(id.index); | 125 | ResetStorageBit(id.index); |
| 71 | } | 126 | } |
| 72 | 127 | ||
| 128 | [[nodiscard]] Iterator begin() noexcept { | ||
| 129 | const auto it = std::ranges::find_if(stored_bitset, [](u64 value) { return value != 0; }); | ||
| 130 | if (it == stored_bitset.end()) { | ||
| 131 | return end(); | ||
| 132 | } | ||
| 133 | const u32 word_index = static_cast<u32>(std::distance(it, stored_bitset.begin())); | ||
| 134 | const SlotId first_id{word_index * 64 + static_cast<u32>(std::countr_zero(*it))}; | ||
| 135 | return Iterator(this, first_id); | ||
| 136 | } | ||
| 137 | |||
| 138 | [[nodiscard]] Iterator end() noexcept { | ||
| 139 | return Iterator(this, SlotId{SlotId::INVALID_INDEX}); | ||
| 140 | } | ||
| 141 | |||
| 73 | private: | 142 | private: |
| 74 | struct NonTrivialDummy { | 143 | struct NonTrivialDummy { |
| 75 | NonTrivialDummy() noexcept {} | 144 | NonTrivialDummy() noexcept {} |
| @@ -140,7 +209,6 @@ private: | |||
| 140 | 209 | ||
| 141 | Entry* values = nullptr; | 210 | Entry* values = nullptr; |
| 142 | size_t values_capacity = 0; | 211 | size_t values_capacity = 0; |
| 143 | size_t values_size = 0; | ||
| 144 | 212 | ||
| 145 | std::vector<u64> stored_bitset; | 213 | std::vector<u64> stored_bitset; |
| 146 | std::vector<u32> free_list; | 214 | std::vector<u32> free_list; |
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 59b7c678b..e7f8478b4 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -20,8 +20,10 @@ | |||
| 20 | 20 | ||
| 21 | #include "common/alignment.h" | 21 | #include "common/alignment.h" |
| 22 | #include "common/common_funcs.h" | 22 | #include "common/common_funcs.h" |
| 23 | #include "common/common_sizes.h" | ||
| 23 | #include "common/common_types.h" | 24 | #include "common/common_types.h" |
| 24 | #include "common/logging/log.h" | 25 | #include "common/logging/log.h" |
| 26 | #include "common/settings.h" | ||
| 25 | #include "video_core/compatible_formats.h" | 27 | #include "video_core/compatible_formats.h" |
| 26 | #include "video_core/delayed_destruction_ring.h" | 28 | #include "video_core/delayed_destruction_ring.h" |
| 27 | #include "video_core/dirty_flags.h" | 29 | #include "video_core/dirty_flags.h" |
| @@ -69,12 +71,17 @@ class TextureCache { | |||
| 69 | static constexpr bool FRAMEBUFFER_BLITS = P::FRAMEBUFFER_BLITS; | 71 | static constexpr bool FRAMEBUFFER_BLITS = P::FRAMEBUFFER_BLITS; |
| 70 | /// True when some copies have to be emulated | 72 | /// True when some copies have to be emulated |
| 71 | static constexpr bool HAS_EMULATED_COPIES = P::HAS_EMULATED_COPIES; | 73 | static constexpr bool HAS_EMULATED_COPIES = P::HAS_EMULATED_COPIES; |
| 74 | /// True when the API can provide info about the memory of the device. | ||
| 75 | static constexpr bool HAS_DEVICE_MEMORY_INFO = P::HAS_DEVICE_MEMORY_INFO; | ||
| 72 | 76 | ||
| 73 | /// Image view ID for null descriptors | 77 | /// Image view ID for null descriptors |
| 74 | static constexpr ImageViewId NULL_IMAGE_VIEW_ID{0}; | 78 | static constexpr ImageViewId NULL_IMAGE_VIEW_ID{0}; |
| 75 | /// Sampler ID for bugged sampler ids | 79 | /// Sampler ID for bugged sampler ids |
| 76 | static constexpr SamplerId NULL_SAMPLER_ID{0}; | 80 | static constexpr SamplerId NULL_SAMPLER_ID{0}; |
| 77 | 81 | ||
| 82 | static constexpr u64 DEFAULT_EXPECTED_MEMORY = Common::Size_1_GB; | ||
| 83 | static constexpr u64 DEFAULT_CRITICAL_MEMORY = Common::Size_2_GB; | ||
| 84 | |||
| 78 | using Runtime = typename P::Runtime; | 85 | using Runtime = typename P::Runtime; |
| 79 | using Image = typename P::Image; | 86 | using Image = typename P::Image; |
| 80 | using ImageAlloc = typename P::ImageAlloc; | 87 | using ImageAlloc = typename P::ImageAlloc; |
| @@ -103,6 +110,9 @@ public: | |||
| 103 | /// Notify the cache that a new frame has been queued | 110 | /// Notify the cache that a new frame has been queued |
| 104 | void TickFrame(); | 111 | void TickFrame(); |
| 105 | 112 | ||
| 113 | /// Runs the Garbage Collector. | ||
| 114 | void RunGarbageCollector(); | ||
| 115 | |||
| 106 | /// Return a constant reference to the given image view id | 116 | /// Return a constant reference to the given image view id |
| 107 | [[nodiscard]] const ImageView& GetImageView(ImageViewId id) const noexcept; | 117 | [[nodiscard]] const ImageView& GetImageView(ImageViewId id) const noexcept; |
| 108 | 118 | ||
| @@ -333,6 +343,10 @@ private: | |||
| 333 | std::unordered_map<u64, std::vector<ImageId>, IdentityHash<u64>> page_table; | 343 | std::unordered_map<u64, std::vector<ImageId>, IdentityHash<u64>> page_table; |
| 334 | 344 | ||
| 335 | bool has_deleted_images = false; | 345 | bool has_deleted_images = false; |
| 346 | u64 total_used_memory = 0; | ||
| 347 | u64 minimum_memory; | ||
| 348 | u64 expected_memory; | ||
| 349 | u64 critical_memory; | ||
| 336 | 350 | ||
| 337 | SlotVector<Image> slot_images; | 351 | SlotVector<Image> slot_images; |
| 338 | SlotVector<ImageView> slot_image_views; | 352 | SlotVector<ImageView> slot_image_views; |
| @@ -353,6 +367,7 @@ private: | |||
| 353 | 367 | ||
| 354 | u64 modification_tick = 0; | 368 | u64 modification_tick = 0; |
| 355 | u64 frame_tick = 0; | 369 | u64 frame_tick = 0; |
| 370 | typename SlotVector<Image>::Iterator deletion_iterator; | ||
| 356 | }; | 371 | }; |
| 357 | 372 | ||
| 358 | template <class P> | 373 | template <class P> |
| @@ -373,11 +388,94 @@ TextureCache<P>::TextureCache(Runtime& runtime_, VideoCore::RasterizerInterface& | |||
| 373 | // This way the null resource becomes a compile time constant | 388 | // This way the null resource becomes a compile time constant |
| 374 | void(slot_image_views.insert(runtime, NullImageParams{})); | 389 | void(slot_image_views.insert(runtime, NullImageParams{})); |
| 375 | void(slot_samplers.insert(runtime, sampler_descriptor)); | 390 | void(slot_samplers.insert(runtime, sampler_descriptor)); |
| 391 | |||
| 392 | deletion_iterator = slot_images.begin(); | ||
| 393 | |||
| 394 | if constexpr (HAS_DEVICE_MEMORY_INFO) { | ||
| 395 | const auto device_memory = runtime.GetDeviceLocalMemory(); | ||
| 396 | const u64 possible_expected_memory = (device_memory * 3) / 10; | ||
| 397 | const u64 possible_critical_memory = (device_memory * 6) / 10; | ||
| 398 | expected_memory = std::max(possible_expected_memory, DEFAULT_EXPECTED_MEMORY); | ||
| 399 | critical_memory = std::max(possible_critical_memory, DEFAULT_CRITICAL_MEMORY); | ||
| 400 | minimum_memory = 0; | ||
| 401 | } else { | ||
| 402 | // on OGL we can be more conservatives as the driver takes care. | ||
| 403 | expected_memory = DEFAULT_EXPECTED_MEMORY + Common::Size_512_MB; | ||
| 404 | critical_memory = DEFAULT_CRITICAL_MEMORY + Common::Size_1_GB; | ||
| 405 | minimum_memory = expected_memory; | ||
| 406 | } | ||
| 407 | } | ||
| 408 | |||
| 409 | template <class P> | ||
| 410 | void TextureCache<P>::RunGarbageCollector() { | ||
| 411 | const bool high_priority_mode = total_used_memory >= expected_memory; | ||
| 412 | const bool aggressive_mode = total_used_memory >= critical_memory; | ||
| 413 | const u64 ticks_to_destroy = high_priority_mode ? 60 : 100; | ||
| 414 | int num_iterations = aggressive_mode ? 256 : (high_priority_mode ? 128 : 64); | ||
| 415 | for (; num_iterations > 0; --num_iterations) { | ||
| 416 | if (deletion_iterator == slot_images.end()) { | ||
| 417 | deletion_iterator = slot_images.begin(); | ||
| 418 | if (deletion_iterator == slot_images.end()) { | ||
| 419 | break; | ||
| 420 | } | ||
| 421 | } | ||
| 422 | auto [image_id, image_tmp] = *deletion_iterator; | ||
| 423 | Image* image = image_tmp; // fix clang error. | ||
| 424 | const bool is_alias = True(image->flags & ImageFlagBits::Alias); | ||
| 425 | const bool is_bad_overlap = True(image->flags & ImageFlagBits::BadOverlap); | ||
| 426 | const bool must_download = image->IsSafeDownload(); | ||
| 427 | bool should_care = is_bad_overlap || is_alias || (high_priority_mode && !must_download); | ||
| 428 | const u64 ticks_needed = | ||
| 429 | is_bad_overlap | ||
| 430 | ? ticks_to_destroy >> 4 | ||
| 431 | : ((should_care && aggressive_mode) ? ticks_to_destroy >> 1 : ticks_to_destroy); | ||
| 432 | should_care |= aggressive_mode; | ||
| 433 | if (should_care && image->frame_tick + ticks_needed < frame_tick) { | ||
| 434 | if (is_bad_overlap) { | ||
| 435 | const bool overlap_check = std::ranges::all_of( | ||
| 436 | image->overlapping_images, [&, image](const ImageId& overlap_id) { | ||
| 437 | auto& overlap = slot_images[overlap_id]; | ||
| 438 | return overlap.frame_tick >= image->frame_tick; | ||
| 439 | }); | ||
| 440 | if (!overlap_check) { | ||
| 441 | ++deletion_iterator; | ||
| 442 | continue; | ||
| 443 | } | ||
| 444 | } | ||
| 445 | if (!is_bad_overlap && must_download) { | ||
| 446 | const bool alias_check = std::ranges::none_of( | ||
| 447 | image->aliased_images, [&, image](const AliasedImage& alias) { | ||
| 448 | auto& alias_image = slot_images[alias.id]; | ||
| 449 | return (alias_image.frame_tick < image->frame_tick) || | ||
| 450 | (alias_image.modification_tick < image->modification_tick); | ||
| 451 | }); | ||
| 452 | |||
| 453 | if (alias_check) { | ||
| 454 | auto map = runtime.DownloadStagingBuffer(image->unswizzled_size_bytes); | ||
| 455 | const auto copies = FullDownloadCopies(image->info); | ||
| 456 | image->DownloadMemory(map, copies); | ||
| 457 | runtime.Finish(); | ||
| 458 | SwizzleImage(gpu_memory, image->gpu_addr, image->info, copies, map.mapped_span); | ||
| 459 | } | ||
| 460 | } | ||
| 461 | if (True(image->flags & ImageFlagBits::Tracked)) { | ||
| 462 | UntrackImage(*image); | ||
| 463 | } | ||
| 464 | UnregisterImage(image_id); | ||
| 465 | DeleteImage(image_id); | ||
| 466 | if (is_bad_overlap) { | ||
| 467 | ++num_iterations; | ||
| 468 | } | ||
| 469 | } | ||
| 470 | ++deletion_iterator; | ||
| 471 | } | ||
| 376 | } | 472 | } |
| 377 | 473 | ||
| 378 | template <class P> | 474 | template <class P> |
| 379 | void TextureCache<P>::TickFrame() { | 475 | void TextureCache<P>::TickFrame() { |
| 380 | // Tick sentenced resources in this order to ensure they are destroyed in the right order | 476 | if (Settings::values.use_caches_gc.GetValue() && total_used_memory > minimum_memory) { |
| 477 | RunGarbageCollector(); | ||
| 478 | } | ||
| 381 | sentenced_images.Tick(); | 479 | sentenced_images.Tick(); |
| 382 | sentenced_framebuffers.Tick(); | 480 | sentenced_framebuffers.Tick(); |
| 383 | sentenced_image_view.Tick(); | 481 | sentenced_image_view.Tick(); |
| @@ -568,17 +666,7 @@ template <class P> | |||
| 568 | void TextureCache<P>::DownloadMemory(VAddr cpu_addr, size_t size) { | 666 | void TextureCache<P>::DownloadMemory(VAddr cpu_addr, size_t size) { |
| 569 | std::vector<ImageId> images; | 667 | std::vector<ImageId> images; |
| 570 | ForEachImageInRegion(cpu_addr, size, [this, &images](ImageId image_id, ImageBase& image) { | 668 | ForEachImageInRegion(cpu_addr, size, [this, &images](ImageId image_id, ImageBase& image) { |
| 571 | // Skip images that were not modified from the GPU | 669 | if (!image.IsSafeDownload()) { |
| 572 | if (False(image.flags & ImageFlagBits::GpuModified)) { | ||
| 573 | return; | ||
| 574 | } | ||
| 575 | // Skip images that .are. modified from the CPU | ||
| 576 | // We don't want to write sensitive data from the guest | ||
| 577 | if (True(image.flags & ImageFlagBits::CpuModified)) { | ||
| 578 | return; | ||
| 579 | } | ||
| 580 | if (image.info.num_samples > 1) { | ||
| 581 | LOG_WARNING(HW_GPU, "MSAA image downloads are not implemented"); | ||
| 582 | return; | 670 | return; |
| 583 | } | 671 | } |
| 584 | image.flags &= ~ImageFlagBits::GpuModified; | 672 | image.flags &= ~ImageFlagBits::GpuModified; |
| @@ -967,6 +1055,7 @@ ImageId TextureCache<P>::JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, VA | |||
| 967 | std::vector<ImageId> overlap_ids; | 1055 | std::vector<ImageId> overlap_ids; |
| 968 | std::vector<ImageId> left_aliased_ids; | 1056 | std::vector<ImageId> left_aliased_ids; |
| 969 | std::vector<ImageId> right_aliased_ids; | 1057 | std::vector<ImageId> right_aliased_ids; |
| 1058 | std::vector<ImageId> bad_overlap_ids; | ||
| 970 | ForEachImageInRegion(cpu_addr, size_bytes, [&](ImageId overlap_id, ImageBase& overlap) { | 1059 | ForEachImageInRegion(cpu_addr, size_bytes, [&](ImageId overlap_id, ImageBase& overlap) { |
| 971 | if (info.type != overlap.info.type) { | 1060 | if (info.type != overlap.info.type) { |
| 972 | return; | 1061 | return; |
| @@ -992,9 +1081,14 @@ ImageId TextureCache<P>::JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, VA | |||
| 992 | const ImageBase new_image_base(new_info, gpu_addr, cpu_addr); | 1081 | const ImageBase new_image_base(new_info, gpu_addr, cpu_addr); |
| 993 | if (IsSubresource(new_info, overlap, gpu_addr, options, broken_views, native_bgr)) { | 1082 | if (IsSubresource(new_info, overlap, gpu_addr, options, broken_views, native_bgr)) { |
| 994 | left_aliased_ids.push_back(overlap_id); | 1083 | left_aliased_ids.push_back(overlap_id); |
| 1084 | overlap.flags |= ImageFlagBits::Alias; | ||
| 995 | } else if (IsSubresource(overlap.info, new_image_base, overlap.gpu_addr, options, | 1085 | } else if (IsSubresource(overlap.info, new_image_base, overlap.gpu_addr, options, |
| 996 | broken_views, native_bgr)) { | 1086 | broken_views, native_bgr)) { |
| 997 | right_aliased_ids.push_back(overlap_id); | 1087 | right_aliased_ids.push_back(overlap_id); |
| 1088 | overlap.flags |= ImageFlagBits::Alias; | ||
| 1089 | } else { | ||
| 1090 | bad_overlap_ids.push_back(overlap_id); | ||
| 1091 | overlap.flags |= ImageFlagBits::BadOverlap; | ||
| 998 | } | 1092 | } |
| 999 | }); | 1093 | }); |
| 1000 | const ImageId new_image_id = slot_images.insert(runtime, new_info, gpu_addr, cpu_addr); | 1094 | const ImageId new_image_id = slot_images.insert(runtime, new_info, gpu_addr, cpu_addr); |
| @@ -1022,10 +1116,18 @@ ImageId TextureCache<P>::JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, VA | |||
| 1022 | for (const ImageId aliased_id : right_aliased_ids) { | 1116 | for (const ImageId aliased_id : right_aliased_ids) { |
| 1023 | ImageBase& aliased = slot_images[aliased_id]; | 1117 | ImageBase& aliased = slot_images[aliased_id]; |
| 1024 | AddImageAlias(new_image_base, aliased, new_image_id, aliased_id); | 1118 | AddImageAlias(new_image_base, aliased, new_image_id, aliased_id); |
| 1119 | new_image.flags |= ImageFlagBits::Alias; | ||
| 1025 | } | 1120 | } |
| 1026 | for (const ImageId aliased_id : left_aliased_ids) { | 1121 | for (const ImageId aliased_id : left_aliased_ids) { |
| 1027 | ImageBase& aliased = slot_images[aliased_id]; | 1122 | ImageBase& aliased = slot_images[aliased_id]; |
| 1028 | AddImageAlias(aliased, new_image_base, aliased_id, new_image_id); | 1123 | AddImageAlias(aliased, new_image_base, aliased_id, new_image_id); |
| 1124 | new_image.flags |= ImageFlagBits::Alias; | ||
| 1125 | } | ||
| 1126 | for (const ImageId aliased_id : bad_overlap_ids) { | ||
| 1127 | ImageBase& aliased = slot_images[aliased_id]; | ||
| 1128 | aliased.overlapping_images.push_back(new_image_id); | ||
| 1129 | new_image.overlapping_images.push_back(aliased_id); | ||
| 1130 | new_image.flags |= ImageFlagBits::BadOverlap; | ||
| 1029 | } | 1131 | } |
| 1030 | RegisterImage(new_image_id); | 1132 | RegisterImage(new_image_id); |
| 1031 | return new_image_id; | 1133 | return new_image_id; |
| @@ -1195,6 +1297,13 @@ void TextureCache<P>::RegisterImage(ImageId image_id) { | |||
| 1195 | image.flags |= ImageFlagBits::Registered; | 1297 | image.flags |= ImageFlagBits::Registered; |
| 1196 | ForEachPage(image.cpu_addr, image.guest_size_bytes, | 1298 | ForEachPage(image.cpu_addr, image.guest_size_bytes, |
| 1197 | [this, image_id](u64 page) { page_table[page].push_back(image_id); }); | 1299 | [this, image_id](u64 page) { page_table[page].push_back(image_id); }); |
| 1300 | u64 tentative_size = std::max(image.guest_size_bytes, image.unswizzled_size_bytes); | ||
| 1301 | if ((IsPixelFormatASTC(image.info.format) && | ||
| 1302 | True(image.flags & ImageFlagBits::AcceleratedUpload)) || | ||
| 1303 | True(image.flags & ImageFlagBits::Converted)) { | ||
| 1304 | tentative_size = EstimatedDecompressedSize(tentative_size, image.info.format); | ||
| 1305 | } | ||
| 1306 | total_used_memory += Common::AlignUp(tentative_size, 1024); | ||
| 1198 | } | 1307 | } |
| 1199 | 1308 | ||
| 1200 | template <class P> | 1309 | template <class P> |
| @@ -1203,6 +1312,14 @@ void TextureCache<P>::UnregisterImage(ImageId image_id) { | |||
| 1203 | ASSERT_MSG(True(image.flags & ImageFlagBits::Registered), | 1312 | ASSERT_MSG(True(image.flags & ImageFlagBits::Registered), |
| 1204 | "Trying to unregister an already registered image"); | 1313 | "Trying to unregister an already registered image"); |
| 1205 | image.flags &= ~ImageFlagBits::Registered; | 1314 | image.flags &= ~ImageFlagBits::Registered; |
| 1315 | image.flags &= ~ImageFlagBits::BadOverlap; | ||
| 1316 | u64 tentative_size = std::max(image.guest_size_bytes, image.unswizzled_size_bytes); | ||
| 1317 | if ((IsPixelFormatASTC(image.info.format) && | ||
| 1318 | True(image.flags & ImageFlagBits::AcceleratedUpload)) || | ||
| 1319 | True(image.flags & ImageFlagBits::Converted)) { | ||
| 1320 | tentative_size = EstimatedDecompressedSize(tentative_size, image.info.format); | ||
| 1321 | } | ||
| 1322 | total_used_memory -= Common::AlignUp(tentative_size, 1024); | ||
| 1206 | ForEachPage(image.cpu_addr, image.guest_size_bytes, [this, image_id](u64 page) { | 1323 | ForEachPage(image.cpu_addr, image.guest_size_bytes, [this, image_id](u64 page) { |
| 1207 | const auto page_it = page_table.find(page); | 1324 | const auto page_it = page_table.find(page); |
| 1208 | if (page_it == page_table.end()) { | 1325 | if (page_it == page_table.end()) { |
| @@ -1276,9 +1393,19 @@ void TextureCache<P>::DeleteImage(ImageId image_id) { | |||
| 1276 | std::erase_if(other_image.aliased_images, [image_id](const AliasedImage& other_alias) { | 1393 | std::erase_if(other_image.aliased_images, [image_id](const AliasedImage& other_alias) { |
| 1277 | return other_alias.id == image_id; | 1394 | return other_alias.id == image_id; |
| 1278 | }); | 1395 | }); |
| 1396 | other_image.CheckAliasState(); | ||
| 1279 | ASSERT_MSG(num_removed_aliases == 1, "Invalid number of removed aliases: {}", | 1397 | ASSERT_MSG(num_removed_aliases == 1, "Invalid number of removed aliases: {}", |
| 1280 | num_removed_aliases); | 1398 | num_removed_aliases); |
| 1281 | } | 1399 | } |
| 1400 | for (const ImageId overlap_id : image.overlapping_images) { | ||
| 1401 | ImageBase& other_image = slot_images[overlap_id]; | ||
| 1402 | [[maybe_unused]] const size_t num_removed_overlaps = std::erase_if( | ||
| 1403 | other_image.overlapping_images, | ||
| 1404 | [image_id](const ImageId other_overlap_id) { return other_overlap_id == image_id; }); | ||
| 1405 | other_image.CheckBadOverlapState(); | ||
| 1406 | ASSERT_MSG(num_removed_overlaps == 1, "Invalid number of removed overlapps: {}", | ||
| 1407 | num_removed_overlaps); | ||
| 1408 | } | ||
| 1282 | for (const ImageViewId image_view_id : image_view_ids) { | 1409 | for (const ImageViewId image_view_id : image_view_ids) { |
| 1283 | sentenced_image_view.Push(std::move(slot_image_views[image_view_id])); | 1410 | sentenced_image_view.Push(std::move(slot_image_views[image_view_id])); |
| 1284 | slot_image_views.erase(image_view_id); | 1411 | slot_image_views.erase(image_view_id); |
diff --git a/src/video_core/texture_cache/util.cpp b/src/video_core/texture_cache/util.cpp index 6835fd747..4efe042b6 100644 --- a/src/video_core/texture_cache/util.cpp +++ b/src/video_core/texture_cache/util.cpp | |||
| @@ -581,6 +581,8 @@ void SwizzleBlockLinearImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr | |||
| 581 | 581 | ||
| 582 | for (s32 layer = 0; layer < info.resources.layers; ++layer) { | 582 | for (s32 layer = 0; layer < info.resources.layers; ++layer) { |
| 583 | const std::span<const u8> src = input.subspan(host_offset); | 583 | const std::span<const u8> src = input.subspan(host_offset); |
| 584 | gpu_memory.ReadBlockUnsafe(gpu_addr + guest_offset, dst.data(), dst.size_bytes()); | ||
| 585 | |||
| 584 | SwizzleTexture(dst, src, bytes_per_block, num_tiles.width, num_tiles.height, | 586 | SwizzleTexture(dst, src, bytes_per_block, num_tiles.width, num_tiles.height, |
| 585 | num_tiles.depth, block.height, block.depth); | 587 | num_tiles.depth, block.height, block.depth); |
| 586 | 588 | ||
diff --git a/src/video_core/vulkan_common/nsight_aftermath_tracker.cpp b/src/video_core/vulkan_common/nsight_aftermath_tracker.cpp index f0ee76519..758c038ba 100644 --- a/src/video_core/vulkan_common/nsight_aftermath_tracker.cpp +++ b/src/video_core/vulkan_common/nsight_aftermath_tracker.cpp | |||
| @@ -50,7 +50,7 @@ NsightAftermathTracker::NsightAftermathTracker() { | |||
| 50 | } | 50 | } |
| 51 | dump_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::LogDir) / "gpucrash"; | 51 | dump_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::LogDir) / "gpucrash"; |
| 52 | 52 | ||
| 53 | void(Common::FS::RemoveDirRecursively(dump_dir)); | 53 | Common::FS::RemoveDirRecursively(dump_dir); |
| 54 | if (!Common::FS::CreateDir(dump_dir)) { | 54 | if (!Common::FS::CreateDir(dump_dir)) { |
| 55 | LOG_ERROR(Render_Vulkan, "Failed to create Nsight Aftermath dump directory"); | 55 | LOG_ERROR(Render_Vulkan, "Failed to create Nsight Aftermath dump directory"); |
| 56 | return; | 56 | return; |
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index 64206b3d2..707a8b8fb 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp | |||
| @@ -408,6 +408,7 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 408 | } | 408 | } |
| 409 | logical = vk::Device::Create(physical, queue_cis, extensions, first_next, dld); | 409 | logical = vk::Device::Create(physical, queue_cis, extensions, first_next, dld); |
| 410 | 410 | ||
| 411 | CollectPhysicalMemoryInfo(); | ||
| 411 | CollectTelemetryParameters(); | 412 | CollectTelemetryParameters(); |
| 412 | CollectToolingInfo(); | 413 | CollectToolingInfo(); |
| 413 | 414 | ||
| @@ -818,6 +819,17 @@ void Device::CollectTelemetryParameters() { | |||
| 818 | } | 819 | } |
| 819 | } | 820 | } |
| 820 | 821 | ||
| 822 | void Device::CollectPhysicalMemoryInfo() { | ||
| 823 | const auto mem_properties = physical.GetMemoryProperties(); | ||
| 824 | const std::size_t num_properties = mem_properties.memoryHeapCount; | ||
| 825 | device_access_memory = 0; | ||
| 826 | for (std::size_t element = 0; element < num_properties; element++) { | ||
| 827 | if ((mem_properties.memoryHeaps[element].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) != 0) { | ||
| 828 | device_access_memory += mem_properties.memoryHeaps[element].size; | ||
| 829 | } | ||
| 830 | } | ||
| 831 | } | ||
| 832 | |||
| 821 | void Device::CollectToolingInfo() { | 833 | void Device::CollectToolingInfo() { |
| 822 | if (!ext_tooling_info) { | 834 | if (!ext_tooling_info) { |
| 823 | return; | 835 | return; |
diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index 67d70cd22..a1aba973b 100644 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h | |||
| @@ -225,6 +225,10 @@ public: | |||
| 225 | return use_asynchronous_shaders; | 225 | return use_asynchronous_shaders; |
| 226 | } | 226 | } |
| 227 | 227 | ||
| 228 | u64 GetDeviceLocalMemory() const { | ||
| 229 | return device_access_memory; | ||
| 230 | } | ||
| 231 | |||
| 228 | private: | 232 | private: |
| 229 | /// Checks if the physical device is suitable. | 233 | /// Checks if the physical device is suitable. |
| 230 | void CheckSuitability(bool requires_swapchain) const; | 234 | void CheckSuitability(bool requires_swapchain) const; |
| @@ -244,6 +248,9 @@ private: | |||
| 244 | /// Collects information about attached tools. | 248 | /// Collects information about attached tools. |
| 245 | void CollectToolingInfo(); | 249 | void CollectToolingInfo(); |
| 246 | 250 | ||
| 251 | /// Collects information about the device's local memory. | ||
| 252 | void CollectPhysicalMemoryInfo(); | ||
| 253 | |||
| 247 | /// Returns a list of queue initialization descriptors. | 254 | /// Returns a list of queue initialization descriptors. |
| 248 | std::vector<VkDeviceQueueCreateInfo> GetDeviceQueueCreateInfos() const; | 255 | std::vector<VkDeviceQueueCreateInfo> GetDeviceQueueCreateInfos() const; |
| 249 | 256 | ||
| @@ -302,6 +309,8 @@ private: | |||
| 302 | 309 | ||
| 303 | /// Nsight Aftermath GPU crash tracker | 310 | /// Nsight Aftermath GPU crash tracker |
| 304 | std::unique_ptr<NsightAftermathTracker> nsight_aftermath_tracker; | 311 | std::unique_ptr<NsightAftermathTracker> nsight_aftermath_tracker; |
| 312 | |||
| 313 | u64 device_access_memory; | ||
| 305 | }; | 314 | }; |
| 306 | 315 | ||
| 307 | } // namespace Vulkan | 316 | } // namespace Vulkan |
diff --git a/src/video_core/vulkan_common/vulkan_memory_allocator.cpp b/src/video_core/vulkan_common/vulkan_memory_allocator.cpp index 5edd06ebc..aa173d19e 100644 --- a/src/video_core/vulkan_common/vulkan_memory_allocator.cpp +++ b/src/video_core/vulkan_common/vulkan_memory_allocator.cpp | |||
| @@ -69,10 +69,10 @@ constexpr VkExportMemoryAllocateInfo EXPORT_ALLOCATE_INFO{ | |||
| 69 | 69 | ||
| 70 | class MemoryAllocation { | 70 | class MemoryAllocation { |
| 71 | public: | 71 | public: |
| 72 | explicit MemoryAllocation(vk::DeviceMemory memory_, VkMemoryPropertyFlags properties, | 72 | explicit MemoryAllocation(MemoryAllocator* const allocator_, vk::DeviceMemory memory_, |
| 73 | u64 allocation_size_, u32 type) | 73 | VkMemoryPropertyFlags properties, u64 allocation_size_, u32 type) |
| 74 | : memory{std::move(memory_)}, allocation_size{allocation_size_}, property_flags{properties}, | 74 | : allocator{allocator_}, memory{std::move(memory_)}, allocation_size{allocation_size_}, |
| 75 | shifted_memory_type{1U << type} {} | 75 | property_flags{properties}, shifted_memory_type{1U << type} {} |
| 76 | 76 | ||
| 77 | #if defined(_WIN32) || defined(__unix__) | 77 | #if defined(_WIN32) || defined(__unix__) |
| 78 | ~MemoryAllocation() { | 78 | ~MemoryAllocation() { |
| @@ -106,6 +106,10 @@ public: | |||
| 106 | const auto it = std::ranges::find(commits, begin, &Range::begin); | 106 | const auto it = std::ranges::find(commits, begin, &Range::begin); |
| 107 | ASSERT_MSG(it != commits.end(), "Invalid commit"); | 107 | ASSERT_MSG(it != commits.end(), "Invalid commit"); |
| 108 | commits.erase(it); | 108 | commits.erase(it); |
| 109 | if (commits.empty()) { | ||
| 110 | // Do not call any code involving 'this' after this call, the object will be destroyed | ||
| 111 | allocator->ReleaseMemory(this); | ||
| 112 | } | ||
| 109 | } | 113 | } |
| 110 | 114 | ||
| 111 | [[nodiscard]] std::span<u8> Map() { | 115 | [[nodiscard]] std::span<u8> Map() { |
| @@ -171,6 +175,7 @@ private: | |||
| 171 | return candidate; | 175 | return candidate; |
| 172 | } | 176 | } |
| 173 | 177 | ||
| 178 | MemoryAllocator* const allocator; ///< Parent memory allocation. | ||
| 174 | const vk::DeviceMemory memory; ///< Vulkan memory allocation handler. | 179 | const vk::DeviceMemory memory; ///< Vulkan memory allocation handler. |
| 175 | const u64 allocation_size; ///< Size of this allocation. | 180 | const u64 allocation_size; ///< Size of this allocation. |
| 176 | const VkMemoryPropertyFlags property_flags; ///< Vulkan memory property flags. | 181 | const VkMemoryPropertyFlags property_flags; ///< Vulkan memory property flags. |
| @@ -275,10 +280,17 @@ bool MemoryAllocator::TryAllocMemory(VkMemoryPropertyFlags flags, u32 type_mask, | |||
| 275 | return false; | 280 | return false; |
| 276 | } | 281 | } |
| 277 | } | 282 | } |
| 278 | allocations.push_back(std::make_unique<MemoryAllocation>(std::move(memory), flags, size, type)); | 283 | allocations.push_back( |
| 284 | std::make_unique<MemoryAllocation>(this, std::move(memory), flags, size, type)); | ||
| 279 | return true; | 285 | return true; |
| 280 | } | 286 | } |
| 281 | 287 | ||
| 288 | void MemoryAllocator::ReleaseMemory(MemoryAllocation* alloc) { | ||
| 289 | const auto it = std::ranges::find(allocations, alloc, &std::unique_ptr<MemoryAllocation>::get); | ||
| 290 | ASSERT(it != allocations.end()); | ||
| 291 | allocations.erase(it); | ||
| 292 | } | ||
| 293 | |||
| 282 | std::optional<MemoryCommit> MemoryAllocator::TryCommit(const VkMemoryRequirements& requirements, | 294 | std::optional<MemoryCommit> MemoryAllocator::TryCommit(const VkMemoryRequirements& requirements, |
| 283 | VkMemoryPropertyFlags flags) { | 295 | VkMemoryPropertyFlags flags) { |
| 284 | for (auto& allocation : allocations) { | 296 | for (auto& allocation : allocations) { |
diff --git a/src/video_core/vulkan_common/vulkan_memory_allocator.h b/src/video_core/vulkan_common/vulkan_memory_allocator.h index db12d02f4..b61e931e0 100644 --- a/src/video_core/vulkan_common/vulkan_memory_allocator.h +++ b/src/video_core/vulkan_common/vulkan_memory_allocator.h | |||
| @@ -69,6 +69,8 @@ private: | |||
| 69 | /// Memory allocator container. | 69 | /// Memory allocator container. |
| 70 | /// Allocates and releases memory allocations on demand. | 70 | /// Allocates and releases memory allocations on demand. |
| 71 | class MemoryAllocator { | 71 | class MemoryAllocator { |
| 72 | friend MemoryAllocation; | ||
| 73 | |||
| 72 | public: | 74 | public: |
| 73 | /** | 75 | /** |
| 74 | * Construct memory allocator | 76 | * Construct memory allocator |
| @@ -104,6 +106,9 @@ private: | |||
| 104 | /// Tries to allocate a chunk of memory. | 106 | /// Tries to allocate a chunk of memory. |
| 105 | bool TryAllocMemory(VkMemoryPropertyFlags flags, u32 type_mask, u64 size); | 107 | bool TryAllocMemory(VkMemoryPropertyFlags flags, u32 type_mask, u64 size); |
| 106 | 108 | ||
| 109 | /// Releases a chunk of memory. | ||
| 110 | void ReleaseMemory(MemoryAllocation* alloc); | ||
| 111 | |||
| 107 | /// Tries to allocate a memory commit. | 112 | /// Tries to allocate a memory commit. |
| 108 | std::optional<MemoryCommit> TryCommit(const VkMemoryRequirements& requirements, | 113 | std::optional<MemoryCommit> TryCommit(const VkMemoryRequirements& requirements, |
| 109 | VkMemoryPropertyFlags flags); | 114 | VkMemoryPropertyFlags flags); |
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 86495803e..7524e3c40 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp | |||
| @@ -51,11 +51,11 @@ void EmuThread::run() { | |||
| 51 | Common::SetCurrentThreadName(name.c_str()); | 51 | Common::SetCurrentThreadName(name.c_str()); |
| 52 | 52 | ||
| 53 | auto& system = Core::System::GetInstance(); | 53 | auto& system = Core::System::GetInstance(); |
| 54 | auto& gpu = system.GPU(); | ||
| 55 | auto stop_token = stop_source.get_token(); | ||
| 54 | 56 | ||
| 55 | system.RegisterHostThread(); | 57 | system.RegisterHostThread(); |
| 56 | 58 | ||
| 57 | auto& gpu = system.GPU(); | ||
| 58 | |||
| 59 | // Main process has been loaded. Make the context current to this thread and begin GPU and CPU | 59 | // Main process has been loaded. Make the context current to this thread and begin GPU and CPU |
| 60 | // execution. | 60 | // execution. |
| 61 | gpu.Start(); | 61 | gpu.Start(); |
| @@ -65,7 +65,7 @@ void EmuThread::run() { | |||
| 65 | emit LoadProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0); | 65 | emit LoadProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0); |
| 66 | 66 | ||
| 67 | system.Renderer().ReadRasterizer()->LoadDiskResources( | 67 | system.Renderer().ReadRasterizer()->LoadDiskResources( |
| 68 | system.CurrentProcess()->GetTitleID(), stop_run, | 68 | system.CurrentProcess()->GetTitleID(), stop_token, |
| 69 | [this](VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total) { | 69 | [this](VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total) { |
| 70 | emit LoadProgress(stage, value, total); | 70 | emit LoadProgress(stage, value, total); |
| 71 | }); | 71 | }); |
| @@ -78,7 +78,7 @@ void EmuThread::run() { | |||
| 78 | // so that the DebugModeLeft signal can be emitted before the | 78 | // so that the DebugModeLeft signal can be emitted before the |
| 79 | // next execution step | 79 | // next execution step |
| 80 | bool was_active = false; | 80 | bool was_active = false; |
| 81 | while (!stop_run) { | 81 | while (!stop_token.stop_requested()) { |
| 82 | if (running) { | 82 | if (running) { |
| 83 | if (was_active) { | 83 | if (was_active) { |
| 84 | emit DebugModeLeft(); | 84 | emit DebugModeLeft(); |
| @@ -100,7 +100,7 @@ void EmuThread::run() { | |||
| 100 | } | 100 | } |
| 101 | running_guard = false; | 101 | running_guard = false; |
| 102 | 102 | ||
| 103 | if (!stop_run) { | 103 | if (!stop_token.stop_requested()) { |
| 104 | was_active = true; | 104 | was_active = true; |
| 105 | emit DebugModeEntered(); | 105 | emit DebugModeEntered(); |
| 106 | } | 106 | } |
| @@ -108,7 +108,7 @@ void EmuThread::run() { | |||
| 108 | UNIMPLEMENTED(); | 108 | UNIMPLEMENTED(); |
| 109 | } else { | 109 | } else { |
| 110 | std::unique_lock lock{running_mutex}; | 110 | std::unique_lock lock{running_mutex}; |
| 111 | running_cv.wait(lock, [this] { return IsRunning() || exec_step || stop_run; }); | 111 | running_cv.wait(lock, stop_token, [this] { return IsRunning() || exec_step; }); |
| 112 | } | 112 | } |
| 113 | } | 113 | } |
| 114 | 114 | ||
diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index acfe2bc8c..402dd2ee1 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h | |||
| @@ -89,16 +89,16 @@ public: | |||
| 89 | * Requests for the emulation thread to stop running | 89 | * Requests for the emulation thread to stop running |
| 90 | */ | 90 | */ |
| 91 | void RequestStop() { | 91 | void RequestStop() { |
| 92 | stop_run = true; | 92 | stop_source.request_stop(); |
| 93 | SetRunning(false); | 93 | SetRunning(false); |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | private: | 96 | private: |
| 97 | bool exec_step = false; | 97 | bool exec_step = false; |
| 98 | bool running = false; | 98 | bool running = false; |
| 99 | std::atomic_bool stop_run{false}; | 99 | std::stop_source stop_source; |
| 100 | std::mutex running_mutex; | 100 | std::mutex running_mutex; |
| 101 | std::condition_variable running_cv; | 101 | std::condition_variable_any running_cv; |
| 102 | Common::Event running_wait{}; | 102 | Common::Event running_wait{}; |
| 103 | std::atomic_bool running_guard{false}; | 103 | std::atomic_bool running_guard{false}; |
| 104 | 104 | ||
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 916a22724..62bafc453 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -221,7 +221,7 @@ const std::array<int, Settings::NativeKeyboard::NumKeyboardMods> Config::default | |||
| 221 | // This must be in alphabetical order according to action name as it must have the same order as | 221 | // This must be in alphabetical order according to action name as it must have the same order as |
| 222 | // UISetting::values.shortcuts, which is alphabetically ordered. | 222 | // UISetting::values.shortcuts, which is alphabetically ordered. |
| 223 | // clang-format off | 223 | // clang-format off |
| 224 | const std::array<UISettings::Shortcut, 17> Config::default_hotkeys{{ | 224 | const std::array<UISettings::Shortcut, 18> Config::default_hotkeys{{ |
| 225 | {QStringLiteral("Capture Screenshot"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+P"), Qt::WidgetWithChildrenShortcut}}, | 225 | {QStringLiteral("Capture Screenshot"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+P"), Qt::WidgetWithChildrenShortcut}}, |
| 226 | {QStringLiteral("Change Docked Mode"), QStringLiteral("Main Window"), {QStringLiteral("F10"), Qt::ApplicationShortcut}}, | 226 | {QStringLiteral("Change Docked Mode"), QStringLiteral("Main Window"), {QStringLiteral("F10"), Qt::ApplicationShortcut}}, |
| 227 | {QStringLiteral("Continue/Pause Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F4"), Qt::WindowShortcut}}, | 227 | {QStringLiteral("Continue/Pause Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F4"), Qt::WindowShortcut}}, |
| @@ -236,6 +236,7 @@ const std::array<UISettings::Shortcut, 17> Config::default_hotkeys{{ | |||
| 236 | {QStringLiteral("Restart Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F6"), Qt::WindowShortcut}}, | 236 | {QStringLiteral("Restart Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F6"), Qt::WindowShortcut}}, |
| 237 | {QStringLiteral("Stop Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F5"), Qt::WindowShortcut}}, | 237 | {QStringLiteral("Stop Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F5"), Qt::WindowShortcut}}, |
| 238 | {QStringLiteral("Toggle Filter Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F"), Qt::WindowShortcut}}, | 238 | {QStringLiteral("Toggle Filter Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F"), Qt::WindowShortcut}}, |
| 239 | {QStringLiteral("Toggle Framerate Limit"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+U"), Qt::ApplicationShortcut}}, | ||
| 239 | {QStringLiteral("Toggle Mouse Panning"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F9"), Qt::ApplicationShortcut}}, | 240 | {QStringLiteral("Toggle Mouse Panning"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F9"), Qt::ApplicationShortcut}}, |
| 240 | {QStringLiteral("Toggle Speed Limit"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+Z"), Qt::ApplicationShortcut}}, | 241 | {QStringLiteral("Toggle Speed Limit"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+Z"), Qt::ApplicationShortcut}}, |
| 241 | {QStringLiteral("Toggle Status Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+S"), Qt::WindowShortcut}}, | 242 | {QStringLiteral("Toggle Status Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+S"), Qt::WindowShortcut}}, |
| @@ -756,6 +757,8 @@ void Config::ReadCpuValues() { | |||
| 756 | QStringLiteral("cpuopt_unsafe_unfuse_fma"), true); | 757 | QStringLiteral("cpuopt_unsafe_unfuse_fma"), true); |
| 757 | ReadSettingGlobal(Settings::values.cpuopt_unsafe_reduce_fp_error, | 758 | ReadSettingGlobal(Settings::values.cpuopt_unsafe_reduce_fp_error, |
| 758 | QStringLiteral("cpuopt_unsafe_reduce_fp_error"), true); | 759 | QStringLiteral("cpuopt_unsafe_reduce_fp_error"), true); |
| 760 | ReadSettingGlobal(Settings::values.cpuopt_unsafe_ignore_standard_fpcr, | ||
| 761 | QStringLiteral("cpuopt_unsafe_ignore_standard_fpcr"), true); | ||
| 759 | ReadSettingGlobal(Settings::values.cpuopt_unsafe_inaccurate_nan, | 762 | ReadSettingGlobal(Settings::values.cpuopt_unsafe_inaccurate_nan, |
| 760 | QStringLiteral("cpuopt_unsafe_inaccurate_nan"), true); | 763 | QStringLiteral("cpuopt_unsafe_inaccurate_nan"), true); |
| 761 | ReadSettingGlobal(Settings::values.cpuopt_unsafe_fastmem_check, | 764 | ReadSettingGlobal(Settings::values.cpuopt_unsafe_fastmem_check, |
| @@ -811,12 +814,15 @@ void Config::ReadRendererValues() { | |||
| 811 | true); | 814 | true); |
| 812 | ReadSettingGlobal(Settings::values.accelerate_astc, QStringLiteral("accelerate_astc"), true); | 815 | ReadSettingGlobal(Settings::values.accelerate_astc, QStringLiteral("accelerate_astc"), true); |
| 813 | ReadSettingGlobal(Settings::values.use_vsync, QStringLiteral("use_vsync"), true); | 816 | ReadSettingGlobal(Settings::values.use_vsync, QStringLiteral("use_vsync"), true); |
| 817 | ReadSettingGlobal(Settings::values.disable_fps_limit, QStringLiteral("disable_fps_limit"), | ||
| 818 | false); | ||
| 814 | ReadSettingGlobal(Settings::values.use_assembly_shaders, QStringLiteral("use_assembly_shaders"), | 819 | ReadSettingGlobal(Settings::values.use_assembly_shaders, QStringLiteral("use_assembly_shaders"), |
| 815 | false); | 820 | false); |
| 816 | ReadSettingGlobal(Settings::values.use_asynchronous_shaders, | 821 | ReadSettingGlobal(Settings::values.use_asynchronous_shaders, |
| 817 | QStringLiteral("use_asynchronous_shaders"), false); | 822 | QStringLiteral("use_asynchronous_shaders"), false); |
| 818 | ReadSettingGlobal(Settings::values.use_fast_gpu_time, QStringLiteral("use_fast_gpu_time"), | 823 | ReadSettingGlobal(Settings::values.use_fast_gpu_time, QStringLiteral("use_fast_gpu_time"), |
| 819 | true); | 824 | true); |
| 825 | ReadSettingGlobal(Settings::values.use_caches_gc, QStringLiteral("use_caches_gc"), false); | ||
| 820 | ReadSettingGlobal(Settings::values.bg_red, QStringLiteral("bg_red"), 0.0); | 826 | ReadSettingGlobal(Settings::values.bg_red, QStringLiteral("bg_red"), 0.0); |
| 821 | ReadSettingGlobal(Settings::values.bg_green, QStringLiteral("bg_green"), 0.0); | 827 | ReadSettingGlobal(Settings::values.bg_green, QStringLiteral("bg_green"), 0.0); |
| 822 | ReadSettingGlobal(Settings::values.bg_blue, QStringLiteral("bg_blue"), 0.0); | 828 | ReadSettingGlobal(Settings::values.bg_blue, QStringLiteral("bg_blue"), 0.0); |
| @@ -1339,6 +1345,8 @@ void Config::SaveCpuValues() { | |||
| 1339 | Settings::values.cpuopt_unsafe_unfuse_fma, true); | 1345 | Settings::values.cpuopt_unsafe_unfuse_fma, true); |
| 1340 | WriteSettingGlobal(QStringLiteral("cpuopt_unsafe_reduce_fp_error"), | 1346 | WriteSettingGlobal(QStringLiteral("cpuopt_unsafe_reduce_fp_error"), |
| 1341 | Settings::values.cpuopt_unsafe_reduce_fp_error, true); | 1347 | Settings::values.cpuopt_unsafe_reduce_fp_error, true); |
| 1348 | WriteSettingGlobal(QStringLiteral("cpuopt_unsafe_ignore_standard_fpcr"), | ||
| 1349 | Settings::values.cpuopt_unsafe_ignore_standard_fpcr, true); | ||
| 1342 | WriteSettingGlobal(QStringLiteral("cpuopt_unsafe_inaccurate_nan"), | 1350 | WriteSettingGlobal(QStringLiteral("cpuopt_unsafe_inaccurate_nan"), |
| 1343 | Settings::values.cpuopt_unsafe_inaccurate_nan, true); | 1351 | Settings::values.cpuopt_unsafe_inaccurate_nan, true); |
| 1344 | WriteSettingGlobal(QStringLiteral("cpuopt_unsafe_fastmem_check"), | 1352 | WriteSettingGlobal(QStringLiteral("cpuopt_unsafe_fastmem_check"), |
| @@ -1395,12 +1403,15 @@ void Config::SaveRendererValues() { | |||
| 1395 | true); | 1403 | true); |
| 1396 | WriteSettingGlobal(QStringLiteral("accelerate_astc"), Settings::values.accelerate_astc, true); | 1404 | WriteSettingGlobal(QStringLiteral("accelerate_astc"), Settings::values.accelerate_astc, true); |
| 1397 | WriteSettingGlobal(QStringLiteral("use_vsync"), Settings::values.use_vsync, true); | 1405 | WriteSettingGlobal(QStringLiteral("use_vsync"), Settings::values.use_vsync, true); |
| 1406 | WriteSettingGlobal(QStringLiteral("disable_fps_limit"), Settings::values.disable_fps_limit, | ||
| 1407 | false); | ||
| 1398 | WriteSettingGlobal(QStringLiteral("use_assembly_shaders"), | 1408 | WriteSettingGlobal(QStringLiteral("use_assembly_shaders"), |
| 1399 | Settings::values.use_assembly_shaders, false); | 1409 | Settings::values.use_assembly_shaders, false); |
| 1400 | WriteSettingGlobal(QStringLiteral("use_asynchronous_shaders"), | 1410 | WriteSettingGlobal(QStringLiteral("use_asynchronous_shaders"), |
| 1401 | Settings::values.use_asynchronous_shaders, false); | 1411 | Settings::values.use_asynchronous_shaders, false); |
| 1402 | WriteSettingGlobal(QStringLiteral("use_fast_gpu_time"), Settings::values.use_fast_gpu_time, | 1412 | WriteSettingGlobal(QStringLiteral("use_fast_gpu_time"), Settings::values.use_fast_gpu_time, |
| 1403 | true); | 1413 | true); |
| 1414 | WriteSettingGlobal(QStringLiteral("use_caches_gc"), Settings::values.use_caches_gc, false); | ||
| 1404 | // Cast to double because Qt's written float values are not human-readable | 1415 | // Cast to double because Qt's written float values are not human-readable |
| 1405 | WriteSettingGlobal(QStringLiteral("bg_red"), Settings::values.bg_red, 0.0); | 1416 | WriteSettingGlobal(QStringLiteral("bg_red"), Settings::values.bg_red, 0.0); |
| 1406 | WriteSettingGlobal(QStringLiteral("bg_green"), Settings::values.bg_green, 0.0); | 1417 | WriteSettingGlobal(QStringLiteral("bg_green"), Settings::values.bg_green, 0.0); |
diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index ce3355588..3c1de0ac9 100644 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h | |||
| @@ -42,7 +42,7 @@ public: | |||
| 42 | default_mouse_buttons; | 42 | default_mouse_buttons; |
| 43 | static const std::array<int, Settings::NativeKeyboard::NumKeyboardKeys> default_keyboard_keys; | 43 | static const std::array<int, Settings::NativeKeyboard::NumKeyboardKeys> default_keyboard_keys; |
| 44 | static const std::array<int, Settings::NativeKeyboard::NumKeyboardMods> default_keyboard_mods; | 44 | static const std::array<int, Settings::NativeKeyboard::NumKeyboardMods> default_keyboard_mods; |
| 45 | static const std::array<UISettings::Shortcut, 17> default_hotkeys; | 45 | static const std::array<UISettings::Shortcut, 18> default_hotkeys; |
| 46 | 46 | ||
| 47 | private: | 47 | private: |
| 48 | void Initialize(const std::string& config_name); | 48 | void Initialize(const std::string& config_name); |
diff --git a/src/yuzu/configuration/configure_cpu.cpp b/src/yuzu/configuration/configure_cpu.cpp index 22219cbad..13db2ba98 100644 --- a/src/yuzu/configuration/configure_cpu.cpp +++ b/src/yuzu/configuration/configure_cpu.cpp | |||
| @@ -34,12 +34,15 @@ void ConfigureCpu::SetConfiguration() { | |||
| 34 | ui->accuracy->setEnabled(runtime_lock); | 34 | ui->accuracy->setEnabled(runtime_lock); |
| 35 | ui->cpuopt_unsafe_unfuse_fma->setEnabled(runtime_lock); | 35 | ui->cpuopt_unsafe_unfuse_fma->setEnabled(runtime_lock); |
| 36 | ui->cpuopt_unsafe_reduce_fp_error->setEnabled(runtime_lock); | 36 | ui->cpuopt_unsafe_reduce_fp_error->setEnabled(runtime_lock); |
| 37 | ui->cpuopt_unsafe_ignore_standard_fpcr->setEnabled(runtime_lock); | ||
| 37 | ui->cpuopt_unsafe_inaccurate_nan->setEnabled(runtime_lock); | 38 | ui->cpuopt_unsafe_inaccurate_nan->setEnabled(runtime_lock); |
| 38 | ui->cpuopt_unsafe_fastmem_check->setEnabled(runtime_lock); | 39 | ui->cpuopt_unsafe_fastmem_check->setEnabled(runtime_lock); |
| 39 | 40 | ||
| 40 | ui->cpuopt_unsafe_unfuse_fma->setChecked(Settings::values.cpuopt_unsafe_unfuse_fma.GetValue()); | 41 | ui->cpuopt_unsafe_unfuse_fma->setChecked(Settings::values.cpuopt_unsafe_unfuse_fma.GetValue()); |
| 41 | ui->cpuopt_unsafe_reduce_fp_error->setChecked( | 42 | ui->cpuopt_unsafe_reduce_fp_error->setChecked( |
| 42 | Settings::values.cpuopt_unsafe_reduce_fp_error.GetValue()); | 43 | Settings::values.cpuopt_unsafe_reduce_fp_error.GetValue()); |
| 44 | ui->cpuopt_unsafe_ignore_standard_fpcr->setChecked( | ||
| 45 | Settings::values.cpuopt_unsafe_ignore_standard_fpcr.GetValue()); | ||
| 43 | ui->cpuopt_unsafe_inaccurate_nan->setChecked( | 46 | ui->cpuopt_unsafe_inaccurate_nan->setChecked( |
| 44 | Settings::values.cpuopt_unsafe_inaccurate_nan.GetValue()); | 47 | Settings::values.cpuopt_unsafe_inaccurate_nan.GetValue()); |
| 45 | ui->cpuopt_unsafe_fastmem_check->setChecked( | 48 | ui->cpuopt_unsafe_fastmem_check->setChecked( |
| @@ -84,6 +87,9 @@ void ConfigureCpu::ApplyConfiguration() { | |||
| 84 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_reduce_fp_error, | 87 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_reduce_fp_error, |
| 85 | ui->cpuopt_unsafe_reduce_fp_error, | 88 | ui->cpuopt_unsafe_reduce_fp_error, |
| 86 | cpuopt_unsafe_reduce_fp_error); | 89 | cpuopt_unsafe_reduce_fp_error); |
| 90 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_ignore_standard_fpcr, | ||
| 91 | ui->cpuopt_unsafe_ignore_standard_fpcr, | ||
| 92 | cpuopt_unsafe_ignore_standard_fpcr); | ||
| 87 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_inaccurate_nan, | 93 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_inaccurate_nan, |
| 88 | ui->cpuopt_unsafe_inaccurate_nan, | 94 | ui->cpuopt_unsafe_inaccurate_nan, |
| 89 | cpuopt_unsafe_inaccurate_nan); | 95 | cpuopt_unsafe_inaccurate_nan); |
| @@ -137,6 +143,9 @@ void ConfigureCpu::SetupPerGameUI() { | |||
| 137 | ConfigurationShared::SetColoredTristate(ui->cpuopt_unsafe_reduce_fp_error, | 143 | ConfigurationShared::SetColoredTristate(ui->cpuopt_unsafe_reduce_fp_error, |
| 138 | Settings::values.cpuopt_unsafe_reduce_fp_error, | 144 | Settings::values.cpuopt_unsafe_reduce_fp_error, |
| 139 | cpuopt_unsafe_reduce_fp_error); | 145 | cpuopt_unsafe_reduce_fp_error); |
| 146 | ConfigurationShared::SetColoredTristate(ui->cpuopt_unsafe_ignore_standard_fpcr, | ||
| 147 | Settings::values.cpuopt_unsafe_ignore_standard_fpcr, | ||
| 148 | cpuopt_unsafe_ignore_standard_fpcr); | ||
| 140 | ConfigurationShared::SetColoredTristate(ui->cpuopt_unsafe_inaccurate_nan, | 149 | ConfigurationShared::SetColoredTristate(ui->cpuopt_unsafe_inaccurate_nan, |
| 141 | Settings::values.cpuopt_unsafe_inaccurate_nan, | 150 | Settings::values.cpuopt_unsafe_inaccurate_nan, |
| 142 | cpuopt_unsafe_inaccurate_nan); | 151 | cpuopt_unsafe_inaccurate_nan); |
diff --git a/src/yuzu/configuration/configure_cpu.h b/src/yuzu/configuration/configure_cpu.h index 57ff2772a..b2b5f1671 100644 --- a/src/yuzu/configuration/configure_cpu.h +++ b/src/yuzu/configuration/configure_cpu.h | |||
| @@ -40,6 +40,7 @@ private: | |||
| 40 | 40 | ||
| 41 | ConfigurationShared::CheckState cpuopt_unsafe_unfuse_fma; | 41 | ConfigurationShared::CheckState cpuopt_unsafe_unfuse_fma; |
| 42 | ConfigurationShared::CheckState cpuopt_unsafe_reduce_fp_error; | 42 | ConfigurationShared::CheckState cpuopt_unsafe_reduce_fp_error; |
| 43 | ConfigurationShared::CheckState cpuopt_unsafe_ignore_standard_fpcr; | ||
| 43 | ConfigurationShared::CheckState cpuopt_unsafe_inaccurate_nan; | 44 | ConfigurationShared::CheckState cpuopt_unsafe_inaccurate_nan; |
| 44 | ConfigurationShared::CheckState cpuopt_unsafe_fastmem_check; | 45 | ConfigurationShared::CheckState cpuopt_unsafe_fastmem_check; |
| 45 | }; | 46 | }; |
diff --git a/src/yuzu/configuration/configure_cpu.ui b/src/yuzu/configuration/configure_cpu.ui index 31ef9e3f5..0e296d4e5 100644 --- a/src/yuzu/configuration/configure_cpu.ui +++ b/src/yuzu/configuration/configure_cpu.ui | |||
| @@ -112,6 +112,18 @@ | |||
| 112 | </widget> | 112 | </widget> |
| 113 | </item> | 113 | </item> |
| 114 | <item> | 114 | <item> |
| 115 | <widget class="QCheckBox" name="cpuopt_unsafe_ignore_standard_fpcr"> | ||
| 116 | <property name="toolTip"> | ||
| 117 | <string> | ||
| 118 | <div>This option improves the speed of 32 bits ASIMD floating-point functions by running with incorrect rounding modes.</div> | ||
| 119 | </string> | ||
| 120 | </property> | ||
| 121 | <property name="text"> | ||
| 122 | <string>Faster ASIMD instructions (32 bits only)</string> | ||
| 123 | </property> | ||
| 124 | </widget> | ||
| 125 | </item> | ||
| 126 | <item> | ||
| 115 | <widget class="QCheckBox" name="cpuopt_unsafe_inaccurate_nan"> | 127 | <widget class="QCheckBox" name="cpuopt_unsafe_inaccurate_nan"> |
| 116 | <property name="toolTip"> | 128 | <property name="toolTip"> |
| 117 | <string> | 129 | <string> |
diff --git a/src/yuzu/configuration/configure_graphics_advanced.cpp b/src/yuzu/configuration/configure_graphics_advanced.cpp index 35bf9c6be..8d13c9857 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.cpp +++ b/src/yuzu/configuration/configure_graphics_advanced.cpp | |||
| @@ -28,8 +28,10 @@ void ConfigureGraphicsAdvanced::SetConfiguration() { | |||
| 28 | ui->anisotropic_filtering_combobox->setEnabled(runtime_lock); | 28 | ui->anisotropic_filtering_combobox->setEnabled(runtime_lock); |
| 29 | 29 | ||
| 30 | ui->use_vsync->setChecked(Settings::values.use_vsync.GetValue()); | 30 | ui->use_vsync->setChecked(Settings::values.use_vsync.GetValue()); |
| 31 | ui->disable_fps_limit->setChecked(Settings::values.disable_fps_limit.GetValue()); | ||
| 31 | ui->use_assembly_shaders->setChecked(Settings::values.use_assembly_shaders.GetValue()); | 32 | ui->use_assembly_shaders->setChecked(Settings::values.use_assembly_shaders.GetValue()); |
| 32 | ui->use_asynchronous_shaders->setChecked(Settings::values.use_asynchronous_shaders.GetValue()); | 33 | ui->use_asynchronous_shaders->setChecked(Settings::values.use_asynchronous_shaders.GetValue()); |
| 34 | ui->use_caches_gc->setChecked(Settings::values.use_caches_gc.GetValue()); | ||
| 33 | ui->use_fast_gpu_time->setChecked(Settings::values.use_fast_gpu_time.GetValue()); | 35 | ui->use_fast_gpu_time->setChecked(Settings::values.use_fast_gpu_time.GetValue()); |
| 34 | 36 | ||
| 35 | if (Settings::IsConfiguringGlobal()) { | 37 | if (Settings::IsConfiguringGlobal()) { |
| @@ -57,11 +59,15 @@ void ConfigureGraphicsAdvanced::ApplyConfiguration() { | |||
| 57 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.max_anisotropy, | 59 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.max_anisotropy, |
| 58 | ui->anisotropic_filtering_combobox); | 60 | ui->anisotropic_filtering_combobox); |
| 59 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_vsync, ui->use_vsync, use_vsync); | 61 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_vsync, ui->use_vsync, use_vsync); |
| 62 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.disable_fps_limit, | ||
| 63 | ui->disable_fps_limit, disable_fps_limit); | ||
| 60 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_assembly_shaders, | 64 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_assembly_shaders, |
| 61 | ui->use_assembly_shaders, use_assembly_shaders); | 65 | ui->use_assembly_shaders, use_assembly_shaders); |
| 62 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_asynchronous_shaders, | 66 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_asynchronous_shaders, |
| 63 | ui->use_asynchronous_shaders, | 67 | ui->use_asynchronous_shaders, |
| 64 | use_asynchronous_shaders); | 68 | use_asynchronous_shaders); |
| 69 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_caches_gc, ui->use_caches_gc, | ||
| 70 | use_caches_gc); | ||
| 65 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_fast_gpu_time, | 71 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_fast_gpu_time, |
| 66 | ui->use_fast_gpu_time, use_fast_gpu_time); | 72 | ui->use_fast_gpu_time, use_fast_gpu_time); |
| 67 | 73 | ||
| @@ -97,10 +103,12 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() { | |||
| 97 | if (Settings::IsConfiguringGlobal()) { | 103 | if (Settings::IsConfiguringGlobal()) { |
| 98 | ui->gpu_accuracy->setEnabled(Settings::values.gpu_accuracy.UsingGlobal()); | 104 | ui->gpu_accuracy->setEnabled(Settings::values.gpu_accuracy.UsingGlobal()); |
| 99 | ui->use_vsync->setEnabled(Settings::values.use_vsync.UsingGlobal()); | 105 | ui->use_vsync->setEnabled(Settings::values.use_vsync.UsingGlobal()); |
| 106 | ui->disable_fps_limit->setEnabled(Settings::values.disable_fps_limit.UsingGlobal()); | ||
| 100 | ui->use_assembly_shaders->setEnabled(Settings::values.use_assembly_shaders.UsingGlobal()); | 107 | ui->use_assembly_shaders->setEnabled(Settings::values.use_assembly_shaders.UsingGlobal()); |
| 101 | ui->use_asynchronous_shaders->setEnabled( | 108 | ui->use_asynchronous_shaders->setEnabled( |
| 102 | Settings::values.use_asynchronous_shaders.UsingGlobal()); | 109 | Settings::values.use_asynchronous_shaders.UsingGlobal()); |
| 103 | ui->use_fast_gpu_time->setEnabled(Settings::values.use_fast_gpu_time.UsingGlobal()); | 110 | ui->use_fast_gpu_time->setEnabled(Settings::values.use_fast_gpu_time.UsingGlobal()); |
| 111 | ui->use_caches_gc->setEnabled(Settings::values.use_caches_gc.UsingGlobal()); | ||
| 104 | ui->anisotropic_filtering_combobox->setEnabled( | 112 | ui->anisotropic_filtering_combobox->setEnabled( |
| 105 | Settings::values.max_anisotropy.UsingGlobal()); | 113 | Settings::values.max_anisotropy.UsingGlobal()); |
| 106 | 114 | ||
| @@ -108,6 +116,8 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() { | |||
| 108 | } | 116 | } |
| 109 | 117 | ||
| 110 | ConfigurationShared::SetColoredTristate(ui->use_vsync, Settings::values.use_vsync, use_vsync); | 118 | ConfigurationShared::SetColoredTristate(ui->use_vsync, Settings::values.use_vsync, use_vsync); |
| 119 | ConfigurationShared::SetColoredTristate(ui->disable_fps_limit, | ||
| 120 | Settings::values.disable_fps_limit, disable_fps_limit); | ||
| 111 | ConfigurationShared::SetColoredTristate( | 121 | ConfigurationShared::SetColoredTristate( |
| 112 | ui->use_assembly_shaders, Settings::values.use_assembly_shaders, use_assembly_shaders); | 122 | ui->use_assembly_shaders, Settings::values.use_assembly_shaders, use_assembly_shaders); |
| 113 | ConfigurationShared::SetColoredTristate(ui->use_asynchronous_shaders, | 123 | ConfigurationShared::SetColoredTristate(ui->use_asynchronous_shaders, |
| @@ -115,6 +125,8 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() { | |||
| 115 | use_asynchronous_shaders); | 125 | use_asynchronous_shaders); |
| 116 | ConfigurationShared::SetColoredTristate(ui->use_fast_gpu_time, | 126 | ConfigurationShared::SetColoredTristate(ui->use_fast_gpu_time, |
| 117 | Settings::values.use_fast_gpu_time, use_fast_gpu_time); | 127 | Settings::values.use_fast_gpu_time, use_fast_gpu_time); |
| 128 | ConfigurationShared::SetColoredTristate(ui->use_caches_gc, Settings::values.use_caches_gc, | ||
| 129 | use_caches_gc); | ||
| 118 | ConfigurationShared::SetColoredComboBox( | 130 | ConfigurationShared::SetColoredComboBox( |
| 119 | ui->gpu_accuracy, ui->label_gpu_accuracy, | 131 | ui->gpu_accuracy, ui->label_gpu_accuracy, |
| 120 | static_cast<int>(Settings::values.gpu_accuracy.GetValue(true))); | 132 | static_cast<int>(Settings::values.gpu_accuracy.GetValue(true))); |
diff --git a/src/yuzu/configuration/configure_graphics_advanced.h b/src/yuzu/configuration/configure_graphics_advanced.h index e61b571c7..6ac5f20ec 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.h +++ b/src/yuzu/configuration/configure_graphics_advanced.h | |||
| @@ -35,7 +35,9 @@ private: | |||
| 35 | std::unique_ptr<Ui::ConfigureGraphicsAdvanced> ui; | 35 | std::unique_ptr<Ui::ConfigureGraphicsAdvanced> ui; |
| 36 | 36 | ||
| 37 | ConfigurationShared::CheckState use_vsync; | 37 | ConfigurationShared::CheckState use_vsync; |
| 38 | ConfigurationShared::CheckState disable_fps_limit; | ||
| 38 | ConfigurationShared::CheckState use_assembly_shaders; | 39 | ConfigurationShared::CheckState use_assembly_shaders; |
| 39 | ConfigurationShared::CheckState use_asynchronous_shaders; | 40 | ConfigurationShared::CheckState use_asynchronous_shaders; |
| 40 | ConfigurationShared::CheckState use_fast_gpu_time; | 41 | ConfigurationShared::CheckState use_fast_gpu_time; |
| 42 | ConfigurationShared::CheckState use_caches_gc; | ||
| 41 | }; | 43 | }; |
diff --git a/src/yuzu/configuration/configure_graphics_advanced.ui b/src/yuzu/configuration/configure_graphics_advanced.ui index 846a30586..18c43629e 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.ui +++ b/src/yuzu/configuration/configure_graphics_advanced.ui | |||
| @@ -77,6 +77,24 @@ | |||
| 77 | </widget> | 77 | </widget> |
| 78 | </item> | 78 | </item> |
| 79 | <item> | 79 | <item> |
| 80 | <widget class="QCheckBox" name="disable_fps_limit"> | ||
| 81 | <property name="enabled"> | ||
| 82 | <bool>true</bool> | ||
| 83 | </property> | ||
| 84 | <property name="toolTip"> | ||
| 85 | <string> | ||
| 86 | <html><head/><body> | ||
| 87 | <p>Presents guest frames as they become available, disabling the FPS limit in most titles.</p> | ||
| 88 | <p>NOTE: Will cause instabilities.</p> | ||
| 89 | </body></html> | ||
| 90 | </string> | ||
| 91 | </property> | ||
| 92 | <property name="text"> | ||
| 93 | <string>Disable framerate limit (experimental)</string> | ||
| 94 | </property> | ||
| 95 | </widget> | ||
| 96 | </item> | ||
| 97 | <item> | ||
| 80 | <widget class="QCheckBox" name="use_assembly_shaders"> | 98 | <widget class="QCheckBox" name="use_assembly_shaders"> |
| 81 | <property name="toolTip"> | 99 | <property name="toolTip"> |
| 82 | <string>Enabling this reduces shader stutter. Enables OpenGL assembly shaders on supported Nvidia devices (NV_gpu_program5 is required). This feature is experimental.</string> | 100 | <string>Enabling this reduces shader stutter. Enables OpenGL assembly shaders on supported Nvidia devices (NV_gpu_program5 is required). This feature is experimental.</string> |
| @@ -104,6 +122,16 @@ | |||
| 104 | </widget> | 122 | </widget> |
| 105 | </item> | 123 | </item> |
| 106 | <item> | 124 | <item> |
| 125 | <widget class="QCheckBox" name="use_caches_gc"> | ||
| 126 | <property name="toolTip"> | ||
| 127 | <string>Enables garbage collection for the GPU caches, this will try to keep VRAM within 3-4 GB by flushing the least used textures/buffers. May cause issues in a few games.</string> | ||
| 128 | </property> | ||
| 129 | <property name="text"> | ||
| 130 | <string>Enable GPU cache garbage collection (experimental)</string> | ||
| 131 | </property> | ||
| 132 | </widget> | ||
| 133 | </item> | ||
| 134 | <item> | ||
| 107 | <widget class="QWidget" name="af_layout" native="true"> | 135 | <widget class="QWidget" name="af_layout" native="true"> |
| 108 | <layout class="QHBoxLayout" name="horizontalLayout_1"> | 136 | <layout class="QHBoxLayout" name="horizontalLayout_1"> |
| 109 | <property name="leftMargin"> | 137 | <property name="leftMargin"> |
diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp index a1d434aca..8c00eec59 100644 --- a/src/yuzu/configuration/configure_per_game.cpp +++ b/src/yuzu/configuration/configure_per_game.cpp | |||
| @@ -47,6 +47,8 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id, const std::str | |||
| 47 | ui->setupUi(this); | 47 | ui->setupUi(this); |
| 48 | setFocusPolicy(Qt::ClickFocus); | 48 | setFocusPolicy(Qt::ClickFocus); |
| 49 | setWindowTitle(tr("Properties")); | 49 | setWindowTitle(tr("Properties")); |
| 50 | // remove Help question mark button from the title bar | ||
| 51 | setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); | ||
| 50 | 52 | ||
| 51 | ui->addonsTab->SetTitleId(title_id); | 53 | ui->addonsTab->SetTitleId(title_id); |
| 52 | 54 | ||
diff --git a/src/yuzu/configuration/configure_per_game.ui b/src/yuzu/configuration/configure_per_game.ui index adf6d0b39..7da14146b 100644 --- a/src/yuzu/configuration/configure_per_game.ui +++ b/src/yuzu/configuration/configure_per_game.ui | |||
| @@ -6,10 +6,15 @@ | |||
| 6 | <rect> | 6 | <rect> |
| 7 | <x>0</x> | 7 | <x>0</x> |
| 8 | <y>0</y> | 8 | <y>0</y> |
| 9 | <width>800</width> | 9 | <width>900</width> |
| 10 | <height>600</height> | 10 | <height>600</height> |
| 11 | </rect> | 11 | </rect> |
| 12 | </property> | 12 | </property> |
| 13 | <property name="minimumSize"> | ||
| 14 | <size> | ||
| 15 | <width>900</width> | ||
| 16 | </size> | ||
| 17 | </property> | ||
| 13 | <property name="windowTitle"> | 18 | <property name="windowTitle"> |
| 14 | <string>Dialog</string> | 19 | <string>Dialog</string> |
| 15 | </property> | 20 | </property> |
diff --git a/src/yuzu/configuration/configure_per_game_addons.cpp b/src/yuzu/configuration/configure_per_game_addons.cpp index 9b709d405..ebb0f411c 100644 --- a/src/yuzu/configuration/configure_per_game_addons.cpp +++ b/src/yuzu/configuration/configure_per_game_addons.cpp | |||
| @@ -79,8 +79,8 @@ void ConfigurePerGameAddons::ApplyConfiguration() { | |||
| 79 | std::sort(disabled_addons.begin(), disabled_addons.end()); | 79 | std::sort(disabled_addons.begin(), disabled_addons.end()); |
| 80 | std::sort(current.begin(), current.end()); | 80 | std::sort(current.begin(), current.end()); |
| 81 | if (disabled_addons != current) { | 81 | if (disabled_addons != current) { |
| 82 | void(Common::FS::RemoveFile(Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / | 82 | Common::FS::RemoveFile(Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / |
| 83 | "game_list" / fmt::format("{:016X}.pv.txt", title_id))); | 83 | "game_list" / fmt::format("{:016X}.pv.txt", title_id)); |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | Settings::values.disabled_addons[title_id] = disabled_addons; | 86 | Settings::values.disabled_addons[title_id] = disabled_addons; |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index be8933c5c..75ab5ef44 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -194,10 +194,10 @@ static void RemoveCachedContents() { | |||
| 194 | const auto offline_legal_information = cache_dir / "offline_web_applet_legal_information"; | 194 | const auto offline_legal_information = cache_dir / "offline_web_applet_legal_information"; |
| 195 | const auto offline_system_data = cache_dir / "offline_web_applet_system_data"; | 195 | const auto offline_system_data = cache_dir / "offline_web_applet_system_data"; |
| 196 | 196 | ||
| 197 | void(Common::FS::RemoveDirRecursively(offline_fonts)); | 197 | Common::FS::RemoveDirRecursively(offline_fonts); |
| 198 | void(Common::FS::RemoveDirRecursively(offline_manual)); | 198 | Common::FS::RemoveDirRecursively(offline_manual); |
| 199 | void(Common::FS::RemoveDirRecursively(offline_legal_information)); | 199 | Common::FS::RemoveDirRecursively(offline_legal_information); |
| 200 | void(Common::FS::RemoveDirRecursively(offline_system_data)); | 200 | Common::FS::RemoveDirRecursively(offline_system_data); |
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | GMainWindow::GMainWindow() | 203 | GMainWindow::GMainWindow() |
| @@ -1025,7 +1025,11 @@ void GMainWindow::InitializeHotkeys() { | |||
| 1025 | connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Mute Audio"), this), | 1025 | connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Mute Audio"), this), |
| 1026 | &QShortcut::activated, this, | 1026 | &QShortcut::activated, this, |
| 1027 | [] { Settings::values.audio_muted = !Settings::values.audio_muted; }); | 1027 | [] { Settings::values.audio_muted = !Settings::values.audio_muted; }); |
| 1028 | 1028 | connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Framerate Limit"), this), | |
| 1029 | &QShortcut::activated, this, [] { | ||
| 1030 | Settings::values.disable_fps_limit.SetValue( | ||
| 1031 | !Settings::values.disable_fps_limit.GetValue()); | ||
| 1032 | }); | ||
| 1029 | connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Mouse Panning"), this), | 1033 | connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Mouse Panning"), this), |
| 1030 | &QShortcut::activated, this, [&] { | 1034 | &QShortcut::activated, this, [&] { |
| 1031 | Settings::values.mouse_panning = !Settings::values.mouse_panning; | 1035 | Settings::values.mouse_panning = !Settings::values.mouse_panning; |
| @@ -1739,8 +1743,8 @@ void GMainWindow::OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryT | |||
| 1739 | RemoveAddOnContent(program_id, entry_type); | 1743 | RemoveAddOnContent(program_id, entry_type); |
| 1740 | break; | 1744 | break; |
| 1741 | } | 1745 | } |
| 1742 | void(Common::FS::RemoveDirRecursively(Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / | 1746 | Common::FS::RemoveDirRecursively(Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / |
| 1743 | "game_list")); | 1747 | "game_list"); |
| 1744 | game_list->PopulateAsync(UISettings::values.game_dirs); | 1748 | game_list->PopulateAsync(UISettings::values.game_dirs); |
| 1745 | } | 1749 | } |
| 1746 | 1750 | ||
| @@ -2209,8 +2213,8 @@ void GMainWindow::OnMenuInstallToNAND() { | |||
| 2209 | : tr("%n file(s) failed to install\n", "", failed_files.size())); | 2213 | : tr("%n file(s) failed to install\n", "", failed_files.size())); |
| 2210 | 2214 | ||
| 2211 | QMessageBox::information(this, tr("Install Results"), install_results); | 2215 | QMessageBox::information(this, tr("Install Results"), install_results); |
| 2212 | void(Common::FS::RemoveDirRecursively(Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / | 2216 | Common::FS::RemoveDirRecursively(Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / |
| 2213 | "game_list")); | 2217 | "game_list"); |
| 2214 | game_list->PopulateAsync(UISettings::values.game_dirs); | 2218 | game_list->PopulateAsync(UISettings::values.game_dirs); |
| 2215 | ui.action_Install_File_NAND->setEnabled(true); | 2219 | ui.action_Install_File_NAND->setEnabled(true); |
| 2216 | } | 2220 | } |
| @@ -2842,7 +2846,7 @@ void GMainWindow::MigrateConfigFiles() { | |||
| 2842 | LOG_INFO(Frontend, "Migrating config file from {} to {}", origin, destination); | 2846 | LOG_INFO(Frontend, "Migrating config file from {} to {}", origin, destination); |
| 2843 | if (!Common::FS::RenameFile(origin, destination)) { | 2847 | if (!Common::FS::RenameFile(origin, destination)) { |
| 2844 | // Delete the old config file if one already exists in the new location. | 2848 | // Delete the old config file if one already exists in the new location. |
| 2845 | void(Common::FS::RemoveFile(origin)); | 2849 | Common::FS::RemoveFile(origin); |
| 2846 | } | 2850 | } |
| 2847 | } | 2851 | } |
| 2848 | } | 2852 | } |
| @@ -3036,9 +3040,9 @@ void GMainWindow::OnReinitializeKeys(ReinitializeKeyBehavior behavior) { | |||
| 3036 | 3040 | ||
| 3037 | const auto keys_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::KeysDir); | 3041 | const auto keys_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::KeysDir); |
| 3038 | 3042 | ||
| 3039 | void(Common::FS::RemoveFile(keys_dir / "prod.keys_autogenerated")); | 3043 | Common::FS::RemoveFile(keys_dir / "prod.keys_autogenerated"); |
| 3040 | void(Common::FS::RemoveFile(keys_dir / "console.keys_autogenerated")); | 3044 | Common::FS::RemoveFile(keys_dir / "console.keys_autogenerated"); |
| 3041 | void(Common::FS::RemoveFile(keys_dir / "title.keys_autogenerated")); | 3045 | Common::FS::RemoveFile(keys_dir / "title.keys_autogenerated"); |
| 3042 | } | 3046 | } |
| 3043 | 3047 | ||
| 3044 | Core::Crypto::KeyManager& keys = Core::Crypto::KeyManager::Instance(); | 3048 | Core::Crypto::KeyManager& keys = Core::Crypto::KeyManager::Instance(); |
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index 621b31571..60bf66ec0 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp | |||
| @@ -443,6 +443,8 @@ void Config::ReadValues() { | |||
| 443 | sdl2_config->GetBoolean("Renderer", "use_asynchronous_gpu_emulation", true)); | 443 | sdl2_config->GetBoolean("Renderer", "use_asynchronous_gpu_emulation", true)); |
| 444 | Settings::values.use_vsync.SetValue( | 444 | Settings::values.use_vsync.SetValue( |
| 445 | static_cast<u16>(sdl2_config->GetInteger("Renderer", "use_vsync", 1))); | 445 | static_cast<u16>(sdl2_config->GetInteger("Renderer", "use_vsync", 1))); |
| 446 | Settings::values.disable_fps_limit.SetValue( | ||
| 447 | sdl2_config->GetBoolean("Renderer", "disable_fps_limit", false)); | ||
| 446 | Settings::values.use_assembly_shaders.SetValue( | 448 | Settings::values.use_assembly_shaders.SetValue( |
| 447 | sdl2_config->GetBoolean("Renderer", "use_assembly_shaders", true)); | 449 | sdl2_config->GetBoolean("Renderer", "use_assembly_shaders", true)); |
| 448 | Settings::values.use_asynchronous_shaders.SetValue( | 450 | Settings::values.use_asynchronous_shaders.SetValue( |
diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h index 37d895ebd..cc9850aad 100644 --- a/src/yuzu_cmd/default_ini.h +++ b/src/yuzu_cmd/default_ini.h | |||
| @@ -227,6 +227,10 @@ use_asynchronous_gpu_emulation = | |||
| 227 | # 0: Off, 1 (default): On | 227 | # 0: Off, 1 (default): On |
| 228 | use_vsync = | 228 | use_vsync = |
| 229 | 229 | ||
| 230 | # Whether to use garbage collection or not for GPU caches. | ||
| 231 | # 0 (default): Off, 1: On | ||
| 232 | use_caches_gc = | ||
| 233 | |||
| 230 | # The clear color for the renderer. What shows up on the sides of the bottom screen. | 234 | # The clear color for the renderer. What shows up on the sides of the bottom screen. |
| 231 | # Must be in range of 0.0-1.0. Defaults to 1.0 for all. | 235 | # Must be in range of 0.0-1.0. Defaults to 1.0 for all. |
| 232 | bg_red = | 236 | bg_red = |
| @@ -362,6 +366,9 @@ use_debug_asserts = | |||
| 362 | use_auto_stub = | 366 | use_auto_stub = |
| 363 | # Enables/Disables the macro JIT compiler | 367 | # Enables/Disables the macro JIT compiler |
| 364 | disable_macro_jit=false | 368 | disable_macro_jit=false |
| 369 | # Presents guest frames as they become available. Experimental. | ||
| 370 | # false: Disabled (default), true: Enabled | ||
| 371 | disable_fps_limit=false | ||
| 365 | 372 | ||
| 366 | [WebService] | 373 | [WebService] |
| 367 | # Whether or not to enable telemetry | 374 | # Whether or not to enable telemetry |
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 584967f5c..50e388312 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp | |||
| @@ -219,7 +219,7 @@ int main(int argc, char** argv) { | |||
| 219 | system.GPU().Start(); | 219 | system.GPU().Start(); |
| 220 | 220 | ||
| 221 | system.Renderer().ReadRasterizer()->LoadDiskResources( | 221 | system.Renderer().ReadRasterizer()->LoadDiskResources( |
| 222 | system.CurrentProcess()->GetTitleID(), false, | 222 | system.CurrentProcess()->GetTitleID(), std::stop_token{}, |
| 223 | [](VideoCore::LoadCallbackStage, size_t value, size_t total) {}); | 223 | [](VideoCore::LoadCallbackStage, size_t value, size_t total) {}); |
| 224 | 224 | ||
| 225 | void(system.Run()); | 225 | void(system.Run()); |