Implement event browser time drawcalls button

This commit is contained in:
baldurk
2015-07-09 14:33:55 +02:00
parent af5c40cf7b
commit 7eded723a9
3 changed files with 81 additions and 15 deletions
+72 -10
View File
@@ -3,6 +3,12 @@
#include "Code/Core.h"
enum {
COL_NAME = 0,
COL_EID = 1,
COL_DURATION = 2,
};
uint AddDrawcalls(QTreeWidgetItem *parent, const rdctype::array<FetchDrawcall> &draws)
{
uint lastEID = 0;
@@ -12,7 +18,7 @@ uint AddDrawcalls(QTreeWidgetItem *parent, const rdctype::array<FetchDrawcall> &
QTreeWidgetItem *child = new QTreeWidgetItem(parent, QStringList{QString(draws[i].name.elems), QString("%1").arg(draws[i].eventID), "0.0"});
lastEID = AddDrawcalls(child, draws[i].children);
if(lastEID == 0) lastEID = draws[i].eventID;
child->setData(0, Qt::UserRole, QVariant(lastEID));
child->setData(COL_EID, Qt::UserRole, QVariant(lastEID));
}
return lastEID;
@@ -27,15 +33,15 @@ EventBrowser::EventBrowser(Core *core, QWidget *parent) :
m_Core->AddLogViewer(this);
ui->events->header()->resizeSection(1, 80);
ui->events->header()->resizeSection(COL_EID, 80);
ui->events->header()->setSectionResizeMode(0, QHeaderView::Stretch);
ui->events->header()->setSectionResizeMode(1, QHeaderView::Interactive);
ui->events->header()->setSectionResizeMode(2, QHeaderView::Interactive);
ui->events->header()->setSectionResizeMode(COL_NAME, QHeaderView::Stretch);
ui->events->header()->setSectionResizeMode(COL_EID, QHeaderView::Interactive);
ui->events->header()->setSectionResizeMode(COL_DURATION, QHeaderView::Interactive);
// we set up the name column first, EID second, so that the name column gets the
// expand/collapse widgets. Then we need to put them back in order
ui->events->header()->moveSection(0, 1);
ui->events->header()->moveSection(COL_NAME, COL_EID);
// Qt doesn't allow moving the column with the expand/collapse widgets, so this
// becomes quickly infuriating to rearrange, just disable until that can be fixed.
@@ -52,11 +58,11 @@ void EventBrowser::OnLogfileLoaded()
{
QTreeWidgetItem *frame = new QTreeWidgetItem((QTreeWidget *)NULL, QStringList{QString("Frame #%1").arg(m_Core->FrameInfo()[0].frameNumber), "", ""});
QTreeWidgetItem *framestart = new QTreeWidgetItem(frame, QStringList{"Frame Start", "0", "0.0"});
framestart->setData(0, Qt::UserRole, QVariant(0));
QTreeWidgetItem *framestart = new QTreeWidgetItem(frame, QStringList{"Frame Start", "0", ""});
framestart->setData(COL_EID, Qt::UserRole, QVariant(0));
uint lastEID = AddDrawcalls(frame, m_Core->CurDrawcalls(0));
frame->setData(0, Qt::UserRole, QVariant(lastEID));
frame->setData(COL_EID, Qt::UserRole, QVariant(lastEID));
ui->events->insertTopLevelItem(0, frame);
@@ -81,11 +87,67 @@ void EventBrowser::on_gotoEID_clicked()
{
}
static void SetDrawcallTimes(QTreeWidgetItem *node, const rdctype::array<CounterResult> &results)
{
if(node == NULL) return;
// parent nodes take the value of the sum of their children
double duration = 0.0;
// look up leaf nodes in the dictionary
if(node->childCount() == 0)
{
uint eid = node->data(COL_EID, Qt::UserRole).toUInt();
duration = -1.0;
for(int32_t i=0; i < results.count; i++)
{
if(results[i].eventID == eid)
duration = results[i].value.d;
}
node->setText(COL_DURATION, duration < 0.0f ? "" : QString::number(duration*1000000.0));
node->setData(COL_DURATION, Qt::UserRole, QVariant(duration));
return;
}
for(int i = 0; i < node->childCount(); i++)
{
SetDrawcallTimes(node->child(i), results);
double nd = node->child(i)->data(COL_DURATION, Qt::UserRole).toDouble();
if(nd > 0.0)
duration += nd;
}
node->setText(COL_DURATION, duration < 0.0f ? "" : QString::number(duration*1000000.0));
node->setData(COL_DURATION, Qt::UserRole, QVariant(duration));
}
void EventBrowser::on_timeDraws_clicked()
{
m_Core->Renderer()->AsyncInvoke([this](IReplayRenderer *r) {
uint32_t counters[] = { eCounter_EventGPUDuration };
rdctype::array<CounterResult> results;
r->FetchCounters(m_Core->CurFrame(), 0, ~0U, counters, 1, &results);
GUIInvoke::blockcall([this,results]() {
SetDrawcallTimes(ui->events->topLevelItem(0), results);
_CrtCheckMemory();
});
});
}
void EventBrowser::on_events_itemSelectionChanged()
{
if(ui->events->selectedItems().empty()) return;
uint EID = ui->events->selectedItems()[0]->data(0, Qt::UserRole).toUInt();
uint EID = ui->events->selectedItems()[0]->data(COL_EID, Qt::UserRole).toUInt();
m_Core->SetEventID(this, 0, EID);
}
+2
View File
@@ -28,6 +28,8 @@ class EventBrowser : public QFrame, public ILogViewerForm
void on_events_itemSelectionChanged();
void on_timeDraws_clicked();
private:
Ui::EventBrowser *ui;
Core *m_Core;
+7 -5
View File
@@ -72,7 +72,7 @@
<string/>
</property>
<property name="icon">
<iconset>
<iconset resource="../resources.qrc">
<normaloff>:/Resources/find.png</normaloff>:/Resources/find.png</iconset>
</property>
<property name="shortcut">
@@ -95,7 +95,7 @@
<string/>
</property>
<property name="icon">
<iconset>
<iconset resource="../resources.qrc">
<normaloff>:/Resources/flag_green.png</normaloff>:/Resources/flag_green.png</iconset>
</property>
<property name="autoRaise">
@@ -109,7 +109,7 @@
<string/>
</property>
<property name="icon">
<iconset>
<iconset resource="../resources.qrc">
<normaloff>:/Resources/time.png</normaloff>:/Resources/time.png</iconset>
</property>
<property name="autoRaise">
@@ -194,13 +194,15 @@
</column>
<column>
<property name="text">
<string>Duration</string>
<string>Duration (µs)</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../resources.qrc"/>
</resources>
<connections/>
</ui>