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.cpp47
1 files changed, 24 insertions, 23 deletions
diff --git a/src/citra_qt/debugger/graphics_cmdlists.cpp b/src/citra_qt/debugger/graphics_cmdlists.cpp
index 3e0a0a145..daf1cf1de 100644
--- a/src/citra_qt/debugger/graphics_cmdlists.cpp
+++ b/src/citra_qt/debugger/graphics_cmdlists.cpp
@@ -20,9 +20,9 @@
20 20
21#include "common/vector_math.h" 21#include "common/vector_math.h"
22 22
23#include "video_core/debug_utils/debug_utils.h"
23#include "video_core/pica.h" 24#include "video_core/pica.h"
24#include "video_core/pica_state.h" 25#include "video_core/pica_state.h"
25#include "video_core/debug_utils/debug_utils.h"
26 26
27QImage LoadTexture(u8* src, const Pica::DebugUtils::TextureInfo& info) { 27QImage LoadTexture(u8* src, const Pica::DebugUtils::TextureInfo& info) {
28 QImage decoded_image(info.width, info.height, QImage::Format_ARGB32); 28 QImage decoded_image(info.width, info.height, QImage::Format_ARGB32);
@@ -38,7 +38,8 @@ QImage LoadTexture(u8* src, const Pica::DebugUtils::TextureInfo& info) {
38 38
39class TextureInfoWidget : public QWidget { 39class TextureInfoWidget : public QWidget {
40public: 40public:
41 TextureInfoWidget(u8* src, const Pica::DebugUtils::TextureInfo& info, QWidget* parent = nullptr) : QWidget(parent) { 41 TextureInfoWidget(u8* src, const Pica::DebugUtils::TextureInfo& info, QWidget* parent = nullptr)
42 : QWidget(parent) {
42 QLabel* image_widget = new QLabel; 43 QLabel* image_widget = new QLabel;
43 QPixmap image_pixmap = QPixmap::fromImage(LoadTexture(src, info)); 44 QPixmap image_pixmap = QPixmap::fromImage(LoadTexture(src, info));
44 image_pixmap = image_pixmap.scaled(200, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation); 45 image_pixmap = image_pixmap.scaled(200, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
@@ -51,7 +52,6 @@ public:
51}; 52};
52 53
53GPUCommandListModel::GPUCommandListModel(QObject* parent) : QAbstractListModel(parent) { 54GPUCommandListModel::GPUCommandListModel(QObject* parent) : QAbstractListModel(parent) {
54
55} 55}
56 56
57int GPUCommandListModel::rowCount(const QModelIndex& parent) const { 57int GPUCommandListModel::rowCount(const QModelIndex& parent) const {
@@ -70,7 +70,7 @@ QVariant GPUCommandListModel::data(const QModelIndex& index, int role) const {
70 70
71 if (role == Qt::DisplayRole) { 71 if (role == Qt::DisplayRole) {
72 QString content; 72 QString content;
73 switch ( index.column() ) { 73 switch (index.column()) {
74 case 0: 74 case 0:
75 return QString::fromLatin1(Pica::Regs::GetCommandName(write.cmd_id).c_str()); 75 return QString::fromLatin1(Pica::Regs::GetCommandName(write.cmd_id).c_str());
76 case 1: 76 case 1:
@@ -88,9 +88,8 @@ QVariant GPUCommandListModel::data(const QModelIndex& index, int role) const {
88} 88}
89 89
90QVariant GPUCommandListModel::headerData(int section, Qt::Orientation orientation, int role) const { 90QVariant GPUCommandListModel::headerData(int section, Qt::Orientation orientation, int role) const {
91 switch(role) { 91 switch (role) {
92 case Qt::DisplayRole: 92 case Qt::DisplayRole: {
93 {
94 switch (section) { 93 switch (section) {
95 case 0: 94 case 0:
96 return tr("Command Name"); 95 return tr("Command Name");
@@ -117,14 +116,14 @@ void GPUCommandListModel::OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace&
117 endResetModel(); 116 endResetModel();
118} 117}
119 118
120#define COMMAND_IN_RANGE(cmd_id, reg_name) \ 119#define COMMAND_IN_RANGE(cmd_id, reg_name) \
121 (cmd_id >= PICA_REG_INDEX(reg_name) && \ 120 (cmd_id >= PICA_REG_INDEX(reg_name) && \
122 cmd_id < PICA_REG_INDEX(reg_name) + sizeof(decltype(Pica::g_state.regs.reg_name)) / 4) 121 cmd_id < PICA_REG_INDEX(reg_name) + sizeof(decltype(Pica::g_state.regs.reg_name)) / 4)
123 122
124void GPUCommandListWidget::OnCommandDoubleClicked(const QModelIndex& index) { 123void GPUCommandListWidget::OnCommandDoubleClicked(const QModelIndex& index) {
125 const unsigned int command_id = list_widget->model()->data(index, GPUCommandListModel::CommandIdRole).toUInt(); 124 const unsigned int command_id =
126 if (COMMAND_IN_RANGE(command_id, texture0) || 125 list_widget->model()->data(index, GPUCommandListModel::CommandIdRole).toUInt();
127 COMMAND_IN_RANGE(command_id, texture1) || 126 if (COMMAND_IN_RANGE(command_id, texture0) || COMMAND_IN_RANGE(command_id, texture1) ||
128 COMMAND_IN_RANGE(command_id, texture2)) { 127 COMMAND_IN_RANGE(command_id, texture2)) {
129 128
130 unsigned index; 129 unsigned index;
@@ -148,9 +147,9 @@ void GPUCommandListWidget::OnCommandDoubleClicked(const QModelIndex& index) {
148void GPUCommandListWidget::SetCommandInfo(const QModelIndex& index) { 147void GPUCommandListWidget::SetCommandInfo(const QModelIndex& index) {
149 QWidget* new_info_widget = nullptr; 148 QWidget* new_info_widget = nullptr;
150 149
151 const unsigned int command_id = list_widget->model()->data(index, GPUCommandListModel::CommandIdRole).toUInt(); 150 const unsigned int command_id =
152 if (COMMAND_IN_RANGE(command_id, texture0) || 151 list_widget->model()->data(index, GPUCommandListModel::CommandIdRole).toUInt();
153 COMMAND_IN_RANGE(command_id, texture1) || 152 if (COMMAND_IN_RANGE(command_id, texture0) || COMMAND_IN_RANGE(command_id, texture1) ||
154 COMMAND_IN_RANGE(command_id, texture2)) { 153 COMMAND_IN_RANGE(command_id, texture2)) {
155 154
156 unsigned index; 155 unsigned index;
@@ -179,7 +178,8 @@ void GPUCommandListWidget::SetCommandInfo(const QModelIndex& index) {
179} 178}
180#undef COMMAND_IN_RANGE 179#undef COMMAND_IN_RANGE
181 180
182GPUCommandListWidget::GPUCommandListWidget(QWidget* parent) : QDockWidget(tr("Pica Command List"), parent) { 181GPUCommandListWidget::GPUCommandListWidget(QWidget* parent)
182 : QDockWidget(tr("Pica Command List"), parent) {
183 setObjectName("Pica Command List"); 183 setObjectName("Pica Command List");
184 GPUCommandListModel* model = new GPUCommandListModel(this); 184 GPUCommandListModel* model = new GPUCommandListModel(this);
185 185
@@ -191,23 +191,24 @@ GPUCommandListWidget::GPUCommandListWidget(QWidget* parent) : QDockWidget(tr("Pi
191 list_widget->setRootIsDecorated(false); 191 list_widget->setRootIsDecorated(false);
192 list_widget->setUniformRowHeights(true); 192 list_widget->setUniformRowHeights(true);
193 193
194#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) 194#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
195 list_widget->header()->setSectionResizeMode(QHeaderView::ResizeToContents); 195 list_widget->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
196#else 196#else
197 list_widget->header()->setResizeMode(QHeaderView::ResizeToContents); 197 list_widget->header()->setResizeMode(QHeaderView::ResizeToContents);
198#endif 198#endif
199 199
200 connect(list_widget->selectionModel(), SIGNAL(currentChanged(const QModelIndex&,const QModelIndex&)), 200 connect(list_widget->selectionModel(),
201 this, SLOT(SetCommandInfo(const QModelIndex&))); 201 SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)), this,
202 connect(list_widget, SIGNAL(doubleClicked(const QModelIndex&)), 202 SLOT(SetCommandInfo(const QModelIndex&)));
203 this, SLOT(OnCommandDoubleClicked(const QModelIndex&))); 203 connect(list_widget, SIGNAL(doubleClicked(const QModelIndex&)), this,
204 SLOT(OnCommandDoubleClicked(const QModelIndex&)));
204 205
205 toggle_tracing = new QPushButton(tr("Start Tracing")); 206 toggle_tracing = new QPushButton(tr("Start Tracing"));
206 QPushButton* copy_all = new QPushButton(tr("Copy All")); 207 QPushButton* copy_all = new QPushButton(tr("Copy All"));
207 208
208 connect(toggle_tracing, SIGNAL(clicked()), this, SLOT(OnToggleTracing())); 209 connect(toggle_tracing, SIGNAL(clicked()), this, SLOT(OnToggleTracing()));
209 connect(this, SIGNAL(TracingFinished(const Pica::DebugUtils::PicaTrace&)), 210 connect(this, SIGNAL(TracingFinished(const Pica::DebugUtils::PicaTrace&)), model,
210 model, SLOT(OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace&))); 211 SLOT(OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace&)));
211 212
212 connect(copy_all, SIGNAL(clicked()), this, SLOT(CopyAllToClipboard())); 213 connect(copy_all, SIGNAL(clicked()), this, SLOT(CopyAllToClipboard()));
213 214