mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 17:10:47 +00:00
Use the configured time unit used for the event browser duration column
This commit is contained in:
@@ -93,6 +93,9 @@ struct IEventBrowser
|
||||
"Retrieves the QWidget for this :class:`EventBrowser` if PySide2 is available, or ``None``.");
|
||||
virtual QWidget *Widget() = 0;
|
||||
|
||||
DOCUMENT("Updates the duration column if the selected time unit changes.");
|
||||
virtual void UpdateDurationColumn() = 0;
|
||||
|
||||
protected:
|
||||
IEventBrowser() = default;
|
||||
~IEventBrowser() = default;
|
||||
|
||||
@@ -284,6 +284,9 @@ void SettingsDialog::on_EventBrowser_TimeUnit_currentIndexChanged(int index)
|
||||
|
||||
m_Ctx.Config().EventBrowser_TimeUnit = (TimeUnit)ui->EventBrowser_TimeUnit->currentIndex();
|
||||
|
||||
if(m_Ctx.HasEventBrowser())
|
||||
m_Ctx.GetEventBrowser()->UpdateDurationColumn();
|
||||
|
||||
m_Ctx.Config().Save();
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +71,8 @@ EventBrowser::EventBrowser(ICaptureContext &ctx, QWidget *parent)
|
||||
m_SizeDelegate = new SizeDelegate(QSize(0, 16));
|
||||
ui->events->setItemDelegate(m_SizeDelegate);
|
||||
|
||||
UpdateDurationColumn();
|
||||
|
||||
m_FindHighlight = new QTimer(this);
|
||||
m_FindHighlight->setInterval(400);
|
||||
m_FindHighlight->setSingleShot(true);
|
||||
@@ -217,7 +219,16 @@ void EventBrowser::SetDrawcallTimes(QTreeWidgetItem *node,
|
||||
duration = r.value.d;
|
||||
}
|
||||
|
||||
node->setText(COL_DURATION, duration < 0.0f ? "" : QString::number(duration * 1000000.0));
|
||||
double secs = duration;
|
||||
|
||||
if(m_TimeUnit == TimeUnit::Milliseconds)
|
||||
secs *= 1000.0;
|
||||
else if(m_TimeUnit == TimeUnit::Microseconds)
|
||||
secs *= 1000000.0;
|
||||
else if(m_TimeUnit == TimeUnit::Nanoseconds)
|
||||
secs *= 1000000000.0;
|
||||
|
||||
node->setText(COL_DURATION, duration < 0.0f ? "" : QString::number(secs));
|
||||
node->setData(COL_DURATION, Qt::UserRole, QVariant(duration));
|
||||
|
||||
return;
|
||||
@@ -233,7 +244,16 @@ void EventBrowser::SetDrawcallTimes(QTreeWidgetItem *node,
|
||||
duration += nd;
|
||||
}
|
||||
|
||||
node->setText(COL_DURATION, duration < 0.0f ? "" : QString::number(duration * 1000000.0));
|
||||
double secs = duration;
|
||||
|
||||
if(m_TimeUnit == TimeUnit::Milliseconds)
|
||||
secs *= 1000.0;
|
||||
else if(m_TimeUnit == TimeUnit::Microseconds)
|
||||
secs *= 1000000.0;
|
||||
else if(m_TimeUnit == TimeUnit::Nanoseconds)
|
||||
secs *= 1000000000.0;
|
||||
|
||||
node->setText(COL_DURATION, duration < 0.0f ? "" : QString::number(secs));
|
||||
node->setData(COL_DURATION, Qt::UserRole, QVariant(duration));
|
||||
}
|
||||
|
||||
@@ -263,9 +283,9 @@ void EventBrowser::on_timeDraws_clicked()
|
||||
{
|
||||
m_Ctx.Replay().AsyncInvoke([this](IReplayController *r) {
|
||||
|
||||
rdctype::array<CounterResult> results = r->FetchCounters({GPUCounter::EventGPUDuration});
|
||||
m_Times = r->FetchCounters({GPUCounter::EventGPUDuration});
|
||||
|
||||
GUIInvoke::call([this, results]() { SetDrawcallTimes(ui->events->topLevelItem(0), results); });
|
||||
GUIInvoke::call([this]() { SetDrawcallTimes(ui->events->topLevelItem(0), m_Times); });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -751,3 +771,16 @@ void EventBrowser::Find(bool forward)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EventBrowser::UpdateDurationColumn()
|
||||
{
|
||||
if(m_TimeUnit == m_Ctx.Config().EventBrowser_TimeUnit)
|
||||
return;
|
||||
|
||||
m_TimeUnit = m_Ctx.Config().EventBrowser_TimeUnit;
|
||||
|
||||
ui->events->headerItem()->setText(COL_DURATION, tr("Duration (%1)").arg(UnitSuffix(m_TimeUnit)));
|
||||
|
||||
if(!m_Times.empty())
|
||||
SetDrawcallTimes(ui->events->topLevelItem(0), m_Times);
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ public:
|
||||
|
||||
// IEventBrowser
|
||||
QWidget *Widget() override { return this; }
|
||||
void UpdateDurationColumn() override;
|
||||
// ILogViewerForm
|
||||
void OnLogfileLoaded() override;
|
||||
void OnLogfileClosed() override;
|
||||
@@ -107,6 +108,10 @@ private:
|
||||
int FindEvent(QString filter, uint32_t after, bool forward);
|
||||
void Find(bool forward);
|
||||
|
||||
TimeUnit m_TimeUnit = TimeUnit::Microseconds;
|
||||
|
||||
rdctype::array<CounterResult> m_Times;
|
||||
|
||||
QIcon m_CurrentIcon;
|
||||
QIcon m_FindIcon;
|
||||
QIcon m_BookmarkIcon;
|
||||
|
||||
Reference in New Issue
Block a user