summaryrefslogtreecommitdiff
path: root/src/citra_qt/debugger/graphics/graphics.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/citra_qt/debugger/graphics/graphics.cpp')
-rw-r--r--src/citra_qt/debugger/graphics/graphics.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/citra_qt/debugger/graphics/graphics.cpp b/src/citra_qt/debugger/graphics/graphics.cpp
new file mode 100644
index 000000000..6a76adeae
--- /dev/null
+++ b/src/citra_qt/debugger/graphics/graphics.cpp
@@ -0,0 +1,77 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <QListView>
6#include "citra_qt/debugger/graphics/graphics.h"
7#include "citra_qt/util/util.h"
8
9extern GraphicsDebugger g_debugger;
10
11GPUCommandStreamItemModel::GPUCommandStreamItemModel(QObject* parent)
12 : QAbstractListModel(parent), command_count(0) {
13 connect(this, SIGNAL(GXCommandFinished(int)), this, SLOT(OnGXCommandFinishedInternal(int)));
14}
15
16int GPUCommandStreamItemModel::rowCount(const QModelIndex& parent) const {
17 return command_count;
18}
19
20QVariant GPUCommandStreamItemModel::data(const QModelIndex& index, int role) const {
21 if (!index.isValid())
22 return QVariant();
23
24 int command_index = index.row();
25 const Service::GSP::Command& command = GetDebugger()->ReadGXCommandHistory(command_index);
26 if (role == Qt::DisplayRole) {
27 std::map<Service::GSP::CommandId, const char*> command_names = {
28 {Service::GSP::CommandId::REQUEST_DMA, "REQUEST_DMA"},
29 {Service::GSP::CommandId::SUBMIT_GPU_CMDLIST, "SUBMIT_GPU_CMDLIST"},
30 {Service::GSP::CommandId::SET_MEMORY_FILL, "SET_MEMORY_FILL"},
31 {Service::GSP::CommandId::SET_DISPLAY_TRANSFER, "SET_DISPLAY_TRANSFER"},
32 {Service::GSP::CommandId::SET_TEXTURE_COPY, "SET_TEXTURE_COPY"},
33 {Service::GSP::CommandId::CACHE_FLUSH, "CACHE_FLUSH"},
34 };
35 const u32* command_data = reinterpret_cast<const u32*>(&command);
36 QString str = QString("%1 %2 %3 %4 %5 %6 %7 %8 %9")
37 .arg(command_names[command.id])
38 .arg(command_data[0], 8, 16, QLatin1Char('0'))
39 .arg(command_data[1], 8, 16, QLatin1Char('0'))
40 .arg(command_data[2], 8, 16, QLatin1Char('0'))
41 .arg(command_data[3], 8, 16, QLatin1Char('0'))
42 .arg(command_data[4], 8, 16, QLatin1Char('0'))
43 .arg(command_data[5], 8, 16, QLatin1Char('0'))
44 .arg(command_data[6], 8, 16, QLatin1Char('0'))
45 .arg(command_data[7], 8, 16, QLatin1Char('0'));
46 return QVariant(str);
47 } else {
48 return QVariant();
49 }
50}
51
52void GPUCommandStreamItemModel::GXCommandProcessed(int total_command_count) {
53 emit GXCommandFinished(total_command_count);
54}
55
56void GPUCommandStreamItemModel::OnGXCommandFinishedInternal(int total_command_count) {
57 if (total_command_count == 0)
58 return;
59
60 int prev_command_count = command_count;
61 command_count = total_command_count;
62 emit dataChanged(index(prev_command_count, 0), index(total_command_count - 1, 0));
63}
64
65GPUCommandStreamWidget::GPUCommandStreamWidget(QWidget* parent)
66 : QDockWidget(tr("Graphics Debugger"), parent) {
67 setObjectName("GraphicsDebugger");
68
69 GPUCommandStreamItemModel* command_model = new GPUCommandStreamItemModel(this);
70 g_debugger.RegisterObserver(command_model);
71
72 QListView* command_list = new QListView;
73 command_list->setModel(command_model);
74 command_list->setFont(GetMonospaceFont());
75
76 setWidget(command_list);
77}