diff options
| author | 2020-02-17 15:38:56 -0500 | |
|---|---|---|
| committer | 2020-02-25 21:23:00 -0500 | |
| commit | 667f026c9570b772719d2ada94cc40d420113c23 (patch) | |
| tree | 749c65d2e1424156d8cbc82d91c1ce5131d27ca6 | |
| parent | frontend: sdl2: emu_window: Implement separate presentation thread. (diff) | |
| download | yuzu-667f026c9570b772719d2ada94cc40d420113c23.tar.gz yuzu-667f026c9570b772719d2ada94cc40d420113c23.tar.xz yuzu-667f026c9570b772719d2ada94cc40d420113c23.zip | |
core: frontend: Refactor scope_acquire_window_context to scope_acquire_context.
| -rw-r--r-- | src/core/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | src/core/core.cpp | 3 | ||||
| -rw-r--r-- | src/core/frontend/scope_acquire_context.cpp | 18 | ||||
| -rw-r--r-- | src/core/frontend/scope_acquire_context.h (renamed from src/core/frontend/scope_acquire_window_context.h) | 10 | ||||
| -rw-r--r-- | src/core/frontend/scope_acquire_window_context.cpp | 18 | ||||
| -rw-r--r-- | src/video_core/gpu_thread.cpp | 4 | ||||
| -rw-r--r-- | src/yuzu/bootmanager.cpp | 4 |
7 files changed, 32 insertions, 29 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 88c06b2ce..54be7dc0c 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -131,8 +131,8 @@ add_library(core STATIC | |||
| 131 | frontend/framebuffer_layout.cpp | 131 | frontend/framebuffer_layout.cpp |
| 132 | frontend/framebuffer_layout.h | 132 | frontend/framebuffer_layout.h |
| 133 | frontend/input.h | 133 | frontend/input.h |
| 134 | frontend/scope_acquire_window_context.cpp | 134 | frontend/scope_acquire_context.cpp |
| 135 | frontend/scope_acquire_window_context.h | 135 | frontend/scope_acquire_context.h |
| 136 | gdbstub/gdbstub.cpp | 136 | gdbstub/gdbstub.cpp |
| 137 | gdbstub/gdbstub.h | 137 | gdbstub/gdbstub.h |
| 138 | hardware_interrupt_manager.cpp | 138 | hardware_interrupt_manager.cpp |
diff --git a/src/core/core.cpp b/src/core/core.cpp index 86e314c94..a82faf127 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include "core/file_sys/sdmc_factory.h" | 24 | #include "core/file_sys/sdmc_factory.h" |
| 25 | #include "core/file_sys/vfs_concat.h" | 25 | #include "core/file_sys/vfs_concat.h" |
| 26 | #include "core/file_sys/vfs_real.h" | 26 | #include "core/file_sys/vfs_real.h" |
| 27 | #include "core/frontend/scope_acquire_context.h" | ||
| 27 | #include "core/gdbstub/gdbstub.h" | 28 | #include "core/gdbstub/gdbstub.h" |
| 28 | #include "core/hardware_interrupt_manager.h" | 29 | #include "core/hardware_interrupt_manager.h" |
| 29 | #include "core/hle/kernel/client_port.h" | 30 | #include "core/hle/kernel/client_port.h" |
| @@ -184,6 +185,8 @@ struct System::Impl { | |||
| 184 | 185 | ||
| 185 | ResultStatus Load(System& system, Frontend::EmuWindow& emu_window, | 186 | ResultStatus Load(System& system, Frontend::EmuWindow& emu_window, |
| 186 | const std::string& filepath) { | 187 | const std::string& filepath) { |
| 188 | Core::Frontend::ScopeAcquireContext acquire_context{emu_window}; | ||
| 189 | |||
| 187 | app_loader = Loader::GetLoader(GetGameFileFromPath(virtual_filesystem, filepath)); | 190 | app_loader = Loader::GetLoader(GetGameFileFromPath(virtual_filesystem, filepath)); |
| 188 | if (!app_loader) { | 191 | if (!app_loader) { |
| 189 | LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); | 192 | LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); |
diff --git a/src/core/frontend/scope_acquire_context.cpp b/src/core/frontend/scope_acquire_context.cpp new file mode 100644 index 000000000..878c3157c --- /dev/null +++ b/src/core/frontend/scope_acquire_context.cpp | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | // Copyright 2019 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "core/frontend/emu_window.h" | ||
| 6 | #include "core/frontend/scope_acquire_context.h" | ||
| 7 | |||
| 8 | namespace Core::Frontend { | ||
| 9 | |||
| 10 | ScopeAcquireContext::ScopeAcquireContext(Core::Frontend::GraphicsContext& context) | ||
| 11 | : context{context} { | ||
| 12 | context.MakeCurrent(); | ||
| 13 | } | ||
| 14 | ScopeAcquireContext::~ScopeAcquireContext() { | ||
| 15 | context.DoneCurrent(); | ||
| 16 | } | ||
| 17 | |||
| 18 | } // namespace Core::Frontend | ||
diff --git a/src/core/frontend/scope_acquire_window_context.h b/src/core/frontend/scope_acquire_context.h index 2d9f6e825..7a65c0623 100644 --- a/src/core/frontend/scope_acquire_window_context.h +++ b/src/core/frontend/scope_acquire_context.h | |||
| @@ -8,16 +8,16 @@ | |||
| 8 | 8 | ||
| 9 | namespace Core::Frontend { | 9 | namespace Core::Frontend { |
| 10 | 10 | ||
| 11 | class EmuWindow; | 11 | class GraphicsContext; |
| 12 | 12 | ||
| 13 | /// Helper class to acquire/release window context within a given scope | 13 | /// Helper class to acquire/release window context within a given scope |
| 14 | class ScopeAcquireWindowContext : NonCopyable { | 14 | class ScopeAcquireContext : NonCopyable { |
| 15 | public: | 15 | public: |
| 16 | explicit ScopeAcquireWindowContext(Core::Frontend::EmuWindow& window); | 16 | explicit ScopeAcquireContext(Core::Frontend::GraphicsContext& context); |
| 17 | ~ScopeAcquireWindowContext(); | 17 | ~ScopeAcquireContext(); |
| 18 | 18 | ||
| 19 | private: | 19 | private: |
| 20 | Core::Frontend::EmuWindow& emu_window; | 20 | Core::Frontend::GraphicsContext& context; |
| 21 | }; | 21 | }; |
| 22 | 22 | ||
| 23 | } // namespace Core::Frontend | 23 | } // namespace Core::Frontend |
diff --git a/src/core/frontend/scope_acquire_window_context.cpp b/src/core/frontend/scope_acquire_window_context.cpp deleted file mode 100644 index 3663dad17..000000000 --- a/src/core/frontend/scope_acquire_window_context.cpp +++ /dev/null | |||
| @@ -1,18 +0,0 @@ | |||
| 1 | // Copyright 2019 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "core/frontend/emu_window.h" | ||
| 6 | #include "core/frontend/scope_acquire_window_context.h" | ||
| 7 | |||
| 8 | namespace Core::Frontend { | ||
| 9 | |||
| 10 | ScopeAcquireWindowContext::ScopeAcquireWindowContext(Core::Frontend::EmuWindow& emu_window_) | ||
| 11 | : emu_window{emu_window_} { | ||
| 12 | emu_window.MakeCurrent(); | ||
| 13 | } | ||
| 14 | ScopeAcquireWindowContext::~ScopeAcquireWindowContext() { | ||
| 15 | emu_window.DoneCurrent(); | ||
| 16 | } | ||
| 17 | |||
| 18 | } // namespace Core::Frontend | ||
diff --git a/src/video_core/gpu_thread.cpp b/src/video_core/gpu_thread.cpp index 2cdf1aa7f..b1088af3d 100644 --- a/src/video_core/gpu_thread.cpp +++ b/src/video_core/gpu_thread.cpp | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #include "common/assert.h" | 5 | #include "common/assert.h" |
| 6 | #include "common/microprofile.h" | 6 | #include "common/microprofile.h" |
| 7 | #include "core/core.h" | 7 | #include "core/core.h" |
| 8 | #include "core/frontend/scope_acquire_window_context.h" | 8 | #include "core/frontend/scope_acquire_context.h" |
| 9 | #include "video_core/dma_pusher.h" | 9 | #include "video_core/dma_pusher.h" |
| 10 | #include "video_core/gpu.h" | 10 | #include "video_core/gpu.h" |
| 11 | #include "video_core/gpu_thread.h" | 11 | #include "video_core/gpu_thread.h" |
| @@ -27,7 +27,7 @@ static void RunThread(VideoCore::RendererBase& renderer, Tegra::DmaPusher& dma_p | |||
| 27 | return; | 27 | return; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | Core::Frontend::ScopeAcquireWindowContext acquire_context{renderer.GetRenderWindow()}; | 30 | Core::Frontend::ScopeAcquireContext acquire_context{renderer.GetRenderWindow()}; |
| 31 | 31 | ||
| 32 | CommandDataContainer next; | 32 | CommandDataContainer next; |
| 33 | while (state.is_running) { | 33 | while (state.is_running) { |
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 55a37fffa..4982884f5 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp | |||
| @@ -25,7 +25,7 @@ | |||
| 25 | #include "common/scm_rev.h" | 25 | #include "common/scm_rev.h" |
| 26 | #include "core/core.h" | 26 | #include "core/core.h" |
| 27 | #include "core/frontend/framebuffer_layout.h" | 27 | #include "core/frontend/framebuffer_layout.h" |
| 28 | #include "core/frontend/scope_acquire_window_context.h" | 28 | #include "core/frontend/scope_acquire_context.h" |
| 29 | #include "core/settings.h" | 29 | #include "core/settings.h" |
| 30 | #include "input_common/keyboard.h" | 30 | #include "input_common/keyboard.h" |
| 31 | #include "input_common/main.h" | 31 | #include "input_common/main.h" |
| @@ -569,7 +569,7 @@ bool GRenderWindow::InitializeVulkan() { | |||
| 569 | } | 569 | } |
| 570 | 570 | ||
| 571 | bool GRenderWindow::LoadOpenGL() { | 571 | bool GRenderWindow::LoadOpenGL() { |
| 572 | Core::Frontend::ScopeAcquireWindowContext acquire_context{*this}; | 572 | Core::Frontend::ScopeAcquireContext acquire_context{*this}; |
| 573 | if (!gladLoadGL()) { | 573 | if (!gladLoadGL()) { |
| 574 | QMessageBox::critical(this, tr("Error while initializing OpenGL 4.3!"), | 574 | QMessageBox::critical(this, tr("Error while initializing OpenGL 4.3!"), |
| 575 | tr("Your GPU may not support OpenGL 4.3, or you do not have the " | 575 | tr("Your GPU may not support OpenGL 4.3, or you do not have the " |