diff options
| -rw-r--r-- | src/core/core_timing.cpp | 4 | ||||
| -rw-r--r-- | src/core/core_timing.h | 3 | ||||
| -rw-r--r-- | src/core/hle/service/audio/audout_a.cpp | 2 | ||||
| -rw-r--r-- | src/core/memory.h | 23 | ||||
| -rw-r--r-- | src/core/perf_stats.cpp | 17 | ||||
| -rw-r--r-- | src/core/perf_stats.h | 8 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 14 | 
7 files changed, 33 insertions, 38 deletions
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index b2e3a495a..d3bb6f818 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp @@ -226,8 +226,8 @@ void Idle() {      downcount = 0;  } -u64 GetGlobalTimeUs() { -    return GetTicks() * 1000000 / BASE_CLOCK_RATE; +std::chrono::microseconds GetGlobalTimeUs() { +    return std::chrono::microseconds{GetTicks() * 1000000 / BASE_CLOCK_RATE};  }  int GetDowncount() { diff --git a/src/core/core_timing.h b/src/core/core_timing.h index 5bbde47f4..dfa161c0d 100644 --- a/src/core/core_timing.h +++ b/src/core/core_timing.h @@ -17,6 +17,7 @@   *   ScheduleEvent(periodInCycles - cyclesLate, callback, "whatever")   */ +#include <chrono>  #include <functional>  #include <string>  #include "common/common_types.h" @@ -86,7 +87,7 @@ void ClearPendingEvents();  void ForceExceptionCheck(s64 cycles); -u64 GetGlobalTimeUs(); +std::chrono::microseconds GetGlobalTimeUs();  int GetDowncount(); diff --git a/src/core/hle/service/audio/audout_a.cpp b/src/core/hle/service/audio/audout_a.cpp index 57b934dd6..bf8d40157 100644 --- a/src/core/hle/service/audio/audout_a.cpp +++ b/src/core/hle/service/audio/audout_a.cpp @@ -2,8 +2,6 @@  // Licensed under GPLv2 or any later version  // Refer to the license.txt file included. -#pragma once -  #include "core/hle/service/audio/audout_a.h"  namespace Service::Audio { diff --git a/src/core/memory.h b/src/core/memory.h index b5d885b8a..b7fb3b9ed 100644 --- a/src/core/memory.h +++ b/src/core/memory.h @@ -140,10 +140,10 @@ void SetCurrentPageTable(PageTable* page_table);  PageTable* GetCurrentPageTable();  /// Determines if the given VAddr is valid for the specified process. -bool IsValidVirtualAddress(const Kernel::Process& process, const VAddr vaddr); -bool IsValidVirtualAddress(const VAddr addr); +bool IsValidVirtualAddress(const Kernel::Process& process, VAddr vaddr); +bool IsValidVirtualAddress(VAddr vaddr);  /// Determines if the given VAddr is a kernel address -bool IsKernelVirtualAddress(const VAddr addr); +bool IsKernelVirtualAddress(VAddr vaddr);  u8 Read8(VAddr addr);  u16 Read16(VAddr addr); @@ -155,18 +155,17 @@ void Write16(VAddr addr, u16 data);  void Write32(VAddr addr, u32 data);  void Write64(VAddr addr, u64 data); -void ReadBlock(const Kernel::Process& process, const VAddr src_addr, void* dest_buffer, -               size_t size); -void ReadBlock(const VAddr src_addr, void* dest_buffer, size_t size); -void WriteBlock(const Kernel::Process& process, const VAddr dest_addr, const void* src_buffer, +void ReadBlock(const Kernel::Process& process, VAddr src_addr, void* dest_buffer, size_t size); +void ReadBlock(VAddr src_addr, void* dest_buffer, size_t size); +void WriteBlock(const Kernel::Process& process, VAddr dest_addr, const void* src_buffer,                  size_t size); -void WriteBlock(const VAddr dest_addr, const void* src_buffer, size_t size); -void ZeroBlock(const VAddr dest_addr, const size_t size); +void WriteBlock(VAddr dest_addr, const void* src_buffer, size_t size); +void ZeroBlock(const Kernel::Process& process, VAddr dest_addr, size_t size);  void CopyBlock(VAddr dest_addr, VAddr src_addr, size_t size); -u8* GetPointer(VAddr virtual_address); +u8* GetPointer(VAddr vaddr); -std::string ReadCString(VAddr virtual_address, std::size_t max_length); +std::string ReadCString(VAddr vaddr, std::size_t max_length);  enum class FlushMode {      /// Write back modified surfaces to RAM @@ -180,7 +179,7 @@ enum class FlushMode {  /**   * Mark each page touching the region as cached.   */ -void RasterizerMarkRegionCached(Tegra::GPUVAddr start, u64 size, bool cached); +void RasterizerMarkRegionCached(Tegra::GPUVAddr gpu_addr, u64 size, bool cached);  /**   * Flushes and invalidates any externally cached rasterizer resources touching the given virtual diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp index 5f53b16d3..8e09b9b63 100644 --- a/src/core/perf_stats.cpp +++ b/src/core/perf_stats.cpp @@ -40,22 +40,21 @@ void PerfStats::EndGameFrame() {      game_frames += 1;  } -PerfStats::Results PerfStats::GetAndResetStats(u64 current_system_time_us) { +PerfStats::Results PerfStats::GetAndResetStats(microseconds current_system_time_us) {      std::lock_guard<std::mutex> lock(object_mutex); -    auto now = Clock::now(); +    const auto now = Clock::now();      // Walltime elapsed since stats were reset -    auto interval = duration_cast<DoubleSecs>(now - reset_point).count(); +    const auto interval = duration_cast<DoubleSecs>(now - reset_point).count(); -    auto system_us_per_second = -        static_cast<double>(current_system_time_us - reset_point_system_us) / interval; +    const auto system_us_per_second = (current_system_time_us - reset_point_system_us) / interval;      Results results{};      results.system_fps = static_cast<double>(system_frames) / interval;      results.game_fps = static_cast<double>(game_frames) / interval;      results.frametime = duration_cast<DoubleSecs>(accumulated_frametime).count() /                          static_cast<double>(system_frames); -    results.emulation_speed = system_us_per_second / 1'000'000.0; +    results.emulation_speed = system_us_per_second.count() / 1'000'000.0;      // Reset counters      reset_point = now; @@ -74,10 +73,10 @@ double PerfStats::GetLastFrameTimeScale() {      return duration_cast<DoubleSecs>(previous_frame_length).count() / FRAME_LENGTH;  } -void FrameLimiter::DoFrameLimiting(u64 current_system_time_us) { +void FrameLimiter::DoFrameLimiting(microseconds current_system_time_us) {      // Max lag caused by slow frames. Can be adjusted to compensate for too many slow frames. Higher      // values increase the time needed to recover and limit framerate again after spikes. -    constexpr microseconds MAX_LAG_TIME_US = 25ms; +    constexpr microseconds MAX_LAG_TIME_US = 25us;      if (!Settings::values.toggle_framelimit) {          return; @@ -85,7 +84,7 @@ void FrameLimiter::DoFrameLimiting(u64 current_system_time_us) {      auto now = Clock::now(); -    frame_limiting_delta_err += microseconds(current_system_time_us - previous_system_time_us); +    frame_limiting_delta_err += current_system_time_us - previous_system_time_us;      frame_limiting_delta_err -= duration_cast<microseconds>(now - previous_walltime);      frame_limiting_delta_err =          std::clamp(frame_limiting_delta_err, -MAX_LAG_TIME_US, MAX_LAG_TIME_US); diff --git a/src/core/perf_stats.h b/src/core/perf_stats.h index 362b205c8..6e4619701 100644 --- a/src/core/perf_stats.h +++ b/src/core/perf_stats.h @@ -33,7 +33,7 @@ public:      void EndSystemFrame();      void EndGameFrame(); -    Results GetAndResetStats(u64 current_system_time_us); +    Results GetAndResetStats(std::chrono::microseconds current_system_time_us);      /**       * Gets the ratio between walltime and the emulated time of the previous system frame. This is @@ -47,7 +47,7 @@ private:      /// Point when the cumulative counters were reset      Clock::time_point reset_point = Clock::now();      /// System time when the cumulative counters were reset -    u64 reset_point_system_us = 0; +    std::chrono::microseconds reset_point_system_us{0};      /// Cumulative duration (excluding v-sync/frame-limiting) of frames since last reset      Clock::duration accumulated_frametime = Clock::duration::zero(); @@ -68,11 +68,11 @@ class FrameLimiter {  public:      using Clock = std::chrono::high_resolution_clock; -    void DoFrameLimiting(u64 current_system_time_us); +    void DoFrameLimiting(std::chrono::microseconds current_system_time_us);  private:      /// Emulated system time (in microseconds) at the last limiter invocation -    u64 previous_system_time_us = 0; +    std::chrono::microseconds previous_system_time_us{0};      /// Walltime at the last limiter invocation      Clock::time_point previous_walltime = Clock::now(); diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index e28679cd1..d0415a7dc 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -654,9 +654,8 @@ void GMainWindow::OnMenuRecentFile() {      QAction* action = qobject_cast<QAction*>(sender());      assert(action); -    QString filename = action->data().toString(); -    QFileInfo file_info(filename); -    if (file_info.exists()) { +    const QString filename = action->data().toString(); +    if (QFileInfo::exists(filename)) {          BootGame(filename);      } else {          // Display an error message and remove the file from the list. @@ -947,15 +946,14 @@ void GMainWindow::UpdateUITheme() {      QStringList theme_paths(default_theme_paths);      if (UISettings::values.theme != UISettings::themes[0].second &&          !UISettings::values.theme.isEmpty()) { -        QString theme_uri(":" + UISettings::values.theme + "/style.qss"); +        const QString theme_uri(":" + UISettings::values.theme + "/style.qss");          QFile f(theme_uri); -        if (!f.exists()) { -            LOG_ERROR(Frontend, "Unable to set style, stylesheet file not found"); -        } else { -            f.open(QFile::ReadOnly | QFile::Text); +        if (f.open(QFile::ReadOnly | QFile::Text)) {              QTextStream ts(&f);              qApp->setStyleSheet(ts.readAll());              GMainWindow::setStyleSheet(ts.readAll()); +        } else { +            LOG_ERROR(Frontend, "Unable to set style, stylesheet file not found");          }          theme_paths.append(QStringList{":/icons/default", ":/icons/" + UISettings::values.theme});          QIcon::setThemeName(":/icons/" + UISettings::values.theme);  | 
