From 571451bdfe18e9e53af3fa458f18a3192094eebe Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 13 Feb 2020 22:06:11 -0500 Subject: core: settings: Add setting to enable vsync, which is on by default. --- src/core/settings.cpp | 1 + src/core/settings.h | 1 + src/core/telemetry_session.cpp | 1 + 3 files changed, 3 insertions(+) (limited to 'src/core') diff --git a/src/core/settings.cpp b/src/core/settings.cpp index d1fc94060..7c0303684 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -94,6 +94,7 @@ void LogSettings() { LogSetting("Renderer_UseAccurateGpuEmulation", Settings::values.use_accurate_gpu_emulation); LogSetting("Renderer_UseAsynchronousGpuEmulation", Settings::values.use_asynchronous_gpu_emulation); + LogSetting("Renderer_UseVsync", Settings::values.use_vsync); LogSetting("Audio_OutputEngine", Settings::values.sink_id); LogSetting("Audio_EnableAudioStretching", Settings::values.enable_audio_stretching); LogSetting("Audio_OutputDevice", Settings::values.audio_device_id); diff --git a/src/core/settings.h b/src/core/settings.h index f837d3fbc..15b691342 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -435,6 +435,7 @@ struct Values { bool use_disk_shader_cache; bool use_accurate_gpu_emulation; bool use_asynchronous_gpu_emulation; + bool use_vsync; bool force_30fps_mode; float bg_red; diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index 0e72d31cd..0f3685d1c 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp @@ -188,6 +188,7 @@ void TelemetrySession::AddInitialInfo(Loader::AppLoader& app_loader) { Settings::values.use_accurate_gpu_emulation); AddField(field_type, "Renderer_UseAsynchronousGpuEmulation", Settings::values.use_asynchronous_gpu_emulation); + AddField(field_type, "Renderer_UseVsync", Settings::values.use_vsync); AddField(field_type, "System_UseDockedMode", Settings::values.use_docked_mode); } -- cgit v1.2.3 From 0c82b00dfde1071b3619e288b223f771953775eb Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 13 Feb 2020 22:10:20 -0500 Subject: core: frontend: emu_window: Add TextureMailbox class. --- src/core/frontend/emu_window.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src/core') diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h index 3376eedc5..5dde199d4 100644 --- a/src/core/frontend/emu_window.h +++ b/src/core/frontend/emu_window.h @@ -12,6 +12,45 @@ namespace Core::Frontend { +struct Frame; +/** + * For smooth Vsync rendering, we want to always present the latest frame that the core generates, + * but also make sure that rendering happens at the pace that the frontend dictates. This is a + * helper class that the renderer can define to sync frames between the render thread and the + * presentation thread + */ +class TextureMailbox { +public: + virtual ~TextureMailbox() = default; + + /** + * Recreate the render objects attached to this frame with the new specified width/height + */ + virtual void ReloadRenderFrame(Frontend::Frame* frame, u32 width, u32 height) = 0; + + /** + * Recreate the presentation objects attached to this frame with the new specified width/height + */ + virtual void ReloadPresentFrame(Frontend::Frame* frame, u32 width, u32 height) = 0; + + /** + * Render thread calls this to get an available frame to present + */ + virtual Frontend::Frame* GetRenderFrame() = 0; + + /** + * Render thread calls this after draw commands are done to add to the presentation mailbox + */ + virtual void ReleaseRenderFrame(Frame* frame) = 0; + + /** + * Presentation thread calls this to get the latest frame available to present. If there is no + * frame available after timeout, returns the previous frame. If there is no previous frame it + * returns nullptr + */ + virtual Frontend::Frame* TryGetPresentFrame(int timeout_ms) = 0; +}; + /** * Represents a graphics context that can be used for background computation or drawing. If the * graphics backend doesn't require the context, then the implementation of these methods can be @@ -132,6 +171,8 @@ public: */ void UpdateCurrentFramebufferLayout(unsigned width, unsigned height); + std::unique_ptr mailbox; + protected: EmuWindow(); virtual ~EmuWindow(); -- cgit v1.2.3 From dc672ca4b39c1ab9c2ee81257b6fb605a23cbcd8 Mon Sep 17 00:00:00 2001 From: bunnei Date: Mon, 17 Feb 2020 14:31:14 -0500 Subject: renderer_opengl: Add texture mailbox support for presenter thread. --- src/core/frontend/framebuffer_layout.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core') diff --git a/src/core/frontend/framebuffer_layout.h b/src/core/frontend/framebuffer_layout.h index 1d39c1faf..e9d0a40d3 100644 --- a/src/core/frontend/framebuffer_layout.h +++ b/src/core/frontend/framebuffer_layout.h @@ -29,6 +29,7 @@ enum class AspectRatio { struct FramebufferLayout { u32 width{ScreenUndocked::Width}; u32 height{ScreenUndocked::Height}; + bool is_srgb{}; Common::Rectangle screen; -- cgit v1.2.3 From 2e16c237845bf1b5ff89b7b7a3f8bc1a84729eb1 Mon Sep 17 00:00:00 2001 From: bunnei Date: Mon, 17 Feb 2020 15:35:14 -0500 Subject: frontend: sdl2: emu_window: Implement separate presentation thread. --- src/core/frontend/emu_window.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/core') 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: /// Releases (dunno if this is the "right" word) the context from the caller thread virtual void DoneCurrent() = 0; - - /// Swap buffers to display the next frame - virtual void SwapBuffers() = 0; }; /** -- cgit v1.2.3 From 667f026c9570b772719d2ada94cc40d420113c23 Mon Sep 17 00:00:00 2001 From: bunnei Date: Mon, 17 Feb 2020 15:38:56 -0500 Subject: core: frontend: Refactor scope_acquire_window_context to scope_acquire_context. --- src/core/CMakeLists.txt | 4 ++-- src/core/core.cpp | 3 +++ src/core/frontend/scope_acquire_context.cpp | 18 +++++++++++++++++ src/core/frontend/scope_acquire_context.h | 23 ++++++++++++++++++++++ src/core/frontend/scope_acquire_window_context.cpp | 18 ----------------- src/core/frontend/scope_acquire_window_context.h | 23 ---------------------- 6 files changed, 46 insertions(+), 43 deletions(-) create mode 100644 src/core/frontend/scope_acquire_context.cpp create mode 100644 src/core/frontend/scope_acquire_context.h delete mode 100644 src/core/frontend/scope_acquire_window_context.cpp delete mode 100644 src/core/frontend/scope_acquire_window_context.h (limited to 'src/core') diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 88c06b2ce..54be7dc0c 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -131,8 +131,8 @@ add_library(core STATIC frontend/framebuffer_layout.cpp frontend/framebuffer_layout.h frontend/input.h - frontend/scope_acquire_window_context.cpp - frontend/scope_acquire_window_context.h + frontend/scope_acquire_context.cpp + frontend/scope_acquire_context.h gdbstub/gdbstub.cpp gdbstub/gdbstub.h hardware_interrupt_manager.cpp diff --git a/src/core/core.cpp b/src/core/core.cpp index 86e314c94..a82faf127 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -24,6 +24,7 @@ #include "core/file_sys/sdmc_factory.h" #include "core/file_sys/vfs_concat.h" #include "core/file_sys/vfs_real.h" +#include "core/frontend/scope_acquire_context.h" #include "core/gdbstub/gdbstub.h" #include "core/hardware_interrupt_manager.h" #include "core/hle/kernel/client_port.h" @@ -184,6 +185,8 @@ struct System::Impl { ResultStatus Load(System& system, Frontend::EmuWindow& emu_window, const std::string& filepath) { + Core::Frontend::ScopeAcquireContext acquire_context{emu_window}; + app_loader = Loader::GetLoader(GetGameFileFromPath(virtual_filesystem, filepath)); if (!app_loader) { LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); diff --git a/src/core/frontend/scope_acquire_context.cpp b/src/core/frontend/scope_acquire_context.cpp new file mode 100644 index 000000000..878c3157c --- /dev/null +++ b/src/core/frontend/scope_acquire_context.cpp @@ -0,0 +1,18 @@ +// Copyright 2019 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "core/frontend/emu_window.h" +#include "core/frontend/scope_acquire_context.h" + +namespace Core::Frontend { + +ScopeAcquireContext::ScopeAcquireContext(Core::Frontend::GraphicsContext& context) + : context{context} { + context.MakeCurrent(); +} +ScopeAcquireContext::~ScopeAcquireContext() { + context.DoneCurrent(); +} + +} // namespace Core::Frontend diff --git a/src/core/frontend/scope_acquire_context.h b/src/core/frontend/scope_acquire_context.h new file mode 100644 index 000000000..7a65c0623 --- /dev/null +++ b/src/core/frontend/scope_acquire_context.h @@ -0,0 +1,23 @@ +// Copyright 2019 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include "common/common_types.h" + +namespace Core::Frontend { + +class GraphicsContext; + +/// Helper class to acquire/release window context within a given scope +class ScopeAcquireContext : NonCopyable { +public: + explicit ScopeAcquireContext(Core::Frontend::GraphicsContext& context); + ~ScopeAcquireContext(); + +private: + Core::Frontend::GraphicsContext& context; +}; + +} // namespace Core::Frontend diff --git a/src/core/frontend/scope_acquire_window_context.cpp b/src/core/frontend/scope_acquire_window_context.cpp deleted file mode 100644 index 3663dad17..000000000 --- a/src/core/frontend/scope_acquire_window_context.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2019 yuzu Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "core/frontend/emu_window.h" -#include "core/frontend/scope_acquire_window_context.h" - -namespace Core::Frontend { - -ScopeAcquireWindowContext::ScopeAcquireWindowContext(Core::Frontend::EmuWindow& emu_window_) - : emu_window{emu_window_} { - emu_window.MakeCurrent(); -} -ScopeAcquireWindowContext::~ScopeAcquireWindowContext() { - emu_window.DoneCurrent(); -} - -} // namespace Core::Frontend diff --git a/src/core/frontend/scope_acquire_window_context.h b/src/core/frontend/scope_acquire_window_context.h deleted file mode 100644 index 2d9f6e825..000000000 --- a/src/core/frontend/scope_acquire_window_context.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2019 yuzu Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include "common/common_types.h" - -namespace Core::Frontend { - -class EmuWindow; - -/// Helper class to acquire/release window context within a given scope -class ScopeAcquireWindowContext : NonCopyable { -public: - explicit ScopeAcquireWindowContext(Core::Frontend::EmuWindow& window); - ~ScopeAcquireWindowContext(); - -private: - Core::Frontend::EmuWindow& emu_window; -}; - -} // namespace Core::Frontend -- cgit v1.2.3 From aef159354cd6c5cbbf6366bcfd767a9b4e0b7dd9 Mon Sep 17 00:00:00 2001 From: bunnei Date: Wed, 26 Feb 2020 18:28:50 -0500 Subject: renderer_opengl: Move Frame/FrameMailbox to OpenGL namespace. --- src/core/frontend/emu_window.h | 41 ----------------------------------------- 1 file changed, 41 deletions(-) (limited to 'src/core') diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h index 856cb61e9..5eb87fb63 100644 --- a/src/core/frontend/emu_window.h +++ b/src/core/frontend/emu_window.h @@ -12,45 +12,6 @@ namespace Core::Frontend { -struct Frame; -/** - * For smooth Vsync rendering, we want to always present the latest frame that the core generates, - * but also make sure that rendering happens at the pace that the frontend dictates. This is a - * helper class that the renderer can define to sync frames between the render thread and the - * presentation thread - */ -class TextureMailbox { -public: - virtual ~TextureMailbox() = default; - - /** - * Recreate the render objects attached to this frame with the new specified width/height - */ - virtual void ReloadRenderFrame(Frontend::Frame* frame, u32 width, u32 height) = 0; - - /** - * Recreate the presentation objects attached to this frame with the new specified width/height - */ - virtual void ReloadPresentFrame(Frontend::Frame* frame, u32 width, u32 height) = 0; - - /** - * Render thread calls this to get an available frame to present - */ - virtual Frontend::Frame* GetRenderFrame() = 0; - - /** - * Render thread calls this after draw commands are done to add to the presentation mailbox - */ - virtual void ReleaseRenderFrame(Frame* frame) = 0; - - /** - * Presentation thread calls this to get the latest frame available to present. If there is no - * frame available after timeout, returns the previous frame. If there is no previous frame it - * returns nullptr - */ - virtual Frontend::Frame* TryGetPresentFrame(int timeout_ms) = 0; -}; - /** * Represents a graphics context that can be used for background computation or drawing. If the * graphics backend doesn't require the context, then the implementation of these methods can be @@ -168,8 +129,6 @@ public: */ void UpdateCurrentFramebufferLayout(unsigned width, unsigned height); - std::unique_ptr mailbox; - protected: EmuWindow(); virtual ~EmuWindow(); -- cgit v1.2.3