Skip to content

Commit

Permalink
Fix same object count being used for all frames in the FIFO analyzer
Browse files Browse the repository at this point in the history
If the number of objects varied, this would result in either missing objects on some frames, or too many objects on some frames; the latter case could cause crashes.  Since it used the current frame to get the count, if the FIFO is started before the FIFO analyzer is opened, then the current frame is effectively random, making it hard to reproduce consistently.

This issue has existed since the FIFO analyzer was implemented for Qt.
  • Loading branch information
Pokechu22 committed May 7, 2021
1 parent ef75381 commit 28b71c6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
11 changes: 8 additions & 3 deletions Source/Core/Core/FifoPlayer/FifoPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,21 @@ u32 FifoPlayer::GetMaxObjectCount() const
return result;
}

u32 FifoPlayer::GetFrameObjectCount() const
u32 FifoPlayer::GetFrameObjectCount(u32 frame) const
{
if (m_CurrentFrame < m_FrameInfo.size())
if (frame < m_FrameInfo.size())
{
return (u32)(m_FrameInfo[m_CurrentFrame].objectStarts.size());
return static_cast<u32>(m_FrameInfo[frame].objectStarts.size());
}

return 0;
}

u32 FifoPlayer::GetCurrentFrameObjectCount() const
{
return GetFrameObjectCount(m_CurrentFrame);
}

void FifoPlayer::SetFrameRangeStart(u32 start)
{
if (m_File)
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/FifoPlayer/FifoPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class FifoPlayer

FifoDataFile* GetFile() const { return m_File.get(); }
u32 GetMaxObjectCount() const;
u32 GetFrameObjectCount() const;
u32 GetFrameObjectCount(u32 frame) const;
u32 GetCurrentFrameObjectCount() const;
u32 GetCurrentFrameNum() const { return m_CurrentFrame; }
const AnalyzedFrameInfo& GetAnalyzedFrameInfo(u32 frame) const { return m_FrameInfo[frame]; }
// Frame range
Expand Down
17 changes: 8 additions & 9 deletions Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,22 @@ void FIFOAnalyzer::UpdateTree()

auto* file = FifoPlayer::GetInstance().GetFile();

int object_count = FifoPlayer::GetInstance().GetFrameObjectCount();
int frame_count = file->GetFrameCount();

for (int i = 0; i < frame_count; i++)
const u32 frame_count = file->GetFrameCount();
for (u32 frame = 0; frame < frame_count; frame++)
{
auto* frame_item = new QTreeWidgetItem({tr("Frame %1").arg(i)});
auto* frame_item = new QTreeWidgetItem({tr("Frame %1").arg(frame)});

recording_item->addChild(frame_item);

for (int j = 0; j < object_count; j++)
const u32 object_count = FifoPlayer::GetInstance().GetFrameObjectCount(frame);
for (u32 object = 0; object < object_count; object++)
{
auto* object_item = new QTreeWidgetItem({tr("Object %1").arg(j)});
auto* object_item = new QTreeWidgetItem({tr("Object %1").arg(object)});

frame_item->addChild(object_item);

object_item->setData(0, FRAME_ROLE, i);
object_item->setData(0, OBJECT_ROLE, j);
object_item->setData(0, FRAME_ROLE, frame);
object_item->setData(0, OBJECT_ROLE, object);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void FIFOPlayerWindow::UpdateInfo()
m_info_label->setText(
tr("%1 frame(s)\n%2 object(s)\nCurrent Frame: %3")
.arg(QString::number(file->GetFrameCount()),
QString::number(FifoPlayer::GetInstance().GetFrameObjectCount()),
QString::number(FifoPlayer::GetInstance().GetCurrentFrameObjectCount()),
QString::number(FifoPlayer::GetInstance().GetCurrentFrameNum())));
return;
}
Expand Down

0 comments on commit 28b71c6

Please sign in to comment.