summaryrefslogtreecommitdiff
path: root/src/yuzu_cmd
diff options
context:
space:
mode:
authorGravatar James Rowe2020-03-24 20:58:49 -0600
committerGravatar James Rowe2020-03-24 21:03:42 -0600
commit282adfc70b5d7d958d564bfda0227bb3fbd8d110 (patch)
tree2a98e3bedec2e7fdb33478814a73be664661aecc /src/yuzu_cmd
parentUse the correct directory for Qt Plugins (diff)
downloadyuzu-282adfc70b5d7d958d564bfda0227bb3fbd8d110.tar.gz
yuzu-282adfc70b5d7d958d564bfda0227bb3fbd8d110.tar.xz
yuzu-282adfc70b5d7d958d564bfda0227bb3fbd8d110.zip
Frontend/GPU: Refactor context management
Changes the GraphicsContext to be managed by the GPU core. This eliminates the need for the frontends to fool around with tricky MakeCurrent/DoneCurrent calls that are dependent on the settings (such as async gpu option). This also refactors out the need to use QWidget::fromWindowContainer as that caused issues with focus and input handling. Now we use a regular QWidget and just access the native windowHandle() directly. Another change is removing the debug tool setting in FrameMailbox. Instead of trying to block the frontend until a new frame is ready, the core will now take over presentation and draw directly to the window if the renderer detects that its hooked by NSight or RenderDoc Lastly, since it was in the way, I removed ScopeAcquireWindowContext and replaced it with a simple subclass in GraphicsContext that achieves the same result
Diffstat (limited to 'src/yuzu_cmd')
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp8
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h2
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp8
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h2
-rw-r--r--src/yuzu_cmd/yuzu.cpp11
5 files changed, 2 insertions, 29 deletions
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 c0d373477..ee61179a0 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp
@@ -148,14 +148,6 @@ EmuWindow_SDL2_GL::~EmuWindow_SDL2_GL() {
148 SDL_GL_DeleteContext(window_context); 148 SDL_GL_DeleteContext(window_context);
149} 149}
150 150
151void EmuWindow_SDL2_GL::MakeCurrent() {
152 core_context->MakeCurrent();
153}
154
155void EmuWindow_SDL2_GL::DoneCurrent() {
156 core_context->DoneCurrent();
157}
158
159void EmuWindow_SDL2_GL::RetrieveVulkanHandlers(void* get_instance_proc_addr, void* instance, 151void EmuWindow_SDL2_GL::RetrieveVulkanHandlers(void* get_instance_proc_addr, void* instance,
160 void* surface) const { 152 void* surface) const {
161 // Should not have been called from OpenGL 153 // Should not have been called from OpenGL
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 b80669ff0..e092021d7 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h
@@ -13,8 +13,6 @@ public:
13 explicit EmuWindow_SDL2_GL(Core::System& system, bool fullscreen); 13 explicit EmuWindow_SDL2_GL(Core::System& system, bool fullscreen);
14 ~EmuWindow_SDL2_GL(); 14 ~EmuWindow_SDL2_GL();
15 15
16 void MakeCurrent() override;
17 void DoneCurrent() override;
18 void Present() override; 16 void Present() override;
19 17
20 /// Ignored in OpenGL 18 /// Ignored in OpenGL
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 abcc58165..46d053f04 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp
@@ -111,14 +111,6 @@ EmuWindow_SDL2_VK::~EmuWindow_SDL2_VK() {
111 vkDestroyInstance(vk_instance, nullptr); 111 vkDestroyInstance(vk_instance, nullptr);
112} 112}
113 113
114void EmuWindow_SDL2_VK::MakeCurrent() {
115 // Unused on Vulkan
116}
117
118void EmuWindow_SDL2_VK::DoneCurrent() {
119 // Unused on Vulkan
120}
121
122void EmuWindow_SDL2_VK::RetrieveVulkanHandlers(void* get_instance_proc_addr, void* instance, 114void EmuWindow_SDL2_VK::RetrieveVulkanHandlers(void* get_instance_proc_addr, void* instance,
123 void* surface) const { 115 void* surface) const {
124 const auto instance_proc_addr = vkGetInstanceProcAddr; 116 const auto instance_proc_addr = vkGetInstanceProcAddr;
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 1eb8c0868..3dd1f3f61 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h
@@ -13,8 +13,6 @@ public:
13 explicit EmuWindow_SDL2_VK(Core::System& system, bool fullscreen); 13 explicit EmuWindow_SDL2_VK(Core::System& system, bool fullscreen);
14 ~EmuWindow_SDL2_VK(); 14 ~EmuWindow_SDL2_VK();
15 15
16 void MakeCurrent() override;
17 void DoneCurrent() override;
18 void Present() override; 16 void Present() override;
19 void RetrieveVulkanHandlers(void* get_instance_proc_addr, void* instance, 17 void RetrieveVulkanHandlers(void* get_instance_proc_addr, void* instance,
20 void* surface) const override; 18 void* surface) const override;
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp
index babf4c3a4..e5db7d819 100644
--- a/src/yuzu_cmd/yuzu.cpp
+++ b/src/yuzu_cmd/yuzu.cpp
@@ -232,15 +232,8 @@ int main(int argc, char** argv) {
232 232
233 system.Renderer().Rasterizer().LoadDiskResources(); 233 system.Renderer().Rasterizer().LoadDiskResources();
234 234
235 // Acquire render context for duration of the thread if this is the rendering thread 235 // Core is loaded, start the GPU (makes the GPU contexts current to this thread)
236 if (!Settings::values.use_asynchronous_gpu_emulation) { 236 system.GPU().Start();
237 emu_window->MakeCurrent();
238 }
239 SCOPE_EXIT({
240 if (!Settings::values.use_asynchronous_gpu_emulation) {
241 emu_window->DoneCurrent();
242 }
243 });
244 237
245 std::thread render_thread([&emu_window] { emu_window->Present(); }); 238 std::thread render_thread([&emu_window] { emu_window->Present(); });
246 while (emu_window->IsOpen()) { 239 while (emu_window->IsOpen()) {