summaryrefslogtreecommitdiffstats
path: root/src/citra_qt/debugger
diff options
context:
space:
mode:
authorTony Wasserka <NeoBrainX@gmail.com>2014-08-24 14:39:52 +0200
committerTony Wasserka <NeoBrainX@gmail.com>2014-12-09 16:37:34 +0100
commitfd194d95b0f1522b970a2b77f9ea490fb8c3ef08 (patch)
tree61e8f33ae8c83dadc48271b8b872949791637dae /src/citra_qt/debugger
parentAdd GUI widget for controlling pica breakpoints. (diff)
downloadyuzu-fd194d95b0f1522b970a2b77f9ea490fb8c3ef08.tar
yuzu-fd194d95b0f1522b970a2b77f9ea490fb8c3ef08.tar.gz
yuzu-fd194d95b0f1522b970a2b77f9ea490fb8c3ef08.tar.bz2
yuzu-fd194d95b0f1522b970a2b77f9ea490fb8c3ef08.tar.lz
yuzu-fd194d95b0f1522b970a2b77f9ea490fb8c3ef08.tar.xz
yuzu-fd194d95b0f1522b970a2b77f9ea490fb8c3ef08.tar.zst
yuzu-fd194d95b0f1522b970a2b77f9ea490fb8c3ef08.zip
Diffstat (limited to 'src/citra_qt/debugger')
-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 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
+#include <QLabel>
#include <QListView>
#include <QPushButton>
#include <QVBoxLayout>
@@ -9,6 +10,33 @@
#include "graphics_cmdlists.hxx"
+#include "video_core/pica.h"
+#include "video_core/math.h"
+
+#include "video_core/debug_utils/debug_utils.h"
+
+class TextureInfoWidget : public QWidget {
+public:
+ TextureInfoWidget(u8* src, const Pica::DebugUtils::TextureInfo& info, QWidget* parent = nullptr) : QWidget(parent) {
+ QImage decoded_image(info.width, info.height, QImage::Format_ARGB32);
+ for (int y = 0; y < info.height; ++y) {
+ for (int x = 0; x < info.width; ++x) {
+ Math::Vec4<u8> color = Pica::DebugUtils::LookupTexture(src, x, y, info);
+ decoded_image.setPixel(x, y, qRgba(color.r(), color.g(), color.b(), color.a()));
+ }
+ }
+
+ QLabel* image_widget = new QLabel;
+ QPixmap image_pixmap = QPixmap::fromImage(decoded_image);
+ image_pixmap = image_pixmap.scaled(200, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ image_widget->setPixmap(image_pixmap);
+
+ QVBoxLayout* layout = new QVBoxLayout;
+ layout->addWidget(image_widget);
+ setLayout(layout);
+ }
+};
+
GPUCommandListModel::GPUCommandListModel(QObject* parent) : QAbstractListModel(parent)
{
@@ -44,6 +72,8 @@ QVariant GPUCommandListModel::data(const QModelIndex& index, int role) const
}
return QVariant(content);
+ } else if (role == CommandIdRole) {
+ return QVariant::fromValue<int>(cmd.cmd_id.Value());
}
return QVariant();
@@ -76,27 +106,59 @@ void GPUCommandListModel::OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace&
endResetModel();
}
+void GPUCommandListWidget::SetCommandInfo(const QModelIndex& index)
+{
+ QWidget* new_info_widget;
+
+#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)
+ const int command_id = list_widget->model()->data(index, GPUCommandListModel::CommandIdRole).toInt();
+ if (COMMAND_IN_RANGE(command_id, texture0)) {
+ u8* src = Memory::GetPointer(Pica::registers.texture0.GetPhysicalAddress());
+ Pica::DebugUtils::TextureInfo info;
+ info.width = Pica::registers.texture0.width;
+ info.height = Pica::registers.texture0.height;
+ info.stride = 3 * Pica::registers.texture0.width;
+ info.format = Pica::registers.texture0_format;
+ new_info_widget = new TextureInfoWidget(src, info);
+ } else {
+ new_info_widget = new QWidget;
+ }
+#undef COMMAND_IN_RANGE
+
+ widget()->layout()->removeWidget(command_info_widget);
+ delete command_info_widget;
+ widget()->layout()->addWidget(new_info_widget);
+ command_info_widget = new_info_widget;
+}
GPUCommandListWidget::GPUCommandListWidget(QWidget* parent) : QDockWidget(tr("Pica Command List"), parent)
{
+ setObjectName("Pica Command List");
GPUCommandListModel* model = new GPUCommandListModel(this);
QWidget* main_widget = new QWidget;
- QTreeView* list_widget = new QTreeView;
+ list_widget = new QTreeView;
list_widget->setModel(model);
list_widget->setFont(QFont("monospace"));
list_widget->setRootIsDecorated(false);
+ connect(list_widget->selectionModel(), SIGNAL(currentChanged(const QModelIndex&,const QModelIndex&)),
+ this, SLOT(SetCommandInfo(const QModelIndex&)));
+
+
toggle_tracing = new QPushButton(tr("Start Tracing"));
connect(toggle_tracing, SIGNAL(clicked()), this, SLOT(OnToggleTracing()));
connect(this, SIGNAL(TracingFinished(const Pica::DebugUtils::PicaTrace&)),
model, SLOT(OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace&)));
+ command_info_widget = new QWidget;
+
QVBoxLayout* main_layout = new QVBoxLayout;
main_layout->addWidget(list_widget);
main_layout->addWidget(toggle_tracing);
+ main_layout->addWidget(command_info_widget);
main_widget->setLayout(main_layout);
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 @@
#include "video_core/debug_utils/debug_utils.h"
class QPushButton;
+class QTreeView;
class GPUCommandListModel : public QAbstractListModel
{
Q_OBJECT
public:
+ enum {
+ CommandIdRole = Qt::UserRole,
+ };
+
GPUCommandListModel(QObject* parent);
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
@@ -40,6 +45,7 @@ public:
public slots:
void OnToggleTracing();
+ void SetCommandInfo(const QModelIndex&);
signals:
void TracingFinished(const Pica::DebugUtils::PicaTrace&);
@@ -47,5 +53,7 @@ signals:
private:
std::unique_ptr<Pica::DebugUtils::PicaTrace> pica_trace;
+ QTreeView* list_widget;
+ QWidget* command_info_widget;
QPushButton* toggle_tracing;
};