summaryrefslogtreecommitdiff
path: root/src/citra_qt/debugger
diff options
context:
space:
mode:
Diffstat (limited to 'src/citra_qt/debugger')
-rw-r--r--src/citra_qt/debugger/callstack.cpp4
-rw-r--r--src/citra_qt/debugger/disassembler.cpp4
-rw-r--r--src/citra_qt/debugger/graphics.cpp2
-rw-r--r--src/citra_qt/debugger/graphics.hxx2
-rw-r--r--src/citra_qt/debugger/graphics_breakpoints.cpp263
-rw-r--r--src/citra_qt/debugger/graphics_breakpoints.hxx53
-rw-r--r--src/citra_qt/debugger/graphics_breakpoints_p.hxx38
-rw-r--r--src/citra_qt/debugger/graphics_cmdlists.cpp275
-rw-r--r--src/citra_qt/debugger/graphics_cmdlists.hxx39
-rw-r--r--src/citra_qt/debugger/graphics_framebuffer.cpp283
-rw-r--r--src/citra_qt/debugger/graphics_framebuffer.hxx92
11 files changed, 1029 insertions, 26 deletions
diff --git a/src/citra_qt/debugger/callstack.cpp b/src/citra_qt/debugger/callstack.cpp
index 895851be3..a9ec2f7fe 100644
--- a/src/citra_qt/debugger/callstack.cpp
+++ b/src/citra_qt/debugger/callstack.cpp
@@ -27,10 +27,10 @@ void CallstackWidget::OnCPUStepped()
27 ARM_Interface* app_core = Core::g_app_core; 27 ARM_Interface* app_core = Core::g_app_core;
28 28
29 u32 sp = app_core->GetReg(13); //stack pointer 29 u32 sp = app_core->GetReg(13); //stack pointer
30 u32 addr, ret_addr, call_addr, func_addr; 30 u32 ret_addr, call_addr, func_addr;
31 31
32 int counter = 0; 32 int counter = 0;
33 for (int addr = 0x10000000; addr >= sp; addr -= 4) 33 for (u32 addr = 0x10000000; addr >= sp; addr -= 4)
34 { 34 {
35 ret_addr = Memory::Read32(addr); 35 ret_addr = Memory::Read32(addr);
36 call_addr = ret_addr - 4; //get call address??? 36 call_addr = ret_addr - 4; //get call address???
diff --git a/src/citra_qt/debugger/disassembler.cpp b/src/citra_qt/debugger/disassembler.cpp
index 2ee877743..14745f3bb 100644
--- a/src/citra_qt/debugger/disassembler.cpp
+++ b/src/citra_qt/debugger/disassembler.cpp
@@ -220,7 +220,9 @@ void DisassemblerWidget::OnPause()
220 emu_thread.SetCpuRunning(false); 220 emu_thread.SetCpuRunning(false);
221 221
222 // TODO: By now, the CPU might not have actually stopped... 222 // TODO: By now, the CPU might not have actually stopped...
223 model->SetNextInstruction(Core::g_app_core->GetPC()); 223 if (Core::g_app_core) {
224 model->SetNextInstruction(Core::g_app_core->GetPC());
225 }
224} 226}
225 227
226void DisassemblerWidget::OnToggleStartStop() 228void DisassemblerWidget::OnToggleStartStop()
diff --git a/src/citra_qt/debugger/graphics.cpp b/src/citra_qt/debugger/graphics.cpp
index a86a55404..6ff4c290d 100644
--- a/src/citra_qt/debugger/graphics.cpp
+++ b/src/citra_qt/debugger/graphics.cpp
@@ -1,5 +1,5 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "graphics.hxx" 5#include "graphics.hxx"
diff --git a/src/citra_qt/debugger/graphics.hxx b/src/citra_qt/debugger/graphics.hxx
index 72656f93c..8119b4c87 100644
--- a/src/citra_qt/debugger/graphics.hxx
+++ b/src/citra_qt/debugger/graphics.hxx
@@ -1,5 +1,5 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#pragma once 5#pragma once
diff --git a/src/citra_qt/debugger/graphics_breakpoints.cpp b/src/citra_qt/debugger/graphics_breakpoints.cpp
new file mode 100644
index 000000000..9486f06cc
--- /dev/null
+++ b/src/citra_qt/debugger/graphics_breakpoints.cpp
@@ -0,0 +1,263 @@
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 <QMetaType>
6#include <QPushButton>
7#include <QTreeWidget>
8#include <QVBoxLayout>
9#include <QLabel>
10
11#include "graphics_breakpoints.hxx"
12#include "graphics_breakpoints_p.hxx"
13
14BreakPointModel::BreakPointModel(std::shared_ptr<Pica::DebugContext> debug_context, QObject* parent)
15 : QAbstractListModel(parent), context_weak(debug_context),
16 at_breakpoint(debug_context->at_breakpoint),
17 active_breakpoint(debug_context->active_breakpoint)
18{
19
20}
21
22int BreakPointModel::columnCount(const QModelIndex& parent) const
23{
24 return 2;
25}
26
27int BreakPointModel::rowCount(const QModelIndex& parent) const
28{
29 return static_cast<int>(Pica::DebugContext::Event::NumEvents);
30}
31
32QVariant BreakPointModel::data(const QModelIndex& index, int role) const
33{
34 const auto event = static_cast<Pica::DebugContext::Event>(index.row());
35
36 switch (role) {
37 case Qt::DisplayRole:
38 {
39 switch (index.column()) {
40 case 0:
41 {
42 static const std::map<Pica::DebugContext::Event, QString> map = {
43 { Pica::DebugContext::Event::CommandLoaded, tr("Pica command loaded") },
44 { Pica::DebugContext::Event::CommandProcessed, tr("Pica command processed") },
45 { Pica::DebugContext::Event::IncomingPrimitiveBatch, tr("Incoming primitive batch") },
46 { Pica::DebugContext::Event::FinishedPrimitiveBatch, tr("Finished primitive batch") },
47 { Pica::DebugContext::Event::VertexLoaded, tr("Vertex Loaded") }
48 };
49
50 _dbg_assert_(Debug_GPU, map.size() == static_cast<size_t>(Pica::DebugContext::Event::NumEvents));
51
52 return (map.find(event) != map.end()) ? map.at(event) : QString();
53 }
54
55 case 1:
56 return data(index, Role_IsEnabled).toBool() ? tr("Enabled") : tr("Disabled");
57
58 default:
59 break;
60 }
61
62 break;
63 }
64
65 case Qt::BackgroundRole:
66 {
67 if (at_breakpoint && index.row() == static_cast<int>(active_breakpoint)) {
68 return QBrush(QColor(0xE0, 0xE0, 0x10));
69 }
70 break;
71 }
72
73 case Role_IsEnabled:
74 {
75 auto context = context_weak.lock();
76 return context && context->breakpoints[event].enabled;
77 }
78
79 default:
80 break;
81 }
82 return QVariant();
83}
84
85QVariant BreakPointModel::headerData(int section, Qt::Orientation orientation, int role) const
86{
87 switch(role) {
88 case Qt::DisplayRole:
89 {
90 if (section == 0) {
91 return tr("Event");
92 } else if (section == 1) {
93 return tr("Status");
94 }
95
96 break;
97 }
98 }
99
100 return QVariant();
101}
102
103bool BreakPointModel::setData(const QModelIndex& index, const QVariant& value, int role)
104{
105 const auto event = static_cast<Pica::DebugContext::Event>(index.row());
106
107 switch (role) {
108 case Role_IsEnabled:
109 {
110 auto context = context_weak.lock();
111 if (!context)
112 return false;
113
114 context->breakpoints[event].enabled = value.toBool();
115 QModelIndex changed_index = createIndex(index.row(), 1);
116 emit dataChanged(changed_index, changed_index);
117 return true;
118 }
119 }
120
121 return false;
122}
123
124
125void BreakPointModel::OnBreakPointHit(Pica::DebugContext::Event event)
126{
127 auto context = context_weak.lock();
128 if (!context)
129 return;
130
131 active_breakpoint = context->active_breakpoint;
132 at_breakpoint = context->at_breakpoint;
133 emit dataChanged(createIndex(static_cast<int>(event), 0),
134 createIndex(static_cast<int>(event), 1));
135}
136
137void BreakPointModel::OnResumed()
138{
139 auto context = context_weak.lock();
140 if (!context)
141 return;
142
143 at_breakpoint = context->at_breakpoint;
144 emit dataChanged(createIndex(static_cast<int>(active_breakpoint), 0),
145 createIndex(static_cast<int>(active_breakpoint), 1));
146 active_breakpoint = context->active_breakpoint;
147}
148
149
150GraphicsBreakPointsWidget::GraphicsBreakPointsWidget(std::shared_ptr<Pica::DebugContext> debug_context,
151 QWidget* parent)
152 : QDockWidget(tr("Pica Breakpoints"), parent),
153 Pica::DebugContext::BreakPointObserver(debug_context)
154{
155 setObjectName("PicaBreakPointsWidget");
156
157 status_text = new QLabel(tr("Emulation running"));
158 resume_button = new QPushButton(tr("Resume"));
159 resume_button->setEnabled(false);
160
161 breakpoint_model = new BreakPointModel(debug_context, this);
162 breakpoint_list = new QTreeView;
163 breakpoint_list->setModel(breakpoint_model);
164
165 toggle_breakpoint_button = new QPushButton(tr("Enable"));
166 toggle_breakpoint_button->setEnabled(false);
167
168 qRegisterMetaType<Pica::DebugContext::Event>("Pica::DebugContext::Event");
169
170 connect(resume_button, SIGNAL(clicked()), this, SLOT(OnResumeRequested()));
171
172 connect(this, SIGNAL(BreakPointHit(Pica::DebugContext::Event,void*)),
173 this, SLOT(OnBreakPointHit(Pica::DebugContext::Event,void*)),
174 Qt::BlockingQueuedConnection);
175 connect(this, SIGNAL(Resumed()), this, SLOT(OnResumed()));
176
177 connect(this, SIGNAL(BreakPointHit(Pica::DebugContext::Event,void*)),
178 breakpoint_model, SLOT(OnBreakPointHit(Pica::DebugContext::Event)),
179 Qt::BlockingQueuedConnection);
180 connect(this, SIGNAL(Resumed()), breakpoint_model, SLOT(OnResumed()));
181
182 connect(this, SIGNAL(BreakPointsChanged(const QModelIndex&,const QModelIndex&)),
183 breakpoint_model, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&)));
184
185 connect(breakpoint_list->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
186 this, SLOT(OnBreakpointSelectionChanged(QModelIndex)));
187
188 connect(toggle_breakpoint_button, SIGNAL(clicked()), this, SLOT(OnToggleBreakpointEnabled()));
189
190 QWidget* main_widget = new QWidget;
191 auto main_layout = new QVBoxLayout;
192 {
193 auto sub_layout = new QHBoxLayout;
194 sub_layout->addWidget(status_text);
195 sub_layout->addWidget(resume_button);
196 main_layout->addLayout(sub_layout);
197 }
198 main_layout->addWidget(breakpoint_list);
199 main_layout->addWidget(toggle_breakpoint_button);
200 main_widget->setLayout(main_layout);
201
202 setWidget(main_widget);
203}
204
205void GraphicsBreakPointsWidget::OnPicaBreakPointHit(Event event, void* data)
206{
207 // Process in GUI thread
208 emit BreakPointHit(event, data);
209}
210
211void GraphicsBreakPointsWidget::OnBreakPointHit(Pica::DebugContext::Event event, void* data)
212{
213 status_text->setText(tr("Emulation halted at breakpoint"));
214 resume_button->setEnabled(true);
215}
216
217void GraphicsBreakPointsWidget::OnPicaResume()
218{
219 // Process in GUI thread
220 emit Resumed();
221}
222
223void GraphicsBreakPointsWidget::OnResumed()
224{
225 status_text->setText(tr("Emulation running"));
226 resume_button->setEnabled(false);
227}
228
229void GraphicsBreakPointsWidget::OnResumeRequested()
230{
231 if (auto context = context_weak.lock())
232 context->Resume();
233}
234
235void GraphicsBreakPointsWidget::OnBreakpointSelectionChanged(const QModelIndex& index)
236{
237 if (!index.isValid()) {
238 toggle_breakpoint_button->setEnabled(false);
239 return;
240 }
241
242 toggle_breakpoint_button->setEnabled(true);
243 UpdateToggleBreakpointButton(index);
244}
245
246void GraphicsBreakPointsWidget::OnToggleBreakpointEnabled()
247{
248 QModelIndex index = breakpoint_list->selectionModel()->currentIndex();
249 bool new_state = !(breakpoint_model->data(index, BreakPointModel::Role_IsEnabled).toBool());
250
251 breakpoint_model->setData(index, new_state,
252 BreakPointModel::Role_IsEnabled);
253 UpdateToggleBreakpointButton(index);
254}
255
256void GraphicsBreakPointsWidget::UpdateToggleBreakpointButton(const QModelIndex& index)
257{
258 if (true == breakpoint_model->data(index, BreakPointModel::Role_IsEnabled).toBool()) {
259 toggle_breakpoint_button->setText(tr("Disable"));
260 } else {
261 toggle_breakpoint_button->setText(tr("Enable"));
262 }
263}
diff --git a/src/citra_qt/debugger/graphics_breakpoints.hxx b/src/citra_qt/debugger/graphics_breakpoints.hxx
new file mode 100644
index 000000000..5b9ba324e
--- /dev/null
+++ b/src/citra_qt/debugger/graphics_breakpoints.hxx
@@ -0,0 +1,53 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <memory>
8
9#include <QAbstractListModel>
10#include <QDockWidget>
11
12#include "video_core/debug_utils/debug_utils.h"
13
14class QLabel;
15class QPushButton;
16class QTreeView;
17
18class BreakPointModel;
19
20class GraphicsBreakPointsWidget : public QDockWidget, Pica::DebugContext::BreakPointObserver {
21 Q_OBJECT
22
23 using Event = Pica::DebugContext::Event;
24
25public:
26 GraphicsBreakPointsWidget(std::shared_ptr<Pica::DebugContext> debug_context,
27 QWidget* parent = nullptr);
28
29 void OnPicaBreakPointHit(Pica::DebugContext::Event event, void* data) override;
30 void OnPicaResume() override;
31
32public slots:
33 void OnBreakPointHit(Pica::DebugContext::Event event, void* data);
34 void OnResumeRequested();
35 void OnResumed();
36 void OnBreakpointSelectionChanged(const QModelIndex&);
37 void OnToggleBreakpointEnabled();
38
39signals:
40 void Resumed();
41 void BreakPointHit(Pica::DebugContext::Event event, void* data);
42 void BreakPointsChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
43
44private:
45 void UpdateToggleBreakpointButton(const QModelIndex& index);
46
47 QLabel* status_text;
48 QPushButton* resume_button;
49 QPushButton* toggle_breakpoint_button;
50
51 BreakPointModel* breakpoint_model;
52 QTreeView* breakpoint_list;
53};
diff --git a/src/citra_qt/debugger/graphics_breakpoints_p.hxx b/src/citra_qt/debugger/graphics_breakpoints_p.hxx
new file mode 100644
index 000000000..232bfc863
--- /dev/null
+++ b/src/citra_qt/debugger/graphics_breakpoints_p.hxx
@@ -0,0 +1,38 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <memory>
8
9#include <QAbstractListModel>
10
11#include "video_core/debug_utils/debug_utils.h"
12
13class BreakPointModel : public QAbstractListModel {
14 Q_OBJECT
15
16public:
17 enum {
18 Role_IsEnabled = Qt::UserRole,
19 };
20
21 BreakPointModel(std::shared_ptr<Pica::DebugContext> context, QObject* parent);
22
23 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
24 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
25 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
26 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
27
28 bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
29
30public slots:
31 void OnBreakPointHit(Pica::DebugContext::Event event);
32 void OnResumed();
33
34private:
35 std::weak_ptr<Pica::DebugContext> context_weak;
36 bool at_breakpoint;
37 Pica::DebugContext::Event active_breakpoint;
38};
diff --git a/src/citra_qt/debugger/graphics_cmdlists.cpp b/src/citra_qt/debugger/graphics_cmdlists.cpp
index 71dd166cd..753cc25da 100644
--- a/src/citra_qt/debugger/graphics_cmdlists.cpp
+++ b/src/citra_qt/debugger/graphics_cmdlists.cpp
@@ -1,31 +1,179 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2 or any later version
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>
7#include <QMainWindow>
6#include <QPushButton> 8#include <QPushButton>
7#include <QVBoxLayout> 9#include <QVBoxLayout>
8#include <QTreeView> 10#include <QTreeView>
11#include <QSpinBox>
12#include <QComboBox>
13
14#include "video_core/pica.h"
15#include "video_core/math.h"
16
17#include "video_core/debug_utils/debug_utils.h"
9 18
10#include "graphics_cmdlists.hxx" 19#include "graphics_cmdlists.hxx"
11 20
12GPUCommandListModel::GPUCommandListModel(QObject* parent) : QAbstractListModel(parent) 21#include "util/spinbox.hxx"
13{ 22
23QImage LoadTexture(u8* src, const Pica::DebugUtils::TextureInfo& info) {
24 QImage decoded_image(info.width, info.height, QImage::Format_ARGB32);
25 for (int y = 0; y < info.height; ++y) {
26 for (int x = 0; x < info.width; ++x) {
27 Math::Vec4<u8> color = Pica::DebugUtils::LookupTexture(src, x, y, info, true);
28 decoded_image.setPixel(x, y, qRgba(color.r(), color.g(), color.b(), color.a()));
29 }
30 }
31
32 return decoded_image;
33}
34
35class TextureInfoWidget : public QWidget {
36public:
37 TextureInfoWidget(u8* src, const Pica::DebugUtils::TextureInfo& info, QWidget* parent = nullptr) : QWidget(parent) {
38 QLabel* image_widget = new QLabel;
39 QPixmap image_pixmap = QPixmap::fromImage(LoadTexture(src, info));
40 image_pixmap = image_pixmap.scaled(200, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
41 image_widget->setPixmap(image_pixmap);
42
43 QVBoxLayout* layout = new QVBoxLayout;
44 layout->addWidget(image_widget);
45 setLayout(layout);
46 }
47};
48
49TextureInfoDockWidget::TextureInfoDockWidget(const Pica::DebugUtils::TextureInfo& info, QWidget* parent)
50 : QDockWidget(tr("Texture 0x%1").arg(info.physical_address, 8, 16, QLatin1Char('0'))),
51 info(info) {
52
53 QWidget* main_widget = new QWidget;
54
55 QLabel* image_widget = new QLabel;
56
57 connect(this, SIGNAL(UpdatePixmap(const QPixmap&)), image_widget, SLOT(setPixmap(const QPixmap&)));
58
59 CSpinBox* phys_address_spinbox = new CSpinBox;
60 phys_address_spinbox->SetBase(16);
61 phys_address_spinbox->SetRange(0, 0xFFFFFFFF);
62 phys_address_spinbox->SetPrefix("0x");
63 phys_address_spinbox->SetValue(info.physical_address);
64 connect(phys_address_spinbox, SIGNAL(ValueChanged(qint64)), this, SLOT(OnAddressChanged(qint64)));
65
66 QComboBox* format_choice = new QComboBox;
67 format_choice->addItem(tr("RGBA8"));
68 format_choice->addItem(tr("RGB8"));
69 format_choice->addItem(tr("RGBA5551"));
70 format_choice->addItem(tr("RGB565"));
71 format_choice->addItem(tr("RGBA4"));
72 format_choice->addItem(tr("IA8"));
73 format_choice->addItem(tr("UNK6"));
74 format_choice->addItem(tr("I8"));
75 format_choice->addItem(tr("A8"));
76 format_choice->addItem(tr("IA4"));
77 format_choice->addItem(tr("UNK10"));
78 format_choice->addItem(tr("A4"));
79 format_choice->setCurrentIndex(static_cast<int>(info.format));
80 connect(format_choice, SIGNAL(currentIndexChanged(int)), this, SLOT(OnFormatChanged(int)));
81
82 QSpinBox* width_spinbox = new QSpinBox;
83 width_spinbox->setMaximum(65535);
84 width_spinbox->setValue(info.width);
85 connect(width_spinbox, SIGNAL(valueChanged(int)), this, SLOT(OnWidthChanged(int)));
86
87 QSpinBox* height_spinbox = new QSpinBox;
88 height_spinbox->setMaximum(65535);
89 height_spinbox->setValue(info.height);
90 connect(height_spinbox, SIGNAL(valueChanged(int)), this, SLOT(OnHeightChanged(int)));
91
92 QSpinBox* stride_spinbox = new QSpinBox;
93 stride_spinbox->setMaximum(65535 * 4);
94 stride_spinbox->setValue(info.stride);
95 connect(stride_spinbox, SIGNAL(valueChanged(int)), this, SLOT(OnStrideChanged(int)));
96
97 QVBoxLayout* main_layout = new QVBoxLayout;
98 main_layout->addWidget(image_widget);
99
100 {
101 QHBoxLayout* sub_layout = new QHBoxLayout;
102 sub_layout->addWidget(new QLabel(tr("Source Address:")));
103 sub_layout->addWidget(phys_address_spinbox);
104 main_layout->addLayout(sub_layout);
105 }
106
107 {
108 QHBoxLayout* sub_layout = new QHBoxLayout;
109 sub_layout->addWidget(new QLabel(tr("Format")));
110 sub_layout->addWidget(format_choice);
111 main_layout->addLayout(sub_layout);
112 }
113
114 {
115 QHBoxLayout* sub_layout = new QHBoxLayout;
116 sub_layout->addWidget(new QLabel(tr("Width:")));
117 sub_layout->addWidget(width_spinbox);
118 sub_layout->addStretch();
119 sub_layout->addWidget(new QLabel(tr("Height:")));
120 sub_layout->addWidget(height_spinbox);
121 sub_layout->addStretch();
122 sub_layout->addWidget(new QLabel(tr("Stride:")));
123 sub_layout->addWidget(stride_spinbox);
124 main_layout->addLayout(sub_layout);
125 }
126
127 main_widget->setLayout(main_layout);
128
129 emit UpdatePixmap(ReloadPixmap());
130
131 setWidget(main_widget);
132}
133
134void TextureInfoDockWidget::OnAddressChanged(qint64 value) {
135 info.physical_address = value;
136 emit UpdatePixmap(ReloadPixmap());
137}
14 138
139void TextureInfoDockWidget::OnFormatChanged(int value) {
140 info.format = static_cast<Pica::Regs::TextureFormat>(value);
141 emit UpdatePixmap(ReloadPixmap());
15} 142}
16 143
17int GPUCommandListModel::rowCount(const QModelIndex& parent) const 144void TextureInfoDockWidget::OnWidthChanged(int value) {
18{ 145 info.width = value;
146 emit UpdatePixmap(ReloadPixmap());
147}
148
149void TextureInfoDockWidget::OnHeightChanged(int value) {
150 info.height = value;
151 emit UpdatePixmap(ReloadPixmap());
152}
153
154void TextureInfoDockWidget::OnStrideChanged(int value) {
155 info.stride = value;
156 emit UpdatePixmap(ReloadPixmap());
157}
158
159QPixmap TextureInfoDockWidget::ReloadPixmap() const {
160 u8* src = Memory::GetPointer(Pica::PAddrToVAddr(info.physical_address));
161 return QPixmap::fromImage(LoadTexture(src, info));
162}
163
164GPUCommandListModel::GPUCommandListModel(QObject* parent) : QAbstractListModel(parent) {
165
166}
167
168int GPUCommandListModel::rowCount(const QModelIndex& parent) const {
19 return pica_trace.writes.size(); 169 return pica_trace.writes.size();
20} 170}
21 171
22int GPUCommandListModel::columnCount(const QModelIndex& parent) const 172int GPUCommandListModel::columnCount(const QModelIndex& parent) const {
23{
24 return 2; 173 return 2;
25} 174}
26 175
27QVariant GPUCommandListModel::data(const QModelIndex& index, int role) const 176QVariant GPUCommandListModel::data(const QModelIndex& index, int role) const {
28{
29 if (!index.isValid()) 177 if (!index.isValid())
30 return QVariant(); 178 return QVariant();
31 179
@@ -36,21 +184,39 @@ QVariant GPUCommandListModel::data(const QModelIndex& index, int role) const
36 if (role == Qt::DisplayRole) { 184 if (role == Qt::DisplayRole) {
37 QString content; 185 QString content;
38 if (index.column() == 0) { 186 if (index.column() == 0) {
39 content = QString::fromLatin1(Pica::Regs::GetCommandName(cmd.cmd_id).c_str()); 187 QString content = QString::fromLatin1(Pica::Regs::GetCommandName(cmd.cmd_id).c_str());
40 content.append(" "); 188 content.append(" ");
189 return content;
41 } else if (index.column() == 1) { 190 } else if (index.column() == 1) {
42 content.append(QString("%1 ").arg(cmd.hex, 8, 16, QLatin1Char('0'))); 191 QString content = QString("%1 ").arg(cmd.hex, 8, 16, QLatin1Char('0'));
43 content.append(QString("%1 ").arg(val, 8, 16, QLatin1Char('0'))); 192 content.append(QString("%1 ").arg(val, 8, 16, QLatin1Char('0')));
193 return content;
44 } 194 }
195 } else if (role == CommandIdRole) {
196 return QVariant::fromValue<int>(cmd.cmd_id.Value());
197 }
45 198
46 return QVariant(content); 199 return QVariant();
200}
201
202QVariant GPUCommandListModel::headerData(int section, Qt::Orientation orientation, int role) const {
203 switch(role) {
204 case Qt::DisplayRole:
205 {
206 if (section == 0) {
207 return tr("Command Name");
208 } else if (section == 1) {
209 return tr("Data");
210 }
211
212 break;
213 }
47 } 214 }
48 215
49 return QVariant(); 216 return QVariant();
50} 217}
51 218
52void GPUCommandListModel::OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace& trace) 219void GPUCommandListModel::OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace& trace) {
53{
54 beginResetModel(); 220 beginResetModel();
55 221
56 pica_trace = trace; 222 pica_trace = trace;
@@ -58,38 +224,107 @@ void GPUCommandListModel::OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace&
58 endResetModel(); 224 endResetModel();
59} 225}
60 226
227#define COMMAND_IN_RANGE(cmd_id, reg_name) \
228 (cmd_id >= PICA_REG_INDEX(reg_name) && \
229 cmd_id < PICA_REG_INDEX(reg_name) + sizeof(decltype(Pica::registers.reg_name)) / 4)
61 230
62GPUCommandListWidget::GPUCommandListWidget(QWidget* parent) : QDockWidget(tr("Pica Command List"), parent) 231void GPUCommandListWidget::OnCommandDoubleClicked(const QModelIndex& index) {
63{ 232 const int command_id = list_widget->model()->data(index, GPUCommandListModel::CommandIdRole).toInt();
233 if (COMMAND_IN_RANGE(command_id, texture0) ||
234 COMMAND_IN_RANGE(command_id, texture1) ||
235 COMMAND_IN_RANGE(command_id, texture2)) {
236
237 unsigned index;
238 if (COMMAND_IN_RANGE(command_id, texture0)) {
239 index = 0;
240 } else if (COMMAND_IN_RANGE(command_id, texture1)) {
241 index = 1;
242 } else {
243 index = 2;
244 }
245 auto config = Pica::registers.GetTextures()[index].config;
246 auto format = Pica::registers.GetTextures()[index].format;
247 auto info = Pica::DebugUtils::TextureInfo::FromPicaRegister(config, format);
248
249 // TODO: Instead, emit a signal here to be caught by the main window widget.
250 auto main_window = static_cast<QMainWindow*>(parent());
251 main_window->tabifyDockWidget(this, new TextureInfoDockWidget(info, main_window));
252 }
253}
254
255void GPUCommandListWidget::SetCommandInfo(const QModelIndex& index) {
256 QWidget* new_info_widget;
257
258 const int command_id = list_widget->model()->data(index, GPUCommandListModel::CommandIdRole).toInt();
259 if (COMMAND_IN_RANGE(command_id, texture0) ||
260 COMMAND_IN_RANGE(command_id, texture1) ||
261 COMMAND_IN_RANGE(command_id, texture2)) {
262
263 unsigned index;
264 if (COMMAND_IN_RANGE(command_id, texture0)) {
265 index = 0;
266 } else if (COMMAND_IN_RANGE(command_id, texture1)) {
267 index = 1;
268 } else {
269 index = 2;
270 }
271 auto config = Pica::registers.GetTextures()[index].config;
272 auto format = Pica::registers.GetTextures()[index].format;
273
274 auto info = Pica::DebugUtils::TextureInfo::FromPicaRegister(config, format);
275 u8* src = Memory::GetPointer(Pica::PAddrToVAddr(config.GetPhysicalAddress()));
276 new_info_widget = new TextureInfoWidget(src, info);
277 } else {
278 new_info_widget = new QWidget;
279 }
280
281 widget()->layout()->removeWidget(command_info_widget);
282 delete command_info_widget;
283 widget()->layout()->addWidget(new_info_widget);
284 command_info_widget = new_info_widget;
285}
286#undef COMMAND_IN_RANGE
287
288GPUCommandListWidget::GPUCommandListWidget(QWidget* parent) : QDockWidget(tr("Pica Command List"), parent) {
289 setObjectName("Pica Command List");
64 GPUCommandListModel* model = new GPUCommandListModel(this); 290 GPUCommandListModel* model = new GPUCommandListModel(this);
65 291
66 QWidget* main_widget = new QWidget; 292 QWidget* main_widget = new QWidget;
67 293
68 QTreeView* list_widget = new QTreeView; 294 list_widget = new QTreeView;
69 list_widget->setModel(model); 295 list_widget->setModel(model);
70 list_widget->setFont(QFont("monospace")); 296 list_widget->setFont(QFont("monospace"));
71 list_widget->setRootIsDecorated(false); 297 list_widget->setRootIsDecorated(false);
72 298
73 QPushButton* toggle_tracing = new QPushButton(tr("Start Tracing")); 299 connect(list_widget->selectionModel(), SIGNAL(currentChanged(const QModelIndex&,const QModelIndex&)),
300 this, SLOT(SetCommandInfo(const QModelIndex&)));
301 connect(list_widget, SIGNAL(doubleClicked(const QModelIndex&)),
302 this, SLOT(OnCommandDoubleClicked(const QModelIndex&)));
303
304 toggle_tracing = new QPushButton(tr("Start Tracing"));
74 305
75 connect(toggle_tracing, SIGNAL(clicked()), this, SLOT(OnToggleTracing())); 306 connect(toggle_tracing, SIGNAL(clicked()), this, SLOT(OnToggleTracing()));
76 connect(this, SIGNAL(TracingFinished(const Pica::DebugUtils::PicaTrace&)), 307 connect(this, SIGNAL(TracingFinished(const Pica::DebugUtils::PicaTrace&)),
77 model, SLOT(OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace&))); 308 model, SLOT(OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace&)));
78 309
310 command_info_widget = new QWidget;
311
79 QVBoxLayout* main_layout = new QVBoxLayout; 312 QVBoxLayout* main_layout = new QVBoxLayout;
80 main_layout->addWidget(list_widget); 313 main_layout->addWidget(list_widget);
81 main_layout->addWidget(toggle_tracing); 314 main_layout->addWidget(toggle_tracing);
315 main_layout->addWidget(command_info_widget);
82 main_widget->setLayout(main_layout); 316 main_widget->setLayout(main_layout);
83 317
84 setWidget(main_widget); 318 setWidget(main_widget);
85} 319}
86 320
87void GPUCommandListWidget::OnToggleTracing() 321void GPUCommandListWidget::OnToggleTracing() {
88{
89 if (!Pica::DebugUtils::IsPicaTracing()) { 322 if (!Pica::DebugUtils::IsPicaTracing()) {
90 Pica::DebugUtils::StartPicaTracing(); 323 Pica::DebugUtils::StartPicaTracing();
324 toggle_tracing->setText(tr("Finish Tracing"));
91 } else { 325 } else {
92 pica_trace = Pica::DebugUtils::FinishPicaTracing(); 326 pica_trace = Pica::DebugUtils::FinishPicaTracing();
93 emit TracingFinished(*pica_trace); 327 emit TracingFinished(*pica_trace);
328 toggle_tracing->setText(tr("Start Tracing"));
94 } 329 }
95} 330}
diff --git a/src/citra_qt/debugger/graphics_cmdlists.hxx b/src/citra_qt/debugger/graphics_cmdlists.hxx
index 1523e724f..a465d044c 100644
--- a/src/citra_qt/debugger/graphics_cmdlists.hxx
+++ b/src/citra_qt/debugger/graphics_cmdlists.hxx
@@ -1,5 +1,5 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#pragma once 5#pragma once
@@ -10,16 +10,24 @@
10#include "video_core/gpu_debugger.h" 10#include "video_core/gpu_debugger.h"
11#include "video_core/debug_utils/debug_utils.h" 11#include "video_core/debug_utils/debug_utils.h"
12 12
13class QPushButton;
14class QTreeView;
15
13class GPUCommandListModel : public QAbstractListModel 16class GPUCommandListModel : public QAbstractListModel
14{ 17{
15 Q_OBJECT 18 Q_OBJECT
16 19
17public: 20public:
21 enum {
22 CommandIdRole = Qt::UserRole,
23 };
24
18 GPUCommandListModel(QObject* parent); 25 GPUCommandListModel(QObject* parent);
19 26
20 int columnCount(const QModelIndex& parent = QModelIndex()) const override; 27 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
21 int rowCount(const QModelIndex& parent = QModelIndex()) const override; 28 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
22 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; 29 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
30 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
23 31
24public slots: 32public slots:
25 void OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace& trace); 33 void OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace& trace);
@@ -37,10 +45,39 @@ public:
37 45
38public slots: 46public slots:
39 void OnToggleTracing(); 47 void OnToggleTracing();
48 void OnCommandDoubleClicked(const QModelIndex&);
49
50 void SetCommandInfo(const QModelIndex&);
40 51
41signals: 52signals:
42 void TracingFinished(const Pica::DebugUtils::PicaTrace&); 53 void TracingFinished(const Pica::DebugUtils::PicaTrace&);
43 54
44private: 55private:
45 std::unique_ptr<Pica::DebugUtils::PicaTrace> pica_trace; 56 std::unique_ptr<Pica::DebugUtils::PicaTrace> pica_trace;
57
58 QTreeView* list_widget;
59 QWidget* command_info_widget;
60 QPushButton* toggle_tracing;
61};
62
63class TextureInfoDockWidget : public QDockWidget {
64 Q_OBJECT
65
66public:
67 TextureInfoDockWidget(const Pica::DebugUtils::TextureInfo& info, QWidget* parent = nullptr);
68
69signals:
70 void UpdatePixmap(const QPixmap& pixmap);
71
72private slots:
73 void OnAddressChanged(qint64 value);
74 void OnFormatChanged(int value);
75 void OnWidthChanged(int value);
76 void OnHeightChanged(int value);
77 void OnStrideChanged(int value);
78
79private:
80 QPixmap ReloadPixmap() const;
81
82 Pica::DebugUtils::TextureInfo info;
46}; 83};
diff --git a/src/citra_qt/debugger/graphics_framebuffer.cpp b/src/citra_qt/debugger/graphics_framebuffer.cpp
new file mode 100644
index 000000000..dd41c3880
--- /dev/null
+++ b/src/citra_qt/debugger/graphics_framebuffer.cpp
@@ -0,0 +1,283 @@
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 <QBoxLayout>
6#include <QComboBox>
7#include <QDebug>
8#include <QLabel>
9#include <QMetaType>
10#include <QPushButton>
11#include <QSpinBox>
12
13#include "video_core/pica.h"
14
15#include "graphics_framebuffer.hxx"
16
17#include "util/spinbox.hxx"
18
19BreakPointObserverDock::BreakPointObserverDock(std::shared_ptr<Pica::DebugContext> debug_context,
20 const QString& title, QWidget* parent)
21 : QDockWidget(title, parent), BreakPointObserver(debug_context)
22{
23 qRegisterMetaType<Pica::DebugContext::Event>("Pica::DebugContext::Event");
24
25 connect(this, SIGNAL(Resumed()), this, SLOT(OnResumed()));
26
27 // NOTE: This signal is emitted from a non-GUI thread, but connect() takes
28 // care of delaying its handling to the GUI thread.
29 connect(this, SIGNAL(BreakPointHit(Pica::DebugContext::Event,void*)),
30 this, SLOT(OnBreakPointHit(Pica::DebugContext::Event,void*)),
31 Qt::BlockingQueuedConnection);
32}
33
34void BreakPointObserverDock::OnPicaBreakPointHit(Pica::DebugContext::Event event, void* data)
35{
36 emit BreakPointHit(event, data);
37}
38
39void BreakPointObserverDock::OnPicaResume()
40{
41 emit Resumed();
42}
43
44
45GraphicsFramebufferWidget::GraphicsFramebufferWidget(std::shared_ptr<Pica::DebugContext> debug_context,
46 QWidget* parent)
47 : BreakPointObserverDock(debug_context, tr("Pica Framebuffer"), parent),
48 framebuffer_source(Source::PicaTarget)
49{
50 setObjectName("PicaFramebuffer");
51
52 framebuffer_source_list = new QComboBox;
53 framebuffer_source_list->addItem(tr("Active Render Target"));
54 framebuffer_source_list->addItem(tr("Custom"));
55 framebuffer_source_list->setCurrentIndex(static_cast<int>(framebuffer_source));
56
57 framebuffer_address_control = new CSpinBox;
58 framebuffer_address_control->SetBase(16);
59 framebuffer_address_control->SetRange(0, 0xFFFFFFFF);
60 framebuffer_address_control->SetPrefix("0x");
61
62 framebuffer_width_control = new QSpinBox;
63 framebuffer_width_control->setMinimum(1);
64 framebuffer_width_control->setMaximum(std::numeric_limits<int>::max()); // TODO: Find actual maximum
65
66 framebuffer_height_control = new QSpinBox;
67 framebuffer_height_control->setMinimum(1);
68 framebuffer_height_control->setMaximum(std::numeric_limits<int>::max()); // TODO: Find actual maximum
69
70 framebuffer_format_control = new QComboBox;
71 framebuffer_format_control->addItem(tr("RGBA8"));
72 framebuffer_format_control->addItem(tr("RGB8"));
73 framebuffer_format_control->addItem(tr("RGBA5551"));
74 framebuffer_format_control->addItem(tr("RGB565"));
75 framebuffer_format_control->addItem(tr("RGBA4"));
76
77 // TODO: This QLabel should shrink the image to the available space rather than just expanding...
78 framebuffer_picture_label = new QLabel;
79
80 auto enlarge_button = new QPushButton(tr("Enlarge"));
81
82 // Connections
83 connect(this, SIGNAL(Update()), this, SLOT(OnUpdate()));
84 connect(framebuffer_source_list, SIGNAL(currentIndexChanged(int)), this, SLOT(OnFramebufferSourceChanged(int)));
85 connect(framebuffer_address_control, SIGNAL(ValueChanged(qint64)), this, SLOT(OnFramebufferAddressChanged(qint64)));
86 connect(framebuffer_width_control, SIGNAL(valueChanged(int)), this, SLOT(OnFramebufferWidthChanged(int)));
87 connect(framebuffer_height_control, SIGNAL(valueChanged(int)), this, SLOT(OnFramebufferHeightChanged(int)));
88 connect(framebuffer_format_control, SIGNAL(currentIndexChanged(int)), this, SLOT(OnFramebufferFormatChanged(int)));
89
90 auto main_widget = new QWidget;
91 auto main_layout = new QVBoxLayout;
92 {
93 auto sub_layout = new QHBoxLayout;
94 sub_layout->addWidget(new QLabel(tr("Source:")));
95 sub_layout->addWidget(framebuffer_source_list);
96 main_layout->addLayout(sub_layout);
97 }
98 {
99 auto sub_layout = new QHBoxLayout;
100 sub_layout->addWidget(new QLabel(tr("Virtual Address:")));
101 sub_layout->addWidget(framebuffer_address_control);
102 main_layout->addLayout(sub_layout);
103 }
104 {
105 auto sub_layout = new QHBoxLayout;
106 sub_layout->addWidget(new QLabel(tr("Width:")));
107 sub_layout->addWidget(framebuffer_width_control);
108 main_layout->addLayout(sub_layout);
109 }
110 {
111 auto sub_layout = new QHBoxLayout;
112 sub_layout->addWidget(new QLabel(tr("Height:")));
113 sub_layout->addWidget(framebuffer_height_control);
114 main_layout->addLayout(sub_layout);
115 }
116 {
117 auto sub_layout = new QHBoxLayout;
118 sub_layout->addWidget(new QLabel(tr("Format:")));
119 sub_layout->addWidget(framebuffer_format_control);
120 main_layout->addLayout(sub_layout);
121 }
122 main_layout->addWidget(framebuffer_picture_label);
123 main_layout->addWidget(enlarge_button);
124 main_widget->setLayout(main_layout);
125 setWidget(main_widget);
126
127 // Load current data - TODO: Make sure this works when emulation is not running
128 if (debug_context && debug_context->at_breakpoint)
129 emit Update();
130 widget()->setEnabled(false); // TODO: Only enable if currently at breakpoint
131}
132
133void GraphicsFramebufferWidget::OnBreakPointHit(Pica::DebugContext::Event event, void* data)
134{
135 emit Update();
136 widget()->setEnabled(true);
137}
138
139void GraphicsFramebufferWidget::OnResumed()
140{
141 widget()->setEnabled(false);
142}
143
144void GraphicsFramebufferWidget::OnFramebufferSourceChanged(int new_value)
145{
146 framebuffer_source = static_cast<Source>(new_value);
147 emit Update();
148}
149
150void GraphicsFramebufferWidget::OnFramebufferAddressChanged(qint64 new_value)
151{
152 if (framebuffer_address != new_value) {
153 framebuffer_address = static_cast<unsigned>(new_value);
154
155 framebuffer_source_list->setCurrentIndex(static_cast<int>(Source::Custom));
156 emit Update();
157 }
158}
159
160void GraphicsFramebufferWidget::OnFramebufferWidthChanged(int new_value)
161{
162 if (framebuffer_width != new_value) {
163 framebuffer_width = new_value;
164
165 framebuffer_source_list->setCurrentIndex(static_cast<int>(Source::Custom));
166 emit Update();
167 }
168}
169
170void GraphicsFramebufferWidget::OnFramebufferHeightChanged(int new_value)
171{
172 if (framebuffer_height != new_value) {
173 framebuffer_height = new_value;
174
175 framebuffer_source_list->setCurrentIndex(static_cast<int>(Source::Custom));
176 emit Update();
177 }
178}
179
180void GraphicsFramebufferWidget::OnFramebufferFormatChanged(int new_value)
181{
182 if (framebuffer_format != static_cast<Format>(new_value)) {
183 framebuffer_format = static_cast<Format>(new_value);
184
185 framebuffer_source_list->setCurrentIndex(static_cast<int>(Source::Custom));
186 emit Update();
187 }
188}
189
190void GraphicsFramebufferWidget::OnUpdate()
191{
192 QPixmap pixmap;
193
194 switch (framebuffer_source) {
195 case Source::PicaTarget:
196 {
197 // TODO: Store a reference to the registers in the debug context instead of accessing them directly...
198
199 auto framebuffer = Pica::registers.framebuffer;
200 using Framebuffer = decltype(framebuffer);
201
202 framebuffer_address = framebuffer.GetColorBufferPhysicalAddress();
203 framebuffer_width = framebuffer.GetWidth();
204 framebuffer_height = framebuffer.GetHeight();
205 framebuffer_format = static_cast<Format>(framebuffer.color_format);
206
207 break;
208 }
209
210 case Source::Custom:
211 {
212 // Keep user-specified values
213 break;
214 }
215
216 default:
217 qDebug() << "Unknown framebuffer source " << static_cast<int>(framebuffer_source);
218 break;
219 }
220
221 // TODO: Implement a good way to visualize alpha components!
222 // TODO: Unify this decoding code with the texture decoder
223 switch (framebuffer_format) {
224 case Format::RGBA8:
225 {
226 QImage decoded_image(framebuffer_width, framebuffer_height, QImage::Format_ARGB32);
227 u32* color_buffer = (u32*)Memory::GetPointer(Pica::PAddrToVAddr(framebuffer_address));
228 for (unsigned y = 0; y < framebuffer_height; ++y) {
229 for (unsigned x = 0; x < framebuffer_width; ++x) {
230 u32 value = *(color_buffer + x + y * framebuffer_width);
231
232 decoded_image.setPixel(x, y, qRgba((value >> 16) & 0xFF, (value >> 8) & 0xFF, value & 0xFF, 255/*value >> 24*/));
233 }
234 }
235 pixmap = QPixmap::fromImage(decoded_image);
236 break;
237 }
238
239 case Format::RGB8:
240 {
241 QImage decoded_image(framebuffer_width, framebuffer_height, QImage::Format_ARGB32);
242 u8* color_buffer = Memory::GetPointer(Pica::PAddrToVAddr(framebuffer_address));
243 for (unsigned y = 0; y < framebuffer_height; ++y) {
244 for (unsigned x = 0; x < framebuffer_width; ++x) {
245 u8* pixel_pointer = color_buffer + x * 3 + y * 3 * framebuffer_width;
246
247 decoded_image.setPixel(x, y, qRgba(pixel_pointer[0], pixel_pointer[1], pixel_pointer[2], 255/*value >> 24*/));
248 }
249 }
250 pixmap = QPixmap::fromImage(decoded_image);
251 break;
252 }
253
254 case Format::RGBA5551:
255 {
256 QImage decoded_image(framebuffer_width, framebuffer_height, QImage::Format_ARGB32);
257 u32* color_buffer = (u32*)Memory::GetPointer(Pica::PAddrToVAddr(framebuffer_address));
258 for (unsigned y = 0; y < framebuffer_height; ++y) {
259 for (unsigned x = 0; x < framebuffer_width; ++x) {
260 u16 value = *(u16*)(((u8*)color_buffer) + x * 2 + y * framebuffer_width * 2);
261 u8 r = (value >> 11) & 0x1F;
262 u8 g = (value >> 6) & 0x1F;
263 u8 b = (value >> 1) & 0x1F;
264 u8 a = value & 1;
265
266 decoded_image.setPixel(x, y, qRgba(r, g, b, 255/*a*/));
267 }
268 }
269 pixmap = QPixmap::fromImage(decoded_image);
270 break;
271 }
272
273 default:
274 qDebug() << "Unknown fb color format " << static_cast<int>(framebuffer_format);
275 break;
276 }
277
278 framebuffer_address_control->SetValue(framebuffer_address);
279 framebuffer_width_control->setValue(framebuffer_width);
280 framebuffer_height_control->setValue(framebuffer_height);
281 framebuffer_format_control->setCurrentIndex(static_cast<int>(framebuffer_format));
282 framebuffer_picture_label->setPixmap(pixmap);
283}
diff --git a/src/citra_qt/debugger/graphics_framebuffer.hxx b/src/citra_qt/debugger/graphics_framebuffer.hxx
new file mode 100644
index 000000000..56215761e
--- /dev/null
+++ b/src/citra_qt/debugger/graphics_framebuffer.hxx
@@ -0,0 +1,92 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <QDockWidget>
8
9#include "video_core/debug_utils/debug_utils.h"
10
11class QComboBox;
12class QLabel;
13class QSpinBox;
14
15class CSpinBox;
16
17// Utility class which forwards calls to OnPicaBreakPointHit and OnPicaResume to public slots.
18// This is because the Pica breakpoint callbacks are called from a non-GUI thread, while
19// the widget usually wants to perform reactions in the GUI thread.
20class BreakPointObserverDock : public QDockWidget, Pica::DebugContext::BreakPointObserver {
21 Q_OBJECT
22
23public:
24 BreakPointObserverDock(std::shared_ptr<Pica::DebugContext> debug_context, const QString& title,
25 QWidget* parent = nullptr);
26
27 void OnPicaBreakPointHit(Pica::DebugContext::Event event, void* data) override;
28 void OnPicaResume() override;
29
30private slots:
31 virtual void OnBreakPointHit(Pica::DebugContext::Event event, void* data) = 0;
32 virtual void OnResumed() = 0;
33
34signals:
35 void Resumed();
36 void BreakPointHit(Pica::DebugContext::Event event, void* data);
37};
38
39class GraphicsFramebufferWidget : public BreakPointObserverDock {
40 Q_OBJECT
41
42 using Event = Pica::DebugContext::Event;
43
44 enum class Source {
45 PicaTarget = 0,
46 Custom = 1,
47
48 // TODO: Add GPU framebuffer sources!
49 };
50
51 enum class Format {
52 RGBA8 = 0,
53 RGB8 = 1,
54 RGBA5551 = 2,
55 RGB565 = 3,
56 RGBA4 = 4,
57 };
58
59public:
60 GraphicsFramebufferWidget(std::shared_ptr<Pica::DebugContext> debug_context, QWidget* parent = nullptr);
61
62public slots:
63 void OnFramebufferSourceChanged(int new_value);
64 void OnFramebufferAddressChanged(qint64 new_value);
65 void OnFramebufferWidthChanged(int new_value);
66 void OnFramebufferHeightChanged(int new_value);
67 void OnFramebufferFormatChanged(int new_value);
68 void OnUpdate();
69
70private slots:
71 void OnBreakPointHit(Pica::DebugContext::Event event, void* data) override;
72 void OnResumed() override;
73
74signals:
75 void Update();
76
77private:
78
79 QComboBox* framebuffer_source_list;
80 CSpinBox* framebuffer_address_control;
81 QSpinBox* framebuffer_width_control;
82 QSpinBox* framebuffer_height_control;
83 QComboBox* framebuffer_format_control;
84
85 QLabel* framebuffer_picture_label;
86
87 Source framebuffer_source;
88 unsigned framebuffer_address;
89 unsigned framebuffer_width;
90 unsigned framebuffer_height;
91 Format framebuffer_format;
92};