summaryrefslogtreecommitdiff
path: root/src/citra_qt/debugger/graphics_cmdlists.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/citra_qt/debugger/graphics_cmdlists.cpp')
-rw-r--r--src/citra_qt/debugger/graphics_cmdlists.cpp98
1 files changed, 83 insertions, 15 deletions
diff --git a/src/citra_qt/debugger/graphics_cmdlists.cpp b/src/citra_qt/debugger/graphics_cmdlists.cpp
index 576882e8a..d07645e78 100644
--- a/src/citra_qt/debugger/graphics_cmdlists.cpp
+++ b/src/citra_qt/debugger/graphics_cmdlists.cpp
@@ -3,18 +3,57 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "graphics_cmdlists.hxx" 5#include "graphics_cmdlists.hxx"
6#include <QListView> 6#include <QTreeView>
7 7
8extern GraphicsDebugger g_debugger; 8extern GraphicsDebugger g_debugger;
9 9
10GPUCommandListModel::GPUCommandListModel(QObject* parent) : QAbstractListModel(parent), row_count(0) 10GPUCommandListModel::GPUCommandListModel(QObject* parent) : QAbstractItemModel(parent)
11{ 11{
12 root_item = new TreeItem(TreeItem::ROOT, 0, NULL, this);
13
12 connect(this, SIGNAL(CommandListCalled()), this, SLOT(OnCommandListCalledInternal()), Qt::UniqueConnection); 14 connect(this, SIGNAL(CommandListCalled()), this, SLOT(OnCommandListCalledInternal()), Qt::UniqueConnection);
13} 15}
14 16
17QModelIndex GPUCommandListModel::index(int row, int column, const QModelIndex& parent) const
18{
19 TreeItem* item;
20
21 if (!parent.isValid()) {
22 item = root_item;
23 } else {
24 item = (TreeItem*)parent.internalPointer();
25 }
26
27 return createIndex(row, column, item->children[row]);
28}
29
30QModelIndex GPUCommandListModel::parent(const QModelIndex& child) const
31{
32 if (!child.isValid())
33 return QModelIndex();
34
35 TreeItem* item = (TreeItem*)child.internalPointer();
36
37 if (item->parent == NULL)
38 return QModelIndex();
39
40 return createIndex(item->parent->index, 0, item->parent);
41}
42
15int GPUCommandListModel::rowCount(const QModelIndex& parent) const 43int GPUCommandListModel::rowCount(const QModelIndex& parent) const
16{ 44{
17 return row_count; 45 TreeItem* item;
46 if (!parent.isValid()) {
47 item = root_item;
48 } else {
49 item = (TreeItem*)parent.internalPointer();
50 }
51 return item->children.size();
52}
53
54int GPUCommandListModel::columnCount(const QModelIndex& parent) const
55{
56 return 1;
18} 57}
19 58
20QVariant GPUCommandListModel::data(const QModelIndex& index, int role) const 59QVariant GPUCommandListModel::data(const QModelIndex& index, int role) const
@@ -22,19 +61,33 @@ QVariant GPUCommandListModel::data(const QModelIndex& index, int role) const
22 if (!index.isValid()) 61 if (!index.isValid())
23 return QVariant(); 62 return QVariant();
24 63
25 int idx = index.row(); 64 const TreeItem* item = (const TreeItem*)index.internalPointer();
26 if (role == Qt::DisplayRole) 65
66 if (item->type == TreeItem::COMMAND_LIST)
27 { 67 {
28 QString content; 68 const GraphicsDebugger::PicaCommandList& cmdlist = command_lists[item->index].second;
29 const GraphicsDebugger::PicaCommandList& cmdlist = command_list[idx].second; 69 u32 address = command_lists[item->index].first;
30 for (int i = 0; i < cmdlist.size(); ++i) 70
71 if (role == Qt::DisplayRole)
31 { 72 {
32 const GraphicsDebugger::PicaCommand& cmd = cmdlist[i]; 73 return QVariant(QString("0x%1 bytes at 0x%2").arg(cmdlist.size(), 0, 16).arg(address, 8, 16, QLatin1Char('0')));
74 }
75 }
76 else
77 {
78 // index refers to a specific command
79 const GraphicsDebugger::PicaCommandList& cmdlist = command_lists[item->parent->index].second;
80 const GraphicsDebugger::PicaCommand& cmd = cmdlist[item->index];
81
82 if (role == Qt::DisplayRole) {
83 QString content;
33 for (int j = 0; j < cmd.size(); ++j) 84 for (int j = 0; j < cmd.size(); ++j)
34 content.append(QString("%1 ").arg(cmd[j], 8, 16, QLatin1Char('0'))); 85 content.append(QString("%1 ").arg(cmd[j], 8, 16, QLatin1Char('0')));
86
87 return QVariant(content);
35 } 88 }
36 return QVariant(content);
37 } 89 }
90
38 return QVariant(); 91 return QVariant();
39} 92}
40 93
@@ -48,8 +101,22 @@ void GPUCommandListModel::OnCommandListCalledInternal()
48{ 101{
49 beginResetModel(); 102 beginResetModel();
50 103
51 command_list = GetDebugger()->GetCommandLists(); 104 command_lists = GetDebugger()->GetCommandLists();
52 row_count = command_list.size(); 105
106 // delete root item and rebuild tree
107 delete root_item;
108 root_item = new TreeItem(TreeItem::ROOT, 0, NULL, this);
109
110 for (int command_list_idx = 0; command_list_idx < command_lists.size(); ++command_list_idx) {
111 TreeItem* command_list_item = new TreeItem(TreeItem::COMMAND_LIST, command_list_idx, root_item, root_item);
112 root_item->children.push_back(command_list_item);
113
114 const GraphicsDebugger::PicaCommandList& command_list = command_lists[command_list_idx].second;
115 for (int command_idx = 0; command_idx < command_list.size(); ++command_idx) {
116 TreeItem* command_item = new TreeItem(TreeItem::COMMAND, command_idx, command_list_item, command_list_item);
117 command_list_item->children.push_back(command_item);
118 }
119 }
53 120
54 endResetModel(); 121 endResetModel();
55} 122}
@@ -59,7 +126,8 @@ GPUCommandListWidget::GPUCommandListWidget(QWidget* parent) : QDockWidget(tr("Pi
59 GPUCommandListModel* model = new GPUCommandListModel(this); 126 GPUCommandListModel* model = new GPUCommandListModel(this);
60 g_debugger.RegisterObserver(model); 127 g_debugger.RegisterObserver(model);
61 128
62 QListView* list_widget = new QListView; 129 QTreeView* tree_widget = new QTreeView;
63 list_widget->setModel(model); 130 tree_widget->setModel(model);
64 setWidget(list_widget); 131 tree_widget->setFont(QFont("monospace"));
132 setWidget(tree_widget);
65} 133}