summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/CMakeLists.txt2
-rw-r--r--src/core/frontend/scope_acquire_window_context.cpp18
-rw-r--r--src/core/frontend/scope_acquire_window_context.h23
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp4
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp16
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.h10
-rw-r--r--src/yuzu/main.cpp17
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
8namespace Core::Frontend {
9
10ScopeAcquireWindowContext::ScopeAcquireWindowContext(Core::Frontend::EmuWindow& emu_window_)
11 : emu_window{emu_window_} {
12 emu_window.MakeCurrent();
13}
14ScopeAcquireWindowContext::~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
9namespace Core::Frontend {
10
11class EmuWindow;
12
13/// Helper class to acquire/release window context within a given scope
14class ScopeAcquireWindowContext : NonCopyable {
15public:
16 explicit ScopeAcquireWindowContext(Core::Frontend::EmuWindow& window);
17 ~ScopeAcquireWindowContext();
18
19private:
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
100ScopeAcquireGLContext::ScopeAcquireGLContext(Core::Frontend::EmuWindow& emu_window_)
101 : emu_window{emu_window_} {
102 if (Settings::values.use_multi_core) {
103 emu_window.MakeCurrent();
104 }
105}
106ScopeAcquireGLContext::~ScopeAcquireGLContext() {
107 if (Settings::values.use_multi_core) {
108 emu_window.DoneCurrent();
109 }
110}
111
112RendererOpenGL::RendererOpenGL(Core::Frontend::EmuWindow& window) 101RendererOpenGL::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)
118void RendererOpenGL::SwapBuffers( 107void 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
508bool RendererOpenGL::Init() { 496bool 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
43class ScopeAcquireGLContext : NonCopyable {
44public:
45 explicit ScopeAcquireGLContext(Core::Frontend::EmuWindow& window);
46 ~ScopeAcquireGLContext();
47
48private:
49 Core::Frontend::EmuWindow& emu_window;
50};
51
52class RendererOpenGL : public VideoCore::RendererBase { 42class RendererOpenGL : public VideoCore::RendererBase {
53public: 43public:
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: