summaryrefslogtreecommitdiff
path: root/src/citra_qt/debugger/graphics_cmdlists.cpp
diff options
context:
space:
mode:
authorGravatar Tony Wasserka2014-08-24 14:39:52 +0200
committerGravatar Tony Wasserka2014-12-09 16:37:34 +0100
commitfd194d95b0f1522b970a2b77f9ea490fb8c3ef08 (patch)
tree61e8f33ae8c83dadc48271b8b872949791637dae /src/citra_qt/debugger/graphics_cmdlists.cpp
parentAdd GUI widget for controlling pica breakpoints. (diff)
downloadyuzu-fd194d95b0f1522b970a2b77f9ea490fb8c3ef08.tar.gz
yuzu-fd194d95b0f1522b970a2b77f9ea490fb8c3ef08.tar.xz
yuzu-fd194d95b0f1522b970a2b77f9ea490fb8c3ef08.zip
citra-qt: Add texture viewer to Pica command list.
The texture viewer is enabled when selecting a write command to one of the texture config registers.
Diffstat (limited to 'src/citra_qt/debugger/graphics_cmdlists.cpp')
-rw-r--r--src/citra_qt/debugger/graphics_cmdlists.cpp64
1 files changed, 63 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);