summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2020-02-21 12:40:23 -0500
committerGravatar bunnei2020-02-25 21:23:02 -0500
commitc6f78a4a6d8746b84b2891e536286d9d6a63015e (patch)
tree341376f25aaa9008eedcff6a39c6cfc84acc9ed8 /src
parentfrontend: qt: bootmanager: Vulkan: Restore support for VK backend. (diff)
downloadyuzu-c6f78a4a6d8746b84b2891e536286d9d6a63015e.tar.gz
yuzu-c6f78a4a6d8746b84b2891e536286d9d6a63015e.tar.xz
yuzu-c6f78a4a6d8746b84b2891e536286d9d6a63015e.zip
frontend: qt: bootmanager: Acquire a shared context in main emu thread.
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/bootmanager.cpp15
-rw-r--r--src/yuzu/bootmanager.h9
2 files changed, 12 insertions, 12 deletions
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp
index 704c5ecdd..c3dbb1a88 100644
--- a/src/yuzu/bootmanager.cpp
+++ b/src/yuzu/bootmanager.cpp
@@ -39,7 +39,10 @@
39#include "yuzu/bootmanager.h" 39#include "yuzu/bootmanager.h"
40#include "yuzu/main.h" 40#include "yuzu/main.h"
41 41
42EmuThread::EmuThread(Core::Frontend::GraphicsContext& core_context) : core_context(core_context) {} 42EmuThread::EmuThread(GRenderWindow& window)
43 : shared_context{window.CreateSharedContext()},
44 context{(Settings::values.use_asynchronous_gpu_emulation && shared_context) ? *shared_context
45 : window} {}
43 46
44EmuThread::~EmuThread() = default; 47EmuThread::~EmuThread() = default;
45 48
@@ -55,15 +58,7 @@ static GMainWindow* GetMainWindow() {
55void EmuThread::run() { 58void EmuThread::run() {
56 MicroProfileOnThreadCreate("EmuThread"); 59 MicroProfileOnThreadCreate("EmuThread");
57 60
58 // Acquire render context for duration of the thread if this is the rendering thread 61 Core::Frontend::ScopeAcquireContext acquire_context{context};
59 if (!Settings::values.use_asynchronous_gpu_emulation) {
60 core_context.MakeCurrent();
61 }
62 SCOPE_EXIT({
63 if (!Settings::values.use_asynchronous_gpu_emulation) {
64 core_context.DoneCurrent();
65 }
66 });
67 62
68 emit LoadProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0); 63 emit LoadProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0);
69 64
diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h
index 6710a6e7f..79b030304 100644
--- a/src/yuzu/bootmanager.h
+++ b/src/yuzu/bootmanager.h
@@ -17,6 +17,7 @@
17#include "core/core.h" 17#include "core/core.h"
18#include "core/frontend/emu_window.h" 18#include "core/frontend/emu_window.h"
19 19
20class GRenderWindow;
20class QKeyEvent; 21class QKeyEvent;
21class QScreen; 22class QScreen;
22class QTouchEvent; 23class QTouchEvent;
@@ -35,7 +36,7 @@ class EmuThread final : public QThread {
35 Q_OBJECT 36 Q_OBJECT
36 37
37public: 38public:
38 explicit EmuThread(Core::Frontend::GraphicsContext& context); 39 explicit EmuThread(GRenderWindow& window);
39 ~EmuThread() override; 40 ~EmuThread() override;
40 41
41 /** 42 /**
@@ -89,7 +90,11 @@ private:
89 std::mutex running_mutex; 90 std::mutex running_mutex;
90 std::condition_variable running_cv; 91 std::condition_variable running_cv;
91 92
92 Core::Frontend::GraphicsContext& core_context; 93 /// Only used in asynchronous GPU mode
94 std::unique_ptr<Core::Frontend::GraphicsContext> shared_context;
95
96 /// This is shared_context in asynchronous GPU mode, core_context in synchronous GPU mode
97 Core::Frontend::GraphicsContext& context;
93 98
94signals: 99signals:
95 /** 100 /**