From 6ecaf46441272f979e4af066590c997ba021dab6 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Tue, 27 Jul 2021 05:04:12 +0200 Subject: [PATCH] early-access version 1929 --- README.md | 2 +- src/common/settings.cpp | 8 +- src/common/settings.h | 4 +- src/core/core.cpp | 10 +- src/core/core.h | 10 +- .../service/nvdrv/devices/nvdisp_disp0.cpp | 2 +- src/core/perf_stats.cpp | 20 ++-- src/core/perf_stats.h | 6 +- src/core/telemetry_session.cpp | 4 +- src/video_core/renderer_base.cpp | 5 +- src/video_core/renderer_base.h | 7 +- .../renderer_opengl/renderer_opengl.cpp | 12 +-- .../renderer_vulkan/renderer_vulkan.cpp | 99 +++++++++++++++++++ .../renderer_vulkan/renderer_vulkan.h | 2 + src/yuzu/bootmanager.cpp | 4 +- src/yuzu/configuration/config.cpp | 8 +- src/yuzu/configuration/configure_general.cpp | 46 ++++----- src/yuzu/configuration/configure_general.h | 2 +- src/yuzu/configuration/configure_general.ui | 4 +- src/yuzu/main.cpp | 18 ++-- src/yuzu_cmd/config.cpp | 4 +- src/yuzu_cmd/default_ini.h | 6 +- 22 files changed, 188 insertions(+), 95 deletions(-) diff --git a/README.md b/README.md index 0d7d22d80..94ffd0d84 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 1928. +This is the source code for early-access 1929. ## Legal Notice diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 66268ea0f..996315999 100755 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -48,8 +48,8 @@ void LogSettings() { log_setting("Core_UseMultiCore", values.use_multi_core.GetValue()); log_setting("CPU_Accuracy", values.cpu_accuracy.GetValue()); log_setting("Renderer_UseResolutionFactor", values.resolution_factor.GetValue()); - log_setting("Renderer_UseFrameLimit", values.use_frame_limit.GetValue()); - log_setting("Renderer_FrameLimit", values.frame_limit.GetValue()); + log_setting("Renderer_UseSpeedLimit", values.use_speed_limit.GetValue()); + log_setting("Renderer_SpeedLimit", values.speed_limit.GetValue()); log_setting("Renderer_UseDiskShaderCache", values.use_disk_shader_cache.GetValue()); log_setting("Renderer_GPUAccuracyLevel", values.gpu_accuracy.GetValue()); log_setting("Renderer_UseAsynchronousGpuEmulation", @@ -132,8 +132,8 @@ void RestoreGlobalState(bool is_powered_on) { values.vulkan_device.SetGlobal(true); values.aspect_ratio.SetGlobal(true); values.max_anisotropy.SetGlobal(true); - values.use_frame_limit.SetGlobal(true); - values.frame_limit.SetGlobal(true); + values.use_speed_limit.SetGlobal(true); + values.speed_limit.SetGlobal(true); values.use_disk_shader_cache.SetGlobal(true); values.gpu_accuracy.SetGlobal(true); values.use_asynchronous_gpu_emulation.SetGlobal(true); diff --git a/src/common/settings.h b/src/common/settings.h index c9a5959e8..c03ee9cb4 100755 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -331,8 +331,8 @@ struct Values { "fullscreen_mode"}; Setting aspect_ratio{0, "aspect_ratio"}; Setting max_anisotropy{0, "max_anisotropy"}; - Setting use_frame_limit{true, "use_frame_limit"}; - Setting frame_limit{100, "frame_limit"}; + Setting use_speed_limit{true, "use_speed_limit"}; + Setting speed_limit{100, "speed_limit"}; Setting use_disk_shader_cache{true, "use_disk_shader_cache"}; Setting gpu_accuracy{GPUAccuracy::High, "gpu_accuracy"}; Setting use_asynchronous_gpu_emulation{true, "use_asynchronous_gpu_emulation"}; diff --git a/src/core/core.cpp b/src/core/core.cpp index 15226cf41..d3e84c4ef 100755 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -411,7 +411,7 @@ struct System::Impl { std::string status_details = ""; std::unique_ptr perf_stats; - Core::FrameLimiter frame_limiter; + Core::SpeedLimiter speed_limiter; bool is_multicore{}; bool is_async_gpu{}; @@ -606,12 +606,12 @@ const Core::PerfStats& System::GetPerfStats() const { return *impl->perf_stats; } -Core::FrameLimiter& System::FrameLimiter() { - return impl->frame_limiter; +Core::SpeedLimiter& System::SpeedLimiter() { + return impl->speed_limiter; } -const Core::FrameLimiter& System::FrameLimiter() const { - return impl->frame_limiter; +const Core::SpeedLimiter& System::SpeedLimiter() const { + return impl->speed_limiter; } Loader::ResultStatus System::GetGameName(std::string& out) const { diff --git a/src/core/core.h b/src/core/core.h index b93c32e60..ea143043c 100755 --- a/src/core/core.h +++ b/src/core/core.h @@ -94,7 +94,7 @@ class ARM_Interface; class CpuManager; class DeviceMemory; class ExclusiveMonitor; -class FrameLimiter; +class SpeedLimiter; class PerfStats; class Reporter; class TelemetrySession; @@ -292,11 +292,11 @@ public: /// Provides a constant reference to the internal PerfStats instance. [[nodiscard]] const Core::PerfStats& GetPerfStats() const; - /// Provides a reference to the frame limiter; - [[nodiscard]] Core::FrameLimiter& FrameLimiter(); + /// Provides a reference to the speed limiter; + [[nodiscard]] Core::SpeedLimiter& SpeedLimiter(); - /// Provides a constant referent to the frame limiter - [[nodiscard]] const Core::FrameLimiter& FrameLimiter() const; + /// Provides a constant reference to the speed limiter + [[nodiscard]] const Core::SpeedLimiter& SpeedLimiter() const; /// Gets the name of the current game [[nodiscard]] Loader::ResultStatus GetGameName(std::string& out) const; diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp index 2cc0da124..ce6065db2 100755 --- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp +++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp @@ -54,7 +54,7 @@ void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u3 system.GetPerfStats().EndSystemFrame(); system.GPU().SwapBuffers(&framebuffer); - system.FrameLimiter().DoFrameLimiting(system.CoreTiming().GetGlobalTimeUs()); + system.SpeedLimiter().DoSpeedLimiting(system.CoreTiming().GetGlobalTimeUs()); system.GetPerfStats().BeginSystemFrame(); } diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp index 6635a1339..c9ded49d0 100755 --- a/src/core/perf_stats.cpp +++ b/src/core/perf_stats.cpp @@ -127,15 +127,15 @@ double PerfStats::GetLastFrameTimeScale() const { return duration_cast(previous_frame_length).count() / FRAME_LENGTH; } -void FrameLimiter::DoFrameLimiting(microseconds current_system_time_us) { - if (!Settings::values.use_frame_limit.GetValue() || +void SpeedLimiter::DoSpeedLimiting(microseconds current_system_time_us) { + if (!Settings::values.use_speed_limit.GetValue() || Settings::values.use_multi_core.GetValue()) { return; } auto now = Clock::now(); - const double sleep_scale = Settings::values.frame_limit.GetValue() / 100.0; + const double sleep_scale = Settings::values.speed_limit.GetValue() / 100.0; // Max lag caused by slow frames. Shouldn't be more than the length of a frame at the current // speed percent or it will clamp too much and prevent this from properly limiting to that @@ -143,17 +143,17 @@ void FrameLimiter::DoFrameLimiting(microseconds current_system_time_us) { // limiting const microseconds max_lag_time_us = duration_cast( std::chrono::duration(25ms / sleep_scale)); - frame_limiting_delta_err += duration_cast( + speed_limiting_delta_err += duration_cast( std::chrono::duration( (current_system_time_us - previous_system_time_us) / sleep_scale)); - frame_limiting_delta_err -= duration_cast(now - previous_walltime); - frame_limiting_delta_err = - std::clamp(frame_limiting_delta_err, -max_lag_time_us, max_lag_time_us); + speed_limiting_delta_err -= duration_cast(now - previous_walltime); + speed_limiting_delta_err = + std::clamp(speed_limiting_delta_err, -max_lag_time_us, max_lag_time_us); - if (frame_limiting_delta_err > microseconds::zero()) { - std::this_thread::sleep_for(frame_limiting_delta_err); + if (speed_limiting_delta_err > microseconds::zero()) { + std::this_thread::sleep_for(speed_limiting_delta_err); auto now_after_sleep = Clock::now(); - frame_limiting_delta_err -= duration_cast(now_after_sleep - now); + speed_limiting_delta_err -= duration_cast(now_after_sleep - now); now = now_after_sleep; } diff --git a/src/core/perf_stats.h b/src/core/perf_stats.h index e5d603717..a2541906f 100755 --- a/src/core/perf_stats.h +++ b/src/core/perf_stats.h @@ -85,11 +85,11 @@ private: double previous_fps = 0; }; -class FrameLimiter { +class SpeedLimiter { public: using Clock = std::chrono::high_resolution_clock; - void DoFrameLimiting(std::chrono::microseconds current_system_time_us); + void DoSpeedLimiting(std::chrono::microseconds current_system_time_us); private: /// Emulated system time (in microseconds) at the last limiter invocation @@ -98,7 +98,7 @@ private: Clock::time_point previous_walltime = Clock::now(); /// Accumulated difference between walltime and emulated time - std::chrono::microseconds frame_limiting_delta_err{0}; + std::chrono::microseconds speed_limiting_delta_err{0}; }; } // namespace Core diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index 422de3a7d..5a8cfd301 100755 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp @@ -221,8 +221,8 @@ void TelemetrySession::AddInitialInfo(Loader::AppLoader& app_loader, TranslateRenderer(Settings::values.renderer_backend.GetValue())); AddField(field_type, "Renderer_ResolutionFactor", Settings::values.resolution_factor.GetValue()); - AddField(field_type, "Renderer_UseFrameLimit", Settings::values.use_frame_limit.GetValue()); - AddField(field_type, "Renderer_FrameLimit", Settings::values.frame_limit.GetValue()); + AddField(field_type, "Renderer_UseSpeedLimit", Settings::values.use_speed_limit.GetValue()); + AddField(field_type, "Renderer_SpeedLimit", Settings::values.speed_limit.GetValue()); AddField(field_type, "Renderer_UseDiskShaderCache", Settings::values.use_disk_shader_cache.GetValue()); AddField(field_type, "Renderer_GPUAccuracyLevel", diff --git a/src/video_core/renderer_base.cpp b/src/video_core/renderer_base.cpp index c9a360aaf..a99c33c37 100755 --- a/src/video_core/renderer_base.cpp +++ b/src/video_core/renderer_base.cpp @@ -19,9 +19,6 @@ RendererBase::~RendererBase() = default; void RendererBase::RefreshBaseSettings() { UpdateCurrentFramebufferLayout(); - - renderer_settings.use_framelimiter = Settings::values.use_frame_limit.GetValue(); - renderer_settings.set_background_color = true; } void RendererBase::UpdateCurrentFramebufferLayout() { @@ -30,7 +27,7 @@ void RendererBase::UpdateCurrentFramebufferLayout() { render_window.UpdateCurrentFramebufferLayout(layout.width, layout.height); } -void RendererBase::RequestScreenshot(void* data, std::function callback, +void RendererBase::RequestScreenshot(void* data, std::function callback, const Layout::FramebufferLayout& layout) { if (renderer_settings.screenshot_requested) { LOG_ERROR(Render, "A screenshot is already requested or in progress, ignoring the request"); diff --git a/src/video_core/renderer_base.h b/src/video_core/renderer_base.h index 63d8ad42a..bb204454e 100755 --- a/src/video_core/renderer_base.h +++ b/src/video_core/renderer_base.h @@ -21,13 +21,10 @@ class GraphicsContext; namespace VideoCore { struct RendererSettings { - std::atomic_bool use_framelimiter{false}; - std::atomic_bool set_background_color{false}; - // Screenshot std::atomic screenshot_requested{false}; void* screenshot_bits{}; - std::function screenshot_complete_callback; + std::function screenshot_complete_callback; Layout::FramebufferLayout screenshot_framebuffer_layout; }; @@ -83,7 +80,7 @@ public: void RefreshBaseSettings(); /// Request a screenshot of the next frame - void RequestScreenshot(void* data, std::function callback, + void RequestScreenshot(void* data, std::function callback, const Layout::FramebufferLayout& layout); protected: diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 285e78384..7d7cba69c 100755 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -328,12 +328,10 @@ void RendererOpenGL::ConfigureFramebufferTexture(TextureInfo& texture, } void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) { - if (renderer_settings.set_background_color) { - // Update background color before drawing - glClearColor(Settings::values.bg_red.GetValue() / 255.0f, - Settings::values.bg_green.GetValue() / 255.0f, - Settings::values.bg_blue.GetValue() / 255.0f, 1.0f); - } + // Update background color before drawing + glClearColor(Settings::values.bg_red.GetValue() / 255.0f, + Settings::values.bg_green.GetValue() / 255.0f, + Settings::values.bg_blue.GetValue() / 255.0f, 1.0f); // Set projection matrix const std::array ortho_matrix = @@ -488,7 +486,7 @@ void RendererOpenGL::RenderScreenshot() { glBindFramebuffer(GL_READ_FRAMEBUFFER, old_read_fb); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, old_draw_fb); - renderer_settings.screenshot_complete_callback(); + renderer_settings.screenshot_complete_callback(true); renderer_settings.screenshot_requested = false; } diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp index a8d04dc61..8f84b0bfb 100755 --- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp +++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp @@ -165,6 +165,7 @@ void RendererVulkan::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) { const VkSemaphore render_semaphore = blit_screen.Draw(*framebuffer, use_accelerated); scheduler.Flush(render_semaphore); scheduler.WaitWorker(); + RenderScreenshot(); swapchain.Present(render_semaphore); gpu.RendererFrameEndNotify(); @@ -193,4 +194,102 @@ void RendererVulkan::Report() const { telemetry_session.AddField(field, "GPU_Vulkan_Extensions", extensions); } +void Vulkan::RendererVulkan::RenderScreenshot() { + if (!renderer_settings.screenshot_requested) { + return; + } + const Layout::FramebufferLayout layout{renderer_settings.screenshot_framebuffer_layout}; + const auto buffer_size = static_cast(layout.width * layout.height * 4); + const VkBufferCreateInfo dst_info{ + .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, + .pNext = nullptr, + .flags = 0, + .size = buffer_size, + .usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT, + .sharingMode = VK_SHARING_MODE_EXCLUSIVE, + .queueFamilyIndexCount = 0, + .pQueueFamilyIndices = nullptr, + }; + const VkImage src_image = swapchain.GetImageIndex(swapchain.GetImageIndex()); + const vk::Buffer dst_buffer = device.GetLogical().CreateBuffer(dst_info); + MemoryCommit dst_memory = memory_allocator.Commit(dst_buffer, MemoryUsage::Download); + + scheduler.RequestOutsideRenderPassOperationContext(); + scheduler.Record([buffer = *dst_buffer, src_image, layout](vk::CommandBuffer cmdbuf) { + const VkImageMemoryBarrier read_barrier{ + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT, + .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT, + .oldLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, + .newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = src_image, + .subresourceRange{ + .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, + .baseMipLevel = 0, + .levelCount = 1, + .baseArrayLayer = 0, + .layerCount = 1, + }, + }; + const VkImageMemoryBarrier image_write_barrier{ + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = 0, + .dstAccessMask = VK_ACCESS_MEMORY_WRITE_BIT, + .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + .newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = src_image, + .subresourceRange{ + .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, + .baseMipLevel = 0, + .levelCount = 1, + .baseArrayLayer = 0, + .layerCount = 1, + }, + }; + static constexpr VkMemoryBarrier memory_write_barrier{ + .sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT, + .dstAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT, + }; + const VkBufferImageCopy copy{ + .bufferOffset = 0, + .bufferRowLength = layout.width, + .bufferImageHeight = layout.height, + .imageSubresource{ + .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, + .mipLevel = 0, + .baseArrayLayer = 0, + .layerCount = 1, + }, + .imageOffset{.x = 0, .y = 0, .z = 0}, + .imageExtent{ + .width = layout.width, + .height = layout.height, + .depth = 1, + }, + + }; + cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, + 0, read_barrier); + cmdbuf.CopyImageToBuffer(src_image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, buffer, copy); + cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, + 0, memory_write_barrier, nullptr, image_write_barrier); + }); + // Ensure the copy is fully completed before saving the screenshot + scheduler.Finish(); + + // Copy backing image data to the QImage screenshot buffer + std::memcpy(renderer_settings.screenshot_bits, dst_memory.Map().data(), + dst_memory.Map().size()); + renderer_settings.screenshot_complete_callback(false); + renderer_settings.screenshot_requested = false; +} + } // namespace Vulkan diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.h b/src/video_core/renderer_vulkan/renderer_vulkan.h index d7d17e110..8388727f8 100755 --- a/src/video_core/renderer_vulkan/renderer_vulkan.h +++ b/src/video_core/renderer_vulkan/renderer_vulkan.h @@ -54,6 +54,8 @@ public: private: void Report() const; + void RenderScreenshot(); + Core::TelemetrySession& telemetry_session; Core::Memory::Memory& cpu_memory; Tegra::GPU& gpu; diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 484b6d71b..1519a46ed 100755 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -634,9 +634,9 @@ void GRenderWindow::CaptureScreenshot(u32 res_scale, const QString& screenshot_p screenshot_image = QImage(QSize(layout.width, layout.height), QImage::Format_RGB32); renderer.RequestScreenshot( screenshot_image.bits(), - [=, this] { + [=, this](bool invert_y) { const std::string std_screenshot_path = screenshot_path.toStdString(); - if (screenshot_image.mirrored(false, true).save(screenshot_path)) { + if (screenshot_image.mirrored(false, invert_y).save(screenshot_path)) { LOG_INFO(Frontend, "Screenshot saved to \"{}\"", std_screenshot_path); } else { LOG_ERROR(Frontend, "Failed to save screenshot to \"{}\"", std_screenshot_path); diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 9834cd2b3..8779ce54c 100755 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -821,8 +821,8 @@ void Config::ReadRendererValues() { ReadGlobalSetting(Settings::values.fullscreen_mode); ReadGlobalSetting(Settings::values.aspect_ratio); ReadGlobalSetting(Settings::values.max_anisotropy); - ReadGlobalSetting(Settings::values.use_frame_limit); - ReadGlobalSetting(Settings::values.frame_limit); + ReadGlobalSetting(Settings::values.use_speed_limit); + ReadGlobalSetting(Settings::values.speed_limit); ReadGlobalSetting(Settings::values.use_disk_shader_cache); ReadGlobalSetting(Settings::values.gpu_accuracy); ReadGlobalSetting(Settings::values.use_asynchronous_gpu_emulation); @@ -1359,8 +1359,8 @@ void Config::SaveRendererValues() { WriteGlobalSetting(Settings::values.fullscreen_mode); WriteGlobalSetting(Settings::values.aspect_ratio); WriteGlobalSetting(Settings::values.max_anisotropy); - WriteGlobalSetting(Settings::values.use_frame_limit); - WriteGlobalSetting(Settings::values.frame_limit); + WriteGlobalSetting(Settings::values.use_speed_limit); + WriteGlobalSetting(Settings::values.speed_limit); WriteGlobalSetting(Settings::values.use_disk_shader_cache); WriteSetting(QString::fromStdString(Settings::values.gpu_accuracy.GetLabel()), static_cast(Settings::values.gpu_accuracy.GetValue(global)), diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index d79d2e23e..1f647a0d1 100755 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp @@ -24,8 +24,8 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent) SetConfiguration(); if (Settings::IsConfiguringGlobal()) { - connect(ui->toggle_frame_limit, &QCheckBox::clicked, ui->frame_limit, - [this]() { ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked()); }); + connect(ui->toggle_speed_limit, &QCheckBox::clicked, ui->speed_limit, + [this]() { ui->speed_limit->setEnabled(ui->toggle_speed_limit->isChecked()); }); } connect(ui->button_reset_defaults, &QPushButton::clicked, this, @@ -45,18 +45,18 @@ void ConfigureGeneral::SetConfiguration() { ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background.GetValue()); ui->toggle_hide_mouse->setChecked(UISettings::values.hide_mouse.GetValue()); - ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit.GetValue()); - ui->frame_limit->setValue(Settings::values.frame_limit.GetValue()); + ui->toggle_speed_limit->setChecked(Settings::values.use_speed_limit.GetValue()); + ui->speed_limit->setValue(Settings::values.speed_limit.GetValue()); ui->fps_cap->setValue(Settings::values.fps_cap.GetValue()); ui->button_reset_defaults->setEnabled(runtime_lock); if (Settings::IsConfiguringGlobal()) { - ui->frame_limit->setEnabled(Settings::values.use_frame_limit.GetValue()); + ui->speed_limit->setEnabled(Settings::values.use_speed_limit.GetValue()); } else { - ui->frame_limit->setEnabled(Settings::values.use_frame_limit.GetValue() && - use_frame_limit != ConfigurationShared::CheckState::Global); + ui->speed_limit->setEnabled(Settings::values.use_speed_limit.GetValue() && + use_speed_limit != ConfigurationShared::CheckState::Global); } } @@ -92,19 +92,19 @@ void ConfigureGeneral::ApplyConfiguration() { Settings::values.fps_cap.SetValue(ui->fps_cap->value()); // Guard if during game and set to game-specific value - if (Settings::values.use_frame_limit.UsingGlobal()) { - Settings::values.use_frame_limit.SetValue(ui->toggle_frame_limit->checkState() == + if (Settings::values.use_speed_limit.UsingGlobal()) { + Settings::values.use_speed_limit.SetValue(ui->toggle_speed_limit->checkState() == Qt::Checked); - Settings::values.frame_limit.SetValue(ui->frame_limit->value()); + Settings::values.speed_limit.SetValue(ui->speed_limit->value()); } } else { - bool global_frame_limit = use_frame_limit == ConfigurationShared::CheckState::Global; - Settings::values.use_frame_limit.SetGlobal(global_frame_limit); - Settings::values.frame_limit.SetGlobal(global_frame_limit); - if (!global_frame_limit) { - Settings::values.use_frame_limit.SetValue(ui->toggle_frame_limit->checkState() == + bool global_speed_limit = use_speed_limit == ConfigurationShared::CheckState::Global; + Settings::values.use_speed_limit.SetGlobal(global_speed_limit); + Settings::values.speed_limit.SetGlobal(global_speed_limit); + if (!global_speed_limit) { + Settings::values.use_speed_limit.SetValue(ui->toggle_speed_limit->checkState() == Qt::Checked); - Settings::values.frame_limit.SetValue(ui->frame_limit->value()); + Settings::values.speed_limit.SetValue(ui->speed_limit->value()); } } } @@ -126,8 +126,8 @@ void ConfigureGeneral::SetupPerGameUI() { // Disables each setting if: // - A game is running (thus settings in use), and // - A non-global setting is applied. - ui->toggle_frame_limit->setEnabled(Settings::values.use_frame_limit.UsingGlobal()); - ui->frame_limit->setEnabled(Settings::values.frame_limit.UsingGlobal()); + ui->toggle_speed_limit->setEnabled(Settings::values.use_speed_limit.UsingGlobal()); + ui->speed_limit->setEnabled(Settings::values.speed_limit.UsingGlobal()); return; } @@ -139,13 +139,13 @@ void ConfigureGeneral::SetupPerGameUI() { ui->button_reset_defaults->setVisible(false); - ConfigurationShared::SetColoredTristate(ui->toggle_frame_limit, - Settings::values.use_frame_limit, use_frame_limit); + ConfigurationShared::SetColoredTristate(ui->toggle_speed_limit, + Settings::values.use_speed_limit, use_speed_limit); ConfigurationShared::SetColoredTristate(ui->use_multi_core, Settings::values.use_multi_core, use_multi_core); - connect(ui->toggle_frame_limit, &QCheckBox::clicked, ui->frame_limit, [this]() { - ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked() && - (use_frame_limit != ConfigurationShared::CheckState::Global)); + connect(ui->toggle_speed_limit, &QCheckBox::clicked, ui->speed_limit, [this]() { + ui->speed_limit->setEnabled(ui->toggle_speed_limit->isChecked() && + (use_speed_limit != ConfigurationShared::CheckState::Global)); }); } diff --git a/src/yuzu/configuration/configure_general.h b/src/yuzu/configuration/configure_general.h index a0fd52492..c9df37d73 100755 --- a/src/yuzu/configuration/configure_general.h +++ b/src/yuzu/configuration/configure_general.h @@ -43,6 +43,6 @@ private: std::unique_ptr ui; - ConfigurationShared::CheckState use_frame_limit; + ConfigurationShared::CheckState use_speed_limit; ConfigurationShared::CheckState use_multi_core; }; diff --git a/src/yuzu/configuration/configure_general.ui b/src/yuzu/configuration/configure_general.ui index bc3c4b481..8ce97edec 100755 --- a/src/yuzu/configuration/configure_general.ui +++ b/src/yuzu/configuration/configure_general.ui @@ -27,14 +27,14 @@ - + Limit Speed Percent - + % diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index db22d0d84..080f0bf23 100755 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -979,23 +979,23 @@ void GMainWindow::InitializeHotkeys() { }); connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Speed Limit"), this), &QShortcut::activated, this, [&] { - Settings::values.use_frame_limit.SetValue( - !Settings::values.use_frame_limit.GetValue()); + Settings::values.use_speed_limit.SetValue( + !Settings::values.use_speed_limit.GetValue()); UpdateStatusBar(); }); constexpr u16 SPEED_LIMIT_STEP = 5; connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Increase Speed Limit"), this), &QShortcut::activated, this, [&] { - if (Settings::values.frame_limit.GetValue() < 9999 - SPEED_LIMIT_STEP) { - Settings::values.frame_limit.SetValue(SPEED_LIMIT_STEP + - Settings::values.frame_limit.GetValue()); + if (Settings::values.speed_limit.GetValue() < 9999 - SPEED_LIMIT_STEP) { + Settings::values.speed_limit.SetValue(SPEED_LIMIT_STEP + + Settings::values.speed_limit.GetValue()); UpdateStatusBar(); } }); connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Decrease Speed Limit"), this), &QShortcut::activated, this, [&] { - if (Settings::values.frame_limit.GetValue() > SPEED_LIMIT_STEP) { - Settings::values.frame_limit.SetValue(Settings::values.frame_limit.GetValue() - + if (Settings::values.speed_limit.GetValue() > SPEED_LIMIT_STEP) { + Settings::values.speed_limit.SetValue(Settings::values.speed_limit.GetValue() - SPEED_LIMIT_STEP); UpdateStatusBar(); } @@ -2965,10 +2965,10 @@ void GMainWindow::UpdateStatusBar() { shader_building_label->setVisible(false); } - if (Settings::values.use_frame_limit.GetValue()) { + if (Settings::values.use_speed_limit.GetValue()) { emu_speed_label->setText(tr("Speed: %1% / %2%") .arg(results.emulation_speed * 100.0, 0, 'f', 0) - .arg(Settings::values.frame_limit.GetValue())); + .arg(Settings::values.speed_limit.GetValue())); } else { emu_speed_label->setText(tr("Speed: %1%").arg(results.emulation_speed * 100.0, 0, 'f', 0)); } diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index d4ca6bb57..5af1ee6a8 100755 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp @@ -451,8 +451,8 @@ void Config::ReadValues() { ReadSetting("Renderer", Settings::values.fullscreen_mode); ReadSetting("Renderer", Settings::values.aspect_ratio); ReadSetting("Renderer", Settings::values.max_anisotropy); - ReadSetting("Renderer", Settings::values.use_frame_limit); - ReadSetting("Renderer", Settings::values.frame_limit); + ReadSetting("Renderer", Settings::values.use_speed_limit); + ReadSetting("Renderer", Settings::values.speed_limit); ReadSetting("Renderer", Settings::values.use_disk_shader_cache); ReadSetting("Renderer", Settings::values.gpu_accuracy); ReadSetting("Renderer", Settings::values.use_asynchronous_gpu_emulation); diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h index b2b2095d1..e646e2d2f 100755 --- a/src/yuzu_cmd/default_ini.h +++ b/src/yuzu_cmd/default_ini.h @@ -265,13 +265,13 @@ use_nvdec_emulation = # 0: Off, 1 (default): On accelerate_astc = -# Turns on the frame limiter, which will limit frames output to the target game speed +# Turns on the speed limiter, which will limit the emulation speed to the desired speed limit value # 0: Off, 1: On (default) -use_frame_limit = +use_speed_limit = # Limits the speed of the game to run no faster than this value as a percentage of target speed # 1 - 9999: Speed limit as a percentage of target game speed. 100 (default) -frame_limit = +speed_limit = # Whether to use disk based shader cache # 0: Off, 1 (default): On