diff options
| -rw-r--r-- | src/video_core/rasterizer_interface.h | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_cache.cpp | 6 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_cache.h | 2 | ||||
| -rw-r--r-- | src/yuzu/bootmanager.cpp | 12 | ||||
| -rw-r--r-- | src/yuzu/bootmanager.h | 6 | ||||
| -rw-r--r-- | src/yuzu_cmd/yuzu.cpp | 2 |
8 files changed, 18 insertions, 18 deletions
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/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_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()); |