diff --git a/qrenderdoc/Code/Interface/QRDInterface.h b/qrenderdoc/Code/Interface/QRDInterface.h index 5eb9d3ee3..a24ad6e56 100644 --- a/qrenderdoc/Code/Interface/QRDInterface.h +++ b/qrenderdoc/Code/Interface/QRDInterface.h @@ -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; diff --git a/qrenderdoc/Windows/Dialogs/SettingsDialog.cpp b/qrenderdoc/Windows/Dialogs/SettingsDialog.cpp index 469db151b..e155fd360 100644 --- a/qrenderdoc/Windows/Dialogs/SettingsDialog.cpp +++ b/qrenderdoc/Windows/Dialogs/SettingsDialog.cpp @@ -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(); } diff --git a/qrenderdoc/Windows/EventBrowser.cpp b/qrenderdoc/Windows/EventBrowser.cpp index 53a84c051..803c73cba 100644 --- a/qrenderdoc/Windows/EventBrowser.cpp +++ b/qrenderdoc/Windows/EventBrowser.cpp @@ -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 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); +} diff --git a/qrenderdoc/Windows/EventBrowser.h b/qrenderdoc/Windows/EventBrowser.h index c7fe2550f..d9c0eb624 100644 --- a/qrenderdoc/Windows/EventBrowser.h +++ b/qrenderdoc/Windows/EventBrowser.h @@ -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 m_Times; + QIcon m_CurrentIcon; QIcon m_FindIcon; QIcon m_BookmarkIcon;