diff options
| author | 2019-01-23 21:20:08 -0500 | |
|---|---|---|
| committer | 2019-01-23 21:20:08 -0500 | |
| commit | f574d324e7f8692ebff0aaa17c416f4840feda5c (patch) | |
| tree | afd89a9ec560c65070c37bbd0151c5327cc71e8a /src | |
| parent | Merge pull request #2049 from FearlessTobi/port-3928 (diff) | |
| parent | frontend: Refactor ScopeAcquireWindowContext out of renderer_opengl. (diff) | |
| download | yuzu-f574d324e7f8692ebff0aaa17c416f4840feda5c.tar.gz yuzu-f574d324e7f8692ebff0aaa17c416f4840feda5c.tar.xz yuzu-f574d324e7f8692ebff0aaa17c416f4840feda5c.zip | |
Merge pull request #2054 from bunnei/scope-context-refactor
frontend: Refactor ScopeAcquireWindowContext out of renderer_opengl.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/frontend/scope_acquire_window_context.cpp | 18 | ||||
| -rw-r--r-- | src/core/frontend/scope_acquire_window_context.h | 23 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 16 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.h | 10 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 17 |
7 files changed, 54 insertions, 36 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index aa9e05089..965c28787 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -95,6 +95,8 @@ add_library(core STATIC | |||
| 95 | frontend/framebuffer_layout.cpp | 95 | frontend/framebuffer_layout.cpp |
| 96 | frontend/framebuffer_layout.h | 96 | frontend/framebuffer_layout.h |
| 97 | frontend/input.h | 97 | frontend/input.h |
| 98 | frontend/scope_acquire_window_context.cpp | ||
| 99 | frontend/scope_acquire_window_context.h | ||
| 98 | gdbstub/gdbstub.cpp | 100 | gdbstub/gdbstub.cpp |
| 99 | gdbstub/gdbstub.h | 101 | gdbstub/gdbstub.h |
| 100 | hle/ipc.h | 102 | hle/ipc.h |
diff --git a/src/core/frontend/scope_acquire_window_context.cpp b/src/core/frontend/scope_acquire_window_context.cpp new file mode 100644 index 000000000..3663dad17 --- /dev/null +++ b/src/core/frontend/scope_acquire_window_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_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/core/frontend/scope_acquire_window_context.h b/src/core/frontend/scope_acquire_window_context.h new file mode 100644 index 000000000..2d9f6e825 --- /dev/null +++ b/src/core/frontend/scope_acquire_window_context.h | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | // Copyright 2019 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/common_types.h" | ||
| 8 | |||
| 9 | namespace Core::Frontend { | ||
| 10 | |||
| 11 | class EmuWindow; | ||
| 12 | |||
| 13 | /// Helper class to acquire/release window context within a given scope | ||
| 14 | class ScopeAcquireWindowContext : NonCopyable { | ||
| 15 | public: | ||
| 16 | explicit ScopeAcquireWindowContext(Core::Frontend::EmuWindow& window); | ||
| 17 | ~ScopeAcquireWindowContext(); | ||
| 18 | |||
| 19 | private: | ||
| 20 | Core::Frontend::EmuWindow& emu_window; | ||
| 21 | }; | ||
| 22 | |||
| 23 | } // namespace Core::Frontend | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index d8e9df5db..6600ad528 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -643,8 +643,6 @@ void RasterizerOpenGL::Clear() { | |||
| 643 | return; | 643 | return; |
| 644 | } | 644 | } |
| 645 | 645 | ||
| 646 | ScopeAcquireGLContext acquire_context{emu_window}; | ||
| 647 | |||
| 648 | ConfigureFramebuffers(clear_state, use_color, use_depth || use_stencil, false, | 646 | ConfigureFramebuffers(clear_state, use_color, use_depth || use_stencil, false, |
| 649 | regs.clear_buffers.RT.Value()); | 647 | regs.clear_buffers.RT.Value()); |
| 650 | if (regs.clear_flags.scissor) { | 648 | if (regs.clear_flags.scissor) { |
| @@ -678,8 +676,6 @@ void RasterizerOpenGL::DrawArrays() { | |||
| 678 | auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); | 676 | auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); |
| 679 | const auto& regs = gpu.regs; | 677 | const auto& regs = gpu.regs; |
| 680 | 678 | ||
| 681 | ScopeAcquireGLContext acquire_context{emu_window}; | ||
| 682 | |||
| 683 | ConfigureFramebuffers(state); | 679 | ConfigureFramebuffers(state); |
| 684 | SyncColorMask(); | 680 | SyncColorMask(); |
| 685 | SyncFragmentColorClampState(); | 681 | SyncFragmentColorClampState(); |
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index c268c9686..e37b65b38 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include "core/core.h" | 14 | #include "core/core.h" |
| 15 | #include "core/core_timing.h" | 15 | #include "core/core_timing.h" |
| 16 | #include "core/frontend/emu_window.h" | 16 | #include "core/frontend/emu_window.h" |
| 17 | #include "core/frontend/scope_acquire_window_context.h" | ||
| 17 | #include "core/memory.h" | 18 | #include "core/memory.h" |
| 18 | #include "core/perf_stats.h" | 19 | #include "core/perf_stats.h" |
| 19 | #include "core/settings.h" | 20 | #include "core/settings.h" |
| @@ -97,18 +98,6 @@ static std::array<GLfloat, 3 * 2> MakeOrthographicMatrix(const float width, cons | |||
| 97 | return matrix; | 98 | return matrix; |
| 98 | } | 99 | } |
| 99 | 100 | ||
| 100 | ScopeAcquireGLContext::ScopeAcquireGLContext(Core::Frontend::EmuWindow& emu_window_) | ||
| 101 | : emu_window{emu_window_} { | ||
| 102 | if (Settings::values.use_multi_core) { | ||
| 103 | emu_window.MakeCurrent(); | ||
| 104 | } | ||
| 105 | } | ||
| 106 | ScopeAcquireGLContext::~ScopeAcquireGLContext() { | ||
| 107 | if (Settings::values.use_multi_core) { | ||
| 108 | emu_window.DoneCurrent(); | ||
| 109 | } | ||
| 110 | } | ||
| 111 | |||
| 112 | RendererOpenGL::RendererOpenGL(Core::Frontend::EmuWindow& window) | 101 | RendererOpenGL::RendererOpenGL(Core::Frontend::EmuWindow& window) |
| 113 | : VideoCore::RendererBase{window} {} | 102 | : VideoCore::RendererBase{window} {} |
| 114 | 103 | ||
| @@ -117,7 +106,6 @@ RendererOpenGL::~RendererOpenGL() = default; | |||
| 117 | /// Swap buffers (render frame) | 106 | /// Swap buffers (render frame) |
| 118 | void RendererOpenGL::SwapBuffers( | 107 | void RendererOpenGL::SwapBuffers( |
| 119 | std::optional<std::reference_wrapper<const Tegra::FramebufferConfig>> framebuffer) { | 108 | std::optional<std::reference_wrapper<const Tegra::FramebufferConfig>> framebuffer) { |
| 120 | ScopeAcquireGLContext acquire_context{render_window}; | ||
| 121 | 109 | ||
| 122 | Core::System::GetInstance().GetPerfStats().EndSystemFrame(); | 110 | Core::System::GetInstance().GetPerfStats().EndSystemFrame(); |
| 123 | 111 | ||
| @@ -506,7 +494,7 @@ static void APIENTRY DebugHandler(GLenum source, GLenum type, GLuint id, GLenum | |||
| 506 | 494 | ||
| 507 | /// Initialize the renderer | 495 | /// Initialize the renderer |
| 508 | bool RendererOpenGL::Init() { | 496 | bool RendererOpenGL::Init() { |
| 509 | ScopeAcquireGLContext acquire_context{render_window}; | 497 | Core::Frontend::ScopeAcquireWindowContext acquire_context{render_window}; |
| 510 | 498 | ||
| 511 | if (GLAD_GL_KHR_debug) { | 499 | if (GLAD_GL_KHR_debug) { |
| 512 | glEnable(GL_DEBUG_OUTPUT); | 500 | glEnable(GL_DEBUG_OUTPUT); |
diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h index b85cc262f..1665018db 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.h +++ b/src/video_core/renderer_opengl/renderer_opengl.h | |||
| @@ -39,16 +39,6 @@ struct ScreenInfo { | |||
| 39 | TextureInfo texture; | 39 | TextureInfo texture; |
| 40 | }; | 40 | }; |
| 41 | 41 | ||
| 42 | /// Helper class to acquire/release OpenGL context within a given scope | ||
| 43 | class ScopeAcquireGLContext : NonCopyable { | ||
| 44 | public: | ||
| 45 | explicit ScopeAcquireGLContext(Core::Frontend::EmuWindow& window); | ||
| 46 | ~ScopeAcquireGLContext(); | ||
| 47 | |||
| 48 | private: | ||
| 49 | Core::Frontend::EmuWindow& emu_window; | ||
| 50 | }; | ||
| 51 | |||
| 52 | class RendererOpenGL : public VideoCore::RendererBase { | 42 | class RendererOpenGL : public VideoCore::RendererBase { |
| 53 | public: | 43 | public: |
| 54 | explicit RendererOpenGL(Core::Frontend::EmuWindow& window); | 44 | explicit RendererOpenGL(Core::Frontend::EmuWindow& window); |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index ca6ddebcb..ab403b3ac 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include "configuration/configure_per_general.h" | 14 | #include "configuration/configure_per_general.h" |
| 15 | #include "core/file_sys/vfs.h" | 15 | #include "core/file_sys/vfs.h" |
| 16 | #include "core/file_sys/vfs_real.h" | 16 | #include "core/file_sys/vfs_real.h" |
| 17 | #include "core/frontend/scope_acquire_window_context.h" | ||
| 17 | #include "core/hle/service/acc/profile_manager.h" | 18 | #include "core/hle/service/acc/profile_manager.h" |
| 18 | #include "core/hle/service/am/applets/applets.h" | 19 | #include "core/hle/service/am/applets/applets.h" |
| 19 | #include "core/hle/service/hid/controllers/npad.h" | 20 | #include "core/hle/service/hid/controllers/npad.h" |
| @@ -747,13 +748,15 @@ bool GMainWindow::LoadROM(const QString& filename) { | |||
| 747 | ShutdownGame(); | 748 | ShutdownGame(); |
| 748 | 749 | ||
| 749 | render_window->InitRenderTarget(); | 750 | render_window->InitRenderTarget(); |
| 750 | render_window->MakeCurrent(); | ||
| 751 | 751 | ||
| 752 | if (!gladLoadGL()) { | 752 | { |
| 753 | QMessageBox::critical(this, tr("Error while initializing OpenGL 4.3 Core!"), | 753 | Core::Frontend::ScopeAcquireWindowContext acquire_context{*render_window}; |
| 754 | tr("Your GPU may not support OpenGL 4.3, or you do not " | 754 | if (!gladLoadGL()) { |
| 755 | "have the latest graphics driver.")); | 755 | QMessageBox::critical(this, tr("Error while initializing OpenGL 4.3 Core!"), |
| 756 | return false; | 756 | tr("Your GPU may not support OpenGL 4.3, or you do not " |
| 757 | "have the latest graphics driver.")); | ||
| 758 | return false; | ||
| 759 | } | ||
| 757 | } | 760 | } |
| 758 | 761 | ||
| 759 | QStringList unsupported_gl_extensions = GetUnsupportedGLExtensions(); | 762 | QStringList unsupported_gl_extensions = GetUnsupportedGLExtensions(); |
| @@ -794,8 +797,6 @@ bool GMainWindow::LoadROM(const QString& filename) { | |||
| 794 | "wiki</a>. This message will not be shown again.")); | 797 | "wiki</a>. This message will not be shown again.")); |
| 795 | } | 798 | } |
| 796 | 799 | ||
| 797 | render_window->DoneCurrent(); | ||
| 798 | |||
| 799 | if (result != Core::System::ResultStatus::Success) { | 800 | if (result != Core::System::ResultStatus::Success) { |
| 800 | switch (result) { | 801 | switch (result) { |
| 801 | case Core::System::ResultStatus::ErrorGetLoader: | 802 | case Core::System::ResultStatus::ErrorGetLoader: |