diff options
| author | 2020-02-21 12:40:23 -0500 | |
|---|---|---|
| committer | 2020-02-25 21:23:02 -0500 | |
| commit | c6f78a4a6d8746b84b2891e536286d9d6a63015e (patch) | |
| tree | 341376f25aaa9008eedcff6a39c6cfc84acc9ed8 /src | |
| parent | frontend: qt: bootmanager: Vulkan: Restore support for VK backend. (diff) | |
| download | yuzu-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.cpp | 15 | ||||
| -rw-r--r-- | src/yuzu/bootmanager.h | 9 |
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 | ||
| 42 | EmuThread::EmuThread(Core::Frontend::GraphicsContext& core_context) : core_context(core_context) {} | 42 | EmuThread::EmuThread(GRenderWindow& window) |
| 43 | : shared_context{window.CreateSharedContext()}, | ||
| 44 | context{(Settings::values.use_asynchronous_gpu_emulation && shared_context) ? *shared_context | ||
| 45 | : window} {} | ||
| 43 | 46 | ||
| 44 | EmuThread::~EmuThread() = default; | 47 | EmuThread::~EmuThread() = default; |
| 45 | 48 | ||
| @@ -55,15 +58,7 @@ static GMainWindow* GetMainWindow() { | |||
| 55 | void EmuThread::run() { | 58 | void 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 | ||
| 20 | class GRenderWindow; | ||
| 20 | class QKeyEvent; | 21 | class QKeyEvent; |
| 21 | class QScreen; | 22 | class QScreen; |
| 22 | class QTouchEvent; | 23 | class QTouchEvent; |
| @@ -35,7 +36,7 @@ class EmuThread final : public QThread { | |||
| 35 | Q_OBJECT | 36 | Q_OBJECT |
| 36 | 37 | ||
| 37 | public: | 38 | public: |
| 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 | ||
| 94 | signals: | 99 | signals: |
| 95 | /** | 100 | /** |