summaryrefslogtreecommitdiff
path: root/src/citra_qt
diff options
context:
space:
mode:
Diffstat (limited to 'src/citra_qt')
-rw-r--r--src/citra_qt/debugger/graphics_cmdlists.cpp64
-rw-r--r--src/citra_qt/debugger/graphics_cmdlists.hxx8
2 files changed, 71 insertions, 1 deletions
diff --git a/src/citra_qt/debugger/graphics_cmdlists.cpp b/src/citra_qt/debugger/graphics_cmdlists.cpp
index 9e53a03d0..dcd0ced33 100644
--- a/src/citra_qt/debugger/graphics_cmdlists.cpp
+++ b/src/citra_qt/debugger/graphics_cmdlists.cpp
@@ -2,6 +2,7 @@
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <QLabel>
5#include <QListView> 6#include <QListView>
6#include <QPushButton> 7#include <QPushButton>
7#include <QVBoxLayout> 8#include <QVBoxLayout>
@@ -9,6 +10,33 @@
9 10
10#include "graphics_cmdlists.hxx" 11#include "graphics_cmdlists.hxx"
11 12
13#include "video_core/pica.h"
14#include "video_core/math.h"
15
16#include "video_core/debug_utils/debug_utils.h"
17
18class TextureInfoWidget : public QWidget {
19public:
20 TextureInfoWidget(u8* src, const Pica::DebugUtils::TextureInfo& info, QWidget* parent = nullptr) : QWidget(parent) {
21 QImage decoded_image(info.width, info.height, QImage::Format_ARGB32);
22 for (int y = 0; y < info.height; ++y) {
23 for (int x = 0; x < info.width; ++x) {
24 Math::Vec4<u8> color = Pica::DebugUtils::LookupTexture(src, x, y, info);
25 decoded_image.setPixel(x, y, qRgba(color.r(), color.g(), color.b(), color.a()));
26 }
27 }
28
29 QLabel* image_widget = new QLabel;
30 QPixmap image_pixmap = QPixmap::fromImage(decoded_image);
31 image_pixmap = image_pixmap.scaled(200, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
32 image_widget->setPixmap(image_pixmap);
33
34 QVBoxLayout* layout = new QVBoxLayout;
35 layout->addWidget(image_widget);
36 setLayout(layout);
37 }
38};
39
12GPUCommandListModel::GPUCommandListModel(QObject* parent) : QAbstractListModel(parent) 40GPUCommandListModel::GPUCommandListModel(QObject* parent) : QAbstractListModel(parent)
13{ 41{
14 42
@@ -44,6 +72,8 @@ QVariant GPUCommandListModel::data(const QModelIndex& index, int role) const
44 } 72 }
45 73
46 return QVariant(content); 74 return QVariant(content);
75 } else if (role == CommandIdRole) {
76 return QVariant::fromValue<int>(cmd.cmd_id.Value());
47 } 77 }
48 78
49 return QVariant(); 79 return QVariant();
@@ -76,27 +106,59 @@ void GPUCommandListModel::OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace&
76 endResetModel(); 106 endResetModel();
77} 107}
78 108
109void GPUCommandListWidget::SetCommandInfo(const QModelIndex& index)
110{
111 QWidget* new_info_widget;
112
113#define COMMAND_IN_RANGE(cmd_id, reg_name) (cmd_id >= PICA_REG_INDEX(reg_name) && cmd_id < PICA_REG_INDEX(reg_name) + sizeof(decltype(Pica::registers.reg_name)) / 4)
114 const int command_id = list_widget->model()->data(index, GPUCommandListModel::CommandIdRole).toInt();
115 if (COMMAND_IN_RANGE(command_id, texture0)) {
116 u8* src = Memory::GetPointer(Pica::registers.texture0.GetPhysicalAddress());
117 Pica::DebugUtils::TextureInfo info;
118 info.width = Pica::registers.texture0.width;
119 info.height = Pica::registers.texture0.height;
120 info.stride = 3 * Pica::registers.texture0.width;
121 info.format = Pica::registers.texture0_format;
122 new_info_widget = new TextureInfoWidget(src, info);
123 } else {
124 new_info_widget = new QWidget;
125 }
126#undef COMMAND_IN_RANGE
127
128 widget()->layout()->removeWidget(command_info_widget);
129 delete command_info_widget;
130 widget()->layout()->addWidget(new_info_widget);
131 command_info_widget = new_info_widget;
132}
79 133
80GPUCommandListWidget::GPUCommandListWidget(QWidget* parent) : QDockWidget(tr("Pica Command List"), parent) 134GPUCommandListWidget::GPUCommandListWidget(QWidget* parent) : QDockWidget(tr("Pica Command List"), parent)
81{ 135{
136 setObjectName("Pica Command List");
82 GPUCommandListModel* model = new GPUCommandListModel(this); 137 GPUCommandListModel* model = new GPUCommandListModel(this);
83 138
84 QWidget* main_widget = new QWidget; 139 QWidget* main_widget = new QWidget;
85 140
86 QTreeView* list_widget = new QTreeView; 141 list_widget = new QTreeView;
87 list_widget->setModel(model); 142 list_widget->setModel(model);
88 list_widget->setFont(QFont("monospace")); 143 list_widget->setFont(QFont("monospace"));
89 list_widget->setRootIsDecorated(false); 144 list_widget->setRootIsDecorated(false);
90 145
146 connect(list_widget->selectionModel(), SIGNAL(currentChanged(const QModelIndex&,const QModelIndex&)),
147 this, SLOT(SetCommandInfo(const QModelIndex&)));
148
149
91 toggle_tracing = new QPushButton(tr("Start Tracing")); 150 toggle_tracing = new QPushButton(tr("Start Tracing"));
92 151
93 connect(toggle_tracing, SIGNAL(clicked()), this, SLOT(OnToggleTracing())); 152 connect(toggle_tracing, SIGNAL(clicked()), this, SLOT(OnToggleTracing()));
94 connect(this, SIGNAL(TracingFinished(const Pica::DebugUtils::PicaTrace&)), 153 connect(this, SIGNAL(TracingFinished(const Pica::DebugUtils::PicaTrace&)),
95 model, SLOT(OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace&))); 154 model, SLOT(OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace&)));
96 155
156 command_info_widget = new QWidget;
157
97 QVBoxLayout* main_layout = new QVBoxLayout; 158 QVBoxLayout* main_layout = new QVBoxLayout;
98 main_layout->addWidget(list_widget); 159 main_layout->addWidget(list_widget);
99 main_layout->addWidget(toggle_tracing); 160 main_layout->addWidget(toggle_tracing);
161 main_layout->addWidget(command_info_widget);
100 main_widget->setLayout(main_layout); 162 main_widget->setLayout(main_layout);
101 163
102 setWidget(main_widget); 164 setWidget(main_widget);
diff --git a/src/citra_qt/debugger/graphics_cmdlists.hxx b/src/citra_qt/debugger/graphics_cmdlists.hxx
index 31bd2546d..37fe19053 100644
--- a/src/citra_qt/debugger/graphics_cmdlists.hxx
+++ b/src/citra_qt/debugger/graphics_cmdlists.hxx
@@ -11,12 +11,17 @@
11#include "video_core/debug_utils/debug_utils.h" 11#include "video_core/debug_utils/debug_utils.h"
12 12
13class QPushButton; 13class QPushButton;
14class QTreeView;
14 15
15class GPUCommandListModel : public QAbstractListModel 16class GPUCommandListModel : public QAbstractListModel
16{ 17{
17 Q_OBJECT 18 Q_OBJECT
18 19
19public: 20public:
21 enum {
22 CommandIdRole = Qt::UserRole,
23 };
24
20 GPUCommandListModel(QObject* parent); 25 GPUCommandListModel(QObject* parent);
21 26
22 int columnCount(const QModelIndex& parent = QModelIndex()) const override; 27 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
@@ -40,6 +45,7 @@ public:
40 45
41public slots: 46public slots:
42 void OnToggleTracing(); 47 void OnToggleTracing();
48 void SetCommandInfo(const QModelIndex&);
43 49
44signals: 50signals:
45 void TracingFinished(const Pica::DebugUtils::PicaTrace&); 51 void TracingFinished(const Pica::DebugUtils::PicaTrace&);
@@ -47,5 +53,7 @@ signals:
47private: 53private:
48 std::unique_ptr<Pica::DebugUtils::PicaTrace> pica_trace; 54 std::unique_ptr<Pica::DebugUtils::PicaTrace> pica_trace;
49 55
56 QTreeView* list_widget;
57 QWidget* command_info_widget;
50 QPushButton* toggle_tracing; 58 QPushButton* toggle_tracing;
51}; 59};