From 263ca79aaeef9d768a779738b7ce3bf2b3e610c7 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Mon, 8 Feb 2021 16:10:57 -0800 Subject: [PATCH] Adjust FIFO player object ranges A single object can be selected instead of 2 (it was already inclusive internally), and the maximum value is the highest number of objects in any frame (minus 1) to reduce jank when multiple frames are being played back. --- Source/Core/Core/FifoPlayer/FifoPlayer.cpp | 12 ++++++++++++ Source/Core/Core/FifoPlayer/FifoPlayer.h | 1 + Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp | 10 +++++----- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp index 880ef791a5..48b6b581d5 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp @@ -189,6 +189,18 @@ bool FifoPlayer::IsRunningWithFakeVideoInterfaceUpdates() const return m_File->ShouldGenerateFakeVIUpdates(); } +u32 FifoPlayer::GetMaxObjectCount() const +{ + u32 result = 0; + for (auto& frame : m_FrameInfo) + { + const u32 count = static_cast(frame.objectStarts.size()); + if (count > result) + result = count; + } + return result; +} + u32 FifoPlayer::GetFrameObjectCount() const { if (m_CurrentFrame < m_FrameInfo.size()) diff --git a/Source/Core/Core/FifoPlayer/FifoPlayer.h b/Source/Core/Core/FifoPlayer/FifoPlayer.h index 5302e8cfcb..0f326c3cdb 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlayer.h +++ b/Source/Core/Core/FifoPlayer/FifoPlayer.h @@ -74,6 +74,7 @@ public: bool IsPlaying() const; FifoDataFile* GetFile() const { return m_File.get(); } + u32 GetMaxObjectCount() const; u32 GetFrameObjectCount() const; u32 GetCurrentFrameNum() const { return m_CurrentFrame; } const AnalyzedFrameInfo& GetAnalyzedFrameInfo(u32 frame) const { return m_FrameInfo[frame]; } diff --git a/Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp b/Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp index d88581b6f5..f888bb255d 100644 --- a/Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp +++ b/Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp @@ -298,16 +298,16 @@ void FIFOPlayerWindow::OnFIFOLoaded() { FifoDataFile* file = FifoPlayer::GetInstance().GetFile(); - auto object_count = FifoPlayer::GetInstance().GetFrameObjectCount(); + auto object_count = FifoPlayer::GetInstance().GetMaxObjectCount(); auto frame_count = file->GetFrameCount(); m_frame_range_to->setMaximum(frame_count); - m_object_range_to->setMaximum(object_count); + m_object_range_to->setMaximum(object_count - 1); m_frame_range_from->setValue(0); m_object_range_from->setValue(0); m_frame_range_to->setValue(frame_count); - m_object_range_to->setValue(object_count); + m_object_range_to->setValue(object_count - 1); UpdateInfo(); UpdateLimits(); @@ -336,8 +336,8 @@ void FIFOPlayerWindow::UpdateLimits() { m_frame_range_from->setMaximum(std::max(m_frame_range_to->value() - 1, 0)); m_frame_range_to->setMinimum(m_frame_range_from->value() + 1); - m_object_range_from->setMaximum(std::max(m_object_range_to->value() - 1, 0)); - m_object_range_to->setMinimum(m_object_range_from->value() + 1); + m_object_range_from->setMaximum(m_object_range_to->value()); + m_object_range_to->setMinimum(m_object_range_from->value()); } void FIFOPlayerWindow::UpdateControls()