summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2020-02-17 15:35:14 -0500
committerGravatar bunnei2020-02-25 21:23:00 -0500
commit2e16c237845bf1b5ff89b7b7a3f8bc1a84729eb1 (patch)
tree2ee5617fc3e3bdc47028d9d65097ceb070031727
parentrenderer_opengl: Add texture mailbox support for presenter thread. (diff)
downloadyuzu-2e16c237845bf1b5ff89b7b7a3f8bc1a84729eb1.tar.gz
yuzu-2e16c237845bf1b5ff89b7b7a3f8bc1a84729eb1.tar.xz
yuzu-2e16c237845bf1b5ff89b7b7a3f8bc1a84729eb1.zip
frontend: sdl2: emu_window: Implement separate presentation thread.
-rw-r--r--src/core/frontend/emu_window.h3
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2.cpp2
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2.h14
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp54
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h18
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp7
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h11
-rw-r--r--src/yuzu_cmd/yuzu.cpp25
-rw-r--r--src/yuzu_tester/emu_window/emu_window_sdl2_hide.cpp4
-rw-r--r--src/yuzu_tester/emu_window/emu_window_sdl2_hide.h3
10 files changed, 79 insertions, 62 deletions
diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h
index 5dde199d4..856cb61e9 100644
--- a/src/core/frontend/emu_window.h
+++ b/src/core/frontend/emu_window.h
@@ -65,9 +65,6 @@ public:
65 65
66 /// Releases (dunno if this is the "right" word) the context from the caller thread 66 /// Releases (dunno if this is the "right" word) the context from the caller thread
67 virtual void DoneCurrent() = 0; 67 virtual void DoneCurrent() = 0;
68
69 /// Swap buffers to display the next frame
70 virtual void SwapBuffers() = 0;
71}; 68};
72 69
73/** 70/**
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
index e96139885..19584360c 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
@@ -13,7 +13,7 @@
13#include "input_common/sdl/sdl.h" 13#include "input_common/sdl/sdl.h"
14#include "yuzu_cmd/emu_window/emu_window_sdl2.h" 14#include "yuzu_cmd/emu_window/emu_window_sdl2.h"
15 15
16EmuWindow_SDL2::EmuWindow_SDL2(bool fullscreen) { 16EmuWindow_SDL2::EmuWindow_SDL2(Core::System& system, bool fullscreen) : system{system} {
17 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) { 17 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {
18 LOG_CRITICAL(Frontend, "Failed to initialize SDL2! Exiting..."); 18 LOG_CRITICAL(Frontend, "Failed to initialize SDL2! Exiting...");
19 exit(1); 19 exit(1);
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.h b/src/yuzu_cmd/emu_window/emu_window_sdl2.h
index b38f56661..fffac4252 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2.h
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.h
@@ -10,9 +10,13 @@
10 10
11struct SDL_Window; 11struct SDL_Window;
12 12
13namespace Core {
14class System;
15}
16
13class EmuWindow_SDL2 : public Core::Frontend::EmuWindow { 17class EmuWindow_SDL2 : public Core::Frontend::EmuWindow {
14public: 18public:
15 explicit EmuWindow_SDL2(bool fullscreen); 19 explicit EmuWindow_SDL2(Core::System& system, bool fullscreen);
16 ~EmuWindow_SDL2(); 20 ~EmuWindow_SDL2();
17 21
18 /// Polls window events 22 /// Polls window events
@@ -24,6 +28,9 @@ public:
24 /// Returns if window is shown (not minimized) 28 /// Returns if window is shown (not minimized)
25 bool IsShown() const override; 29 bool IsShown() const override;
26 30
31 /// Presents the next frame
32 virtual void Present() = 0;
33
27protected: 34protected:
28 /// Called by PollEvents when a key is pressed or released. 35 /// Called by PollEvents when a key is pressed or released.
29 void OnKeyEvent(int key, u8 state); 36 void OnKeyEvent(int key, u8 state);
@@ -55,6 +62,9 @@ protected:
55 /// Called when a configuration change affects the minimal size of the window 62 /// Called when a configuration change affects the minimal size of the window
56 void OnMinimalClientAreaChangeRequest(std::pair<unsigned, unsigned> minimal_size) override; 63 void OnMinimalClientAreaChangeRequest(std::pair<unsigned, unsigned> minimal_size) override;
57 64
65 /// Instance of the system, used to access renderer for the presentation thread
66 Core::System& system;
67
58 /// Is the window still open? 68 /// Is the window still open?
59 bool is_open = true; 69 bool is_open = true;
60 70
@@ -62,7 +72,7 @@ protected:
62 bool is_shown = true; 72 bool is_shown = true;
63 73
64 /// Internal SDL2 render window 74 /// Internal SDL2 render window
65 SDL_Window* render_window; 75 SDL_Window* render_window{};
66 76
67 /// Keeps track of how often to update the title bar during gameplay 77 /// Keeps track of how often to update the title bar during gameplay
68 u32 last_time = 0; 78 u32 last_time = 0;
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp
index 7ffa0ac09..c0d373477 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp
@@ -13,24 +13,25 @@
13#include "common/logging/log.h" 13#include "common/logging/log.h"
14#include "common/scm_rev.h" 14#include "common/scm_rev.h"
15#include "common/string_util.h" 15#include "common/string_util.h"
16#include "core/core.h"
16#include "core/settings.h" 17#include "core/settings.h"
17#include "input_common/keyboard.h" 18#include "input_common/keyboard.h"
18#include "input_common/main.h" 19#include "input_common/main.h"
19#include "input_common/motion_emu.h" 20#include "input_common/motion_emu.h"
21#include "video_core/renderer_base.h"
20#include "yuzu_cmd/emu_window/emu_window_sdl2_gl.h" 22#include "yuzu_cmd/emu_window/emu_window_sdl2_gl.h"
21 23
22class SDLGLContext : public Core::Frontend::GraphicsContext { 24class SDLGLContext : public Core::Frontend::GraphicsContext {
23public: 25public:
24 explicit SDLGLContext() { 26 explicit SDLGLContext() {
25 // create a hidden window to make the shared context against 27 // create a hidden window to make the shared context against
26 window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED, // x position 28 window = SDL_CreateWindow(NULL, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 0, 0,
27 SDL_WINDOWPOS_UNDEFINED, // y position 29 SDL_WINDOW_HIDDEN | SDL_WINDOW_OPENGL);
28 Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height,
29 SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN);
30 context = SDL_GL_CreateContext(window); 30 context = SDL_GL_CreateContext(window);
31 } 31 }
32 32
33 ~SDLGLContext() { 33 ~SDLGLContext() {
34 DoneCurrent();
34 SDL_GL_DeleteContext(context); 35 SDL_GL_DeleteContext(context);
35 SDL_DestroyWindow(window); 36 SDL_DestroyWindow(window);
36 } 37 }
@@ -43,8 +44,6 @@ public:
43 SDL_GL_MakeCurrent(window, nullptr); 44 SDL_GL_MakeCurrent(window, nullptr);
44 } 45 }
45 46
46 void SwapBuffers() override {}
47
48private: 47private:
49 SDL_Window* window; 48 SDL_Window* window;
50 SDL_GLContext context; 49 SDL_GLContext context;
@@ -80,7 +79,8 @@ bool EmuWindow_SDL2_GL::SupportsRequiredGLExtensions() {
80 return unsupported_ext.empty(); 79 return unsupported_ext.empty();
81} 80}
82 81
83EmuWindow_SDL2_GL::EmuWindow_SDL2_GL(bool fullscreen) : EmuWindow_SDL2(fullscreen) { 82EmuWindow_SDL2_GL::EmuWindow_SDL2_GL(Core::System& system, bool fullscreen)
83 : EmuWindow_SDL2{system, fullscreen} {
84 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); 84 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
85 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); 85 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
86 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); 86 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
@@ -90,6 +90,7 @@ EmuWindow_SDL2_GL::EmuWindow_SDL2_GL(bool fullscreen) : EmuWindow_SDL2(fullscree
90 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); 90 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
91 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); 91 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0);
92 SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1); 92 SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
93 SDL_GL_SetSwapInterval(0);
93 94
94 std::string window_title = fmt::format("yuzu {} | {}-{}", Common::g_build_fullname, 95 std::string window_title = fmt::format("yuzu {} | {}-{}", Common::g_build_fullname,
95 Common::g_scm_branch, Common::g_scm_desc); 96 Common::g_scm_branch, Common::g_scm_desc);
@@ -105,13 +106,22 @@ EmuWindow_SDL2_GL::EmuWindow_SDL2_GL(bool fullscreen) : EmuWindow_SDL2(fullscree
105 exit(1); 106 exit(1);
106 } 107 }
107 108
109 dummy_window = SDL_CreateWindow(NULL, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 0, 0,
110 SDL_WINDOW_HIDDEN | SDL_WINDOW_OPENGL);
111
108 if (fullscreen) { 112 if (fullscreen) {
109 Fullscreen(); 113 Fullscreen();
110 } 114 }
111 gl_context = SDL_GL_CreateContext(render_window);
112 115
113 if (gl_context == nullptr) { 116 window_context = SDL_GL_CreateContext(render_window);
114 LOG_CRITICAL(Frontend, "Failed to create SDL2 GL context! {}", SDL_GetError()); 117 core_context = CreateSharedContext();
118
119 if (window_context == nullptr) {
120 LOG_CRITICAL(Frontend, "Failed to create SDL2 GL context: {}", SDL_GetError());
121 exit(1);
122 }
123 if (core_context == nullptr) {
124 LOG_CRITICAL(Frontend, "Failed to create shared SDL2 GL context: {}", SDL_GetError());
115 exit(1); 125 exit(1);
116 } 126 }
117 127
@@ -128,28 +138,22 @@ EmuWindow_SDL2_GL::EmuWindow_SDL2_GL(bool fullscreen) : EmuWindow_SDL2(fullscree
128 OnResize(); 138 OnResize();
129 OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size); 139 OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size);
130 SDL_PumpEvents(); 140 SDL_PumpEvents();
131 SDL_GL_SetSwapInterval(false);
132 LOG_INFO(Frontend, "yuzu Version: {} | {}-{}", Common::g_build_fullname, Common::g_scm_branch, 141 LOG_INFO(Frontend, "yuzu Version: {} | {}-{}", Common::g_build_fullname, Common::g_scm_branch,
133 Common::g_scm_desc); 142 Common::g_scm_desc);
134 Settings::LogSettings(); 143 Settings::LogSettings();
135
136 DoneCurrent();
137} 144}
138 145
139EmuWindow_SDL2_GL::~EmuWindow_SDL2_GL() { 146EmuWindow_SDL2_GL::~EmuWindow_SDL2_GL() {
140 SDL_GL_DeleteContext(gl_context); 147 core_context.reset();
141} 148 SDL_GL_DeleteContext(window_context);
142
143void EmuWindow_SDL2_GL::SwapBuffers() {
144 SDL_GL_SwapWindow(render_window);
145} 149}
146 150
147void EmuWindow_SDL2_GL::MakeCurrent() { 151void EmuWindow_SDL2_GL::MakeCurrent() {
148 SDL_GL_MakeCurrent(render_window, gl_context); 152 core_context->MakeCurrent();
149} 153}
150 154
151void EmuWindow_SDL2_GL::DoneCurrent() { 155void EmuWindow_SDL2_GL::DoneCurrent() {
152 SDL_GL_MakeCurrent(render_window, nullptr); 156 core_context->DoneCurrent();
153} 157}
154 158
155void EmuWindow_SDL2_GL::RetrieveVulkanHandlers(void* get_instance_proc_addr, void* instance, 159void EmuWindow_SDL2_GL::RetrieveVulkanHandlers(void* get_instance_proc_addr, void* instance,
@@ -161,3 +165,13 @@ void EmuWindow_SDL2_GL::RetrieveVulkanHandlers(void* get_instance_proc_addr, voi
161std::unique_ptr<Core::Frontend::GraphicsContext> EmuWindow_SDL2_GL::CreateSharedContext() const { 165std::unique_ptr<Core::Frontend::GraphicsContext> EmuWindow_SDL2_GL::CreateSharedContext() const {
162 return std::make_unique<SDLGLContext>(); 166 return std::make_unique<SDLGLContext>();
163} 167}
168
169void EmuWindow_SDL2_GL::Present() {
170 SDL_GL_MakeCurrent(render_window, window_context);
171 SDL_GL_SetSwapInterval(Settings::values.use_vsync ? 1 : 0);
172 while (IsOpen()) {
173 system.Renderer().TryPresent(100);
174 SDL_GL_SwapWindow(render_window);
175 }
176 SDL_GL_MakeCurrent(render_window, nullptr);
177}
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h
index c753085a8..b80669ff0 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h
@@ -10,17 +10,12 @@
10 10
11class EmuWindow_SDL2_GL final : public EmuWindow_SDL2 { 11class EmuWindow_SDL2_GL final : public EmuWindow_SDL2 {
12public: 12public:
13 explicit EmuWindow_SDL2_GL(bool fullscreen); 13 explicit EmuWindow_SDL2_GL(Core::System& system, bool fullscreen);
14 ~EmuWindow_SDL2_GL(); 14 ~EmuWindow_SDL2_GL();
15 15
16 /// Swap buffers to display the next frame
17 void SwapBuffers() override;
18
19 /// Makes the graphics context current for the caller thread
20 void MakeCurrent() override; 16 void MakeCurrent() override;
21
22 /// Releases the GL context from the caller thread
23 void DoneCurrent() override; 17 void DoneCurrent() override;
18 void Present() override;
24 19
25 /// Ignored in OpenGL 20 /// Ignored in OpenGL
26 void RetrieveVulkanHandlers(void* get_instance_proc_addr, void* instance, 21 void RetrieveVulkanHandlers(void* get_instance_proc_addr, void* instance,
@@ -29,10 +24,17 @@ public:
29 std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override; 24 std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override;
30 25
31private: 26private:
27 /// Fake hidden window for the core context
28 SDL_Window* dummy_window{};
29
32 /// Whether the GPU and driver supports the OpenGL extension required 30 /// Whether the GPU and driver supports the OpenGL extension required
33 bool SupportsRequiredGLExtensions(); 31 bool SupportsRequiredGLExtensions();
34 32
35 using SDL_GLContext = void*; 33 using SDL_GLContext = void*;
34
36 /// The OpenGL context associated with the window 35 /// The OpenGL context associated with the window
37 SDL_GLContext gl_context; 36 SDL_GLContext window_context;
37
38 /// The OpenGL context associated with the core
39 std::unique_ptr<Core::Frontend::GraphicsContext> core_context;
38}; 40};
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp
index a203f0da9..f5f6675b5 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp
@@ -15,7 +15,8 @@
15#include "core/settings.h" 15#include "core/settings.h"
16#include "yuzu_cmd/emu_window/emu_window_sdl2_vk.h" 16#include "yuzu_cmd/emu_window/emu_window_sdl2_vk.h"
17 17
18EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(bool fullscreen) : EmuWindow_SDL2(fullscreen) { 18EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(Core::System& system, bool fullscreen)
19 : EmuWindow_SDL2{system, fullscreen} {
19 if (SDL_Vulkan_LoadLibrary(nullptr) != 0) { 20 if (SDL_Vulkan_LoadLibrary(nullptr) != 0) {
20 LOG_CRITICAL(Frontend, "SDL failed to load the Vulkan library: {}", SDL_GetError()); 21 LOG_CRITICAL(Frontend, "SDL failed to load the Vulkan library: {}", SDL_GetError());
21 exit(EXIT_FAILURE); 22 exit(EXIT_FAILURE);
@@ -110,8 +111,6 @@ EmuWindow_SDL2_VK::~EmuWindow_SDL2_VK() {
110 vkDestroyInstance(vk_instance, nullptr); 111 vkDestroyInstance(vk_instance, nullptr);
111} 112}
112 113
113void EmuWindow_SDL2_VK::SwapBuffers() {}
114
115void EmuWindow_SDL2_VK::MakeCurrent() { 114void EmuWindow_SDL2_VK::MakeCurrent() {
116 // Unused on Vulkan 115 // Unused on Vulkan
117} 116}
@@ -160,3 +159,5 @@ bool EmuWindow_SDL2_VK::UseStandardLayers(PFN_vkGetInstanceProcAddr vkGetInstanc
160 return layer.layerName == std::string("VK_LAYER_LUNARG_standard_validation"); 159 return layer.layerName == std::string("VK_LAYER_LUNARG_standard_validation");
161 }) != layers.end(); 160 }) != layers.end();
162} 161}
162
163void EmuWindow_SDL2_VK::Present() {}
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h
index 2a7c06a24..1eb8c0868 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h
@@ -10,19 +10,12 @@
10 10
11class EmuWindow_SDL2_VK final : public EmuWindow_SDL2 { 11class EmuWindow_SDL2_VK final : public EmuWindow_SDL2 {
12public: 12public:
13 explicit EmuWindow_SDL2_VK(bool fullscreen); 13 explicit EmuWindow_SDL2_VK(Core::System& system, bool fullscreen);
14 ~EmuWindow_SDL2_VK(); 14 ~EmuWindow_SDL2_VK();
15 15
16 /// Swap buffers to display the next frame
17 void SwapBuffers() override;
18
19 /// Makes the graphics context current for the caller thread
20 void MakeCurrent() override; 16 void MakeCurrent() override;
21
22 /// Releases the GL context from the caller thread
23 void DoneCurrent() override; 17 void DoneCurrent() override;
24 18 void Present() override;
25 /// Retrieves Vulkan specific handlers from the window
26 void RetrieveVulkanHandlers(void* get_instance_proc_addr, void* instance, 19 void RetrieveVulkanHandlers(void* get_instance_proc_addr, void* instance,
27 void* surface) const override; 20 void* surface) const override;
28 21
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp
index 325795321..babf4c3a4 100644
--- a/src/yuzu_cmd/yuzu.cpp
+++ b/src/yuzu_cmd/yuzu.cpp
@@ -177,14 +177,16 @@ int main(int argc, char** argv) {
177 Settings::values.use_gdbstub = use_gdbstub; 177 Settings::values.use_gdbstub = use_gdbstub;
178 Settings::Apply(); 178 Settings::Apply();
179 179
180 Core::System& system{Core::System::GetInstance()};
181
180 std::unique_ptr<EmuWindow_SDL2> emu_window; 182 std::unique_ptr<EmuWindow_SDL2> emu_window;
181 switch (Settings::values.renderer_backend) { 183 switch (Settings::values.renderer_backend) {
182 case Settings::RendererBackend::OpenGL: 184 case Settings::RendererBackend::OpenGL:
183 emu_window = std::make_unique<EmuWindow_SDL2_GL>(fullscreen); 185 emu_window = std::make_unique<EmuWindow_SDL2_GL>(system, fullscreen);
184 break; 186 break;
185 case Settings::RendererBackend::Vulkan: 187 case Settings::RendererBackend::Vulkan:
186#ifdef HAS_VULKAN 188#ifdef HAS_VULKAN
187 emu_window = std::make_unique<EmuWindow_SDL2_VK>(fullscreen); 189 emu_window = std::make_unique<EmuWindow_SDL2_VK>(system, fullscreen);
188 break; 190 break;
189#else 191#else
190 LOG_CRITICAL(Frontend, "Vulkan backend has not been compiled!"); 192 LOG_CRITICAL(Frontend, "Vulkan backend has not been compiled!");
@@ -192,12 +194,6 @@ int main(int argc, char** argv) {
192#endif 194#endif
193 } 195 }
194 196
195 if (!Settings::values.use_multi_core) {
196 // Single core mode must acquire OpenGL context for entire emulation session
197 emu_window->MakeCurrent();
198 }
199
200 Core::System& system{Core::System::GetInstance()};
201 system.SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>()); 197 system.SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>());
202 system.SetFilesystem(std::make_shared<FileSys::RealVfsFilesystem>()); 198 system.SetFilesystem(std::make_shared<FileSys::RealVfsFilesystem>());
203 system.GetFileSystemController().CreateFactories(*system.GetFilesystem()); 199 system.GetFileSystemController().CreateFactories(*system.GetFilesystem());
@@ -234,12 +230,23 @@ int main(int argc, char** argv) {
234 230
235 system.TelemetrySession().AddField(Telemetry::FieldType::App, "Frontend", "SDL"); 231 system.TelemetrySession().AddField(Telemetry::FieldType::App, "Frontend", "SDL");
236 232
237 emu_window->MakeCurrent();
238 system.Renderer().Rasterizer().LoadDiskResources(); 233 system.Renderer().Rasterizer().LoadDiskResources();
239 234
235 // Acquire render context for duration of the thread if this is the rendering thread
236 if (!Settings::values.use_asynchronous_gpu_emulation) {
237 emu_window->MakeCurrent();
238 }
239 SCOPE_EXIT({
240 if (!Settings::values.use_asynchronous_gpu_emulation) {
241 emu_window->DoneCurrent();
242 }
243 });
244
245 std::thread render_thread([&emu_window] { emu_window->Present(); });
240 while (emu_window->IsOpen()) { 246 while (emu_window->IsOpen()) {
241 system.RunLoop(); 247 system.RunLoop();
242 } 248 }
249 render_thread.join();
243 250
244 system.Shutdown(); 251 system.Shutdown();
245 252
diff --git a/src/yuzu_tester/emu_window/emu_window_sdl2_hide.cpp b/src/yuzu_tester/emu_window/emu_window_sdl2_hide.cpp
index f2cc4a797..a1bdb1a12 100644
--- a/src/yuzu_tester/emu_window/emu_window_sdl2_hide.cpp
+++ b/src/yuzu_tester/emu_window/emu_window_sdl2_hide.cpp
@@ -112,10 +112,6 @@ EmuWindow_SDL2_Hide::~EmuWindow_SDL2_Hide() {
112 SDL_Quit(); 112 SDL_Quit();
113} 113}
114 114
115void EmuWindow_SDL2_Hide::SwapBuffers() {
116 SDL_GL_SwapWindow(render_window);
117}
118
119void EmuWindow_SDL2_Hide::PollEvents() {} 115void EmuWindow_SDL2_Hide::PollEvents() {}
120 116
121void EmuWindow_SDL2_Hide::MakeCurrent() { 117void EmuWindow_SDL2_Hide::MakeCurrent() {
diff --git a/src/yuzu_tester/emu_window/emu_window_sdl2_hide.h b/src/yuzu_tester/emu_window/emu_window_sdl2_hide.h
index c7fccc002..b13e15309 100644
--- a/src/yuzu_tester/emu_window/emu_window_sdl2_hide.h
+++ b/src/yuzu_tester/emu_window/emu_window_sdl2_hide.h
@@ -13,9 +13,6 @@ public:
13 explicit EmuWindow_SDL2_Hide(); 13 explicit EmuWindow_SDL2_Hide();
14 ~EmuWindow_SDL2_Hide(); 14 ~EmuWindow_SDL2_Hide();
15 15
16 /// Swap buffers to display the next frame
17 void SwapBuffers() override;
18
19 /// Polls window events 16 /// Polls window events
20 void PollEvents() override; 17 void PollEvents() override;
21 18