diff options
Diffstat (limited to 'src/citra_qt/debugger/profiler.cpp')
| -rw-r--r-- | src/citra_qt/debugger/profiler.cpp | 70 |
1 files changed, 33 insertions, 37 deletions
diff --git a/src/citra_qt/debugger/profiler.cpp b/src/citra_qt/debugger/profiler.cpp index 17898f54b..97a377513 100644 --- a/src/citra_qt/debugger/profiler.cpp +++ b/src/citra_qt/debugger/profiler.cpp | |||
| @@ -22,57 +22,58 @@ | |||
| 22 | 22 | ||
| 23 | using namespace Common::Profiling; | 23 | using namespace Common::Profiling; |
| 24 | 24 | ||
| 25 | static QVariant GetDataForColumn(int col, const AggregatedDuration& duration) | 25 | static QVariant GetDataForColumn(int col, const AggregatedDuration& duration) { |
| 26 | { | ||
| 27 | static auto duration_to_float = [](Duration dur) -> float { | 26 | static auto duration_to_float = [](Duration dur) -> float { |
| 28 | using FloatMs = std::chrono::duration<float, std::chrono::milliseconds::period>; | 27 | using FloatMs = std::chrono::duration<float, std::chrono::milliseconds::period>; |
| 29 | return std::chrono::duration_cast<FloatMs>(dur).count(); | 28 | return std::chrono::duration_cast<FloatMs>(dur).count(); |
| 30 | }; | 29 | }; |
| 31 | 30 | ||
| 32 | switch (col) { | 31 | switch (col) { |
| 33 | case 1: return duration_to_float(duration.avg); | 32 | case 1: |
| 34 | case 2: return duration_to_float(duration.min); | 33 | return duration_to_float(duration.avg); |
| 35 | case 3: return duration_to_float(duration.max); | 34 | case 2: |
| 36 | default: return QVariant(); | 35 | return duration_to_float(duration.min); |
| 36 | case 3: | ||
| 37 | return duration_to_float(duration.max); | ||
| 38 | default: | ||
| 39 | return QVariant(); | ||
| 37 | } | 40 | } |
| 38 | } | 41 | } |
| 39 | 42 | ||
| 40 | ProfilerModel::ProfilerModel(QObject* parent) : QAbstractItemModel(parent) | 43 | ProfilerModel::ProfilerModel(QObject* parent) : QAbstractItemModel(parent) { |
| 41 | { | ||
| 42 | updateProfilingInfo(); | 44 | updateProfilingInfo(); |
| 43 | } | 45 | } |
| 44 | 46 | ||
| 45 | QVariant ProfilerModel::headerData(int section, Qt::Orientation orientation, int role) const | 47 | QVariant ProfilerModel::headerData(int section, Qt::Orientation orientation, int role) const { |
| 46 | { | ||
| 47 | if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { | 48 | if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { |
| 48 | switch (section) { | 49 | switch (section) { |
| 49 | case 0: return tr("Category"); | 50 | case 0: |
| 50 | case 1: return tr("Avg"); | 51 | return tr("Category"); |
| 51 | case 2: return tr("Min"); | 52 | case 1: |
| 52 | case 3: return tr("Max"); | 53 | return tr("Avg"); |
| 54 | case 2: | ||
| 55 | return tr("Min"); | ||
| 56 | case 3: | ||
| 57 | return tr("Max"); | ||
| 53 | } | 58 | } |
| 54 | } | 59 | } |
| 55 | 60 | ||
| 56 | return QVariant(); | 61 | return QVariant(); |
| 57 | } | 62 | } |
| 58 | 63 | ||
| 59 | QModelIndex ProfilerModel::index(int row, int column, const QModelIndex& parent) const | 64 | QModelIndex ProfilerModel::index(int row, int column, const QModelIndex& parent) const { |
| 60 | { | ||
| 61 | return createIndex(row, column); | 65 | return createIndex(row, column); |
| 62 | } | 66 | } |
| 63 | 67 | ||
| 64 | QModelIndex ProfilerModel::parent(const QModelIndex& child) const | 68 | QModelIndex ProfilerModel::parent(const QModelIndex& child) const { |
| 65 | { | ||
| 66 | return QModelIndex(); | 69 | return QModelIndex(); |
| 67 | } | 70 | } |
| 68 | 71 | ||
| 69 | int ProfilerModel::columnCount(const QModelIndex& parent) const | 72 | int ProfilerModel::columnCount(const QModelIndex& parent) const { |
| 70 | { | ||
| 71 | return 4; | 73 | return 4; |
| 72 | } | 74 | } |
| 73 | 75 | ||
| 74 | int ProfilerModel::rowCount(const QModelIndex& parent) const | 76 | int ProfilerModel::rowCount(const QModelIndex& parent) const { |
| 75 | { | ||
| 76 | if (parent.isValid()) { | 77 | if (parent.isValid()) { |
| 77 | return 0; | 78 | return 0; |
| 78 | } else { | 79 | } else { |
| @@ -80,8 +81,7 @@ int ProfilerModel::rowCount(const QModelIndex& parent) const | |||
| 80 | } | 81 | } |
| 81 | } | 82 | } |
| 82 | 83 | ||
| 83 | QVariant ProfilerModel::data(const QModelIndex& index, int role) const | 84 | QVariant ProfilerModel::data(const QModelIndex& index, int role) const { |
| 84 | { | ||
| 85 | if (role == Qt::DisplayRole) { | 85 | if (role == Qt::DisplayRole) { |
| 86 | if (index.row() == 0) { | 86 | if (index.row() == 0) { |
| 87 | if (index.column() == 0) { | 87 | if (index.column() == 0) { |
| @@ -101,14 +101,12 @@ QVariant ProfilerModel::data(const QModelIndex& index, int role) const | |||
| 101 | return QVariant(); | 101 | return QVariant(); |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | void ProfilerModel::updateProfilingInfo() | 104 | void ProfilerModel::updateProfilingInfo() { |
| 105 | { | ||
| 106 | results = GetTimingResultsAggregator()->GetAggregatedResults(); | 105 | results = GetTimingResultsAggregator()->GetAggregatedResults(); |
| 107 | emit dataChanged(createIndex(0, 1), createIndex(rowCount() - 1, 3)); | 106 | emit dataChanged(createIndex(0, 1), createIndex(rowCount() - 1, 3)); |
| 108 | } | 107 | } |
| 109 | 108 | ||
| 110 | ProfilerWidget::ProfilerWidget(QWidget* parent) : QDockWidget(parent) | 109 | ProfilerWidget::ProfilerWidget(QWidget* parent) : QDockWidget(parent) { |
| 111 | { | ||
| 112 | ui.setupUi(this); | 110 | ui.setupUi(this); |
| 113 | 111 | ||
| 114 | model = new ProfilerModel(this); | 112 | model = new ProfilerModel(this); |
| @@ -118,8 +116,7 @@ ProfilerWidget::ProfilerWidget(QWidget* parent) : QDockWidget(parent) | |||
| 118 | connect(&update_timer, SIGNAL(timeout()), model, SLOT(updateProfilingInfo())); | 116 | connect(&update_timer, SIGNAL(timeout()), model, SLOT(updateProfilingInfo())); |
| 119 | } | 117 | } |
| 120 | 118 | ||
| 121 | void ProfilerWidget::setProfilingInfoUpdateEnabled(bool enable) | 119 | void ProfilerWidget::setProfilingInfoUpdateEnabled(bool enable) { |
| 122 | { | ||
| 123 | if (enable) { | 120 | if (enable) { |
| 124 | update_timer.start(100); | 121 | update_timer.start(100); |
| 125 | model->updateProfilingInfo(); | 122 | model->updateProfilingInfo(); |
| @@ -157,9 +154,7 @@ private: | |||
| 157 | 154 | ||
| 158 | #endif | 155 | #endif |
| 159 | 156 | ||
| 160 | MicroProfileDialog::MicroProfileDialog(QWidget* parent) | 157 | MicroProfileDialog::MicroProfileDialog(QWidget* parent) : QWidget(parent, Qt::Dialog) { |
| 161 | : QWidget(parent, Qt::Dialog) | ||
| 162 | { | ||
| 163 | setObjectName("MicroProfile"); | 158 | setObjectName("MicroProfile"); |
| 164 | setWindowTitle(tr("MicroProfile")); | 159 | setWindowTitle(tr("MicroProfile")); |
| 165 | resize(1000, 600); | 160 | resize(1000, 600); |
| @@ -175,7 +170,8 @@ MicroProfileDialog::MicroProfileDialog(QWidget* parent) | |||
| 175 | layout->addWidget(widget); | 170 | layout->addWidget(widget); |
| 176 | setLayout(layout); | 171 | setLayout(layout); |
| 177 | 172 | ||
| 178 | // Configure focus so that widget is focusable and the dialog automatically forwards focus to it. | 173 | // Configure focus so that widget is focusable and the dialog automatically forwards focus to |
| 174 | // it. | ||
| 179 | setFocusProxy(widget); | 175 | setFocusProxy(widget); |
| 180 | widget->setFocusPolicy(Qt::StrongFocus); | 176 | widget->setFocusPolicy(Qt::StrongFocus); |
| 181 | widget->setFocus(); | 177 | widget->setFocus(); |
| @@ -207,7 +203,6 @@ void MicroProfileDialog::hideEvent(QHideEvent* ev) { | |||
| 207 | QWidget::hideEvent(ev); | 203 | QWidget::hideEvent(ev); |
| 208 | } | 204 | } |
| 209 | 205 | ||
| 210 | |||
| 211 | #if MICROPROFILE_ENABLED | 206 | #if MICROPROFILE_ENABLED |
| 212 | 207 | ||
| 213 | /// There's no way to pass a user pointer to MicroProfile, so this variable is used to make the | 208 | /// There's no way to pass a user pointer to MicroProfile, so this variable is used to make the |
| @@ -308,7 +303,8 @@ void MicroProfileDrawText(int x, int y, u32 hex_color, const char* text, u32 tex | |||
| 308 | } | 303 | } |
| 309 | } | 304 | } |
| 310 | 305 | ||
| 311 | void MicroProfileDrawBox(int left, int top, int right, int bottom, u32 hex_color, MicroProfileBoxType type) { | 306 | void MicroProfileDrawBox(int left, int top, int right, int bottom, u32 hex_color, |
| 307 | MicroProfileBoxType type) { | ||
| 312 | QColor color = QColor::fromRgba(hex_color); | 308 | QColor color = QColor::fromRgba(hex_color); |
| 313 | QBrush brush = color; | 309 | QBrush brush = color; |
| 314 | if (type == MicroProfileBoxTypeBar) { | 310 | if (type == MicroProfileBoxTypeBar) { |
| @@ -326,7 +322,7 @@ void MicroProfileDrawLine2D(u32 vertices_length, float* vertices, u32 hex_color) | |||
| 326 | static std::vector<QPointF> point_buf; | 322 | static std::vector<QPointF> point_buf; |
| 327 | 323 | ||
| 328 | for (u32 i = 0; i < vertices_length; ++i) { | 324 | for (u32 i = 0; i < vertices_length; ++i) { |
| 329 | point_buf.emplace_back(vertices[i*2 + 0], vertices[i*2 + 1]); | 325 | point_buf.emplace_back(vertices[i * 2 + 0], vertices[i * 2 + 1]); |
| 330 | } | 326 | } |
| 331 | 327 | ||
| 332 | // hex_color does not include an alpha, so it must be assumed to be 255 | 328 | // hex_color does not include an alpha, so it must be assumed to be 255 |