diff options
23 files changed, 86 insertions, 61 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/kernel/event.h b/src/core/hle/kernel/event.h index 1c99911b2..3c20c05e8 100644 --- a/src/core/hle/kernel/event.h +++ b/src/core/hle/kernel/event.h @@ -31,10 +31,9 @@ public:          return HANDLE_TYPE;      } -    ResetType reset_type; ///< Current ResetType - -    bool signaled;    ///< Whether the event has already been signaled -    std::string name; ///< Name of event (optional) +    ResetType GetResetType() const { +        return reset_type; +    }      bool ShouldWait(Thread* thread) const override;      void Acquire(Thread* thread) override; @@ -47,6 +46,11 @@ public:  private:      Event();      ~Event() override; + +    ResetType reset_type; ///< Current ResetType + +    bool signaled;    ///< Whether the event has already been signaled +    std::string name; ///< Name of event (optional)  };  } // namespace Kernel 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/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index a235b543e..5c0ae8009 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp @@ -285,8 +285,6 @@ Texture::TICEntry Maxwell3D::GetTICEntry(u32 tic_index) const {      // TODO(Subv): Different data types for separate components are not supported      ASSERT(r_type == g_type && r_type == b_type && r_type == a_type); -    // TODO(Subv): Only UNORM formats are supported for now. -    ASSERT(r_type == Texture::ComponentType::UNORM);      return tic_entry;  } diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index c8f0c4e28..257aa9571 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -46,6 +46,8 @@ struct FormatTuple {      params.height = Common::AlignUp(config.tic.Height(), GetCompressionFactor(params.pixel_format));      params.unaligned_height = config.tic.Height();      params.size_in_bytes = params.SizeInBytes(); +    params.cache_width = Common::AlignUp(params.width, 16); +    params.cache_height = Common::AlignUp(params.height, 16);      return params;  } @@ -63,6 +65,8 @@ struct FormatTuple {      params.height = config.height;      params.unaligned_height = config.height;      params.size_in_bytes = params.SizeInBytes(); +    params.cache_width = Common::AlignUp(params.width, 16); +    params.cache_height = Common::AlignUp(params.height, 16);      return params;  } @@ -82,6 +86,8 @@ struct FormatTuple {      params.height = zeta_height;      params.unaligned_height = zeta_height;      params.size_in_bytes = params.SizeInBytes(); +    params.cache_width = Common::AlignUp(params.width, 16); +    params.cache_height = Common::AlignUp(params.height, 16);      return params;  } @@ -680,12 +686,12 @@ Surface RasterizerCacheOpenGL::GetSurface(const SurfaceParams& params) {              // If use_accurate_framebuffers is enabled, always load from memory              FlushSurface(surface);              UnregisterSurface(surface); -        } else if (surface->GetSurfaceParams() != params) { -            // If surface parameters changed, recreate the surface from the old one -            return RecreateSurface(surface, params); -        } else { +        } else if (surface->GetSurfaceParams().IsCompatibleSurface(params)) {              // Use the cached surface as-is              return surface; +        } else { +            // If surface parameters changed, recreate the surface from the old one +            return RecreateSurface(surface, params);          }      } diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 4e1e18d9c..39fcf22b4 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h @@ -9,6 +9,7 @@  #include <memory>  #include <vector>  #include <boost/icl/interval_map.hpp> +  #include "common/common_types.h"  #include "common/math_util.h"  #include "video_core/engines/maxwell_3d.h" @@ -546,6 +547,12 @@ struct SurfaceParams {          return !operator==(other);      } +    /// Checks if surfaces are compatible for caching +    bool IsCompatibleSurface(const SurfaceParams& other) const { +        return std::tie(pixel_format, type, cache_width, cache_height) == +               std::tie(other.pixel_format, other.type, other.cache_width, other.cache_height); +    } +      Tegra::GPUVAddr addr;      bool is_tiled;      u32 block_height; @@ -556,6 +563,10 @@ struct SurfaceParams {      u32 height;      u32 unaligned_height;      size_t size_in_bytes; + +    // Parameters used for caching only +    u32 cache_width; +    u32 cache_height;  };  class CachedSurface final { diff --git a/src/yuzu/about_dialog.cpp b/src/yuzu/about_dialog.cpp index 39ed3bccf..a81ad2888 100644 --- a/src/yuzu/about_dialog.cpp +++ b/src/yuzu/about_dialog.cpp @@ -15,4 +15,4 @@ AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AboutDia                                         Common::g_scm_desc, QString(Common::g_build_date).left(10)));  } -AboutDialog::~AboutDialog() {} +AboutDialog::~AboutDialog() = default; diff --git a/src/yuzu/about_dialog.h b/src/yuzu/about_dialog.h index 2eb6e28f5..18e8c11a7 100644 --- a/src/yuzu/about_dialog.h +++ b/src/yuzu/about_dialog.h @@ -16,7 +16,7 @@ class AboutDialog : public QDialog {  public:      explicit AboutDialog(QWidget* parent); -    ~AboutDialog(); +    ~AboutDialog() override;  private:      std::unique_ptr<Ui::AboutDialog> ui; diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index 130bc613b..d0f990c64 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h @@ -106,7 +106,7 @@ class GRenderWindow : public QWidget, public EmuWindow {  public:      GRenderWindow(QWidget* parent, EmuThread* emu_thread); -    ~GRenderWindow(); +    ~GRenderWindow() override;      // EmuWindow implementation      void SwapBuffers() override; diff --git a/src/yuzu/configuration/configure_debug.cpp b/src/yuzu/configuration/configure_debug.cpp index 7fd07539a..45d84f19a 100644 --- a/src/yuzu/configuration/configure_debug.cpp +++ b/src/yuzu/configuration/configure_debug.cpp @@ -24,7 +24,7 @@ ConfigureDebug::ConfigureDebug(QWidget* parent) : QWidget(parent), ui(new Ui::Co      });  } -ConfigureDebug::~ConfigureDebug() {} +ConfigureDebug::~ConfigureDebug() = default;  void ConfigureDebug::setConfiguration() {      ui->toggle_gdbstub->setChecked(Settings::values.use_gdbstub); diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp index f66abf870..1ca7e876c 100644 --- a/src/yuzu/configuration/configure_dialog.cpp +++ b/src/yuzu/configuration/configure_dialog.cpp @@ -12,7 +12,7 @@ ConfigureDialog::ConfigureDialog(QWidget* parent) : QDialog(parent), ui(new Ui::      this->setConfiguration();  } -ConfigureDialog::~ConfigureDialog() {} +ConfigureDialog::~ConfigureDialog() = default;  void ConfigureDialog::setConfiguration() {} diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index cb7d3f8bf..04afc8724 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp @@ -24,7 +24,7 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent)      ui->use_docked_mode->setEnabled(!Core::System::GetInstance().IsPoweredOn());  } -ConfigureGeneral::~ConfigureGeneral() {} +ConfigureGeneral::~ConfigureGeneral() = default;  void ConfigureGeneral::setConfiguration() {      ui->toggle_deepscan->setChecked(UISettings::values.gamedir_deepscan); diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index 3379b7963..4afe0f81b 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -14,7 +14,7 @@ ConfigureGraphics::ConfigureGraphics(QWidget* parent)      this->setConfiguration();  } -ConfigureGraphics::~ConfigureGraphics() {} +ConfigureGraphics::~ConfigureGraphics() = default;  enum class Resolution : int {      Auto, diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 9be2c939c..e9ed9c38f 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -35,7 +35,7 @@ ConfigureSystem::ConfigureSystem(QWidget* parent) : QWidget(parent), ui(new Ui::      this->setConfiguration();  } -ConfigureSystem::~ConfigureSystem() {} +ConfigureSystem::~ConfigureSystem() = default;  void ConfigureSystem::setConfiguration() {      enabled = !Core::System::GetInstance().IsPoweredOn(); diff --git a/src/yuzu/debugger/graphics/graphics_surface.cpp b/src/yuzu/debugger/graphics/graphics_surface.cpp index ff3efcdaa..3f7103ab9 100644 --- a/src/yuzu/debugger/graphics/graphics_surface.cpp +++ b/src/yuzu/debugger/graphics/graphics_surface.cpp @@ -34,7 +34,8 @@ static Tegra::Texture::TextureFormat ConvertToTextureFormat(  SurfacePicture::SurfacePicture(QWidget* parent, GraphicsSurfaceWidget* surface_widget_)      : QLabel(parent), surface_widget(surface_widget_) {} -SurfacePicture::~SurfacePicture() {} + +SurfacePicture::~SurfacePicture() = default;  void SurfacePicture::mousePressEvent(QMouseEvent* event) {      // Only do something while the left mouse button is held down diff --git a/src/yuzu/debugger/graphics/graphics_surface.h b/src/yuzu/debugger/graphics/graphics_surface.h index 58f9db465..323e39d94 100644 --- a/src/yuzu/debugger/graphics/graphics_surface.h +++ b/src/yuzu/debugger/graphics/graphics_surface.h @@ -22,11 +22,11 @@ class SurfacePicture : public QLabel {  public:      explicit SurfacePicture(QWidget* parent = nullptr,                              GraphicsSurfaceWidget* surface_widget = nullptr); -    ~SurfacePicture(); +    ~SurfacePicture() override;  protected slots: -    virtual void mouseMoveEvent(QMouseEvent* event); -    virtual void mousePressEvent(QMouseEvent* event); +    void mouseMoveEvent(QMouseEvent* event) override; +    void mousePressEvent(QMouseEvent* event) override;  private:      GraphicsSurfaceWidget* surface_widget; diff --git a/src/yuzu/debugger/wait_tree.cpp b/src/yuzu/debugger/wait_tree.cpp index f5a5697a0..d0926d723 100644 --- a/src/yuzu/debugger/wait_tree.cpp +++ b/src/yuzu/debugger/wait_tree.cpp @@ -14,7 +14,7 @@  #include "core/hle/kernel/timer.h"  #include "core/hle/kernel/wait_object.h" -WaitTreeItem::~WaitTreeItem() {} +WaitTreeItem::~WaitTreeItem() = default;  QColor WaitTreeItem::GetColor() const {      return QColor(Qt::GlobalColor::black); @@ -316,7 +316,7 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeEvent::GetChildren() const {      list.push_back(std::make_unique<WaitTreeText>(          tr("reset type = %1") -            .arg(GetResetTypeQString(static_cast<const Kernel::Event&>(object).reset_type)))); +            .arg(GetResetTypeQString(static_cast<const Kernel::Event&>(object).GetResetType()))));      return list;  } diff --git a/src/yuzu/debugger/wait_tree.h b/src/yuzu/debugger/wait_tree.h index 6cbce6856..513b3c45d 100644 --- a/src/yuzu/debugger/wait_tree.h +++ b/src/yuzu/debugger/wait_tree.h @@ -25,11 +25,13 @@ class WaitTreeThread;  class WaitTreeItem : public QObject {      Q_OBJECT  public: +    ~WaitTreeItem() override; +      virtual bool IsExpandable() const;      virtual std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const;      virtual QString GetText() const = 0;      virtual QColor GetColor() const; -    virtual ~WaitTreeItem(); +      void Expand();      WaitTreeItem* Parent() const;      const std::vector<std::unique_ptr<WaitTreeItem>>& Children() const; diff --git a/src/yuzu/game_list_p.h b/src/yuzu/game_list_p.h index a758b77aa..aa69a098f 100644 --- a/src/yuzu/game_list_p.h +++ b/src/yuzu/game_list_p.h @@ -5,6 +5,7 @@  #pragma once  #include <atomic> +#include <utility>  #include <QImage>  #include <QRunnable>  #include <QStandardItem> @@ -27,9 +28,8 @@ static QPixmap GetDefaultIcon(bool large) {  class GameListItem : public QStandardItem {  public: -    GameListItem() : QStandardItem() {} -    GameListItem(const QString& string) : QStandardItem(string) {} -    virtual ~GameListItem() override {} +    GameListItem() = default; +    explicit GameListItem(const QString& string) : QStandardItem(string) {}  };  /** @@ -45,9 +45,8 @@ public:      static const int TitleRole = Qt::UserRole + 2;      static const int ProgramIdRole = Qt::UserRole + 3; -    GameListItemPath() : GameListItem() {} -    GameListItemPath(const QString& game_path, const std::vector<u8>& smdh_data, u64 program_id) -        : GameListItem() { +    GameListItemPath() = default; +    GameListItemPath(const QString& game_path, const std::vector<u8>& smdh_data, u64 program_id) {          setData(game_path, FullPathRole);          setData(qulonglong(program_id), ProgramIdRole);      } @@ -75,8 +74,8 @@ class GameListItemSize : public GameListItem {  public:      static const int SizeRole = Qt::UserRole + 1; -    GameListItemSize() : GameListItem() {} -    GameListItemSize(const qulonglong size_bytes) : GameListItem() { +    GameListItemSize() = default; +    explicit GameListItemSize(const qulonglong size_bytes) {          setData(size_bytes, SizeRole);      } @@ -111,7 +110,7 @@ class GameListWorker : public QObject, public QRunnable {  public:      GameListWorker(QString dir_path, bool deep_scan) -        : QObject(), QRunnable(), dir_path(dir_path), deep_scan(deep_scan) {} +        : dir_path(std::move(dir_path)), deep_scan(deep_scan) {}  public slots:      /// Starts the processing of directory tree information. diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index c1e86202f..dd71bd763 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -629,9 +629,15 @@ void GMainWindow::OnMenuLoadFile() {  }  void GMainWindow::OnMenuLoadFolder() { -    QDir dir = QFileDialog::getExistingDirectory(this, tr("Open Extracted ROM Directory")); +    const QString dir_path = +        QFileDialog::getExistingDirectory(this, tr("Open Extracted ROM Directory")); -    QStringList matching_main = dir.entryList(QStringList("main"), QDir::Files); +    if (dir_path.isNull()) { +        return; +    } + +    const QDir dir{dir_path}; +    const QStringList matching_main = dir.entryList(QStringList("main"), QDir::Files);      if (matching_main.size() == 1) {          BootGame(dir.path() + DIR_SEP + matching_main[0]);      } else { @@ -652,9 +658,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. @@ -945,15 +950,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); diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 074bba3f9..a60d831b9 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -43,7 +43,7 @@ public:      void filterBarSetChecked(bool state);      void UpdateUITheme();      GMainWindow(); -    ~GMainWindow(); +    ~GMainWindow() override;  signals: | 
