diff options
| author | 2018-01-11 19:21:20 -0700 | |
|---|---|---|
| committer | 2018-01-12 19:11:03 -0700 | |
| commit | ebf9a784a9f7f4148a669dbb39e7cd50df779a14 (patch) | |
| tree | d585685a1c0a34b903af1d086d62560bf56bb29f /src/citra_qt/debugger | |
| parent | config: Default CPU core to Unicorn. (diff) | |
| download | yuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.tar.gz yuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.tar.xz yuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.zip | |
Massive removal of unused modules
Diffstat (limited to 'src/citra_qt/debugger')
22 files changed, 0 insertions, 3671 deletions
diff --git a/src/citra_qt/debugger/graphics/graphics.cpp b/src/citra_qt/debugger/graphics/graphics.cpp deleted file mode 100644 index 8154363a2..000000000 --- a/src/citra_qt/debugger/graphics/graphics.cpp +++ /dev/null | |||
| @@ -1,77 +0,0 @@ | |||
| 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 <QListView> | ||
| 6 | #include "citra_qt/debugger/graphics/graphics.h" | ||
| 7 | #include "citra_qt/util/util.h" | ||
| 8 | |||
| 9 | GraphicsDebugger g_debugger; | ||
| 10 | |||
| 11 | GPUCommandStreamItemModel::GPUCommandStreamItemModel(QObject* parent) | ||
| 12 | : QAbstractListModel(parent), command_count(0) { | ||
| 13 | connect(this, SIGNAL(GXCommandFinished(int)), this, SLOT(OnGXCommandFinishedInternal(int))); | ||
| 14 | } | ||
| 15 | |||
| 16 | int GPUCommandStreamItemModel::rowCount(const QModelIndex& parent) const { | ||
| 17 | return command_count; | ||
| 18 | } | ||
| 19 | |||
| 20 | QVariant GPUCommandStreamItemModel::data(const QModelIndex& index, int role) const { | ||
| 21 | if (!index.isValid()) | ||
| 22 | return QVariant(); | ||
| 23 | |||
| 24 | int command_index = index.row(); | ||
| 25 | const Service::GSP::Command& command = GetDebugger()->ReadGXCommandHistory(command_index); | ||
| 26 | if (role == Qt::DisplayRole) { | ||
| 27 | std::map<Service::GSP::CommandId, const char*> command_names = { | ||
| 28 | {Service::GSP::CommandId::REQUEST_DMA, "REQUEST_DMA"}, | ||
| 29 | {Service::GSP::CommandId::SUBMIT_GPU_CMDLIST, "SUBMIT_GPU_CMDLIST"}, | ||
| 30 | {Service::GSP::CommandId::SET_MEMORY_FILL, "SET_MEMORY_FILL"}, | ||
| 31 | {Service::GSP::CommandId::SET_DISPLAY_TRANSFER, "SET_DISPLAY_TRANSFER"}, | ||
| 32 | {Service::GSP::CommandId::SET_TEXTURE_COPY, "SET_TEXTURE_COPY"}, | ||
| 33 | {Service::GSP::CommandId::CACHE_FLUSH, "CACHE_FLUSH"}, | ||
| 34 | }; | ||
| 35 | const u32* command_data = reinterpret_cast<const u32*>(&command); | ||
| 36 | QString str = QString("%1 %2 %3 %4 %5 %6 %7 %8 %9") | ||
| 37 | .arg(command_names[command.id]) | ||
| 38 | .arg(command_data[0], 8, 16, QLatin1Char('0')) | ||
| 39 | .arg(command_data[1], 8, 16, QLatin1Char('0')) | ||
| 40 | .arg(command_data[2], 8, 16, QLatin1Char('0')) | ||
| 41 | .arg(command_data[3], 8, 16, QLatin1Char('0')) | ||
| 42 | .arg(command_data[4], 8, 16, QLatin1Char('0')) | ||
| 43 | .arg(command_data[5], 8, 16, QLatin1Char('0')) | ||
| 44 | .arg(command_data[6], 8, 16, QLatin1Char('0')) | ||
| 45 | .arg(command_data[7], 8, 16, QLatin1Char('0')); | ||
| 46 | return QVariant(str); | ||
| 47 | } else { | ||
| 48 | return QVariant(); | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | void GPUCommandStreamItemModel::GXCommandProcessed(int total_command_count) { | ||
| 53 | emit GXCommandFinished(total_command_count); | ||
| 54 | } | ||
| 55 | |||
| 56 | void GPUCommandStreamItemModel::OnGXCommandFinishedInternal(int total_command_count) { | ||
| 57 | if (total_command_count == 0) | ||
| 58 | return; | ||
| 59 | |||
| 60 | int prev_command_count = command_count; | ||
| 61 | command_count = total_command_count; | ||
| 62 | emit dataChanged(index(prev_command_count, 0), index(total_command_count - 1, 0)); | ||
| 63 | } | ||
| 64 | |||
| 65 | GPUCommandStreamWidget::GPUCommandStreamWidget(QWidget* parent) | ||
| 66 | : QDockWidget(tr("Graphics Debugger"), parent) { | ||
| 67 | setObjectName("GraphicsDebugger"); | ||
| 68 | |||
| 69 | GPUCommandStreamItemModel* command_model = new GPUCommandStreamItemModel(this); | ||
| 70 | g_debugger.RegisterObserver(command_model); | ||
| 71 | |||
| 72 | QListView* command_list = new QListView; | ||
| 73 | command_list->setModel(command_model); | ||
| 74 | command_list->setFont(GetMonospaceFont()); | ||
| 75 | |||
| 76 | setWidget(command_list); | ||
| 77 | } | ||
diff --git a/src/citra_qt/debugger/graphics/graphics.h b/src/citra_qt/debugger/graphics/graphics.h deleted file mode 100644 index 8837fb792..000000000 --- a/src/citra_qt/debugger/graphics/graphics.h +++ /dev/null | |||
| @@ -1,41 +0,0 @@ | |||
| 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 <QAbstractListModel> | ||
| 8 | #include <QDockWidget> | ||
| 9 | #include "video_core/gpu_debugger.h" | ||
| 10 | |||
| 11 | class GPUCommandStreamItemModel : public QAbstractListModel, | ||
| 12 | public GraphicsDebugger::DebuggerObserver { | ||
| 13 | Q_OBJECT | ||
| 14 | |||
| 15 | public: | ||
| 16 | explicit GPUCommandStreamItemModel(QObject* parent); | ||
| 17 | |||
| 18 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; | ||
| 19 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; | ||
| 20 | |||
| 21 | public: | ||
| 22 | void GXCommandProcessed(int total_command_count) override; | ||
| 23 | |||
| 24 | public slots: | ||
| 25 | void OnGXCommandFinishedInternal(int total_command_count); | ||
| 26 | |||
| 27 | signals: | ||
| 28 | void GXCommandFinished(int total_command_count); | ||
| 29 | |||
| 30 | private: | ||
| 31 | int command_count; | ||
| 32 | }; | ||
| 33 | |||
| 34 | class GPUCommandStreamWidget : public QDockWidget { | ||
| 35 | Q_OBJECT | ||
| 36 | |||
| 37 | public: | ||
| 38 | GPUCommandStreamWidget(QWidget* parent = nullptr); | ||
| 39 | |||
| 40 | private: | ||
| 41 | }; | ||
diff --git a/src/citra_qt/debugger/graphics/graphics_breakpoint_observer.cpp b/src/citra_qt/debugger/graphics/graphics_breakpoint_observer.cpp deleted file mode 100644 index dc6070dea..000000000 --- a/src/citra_qt/debugger/graphics/graphics_breakpoint_observer.cpp +++ /dev/null | |||
| @@ -1,27 +0,0 @@ | |||
| 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 "citra_qt/debugger/graphics/graphics_breakpoint_observer.h" | ||
| 7 | |||
| 8 | BreakPointObserverDock::BreakPointObserverDock(std::shared_ptr<Pica::DebugContext> debug_context, | ||
| 9 | const QString& title, QWidget* parent) | ||
| 10 | : QDockWidget(title, parent), BreakPointObserver(debug_context) { | ||
| 11 | qRegisterMetaType<Pica::DebugContext::Event>("Pica::DebugContext::Event"); | ||
| 12 | |||
| 13 | connect(this, SIGNAL(Resumed()), this, SLOT(OnResumed())); | ||
| 14 | |||
| 15 | // NOTE: This signal is emitted from a non-GUI thread, but connect() takes | ||
| 16 | // care of delaying its handling to the GUI thread. | ||
| 17 | connect(this, SIGNAL(BreakPointHit(Pica::DebugContext::Event, void*)), this, | ||
| 18 | SLOT(OnBreakPointHit(Pica::DebugContext::Event, void*)), Qt::BlockingQueuedConnection); | ||
| 19 | } | ||
| 20 | |||
| 21 | void BreakPointObserverDock::OnPicaBreakPointHit(Pica::DebugContext::Event event, void* data) { | ||
| 22 | emit BreakPointHit(event, data); | ||
| 23 | } | ||
| 24 | |||
| 25 | void BreakPointObserverDock::OnPicaResume() { | ||
| 26 | emit Resumed(); | ||
| 27 | } | ||
diff --git a/src/citra_qt/debugger/graphics/graphics_breakpoint_observer.h b/src/citra_qt/debugger/graphics/graphics_breakpoint_observer.h deleted file mode 100644 index e77df4f5b..000000000 --- a/src/citra_qt/debugger/graphics/graphics_breakpoint_observer.h +++ /dev/null | |||
| @@ -1,33 +0,0 @@ | |||
| 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 | #include "video_core/debug_utils/debug_utils.h" | ||
| 9 | |||
| 10 | /** | ||
| 11 | * Utility class which forwards calls to OnPicaBreakPointHit and OnPicaResume to public slots. | ||
| 12 | * This is because the Pica breakpoint callbacks are called from a non-GUI thread, while | ||
| 13 | * the widget usually wants to perform reactions in the GUI thread. | ||
| 14 | */ | ||
| 15 | class BreakPointObserverDock : public QDockWidget, | ||
| 16 | protected Pica::DebugContext::BreakPointObserver { | ||
| 17 | Q_OBJECT | ||
| 18 | |||
| 19 | public: | ||
| 20 | BreakPointObserverDock(std::shared_ptr<Pica::DebugContext> debug_context, const QString& title, | ||
| 21 | QWidget* parent = nullptr); | ||
| 22 | |||
| 23 | void OnPicaBreakPointHit(Pica::DebugContext::Event event, void* data) override; | ||
| 24 | void OnPicaResume() override; | ||
| 25 | |||
| 26 | private slots: | ||
| 27 | virtual void OnBreakPointHit(Pica::DebugContext::Event event, void* data) = 0; | ||
| 28 | virtual void OnResumed() = 0; | ||
| 29 | |||
| 30 | signals: | ||
| 31 | void Resumed(); | ||
| 32 | void BreakPointHit(Pica::DebugContext::Event event, void* data); | ||
| 33 | }; | ||
diff --git a/src/citra_qt/debugger/graphics/graphics_breakpoints.cpp b/src/citra_qt/debugger/graphics/graphics_breakpoints.cpp deleted file mode 100644 index 030828ba8..000000000 --- a/src/citra_qt/debugger/graphics/graphics_breakpoints.cpp +++ /dev/null | |||
| @@ -1,213 +0,0 @@ | |||
| 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 <QLabel> | ||
| 6 | #include <QMetaType> | ||
| 7 | #include <QPushButton> | ||
| 8 | #include <QTreeView> | ||
| 9 | #include <QVBoxLayout> | ||
| 10 | #include "citra_qt/debugger/graphics/graphics_breakpoints.h" | ||
| 11 | #include "citra_qt/debugger/graphics/graphics_breakpoints_p.h" | ||
| 12 | #include "common/assert.h" | ||
| 13 | |||
| 14 | BreakPointModel::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 | int BreakPointModel::columnCount(const QModelIndex& parent) const { | ||
| 20 | return 1; | ||
| 21 | } | ||
| 22 | |||
| 23 | int BreakPointModel::rowCount(const QModelIndex& parent) const { | ||
| 24 | return static_cast<int>(Pica::DebugContext::Event::NumEvents); | ||
| 25 | } | ||
| 26 | |||
| 27 | QVariant BreakPointModel::data(const QModelIndex& index, int role) const { | ||
| 28 | const auto event = static_cast<Pica::DebugContext::Event>(index.row()); | ||
| 29 | |||
| 30 | switch (role) { | ||
| 31 | case Qt::DisplayRole: { | ||
| 32 | if (index.column() == 0) { | ||
| 33 | static const std::map<Pica::DebugContext::Event, QString> map = { | ||
| 34 | {Pica::DebugContext::Event::PicaCommandLoaded, tr("Pica command loaded")}, | ||
| 35 | {Pica::DebugContext::Event::PicaCommandProcessed, tr("Pica command processed")}, | ||
| 36 | {Pica::DebugContext::Event::IncomingPrimitiveBatch, tr("Incoming primitive batch")}, | ||
| 37 | {Pica::DebugContext::Event::FinishedPrimitiveBatch, tr("Finished primitive batch")}, | ||
| 38 | {Pica::DebugContext::Event::VertexShaderInvocation, tr("Vertex shader invocation")}, | ||
| 39 | {Pica::DebugContext::Event::IncomingDisplayTransfer, | ||
| 40 | tr("Incoming display transfer")}, | ||
| 41 | {Pica::DebugContext::Event::GSPCommandProcessed, tr("GSP command processed")}, | ||
| 42 | {Pica::DebugContext::Event::BufferSwapped, tr("Buffers swapped")}, | ||
| 43 | }; | ||
| 44 | |||
| 45 | DEBUG_ASSERT(map.size() == static_cast<size_t>(Pica::DebugContext::Event::NumEvents)); | ||
| 46 | return (map.find(event) != map.end()) ? map.at(event) : QString(); | ||
| 47 | } | ||
| 48 | |||
| 49 | break; | ||
| 50 | } | ||
| 51 | |||
| 52 | case Qt::CheckStateRole: { | ||
| 53 | if (index.column() == 0) | ||
| 54 | return data(index, Role_IsEnabled).toBool() ? Qt::Checked : Qt::Unchecked; | ||
| 55 | break; | ||
| 56 | } | ||
| 57 | |||
| 58 | case Qt::BackgroundRole: { | ||
| 59 | if (at_breakpoint && index.row() == static_cast<int>(active_breakpoint)) { | ||
| 60 | return QBrush(QColor(0xE0, 0xE0, 0x10)); | ||
| 61 | } | ||
| 62 | break; | ||
| 63 | } | ||
| 64 | |||
| 65 | case Role_IsEnabled: { | ||
| 66 | auto context = context_weak.lock(); | ||
| 67 | return context && context->breakpoints[(int)event].enabled; | ||
| 68 | } | ||
| 69 | |||
| 70 | default: | ||
| 71 | break; | ||
| 72 | } | ||
| 73 | return QVariant(); | ||
| 74 | } | ||
| 75 | |||
| 76 | Qt::ItemFlags BreakPointModel::flags(const QModelIndex& index) const { | ||
| 77 | if (!index.isValid()) | ||
| 78 | return 0; | ||
| 79 | |||
| 80 | Qt::ItemFlags flags = Qt::ItemIsEnabled; | ||
| 81 | if (index.column() == 0) | ||
| 82 | flags |= Qt::ItemIsUserCheckable; | ||
| 83 | return flags; | ||
| 84 | } | ||
| 85 | |||
| 86 | bool BreakPointModel::setData(const QModelIndex& index, const QVariant& value, int role) { | ||
| 87 | const auto event = static_cast<Pica::DebugContext::Event>(index.row()); | ||
| 88 | |||
| 89 | switch (role) { | ||
| 90 | case Qt::CheckStateRole: { | ||
| 91 | if (index.column() != 0) | ||
| 92 | return false; | ||
| 93 | |||
| 94 | auto context = context_weak.lock(); | ||
| 95 | if (!context) | ||
| 96 | return false; | ||
| 97 | |||
| 98 | context->breakpoints[(int)event].enabled = value == Qt::Checked; | ||
| 99 | QModelIndex changed_index = createIndex(index.row(), 0); | ||
| 100 | emit dataChanged(changed_index, changed_index); | ||
| 101 | return true; | ||
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 105 | return false; | ||
| 106 | } | ||
| 107 | |||
| 108 | void BreakPointModel::OnBreakPointHit(Pica::DebugContext::Event event) { | ||
| 109 | auto context = context_weak.lock(); | ||
| 110 | if (!context) | ||
| 111 | return; | ||
| 112 | |||
| 113 | active_breakpoint = context->active_breakpoint; | ||
| 114 | at_breakpoint = context->at_breakpoint; | ||
| 115 | emit dataChanged(createIndex(static_cast<int>(event), 0), | ||
| 116 | createIndex(static_cast<int>(event), 0)); | ||
| 117 | } | ||
| 118 | |||
| 119 | void BreakPointModel::OnResumed() { | ||
| 120 | auto context = context_weak.lock(); | ||
| 121 | if (!context) | ||
| 122 | return; | ||
| 123 | |||
| 124 | at_breakpoint = context->at_breakpoint; | ||
| 125 | emit dataChanged(createIndex(static_cast<int>(active_breakpoint), 0), | ||
| 126 | createIndex(static_cast<int>(active_breakpoint), 0)); | ||
| 127 | active_breakpoint = context->active_breakpoint; | ||
| 128 | } | ||
| 129 | |||
| 130 | GraphicsBreakPointsWidget::GraphicsBreakPointsWidget( | ||
| 131 | std::shared_ptr<Pica::DebugContext> debug_context, QWidget* parent) | ||
| 132 | : QDockWidget(tr("Pica Breakpoints"), parent), | ||
| 133 | Pica::DebugContext::BreakPointObserver(debug_context) { | ||
| 134 | setObjectName("PicaBreakPointsWidget"); | ||
| 135 | |||
| 136 | status_text = new QLabel(tr("Emulation running")); | ||
| 137 | resume_button = new QPushButton(tr("Resume")); | ||
| 138 | resume_button->setEnabled(false); | ||
| 139 | |||
| 140 | breakpoint_model = new BreakPointModel(debug_context, this); | ||
| 141 | breakpoint_list = new QTreeView; | ||
| 142 | breakpoint_list->setRootIsDecorated(false); | ||
| 143 | breakpoint_list->setHeaderHidden(true); | ||
| 144 | breakpoint_list->setModel(breakpoint_model); | ||
| 145 | |||
| 146 | qRegisterMetaType<Pica::DebugContext::Event>("Pica::DebugContext::Event"); | ||
| 147 | |||
| 148 | connect(breakpoint_list, SIGNAL(doubleClicked(const QModelIndex&)), this, | ||
| 149 | SLOT(OnItemDoubleClicked(const QModelIndex&))); | ||
| 150 | |||
| 151 | connect(resume_button, SIGNAL(clicked()), this, SLOT(OnResumeRequested())); | ||
| 152 | |||
| 153 | connect(this, SIGNAL(BreakPointHit(Pica::DebugContext::Event, void*)), this, | ||
| 154 | SLOT(OnBreakPointHit(Pica::DebugContext::Event, void*)), Qt::BlockingQueuedConnection); | ||
| 155 | connect(this, SIGNAL(Resumed()), this, SLOT(OnResumed())); | ||
| 156 | |||
| 157 | connect(this, SIGNAL(BreakPointHit(Pica::DebugContext::Event, void*)), breakpoint_model, | ||
| 158 | SLOT(OnBreakPointHit(Pica::DebugContext::Event)), Qt::BlockingQueuedConnection); | ||
| 159 | connect(this, SIGNAL(Resumed()), breakpoint_model, SLOT(OnResumed())); | ||
| 160 | |||
| 161 | connect(this, SIGNAL(BreakPointsChanged(const QModelIndex&, const QModelIndex&)), | ||
| 162 | breakpoint_model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&))); | ||
| 163 | |||
| 164 | QWidget* main_widget = new QWidget; | ||
| 165 | auto main_layout = new QVBoxLayout; | ||
| 166 | { | ||
| 167 | auto sub_layout = new QHBoxLayout; | ||
| 168 | sub_layout->addWidget(status_text); | ||
| 169 | sub_layout->addWidget(resume_button); | ||
| 170 | main_layout->addLayout(sub_layout); | ||
| 171 | } | ||
| 172 | main_layout->addWidget(breakpoint_list); | ||
| 173 | main_widget->setLayout(main_layout); | ||
| 174 | |||
| 175 | setWidget(main_widget); | ||
| 176 | } | ||
| 177 | |||
| 178 | void GraphicsBreakPointsWidget::OnPicaBreakPointHit(Event event, void* data) { | ||
| 179 | // Process in GUI thread | ||
| 180 | emit BreakPointHit(event, data); | ||
| 181 | } | ||
| 182 | |||
| 183 | void GraphicsBreakPointsWidget::OnBreakPointHit(Pica::DebugContext::Event event, void* data) { | ||
| 184 | status_text->setText(tr("Emulation halted at breakpoint")); | ||
| 185 | resume_button->setEnabled(true); | ||
| 186 | } | ||
| 187 | |||
| 188 | void GraphicsBreakPointsWidget::OnPicaResume() { | ||
| 189 | // Process in GUI thread | ||
| 190 | emit Resumed(); | ||
| 191 | } | ||
| 192 | |||
| 193 | void GraphicsBreakPointsWidget::OnResumed() { | ||
| 194 | status_text->setText(tr("Emulation running")); | ||
| 195 | resume_button->setEnabled(false); | ||
| 196 | } | ||
| 197 | |||
| 198 | void GraphicsBreakPointsWidget::OnResumeRequested() { | ||
| 199 | if (auto context = context_weak.lock()) | ||
| 200 | context->Resume(); | ||
| 201 | } | ||
| 202 | |||
| 203 | void GraphicsBreakPointsWidget::OnItemDoubleClicked(const QModelIndex& index) { | ||
| 204 | if (!index.isValid()) | ||
| 205 | return; | ||
| 206 | |||
| 207 | QModelIndex check_index = breakpoint_list->model()->index(index.row(), 0); | ||
| 208 | QVariant enabled = breakpoint_list->model()->data(check_index, Qt::CheckStateRole); | ||
| 209 | QVariant new_state = Qt::Unchecked; | ||
| 210 | if (enabled == Qt::Unchecked) | ||
| 211 | new_state = Qt::Checked; | ||
| 212 | breakpoint_list->model()->setData(check_index, new_state, Qt::CheckStateRole); | ||
| 213 | } | ||
diff --git a/src/citra_qt/debugger/graphics/graphics_breakpoints.h b/src/citra_qt/debugger/graphics/graphics_breakpoints.h deleted file mode 100644 index bec72a2db..000000000 --- a/src/citra_qt/debugger/graphics/graphics_breakpoints.h +++ /dev/null | |||
| @@ -1,46 +0,0 @@ | |||
| 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 | #include <QDockWidget> | ||
| 9 | #include "video_core/debug_utils/debug_utils.h" | ||
| 10 | |||
| 11 | class QLabel; | ||
| 12 | class QPushButton; | ||
| 13 | class QTreeView; | ||
| 14 | |||
| 15 | class BreakPointModel; | ||
| 16 | |||
| 17 | class GraphicsBreakPointsWidget : public QDockWidget, Pica::DebugContext::BreakPointObserver { | ||
| 18 | Q_OBJECT | ||
| 19 | |||
| 20 | using Event = Pica::DebugContext::Event; | ||
| 21 | |||
| 22 | public: | ||
| 23 | explicit GraphicsBreakPointsWidget(std::shared_ptr<Pica::DebugContext> debug_context, | ||
| 24 | QWidget* parent = nullptr); | ||
| 25 | |||
| 26 | void OnPicaBreakPointHit(Pica::DebugContext::Event event, void* data) override; | ||
| 27 | void OnPicaResume() override; | ||
| 28 | |||
| 29 | public slots: | ||
| 30 | void OnBreakPointHit(Pica::DebugContext::Event event, void* data); | ||
| 31 | void OnItemDoubleClicked(const QModelIndex&); | ||
| 32 | void OnResumeRequested(); | ||
| 33 | void OnResumed(); | ||
| 34 | |||
| 35 | signals: | ||
| 36 | void Resumed(); | ||
| 37 | void BreakPointHit(Pica::DebugContext::Event event, void* data); | ||
| 38 | void BreakPointsChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight); | ||
| 39 | |||
| 40 | private: | ||
| 41 | QLabel* status_text; | ||
| 42 | QPushButton* resume_button; | ||
| 43 | |||
| 44 | BreakPointModel* breakpoint_model; | ||
| 45 | QTreeView* breakpoint_list; | ||
| 46 | }; | ||
diff --git a/src/citra_qt/debugger/graphics/graphics_breakpoints_p.h b/src/citra_qt/debugger/graphics/graphics_breakpoints_p.h deleted file mode 100644 index dc64706bd..000000000 --- a/src/citra_qt/debugger/graphics/graphics_breakpoints_p.h +++ /dev/null | |||
| @@ -1,36 +0,0 @@ | |||
| 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 | #include <QAbstractListModel> | ||
| 9 | #include "video_core/debug_utils/debug_utils.h" | ||
| 10 | |||
| 11 | class BreakPointModel : public QAbstractListModel { | ||
| 12 | Q_OBJECT | ||
| 13 | |||
| 14 | public: | ||
| 15 | enum { | ||
| 16 | Role_IsEnabled = Qt::UserRole, | ||
| 17 | }; | ||
| 18 | |||
| 19 | BreakPointModel(std::shared_ptr<Pica::DebugContext> context, QObject* parent); | ||
| 20 | |||
| 21 | int columnCount(const QModelIndex& parent = QModelIndex()) const override; | ||
| 22 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; | ||
| 23 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; | ||
| 24 | Qt::ItemFlags flags(const QModelIndex& index) const override; | ||
| 25 | |||
| 26 | bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; | ||
| 27 | |||
| 28 | public slots: | ||
| 29 | void OnBreakPointHit(Pica::DebugContext::Event event); | ||
| 30 | void OnResumed(); | ||
| 31 | |||
| 32 | private: | ||
| 33 | std::weak_ptr<Pica::DebugContext> context_weak; | ||
| 34 | bool at_breakpoint; | ||
| 35 | Pica::DebugContext::Event active_breakpoint; | ||
| 36 | }; | ||
diff --git a/src/citra_qt/debugger/graphics/graphics_cmdlists.cpp b/src/citra_qt/debugger/graphics/graphics_cmdlists.cpp deleted file mode 100644 index ce2b9fa50..000000000 --- a/src/citra_qt/debugger/graphics/graphics_cmdlists.cpp +++ /dev/null | |||
| @@ -1,259 +0,0 @@ | |||
| 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 <QApplication> | ||
| 6 | #include <QClipboard> | ||
| 7 | #include <QComboBox> | ||
| 8 | #include <QHeaderView> | ||
| 9 | #include <QLabel> | ||
| 10 | #include <QListView> | ||
| 11 | #include <QMainWindow> | ||
| 12 | #include <QPushButton> | ||
| 13 | #include <QSpinBox> | ||
| 14 | #include <QTreeView> | ||
| 15 | #include <QVBoxLayout> | ||
| 16 | #include "citra_qt/debugger/graphics/graphics_cmdlists.h" | ||
| 17 | #include "citra_qt/util/spinbox.h" | ||
| 18 | #include "citra_qt/util/util.h" | ||
| 19 | #include "common/vector_math.h" | ||
| 20 | #include "core/memory.h" | ||
| 21 | #include "video_core/debug_utils/debug_utils.h" | ||
| 22 | #include "video_core/pica_state.h" | ||
| 23 | #include "video_core/regs.h" | ||
| 24 | #include "video_core/texture/texture_decode.h" | ||
| 25 | |||
| 26 | namespace { | ||
| 27 | QImage LoadTexture(const u8* src, const Pica::Texture::TextureInfo& info) { | ||
| 28 | QImage decoded_image(info.width, info.height, QImage::Format_ARGB32); | ||
| 29 | for (u32 y = 0; y < info.height; ++y) { | ||
| 30 | for (u32 x = 0; x < info.width; ++x) { | ||
| 31 | Math::Vec4<u8> color = Pica::Texture::LookupTexture(src, x, y, info, true); | ||
| 32 | decoded_image.setPixel(x, y, qRgba(color.r(), color.g(), color.b(), color.a())); | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | return decoded_image; | ||
| 37 | } | ||
| 38 | |||
| 39 | class TextureInfoWidget : public QWidget { | ||
| 40 | public: | ||
| 41 | TextureInfoWidget(const u8* src, const Pica::Texture::TextureInfo& info, | ||
| 42 | QWidget* parent = nullptr) | ||
| 43 | : QWidget(parent) { | ||
| 44 | |||
| 45 | QLabel* image_widget = new QLabel; | ||
| 46 | QPixmap image_pixmap = QPixmap::fromImage(LoadTexture(src, info)); | ||
| 47 | image_pixmap = image_pixmap.scaled(200, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation); | ||
| 48 | image_widget->setPixmap(image_pixmap); | ||
| 49 | |||
| 50 | QVBoxLayout* layout = new QVBoxLayout; | ||
| 51 | layout->addWidget(image_widget); | ||
| 52 | setLayout(layout); | ||
| 53 | } | ||
| 54 | }; | ||
| 55 | } // Anonymous namespace | ||
| 56 | |||
| 57 | GPUCommandListModel::GPUCommandListModel(QObject* parent) : QAbstractListModel(parent) {} | ||
| 58 | |||
| 59 | int GPUCommandListModel::rowCount(const QModelIndex& parent) const { | ||
| 60 | return static_cast<int>(pica_trace.writes.size()); | ||
| 61 | } | ||
| 62 | |||
| 63 | int GPUCommandListModel::columnCount(const QModelIndex& parent) const { | ||
| 64 | return 4; | ||
| 65 | } | ||
| 66 | |||
| 67 | QVariant GPUCommandListModel::data(const QModelIndex& index, int role) const { | ||
| 68 | if (!index.isValid()) | ||
| 69 | return QVariant(); | ||
| 70 | |||
| 71 | const auto& write = pica_trace.writes[index.row()]; | ||
| 72 | |||
| 73 | if (role == Qt::DisplayRole) { | ||
| 74 | switch (index.column()) { | ||
| 75 | case 0: | ||
| 76 | return QString::fromLatin1(Pica::Regs::GetRegisterName(write.cmd_id)); | ||
| 77 | case 1: | ||
| 78 | return QString("%1").arg(write.cmd_id, 3, 16, QLatin1Char('0')); | ||
| 79 | case 2: | ||
| 80 | return QString("%1").arg(write.mask, 4, 2, QLatin1Char('0')); | ||
| 81 | case 3: | ||
| 82 | return QString("%1").arg(write.value, 8, 16, QLatin1Char('0')); | ||
| 83 | } | ||
| 84 | } else if (role == CommandIdRole) { | ||
| 85 | return QVariant::fromValue<int>(write.cmd_id); | ||
| 86 | } | ||
| 87 | |||
| 88 | return QVariant(); | ||
| 89 | } | ||
| 90 | |||
| 91 | QVariant GPUCommandListModel::headerData(int section, Qt::Orientation orientation, int role) const { | ||
| 92 | switch (role) { | ||
| 93 | case Qt::DisplayRole: { | ||
| 94 | switch (section) { | ||
| 95 | case 0: | ||
| 96 | return tr("Command Name"); | ||
| 97 | case 1: | ||
| 98 | return tr("Register"); | ||
| 99 | case 2: | ||
| 100 | return tr("Mask"); | ||
| 101 | case 3: | ||
| 102 | return tr("New Value"); | ||
| 103 | } | ||
| 104 | |||
| 105 | break; | ||
| 106 | } | ||
| 107 | } | ||
| 108 | |||
| 109 | return QVariant(); | ||
| 110 | } | ||
| 111 | |||
| 112 | void GPUCommandListModel::OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace& trace) { | ||
| 113 | beginResetModel(); | ||
| 114 | |||
| 115 | pica_trace = trace; | ||
| 116 | |||
| 117 | endResetModel(); | ||
| 118 | } | ||
| 119 | |||
| 120 | #define COMMAND_IN_RANGE(cmd_id, reg_name) \ | ||
| 121 | (cmd_id >= PICA_REG_INDEX(reg_name) && \ | ||
| 122 | cmd_id < PICA_REG_INDEX(reg_name) + sizeof(decltype(Pica::g_state.regs.reg_name)) / 4) | ||
| 123 | |||
| 124 | void GPUCommandListWidget::OnCommandDoubleClicked(const QModelIndex& index) { | ||
| 125 | const unsigned int command_id = | ||
| 126 | list_widget->model()->data(index, GPUCommandListModel::CommandIdRole).toUInt(); | ||
| 127 | if (COMMAND_IN_RANGE(command_id, texturing.texture0) || | ||
| 128 | COMMAND_IN_RANGE(command_id, texturing.texture1) || | ||
| 129 | COMMAND_IN_RANGE(command_id, texturing.texture2)) { | ||
| 130 | |||
| 131 | unsigned texture_index; | ||
| 132 | if (COMMAND_IN_RANGE(command_id, texturing.texture0)) { | ||
| 133 | texture_index = 0; | ||
| 134 | } else if (COMMAND_IN_RANGE(command_id, texturing.texture1)) { | ||
| 135 | texture_index = 1; | ||
| 136 | } else if (COMMAND_IN_RANGE(command_id, texturing.texture2)) { | ||
| 137 | texture_index = 2; | ||
| 138 | } else { | ||
| 139 | UNREACHABLE_MSG("Unknown texture command"); | ||
| 140 | } | ||
| 141 | |||
| 142 | // TODO: Open a surface debugger | ||
| 143 | } | ||
| 144 | } | ||
| 145 | |||
| 146 | void GPUCommandListWidget::SetCommandInfo(const QModelIndex& index) { | ||
| 147 | QWidget* new_info_widget = nullptr; | ||
| 148 | |||
| 149 | const unsigned int command_id = | ||
| 150 | list_widget->model()->data(index, GPUCommandListModel::CommandIdRole).toUInt(); | ||
| 151 | if (COMMAND_IN_RANGE(command_id, texturing.texture0) || | ||
| 152 | COMMAND_IN_RANGE(command_id, texturing.texture1) || | ||
| 153 | COMMAND_IN_RANGE(command_id, texturing.texture2)) { | ||
| 154 | |||
| 155 | unsigned texture_index; | ||
| 156 | if (COMMAND_IN_RANGE(command_id, texturing.texture0)) { | ||
| 157 | texture_index = 0; | ||
| 158 | } else if (COMMAND_IN_RANGE(command_id, texturing.texture1)) { | ||
| 159 | texture_index = 1; | ||
| 160 | } else { | ||
| 161 | texture_index = 2; | ||
| 162 | } | ||
| 163 | |||
| 164 | const auto texture = Pica::g_state.regs.texturing.GetTextures()[texture_index]; | ||
| 165 | const auto config = texture.config; | ||
| 166 | const auto format = texture.format; | ||
| 167 | |||
| 168 | const auto info = Pica::Texture::TextureInfo::FromPicaRegister(config, format); | ||
| 169 | const u8* src = Memory::GetPhysicalPointer(config.GetPhysicalAddress()); | ||
| 170 | new_info_widget = new TextureInfoWidget(src, info); | ||
| 171 | } | ||
| 172 | if (command_info_widget) { | ||
| 173 | delete command_info_widget; | ||
| 174 | command_info_widget = nullptr; | ||
| 175 | } | ||
| 176 | if (new_info_widget) { | ||
| 177 | widget()->layout()->addWidget(new_info_widget); | ||
| 178 | command_info_widget = new_info_widget; | ||
| 179 | } | ||
| 180 | } | ||
| 181 | #undef COMMAND_IN_RANGE | ||
| 182 | |||
| 183 | GPUCommandListWidget::GPUCommandListWidget(QWidget* parent) | ||
| 184 | : QDockWidget(tr("Pica Command List"), parent) { | ||
| 185 | setObjectName("Pica Command List"); | ||
| 186 | GPUCommandListModel* model = new GPUCommandListModel(this); | ||
| 187 | |||
| 188 | QWidget* main_widget = new QWidget; | ||
| 189 | |||
| 190 | list_widget = new QTreeView; | ||
| 191 | list_widget->setModel(model); | ||
| 192 | list_widget->setFont(GetMonospaceFont()); | ||
| 193 | list_widget->setRootIsDecorated(false); | ||
| 194 | list_widget->setUniformRowHeights(true); | ||
| 195 | |||
| 196 | #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) | ||
| 197 | list_widget->header()->setSectionResizeMode(QHeaderView::ResizeToContents); | ||
| 198 | #else | ||
| 199 | list_widget->header()->setResizeMode(QHeaderView::ResizeToContents); | ||
| 200 | #endif | ||
| 201 | |||
| 202 | connect(list_widget->selectionModel(), | ||
| 203 | SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)), this, | ||
| 204 | SLOT(SetCommandInfo(const QModelIndex&))); | ||
| 205 | connect(list_widget, SIGNAL(doubleClicked(const QModelIndex&)), this, | ||
| 206 | SLOT(OnCommandDoubleClicked(const QModelIndex&))); | ||
| 207 | |||
| 208 | toggle_tracing = new QPushButton(tr("Start Tracing")); | ||
| 209 | QPushButton* copy_all = new QPushButton(tr("Copy All")); | ||
| 210 | |||
| 211 | connect(toggle_tracing, SIGNAL(clicked()), this, SLOT(OnToggleTracing())); | ||
| 212 | connect(this, SIGNAL(TracingFinished(const Pica::DebugUtils::PicaTrace&)), model, | ||
| 213 | SLOT(OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace&))); | ||
| 214 | |||
| 215 | connect(copy_all, SIGNAL(clicked()), this, SLOT(CopyAllToClipboard())); | ||
| 216 | |||
| 217 | command_info_widget = nullptr; | ||
| 218 | |||
| 219 | QVBoxLayout* main_layout = new QVBoxLayout; | ||
| 220 | main_layout->addWidget(list_widget); | ||
| 221 | { | ||
| 222 | QHBoxLayout* sub_layout = new QHBoxLayout; | ||
| 223 | sub_layout->addWidget(toggle_tracing); | ||
| 224 | sub_layout->addWidget(copy_all); | ||
| 225 | main_layout->addLayout(sub_layout); | ||
| 226 | } | ||
| 227 | main_widget->setLayout(main_layout); | ||
| 228 | |||
| 229 | setWidget(main_widget); | ||
| 230 | } | ||
| 231 | |||
| 232 | void GPUCommandListWidget::OnToggleTracing() { | ||
| 233 | if (!Pica::DebugUtils::IsPicaTracing()) { | ||
| 234 | Pica::DebugUtils::StartPicaTracing(); | ||
| 235 | toggle_tracing->setText(tr("Finish Tracing")); | ||
| 236 | } else { | ||
| 237 | pica_trace = Pica::DebugUtils::FinishPicaTracing(); | ||
| 238 | emit TracingFinished(*pica_trace); | ||
| 239 | toggle_tracing->setText(tr("Start Tracing")); | ||
| 240 | } | ||
| 241 | } | ||
| 242 | |||
| 243 | void GPUCommandListWidget::CopyAllToClipboard() { | ||
| 244 | QClipboard* clipboard = QApplication::clipboard(); | ||
| 245 | QString text; | ||
| 246 | |||
| 247 | QAbstractItemModel* model = static_cast<QAbstractItemModel*>(list_widget->model()); | ||
| 248 | |||
| 249 | for (int row = 0; row < model->rowCount({}); ++row) { | ||
| 250 | for (int col = 0; col < model->columnCount({}); ++col) { | ||
| 251 | QModelIndex index = model->index(row, col); | ||
| 252 | text += model->data(index).value<QString>(); | ||
| 253 | text += '\t'; | ||
| 254 | } | ||
| 255 | text += '\n'; | ||
| 256 | } | ||
| 257 | |||
| 258 | clipboard->setText(text); | ||
| 259 | } | ||
diff --git a/src/citra_qt/debugger/graphics/graphics_cmdlists.h b/src/citra_qt/debugger/graphics/graphics_cmdlists.h deleted file mode 100644 index 8f40b94c5..000000000 --- a/src/citra_qt/debugger/graphics/graphics_cmdlists.h +++ /dev/null | |||
| @@ -1,61 +0,0 @@ | |||
| 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 <QAbstractListModel> | ||
| 8 | #include <QDockWidget> | ||
| 9 | #include "video_core/debug_utils/debug_utils.h" | ||
| 10 | #include "video_core/gpu_debugger.h" | ||
| 11 | |||
| 12 | class QPushButton; | ||
| 13 | class QTreeView; | ||
| 14 | |||
| 15 | class GPUCommandListModel : public QAbstractListModel { | ||
| 16 | Q_OBJECT | ||
| 17 | |||
| 18 | public: | ||
| 19 | enum { | ||
| 20 | CommandIdRole = Qt::UserRole, | ||
| 21 | }; | ||
| 22 | |||
| 23 | explicit GPUCommandListModel(QObject* parent); | ||
| 24 | |||
| 25 | int columnCount(const QModelIndex& parent = QModelIndex()) const override; | ||
| 26 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; | ||
| 27 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; | ||
| 28 | QVariant headerData(int section, Qt::Orientation orientation, | ||
| 29 | int role = Qt::DisplayRole) const override; | ||
| 30 | |||
| 31 | public slots: | ||
| 32 | void OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace& trace); | ||
| 33 | |||
| 34 | private: | ||
| 35 | Pica::DebugUtils::PicaTrace pica_trace; | ||
| 36 | }; | ||
| 37 | |||
| 38 | class GPUCommandListWidget : public QDockWidget { | ||
| 39 | Q_OBJECT | ||
| 40 | |||
| 41 | public: | ||
| 42 | explicit GPUCommandListWidget(QWidget* parent = nullptr); | ||
| 43 | |||
| 44 | public slots: | ||
| 45 | void OnToggleTracing(); | ||
| 46 | void OnCommandDoubleClicked(const QModelIndex&); | ||
| 47 | |||
| 48 | void SetCommandInfo(const QModelIndex&); | ||
| 49 | |||
| 50 | void CopyAllToClipboard(); | ||
| 51 | |||
| 52 | signals: | ||
| 53 | void TracingFinished(const Pica::DebugUtils::PicaTrace&); | ||
| 54 | |||
| 55 | private: | ||
| 56 | std::unique_ptr<Pica::DebugUtils::PicaTrace> pica_trace; | ||
| 57 | |||
| 58 | QTreeView* list_widget; | ||
| 59 | QWidget* command_info_widget; | ||
| 60 | QPushButton* toggle_tracing; | ||
| 61 | }; | ||
diff --git a/src/citra_qt/debugger/graphics/graphics_surface.cpp b/src/citra_qt/debugger/graphics/graphics_surface.cpp deleted file mode 100644 index c974545ef..000000000 --- a/src/citra_qt/debugger/graphics/graphics_surface.cpp +++ /dev/null | |||
| @@ -1,713 +0,0 @@ | |||
| 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 <QFileDialog> | ||
| 9 | #include <QLabel> | ||
| 10 | #include <QMouseEvent> | ||
| 11 | #include <QPushButton> | ||
| 12 | #include <QScrollArea> | ||
| 13 | #include <QSpinBox> | ||
| 14 | #include "citra_qt/debugger/graphics/graphics_surface.h" | ||
| 15 | #include "citra_qt/util/spinbox.h" | ||
| 16 | #include "common/color.h" | ||
| 17 | #include "core/hw/gpu.h" | ||
| 18 | #include "core/memory.h" | ||
| 19 | #include "video_core/pica_state.h" | ||
| 20 | #include "video_core/regs_framebuffer.h" | ||
| 21 | #include "video_core/regs_texturing.h" | ||
| 22 | #include "video_core/texture/texture_decode.h" | ||
| 23 | #include "video_core/utils.h" | ||
| 24 | |||
| 25 | SurfacePicture::SurfacePicture(QWidget* parent, GraphicsSurfaceWidget* surface_widget_) | ||
| 26 | : QLabel(parent), surface_widget(surface_widget_) {} | ||
| 27 | SurfacePicture::~SurfacePicture() {} | ||
| 28 | |||
| 29 | void SurfacePicture::mousePressEvent(QMouseEvent* event) { | ||
| 30 | // Only do something while the left mouse button is held down | ||
| 31 | if (!(event->buttons() & Qt::LeftButton)) | ||
| 32 | return; | ||
| 33 | |||
| 34 | if (pixmap() == nullptr) | ||
| 35 | return; | ||
| 36 | |||
| 37 | if (surface_widget) | ||
| 38 | surface_widget->Pick(event->x() * pixmap()->width() / width(), | ||
| 39 | event->y() * pixmap()->height() / height()); | ||
| 40 | } | ||
| 41 | |||
| 42 | void SurfacePicture::mouseMoveEvent(QMouseEvent* event) { | ||
| 43 | // We also want to handle the event if the user moves the mouse while holding down the LMB | ||
| 44 | mousePressEvent(event); | ||
| 45 | } | ||
| 46 | |||
| 47 | GraphicsSurfaceWidget::GraphicsSurfaceWidget(std::shared_ptr<Pica::DebugContext> debug_context, | ||
| 48 | QWidget* parent) | ||
| 49 | : BreakPointObserverDock(debug_context, tr("Pica Surface Viewer"), parent), | ||
| 50 | surface_source(Source::ColorBuffer) { | ||
| 51 | setObjectName("PicaSurface"); | ||
| 52 | |||
| 53 | surface_source_list = new QComboBox; | ||
| 54 | surface_source_list->addItem(tr("Color Buffer")); | ||
| 55 | surface_source_list->addItem(tr("Depth Buffer")); | ||
| 56 | surface_source_list->addItem(tr("Stencil Buffer")); | ||
| 57 | surface_source_list->addItem(tr("Texture 0")); | ||
| 58 | surface_source_list->addItem(tr("Texture 1")); | ||
| 59 | surface_source_list->addItem(tr("Texture 2")); | ||
| 60 | surface_source_list->addItem(tr("Custom")); | ||
| 61 | surface_source_list->setCurrentIndex(static_cast<int>(surface_source)); | ||
| 62 | |||
| 63 | surface_address_control = new CSpinBox; | ||
| 64 | surface_address_control->SetBase(16); | ||
| 65 | surface_address_control->SetRange(0, 0xFFFFFFFF); | ||
| 66 | surface_address_control->SetPrefix("0x"); | ||
| 67 | |||
| 68 | unsigned max_dimension = 16384; // TODO: Find actual maximum | ||
| 69 | |||
| 70 | surface_width_control = new QSpinBox; | ||
| 71 | surface_width_control->setRange(0, max_dimension); | ||
| 72 | |||
| 73 | surface_height_control = new QSpinBox; | ||
| 74 | surface_height_control->setRange(0, max_dimension); | ||
| 75 | |||
| 76 | surface_picker_x_control = new QSpinBox; | ||
| 77 | surface_picker_x_control->setRange(0, max_dimension - 1); | ||
| 78 | |||
| 79 | surface_picker_y_control = new QSpinBox; | ||
| 80 | surface_picker_y_control->setRange(0, max_dimension - 1); | ||
| 81 | |||
| 82 | surface_format_control = new QComboBox; | ||
| 83 | |||
| 84 | // Color formats sorted by Pica texture format index | ||
| 85 | surface_format_control->addItem(tr("RGBA8")); | ||
| 86 | surface_format_control->addItem(tr("RGB8")); | ||
| 87 | surface_format_control->addItem(tr("RGB5A1")); | ||
| 88 | surface_format_control->addItem(tr("RGB565")); | ||
| 89 | surface_format_control->addItem(tr("RGBA4")); | ||
| 90 | surface_format_control->addItem(tr("IA8")); | ||
| 91 | surface_format_control->addItem(tr("RG8")); | ||
| 92 | surface_format_control->addItem(tr("I8")); | ||
| 93 | surface_format_control->addItem(tr("A8")); | ||
| 94 | surface_format_control->addItem(tr("IA4")); | ||
| 95 | surface_format_control->addItem(tr("I4")); | ||
| 96 | surface_format_control->addItem(tr("A4")); | ||
| 97 | surface_format_control->addItem(tr("ETC1")); | ||
| 98 | surface_format_control->addItem(tr("ETC1A4")); | ||
| 99 | surface_format_control->addItem(tr("D16")); | ||
| 100 | surface_format_control->addItem(tr("D24")); | ||
| 101 | surface_format_control->addItem(tr("D24X8")); | ||
| 102 | surface_format_control->addItem(tr("X24S8")); | ||
| 103 | surface_format_control->addItem(tr("Unknown")); | ||
| 104 | |||
| 105 | surface_info_label = new QLabel(); | ||
| 106 | surface_info_label->setWordWrap(true); | ||
| 107 | |||
| 108 | surface_picture_label = new SurfacePicture(0, this); | ||
| 109 | surface_picture_label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); | ||
| 110 | surface_picture_label->setAlignment(Qt::AlignLeft | Qt::AlignTop); | ||
| 111 | surface_picture_label->setScaledContents(false); | ||
| 112 | |||
| 113 | auto scroll_area = new QScrollArea(); | ||
| 114 | scroll_area->setBackgroundRole(QPalette::Dark); | ||
| 115 | scroll_area->setWidgetResizable(false); | ||
| 116 | scroll_area->setWidget(surface_picture_label); | ||
| 117 | |||
| 118 | save_surface = new QPushButton(QIcon::fromTheme("document-save"), tr("Save")); | ||
| 119 | |||
| 120 | // Connections | ||
| 121 | connect(this, SIGNAL(Update()), this, SLOT(OnUpdate())); | ||
| 122 | connect(surface_source_list, SIGNAL(currentIndexChanged(int)), this, | ||
| 123 | SLOT(OnSurfaceSourceChanged(int))); | ||
| 124 | connect(surface_address_control, SIGNAL(ValueChanged(qint64)), this, | ||
| 125 | SLOT(OnSurfaceAddressChanged(qint64))); | ||
| 126 | connect(surface_width_control, SIGNAL(valueChanged(int)), this, | ||
| 127 | SLOT(OnSurfaceWidthChanged(int))); | ||
| 128 | connect(surface_height_control, SIGNAL(valueChanged(int)), this, | ||
| 129 | SLOT(OnSurfaceHeightChanged(int))); | ||
| 130 | connect(surface_format_control, SIGNAL(currentIndexChanged(int)), this, | ||
| 131 | SLOT(OnSurfaceFormatChanged(int))); | ||
| 132 | connect(surface_picker_x_control, SIGNAL(valueChanged(int)), this, | ||
| 133 | SLOT(OnSurfacePickerXChanged(int))); | ||
| 134 | connect(surface_picker_y_control, SIGNAL(valueChanged(int)), this, | ||
| 135 | SLOT(OnSurfacePickerYChanged(int))); | ||
| 136 | connect(save_surface, SIGNAL(clicked()), this, SLOT(SaveSurface())); | ||
| 137 | |||
| 138 | auto main_widget = new QWidget; | ||
| 139 | auto main_layout = new QVBoxLayout; | ||
| 140 | { | ||
| 141 | auto sub_layout = new QHBoxLayout; | ||
| 142 | sub_layout->addWidget(new QLabel(tr("Source:"))); | ||
| 143 | sub_layout->addWidget(surface_source_list); | ||
| 144 | main_layout->addLayout(sub_layout); | ||
| 145 | } | ||
| 146 | { | ||
| 147 | auto sub_layout = new QHBoxLayout; | ||
| 148 | sub_layout->addWidget(new QLabel(tr("Physical Address:"))); | ||
| 149 | sub_layout->addWidget(surface_address_control); | ||
| 150 | main_layout->addLayout(sub_layout); | ||
| 151 | } | ||
| 152 | { | ||
| 153 | auto sub_layout = new QHBoxLayout; | ||
| 154 | sub_layout->addWidget(new QLabel(tr("Width:"))); | ||
| 155 | sub_layout->addWidget(surface_width_control); | ||
| 156 | main_layout->addLayout(sub_layout); | ||
| 157 | } | ||
| 158 | { | ||
| 159 | auto sub_layout = new QHBoxLayout; | ||
| 160 | sub_layout->addWidget(new QLabel(tr("Height:"))); | ||
| 161 | sub_layout->addWidget(surface_height_control); | ||
| 162 | main_layout->addLayout(sub_layout); | ||
| 163 | } | ||
| 164 | { | ||
| 165 | auto sub_layout = new QHBoxLayout; | ||
| 166 | sub_layout->addWidget(new QLabel(tr("Format:"))); | ||
| 167 | sub_layout->addWidget(surface_format_control); | ||
| 168 | main_layout->addLayout(sub_layout); | ||
| 169 | } | ||
| 170 | main_layout->addWidget(scroll_area); | ||
| 171 | |||
| 172 | auto info_layout = new QHBoxLayout; | ||
| 173 | { | ||
| 174 | auto xy_layout = new QVBoxLayout; | ||
| 175 | { | ||
| 176 | { | ||
| 177 | auto sub_layout = new QHBoxLayout; | ||
| 178 | sub_layout->addWidget(new QLabel(tr("X:"))); | ||
| 179 | sub_layout->addWidget(surface_picker_x_control); | ||
| 180 | xy_layout->addLayout(sub_layout); | ||
| 181 | } | ||
| 182 | { | ||
| 183 | auto sub_layout = new QHBoxLayout; | ||
| 184 | sub_layout->addWidget(new QLabel(tr("Y:"))); | ||
| 185 | sub_layout->addWidget(surface_picker_y_control); | ||
| 186 | xy_layout->addLayout(sub_layout); | ||
| 187 | } | ||
| 188 | } | ||
| 189 | info_layout->addLayout(xy_layout); | ||
| 190 | surface_info_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); | ||
| 191 | info_layout->addWidget(surface_info_label); | ||
| 192 | } | ||
| 193 | main_layout->addLayout(info_layout); | ||
| 194 | |||
| 195 | main_layout->addWidget(save_surface); | ||
| 196 | main_widget->setLayout(main_layout); | ||
| 197 | setWidget(main_widget); | ||
| 198 | |||
| 199 | // Load current data - TODO: Make sure this works when emulation is not running | ||
| 200 | if (debug_context && debug_context->at_breakpoint) { | ||
| 201 | emit Update(); | ||
| 202 | widget()->setEnabled(debug_context->at_breakpoint); | ||
| 203 | } else { | ||
| 204 | widget()->setEnabled(false); | ||
| 205 | } | ||
| 206 | } | ||
| 207 | |||
| 208 | void GraphicsSurfaceWidget::OnBreakPointHit(Pica::DebugContext::Event event, void* data) { | ||
| 209 | emit Update(); | ||
| 210 | widget()->setEnabled(true); | ||
| 211 | } | ||
| 212 | |||
| 213 | void GraphicsSurfaceWidget::OnResumed() { | ||
| 214 | widget()->setEnabled(false); | ||
| 215 | } | ||
| 216 | |||
| 217 | void GraphicsSurfaceWidget::OnSurfaceSourceChanged(int new_value) { | ||
| 218 | surface_source = static_cast<Source>(new_value); | ||
| 219 | emit Update(); | ||
| 220 | } | ||
| 221 | |||
| 222 | void GraphicsSurfaceWidget::OnSurfaceAddressChanged(qint64 new_value) { | ||
| 223 | if (surface_address != new_value) { | ||
| 224 | surface_address = static_cast<unsigned>(new_value); | ||
| 225 | |||
| 226 | surface_source_list->setCurrentIndex(static_cast<int>(Source::Custom)); | ||
| 227 | emit Update(); | ||
| 228 | } | ||
| 229 | } | ||
| 230 | |||
| 231 | void GraphicsSurfaceWidget::OnSurfaceWidthChanged(int new_value) { | ||
| 232 | if (surface_width != static_cast<unsigned>(new_value)) { | ||
| 233 | surface_width = static_cast<unsigned>(new_value); | ||
| 234 | |||
| 235 | surface_source_list->setCurrentIndex(static_cast<int>(Source::Custom)); | ||
| 236 | emit Update(); | ||
| 237 | } | ||
| 238 | } | ||
| 239 | |||
| 240 | void GraphicsSurfaceWidget::OnSurfaceHeightChanged(int new_value) { | ||
| 241 | if (surface_height != static_cast<unsigned>(new_value)) { | ||
| 242 | surface_height = static_cast<unsigned>(new_value); | ||
| 243 | |||
| 244 | surface_source_list->setCurrentIndex(static_cast<int>(Source::Custom)); | ||
| 245 | emit Update(); | ||
| 246 | } | ||
| 247 | } | ||
| 248 | |||
| 249 | void GraphicsSurfaceWidget::OnSurfaceFormatChanged(int new_value) { | ||
| 250 | if (surface_format != static_cast<Format>(new_value)) { | ||
| 251 | surface_format = static_cast<Format>(new_value); | ||
| 252 | |||
| 253 | surface_source_list->setCurrentIndex(static_cast<int>(Source::Custom)); | ||
| 254 | emit Update(); | ||
| 255 | } | ||
| 256 | } | ||
| 257 | |||
| 258 | void GraphicsSurfaceWidget::OnSurfacePickerXChanged(int new_value) { | ||
| 259 | if (surface_picker_x != new_value) { | ||
| 260 | surface_picker_x = new_value; | ||
| 261 | Pick(surface_picker_x, surface_picker_y); | ||
| 262 | } | ||
| 263 | } | ||
| 264 | |||
| 265 | void GraphicsSurfaceWidget::OnSurfacePickerYChanged(int new_value) { | ||
| 266 | if (surface_picker_y != new_value) { | ||
| 267 | surface_picker_y = new_value; | ||
| 268 | Pick(surface_picker_x, surface_picker_y); | ||
| 269 | } | ||
| 270 | } | ||
| 271 | |||
| 272 | void GraphicsSurfaceWidget::Pick(int x, int y) { | ||
| 273 | surface_picker_x_control->setValue(x); | ||
| 274 | surface_picker_y_control->setValue(y); | ||
| 275 | |||
| 276 | if (x < 0 || x >= static_cast<int>(surface_width) || y < 0 || | ||
| 277 | y >= static_cast<int>(surface_height)) { | ||
| 278 | surface_info_label->setText(tr("Pixel out of bounds")); | ||
| 279 | surface_info_label->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); | ||
| 280 | return; | ||
| 281 | } | ||
| 282 | |||
| 283 | u8* buffer = Memory::GetPhysicalPointer(surface_address); | ||
| 284 | if (buffer == nullptr) { | ||
| 285 | surface_info_label->setText(tr("(unable to access pixel data)")); | ||
| 286 | surface_info_label->setAlignment(Qt::AlignCenter); | ||
| 287 | return; | ||
| 288 | } | ||
| 289 | |||
| 290 | unsigned nibbles_per_pixel = GraphicsSurfaceWidget::NibblesPerPixel(surface_format); | ||
| 291 | unsigned stride = nibbles_per_pixel * surface_width / 2; | ||
| 292 | |||
| 293 | unsigned bytes_per_pixel; | ||
| 294 | bool nibble_mode = (nibbles_per_pixel == 1); | ||
| 295 | if (nibble_mode) { | ||
| 296 | // As nibbles are contained in a byte we still need to access one byte per nibble | ||
| 297 | bytes_per_pixel = 1; | ||
| 298 | } else { | ||
| 299 | bytes_per_pixel = nibbles_per_pixel / 2; | ||
| 300 | } | ||
| 301 | |||
| 302 | const u32 coarse_y = y & ~7; | ||
| 303 | u32 offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * stride; | ||
| 304 | const u8* pixel = buffer + (nibble_mode ? (offset / 2) : offset); | ||
| 305 | |||
| 306 | auto GetText = [offset](Format format, const u8* pixel) { | ||
| 307 | switch (format) { | ||
| 308 | case Format::RGBA8: { | ||
| 309 | auto value = Color::DecodeRGBA8(pixel) / 255.0f; | ||
| 310 | return QString("Red: %1, Green: %2, Blue: %3, Alpha: %4") | ||
| 311 | .arg(QString::number(value.r(), 'f', 2)) | ||
| 312 | .arg(QString::number(value.g(), 'f', 2)) | ||
| 313 | .arg(QString::number(value.b(), 'f', 2)) | ||
| 314 | .arg(QString::number(value.a(), 'f', 2)); | ||
| 315 | } | ||
| 316 | case Format::RGB8: { | ||
| 317 | auto value = Color::DecodeRGB8(pixel) / 255.0f; | ||
| 318 | return QString("Red: %1, Green: %2, Blue: %3") | ||
| 319 | .arg(QString::number(value.r(), 'f', 2)) | ||
| 320 | .arg(QString::number(value.g(), 'f', 2)) | ||
| 321 | .arg(QString::number(value.b(), 'f', 2)); | ||
| 322 | } | ||
| 323 | case Format::RGB5A1: { | ||
| 324 | auto value = Color::DecodeRGB5A1(pixel) / 255.0f; | ||
| 325 | return QString("Red: %1, Green: %2, Blue: %3, Alpha: %4") | ||
| 326 | .arg(QString::number(value.r(), 'f', 2)) | ||
| 327 | .arg(QString::number(value.g(), 'f', 2)) | ||
| 328 | .arg(QString::number(value.b(), 'f', 2)) | ||
| 329 | .arg(QString::number(value.a(), 'f', 2)); | ||
| 330 | } | ||
| 331 | case Format::RGB565: { | ||
| 332 | auto value = Color::DecodeRGB565(pixel) / 255.0f; | ||
| 333 | return QString("Red: %1, Green: %2, Blue: %3") | ||
| 334 | .arg(QString::number(value.r(), 'f', 2)) | ||
| 335 | .arg(QString::number(value.g(), 'f', 2)) | ||
| 336 | .arg(QString::number(value.b(), 'f', 2)); | ||
| 337 | } | ||
| 338 | case Format::RGBA4: { | ||
| 339 | auto value = Color::DecodeRGBA4(pixel) / 255.0f; | ||
| 340 | return QString("Red: %1, Green: %2, Blue: %3, Alpha: %4") | ||
| 341 | .arg(QString::number(value.r(), 'f', 2)) | ||
| 342 | .arg(QString::number(value.g(), 'f', 2)) | ||
| 343 | .arg(QString::number(value.b(), 'f', 2)) | ||
| 344 | .arg(QString::number(value.a(), 'f', 2)); | ||
| 345 | } | ||
| 346 | case Format::IA8: | ||
| 347 | return QString("Index: %1, Alpha: %2").arg(pixel[0]).arg(pixel[1]); | ||
| 348 | case Format::RG8: { | ||
| 349 | auto value = Color::DecodeRG8(pixel) / 255.0f; | ||
| 350 | return QString("Red: %1, Green: %2") | ||
| 351 | .arg(QString::number(value.r(), 'f', 2)) | ||
| 352 | .arg(QString::number(value.g(), 'f', 2)); | ||
| 353 | } | ||
| 354 | case Format::I8: | ||
| 355 | return QString("Index: %1").arg(*pixel); | ||
| 356 | case Format::A8: | ||
| 357 | return QString("Alpha: %1").arg(QString::number(*pixel / 255.0f, 'f', 2)); | ||
| 358 | case Format::IA4: | ||
| 359 | return QString("Index: %1, Alpha: %2").arg(*pixel & 0xF).arg((*pixel & 0xF0) >> 4); | ||
| 360 | case Format::I4: { | ||
| 361 | u8 i = (*pixel >> ((offset % 2) ? 4 : 0)) & 0xF; | ||
| 362 | return QString("Index: %1").arg(i); | ||
| 363 | } | ||
| 364 | case Format::A4: { | ||
| 365 | u8 a = (*pixel >> ((offset % 2) ? 4 : 0)) & 0xF; | ||
| 366 | return QString("Alpha: %1").arg(QString::number(a / 15.0f, 'f', 2)); | ||
| 367 | } | ||
| 368 | case Format::ETC1: | ||
| 369 | case Format::ETC1A4: | ||
| 370 | // TODO: Display block information or channel values? | ||
| 371 | return QString("Compressed data"); | ||
| 372 | case Format::D16: { | ||
| 373 | auto value = Color::DecodeD16(pixel); | ||
| 374 | return QString("Depth: %1").arg(QString::number(value / (float)0xFFFF, 'f', 4)); | ||
| 375 | } | ||
| 376 | case Format::D24: { | ||
| 377 | auto value = Color::DecodeD24(pixel); | ||
| 378 | return QString("Depth: %1").arg(QString::number(value / (float)0xFFFFFF, 'f', 4)); | ||
| 379 | } | ||
| 380 | case Format::D24X8: | ||
| 381 | case Format::X24S8: { | ||
| 382 | auto values = Color::DecodeD24S8(pixel); | ||
| 383 | return QString("Depth: %1, Stencil: %2") | ||
| 384 | .arg(QString::number(values[0] / (float)0xFFFFFF, 'f', 4)) | ||
| 385 | .arg(values[1]); | ||
| 386 | } | ||
| 387 | case Format::Unknown: | ||
| 388 | return QString("Unknown format"); | ||
| 389 | default: | ||
| 390 | return QString("Unhandled format"); | ||
| 391 | } | ||
| 392 | return QString(""); | ||
| 393 | }; | ||
| 394 | |||
| 395 | QString nibbles = ""; | ||
| 396 | for (unsigned i = 0; i < nibbles_per_pixel; i++) { | ||
| 397 | unsigned nibble_index = i; | ||
| 398 | if (nibble_mode) { | ||
| 399 | nibble_index += (offset % 2) ? 0 : 1; | ||
| 400 | } | ||
| 401 | u8 byte = pixel[nibble_index / 2]; | ||
| 402 | u8 nibble = (byte >> ((nibble_index % 2) ? 0 : 4)) & 0xF; | ||
| 403 | nibbles.append(QString::number(nibble, 16).toUpper()); | ||
| 404 | } | ||
| 405 | |||
| 406 | surface_info_label->setText( | ||
| 407 | QString("Raw: 0x%3\n(%4)").arg(nibbles).arg(GetText(surface_format, pixel))); | ||
| 408 | surface_info_label->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); | ||
| 409 | } | ||
| 410 | |||
| 411 | void GraphicsSurfaceWidget::OnUpdate() { | ||
| 412 | QPixmap pixmap; | ||
| 413 | |||
| 414 | switch (surface_source) { | ||
| 415 | case Source::ColorBuffer: { | ||
| 416 | // TODO: Store a reference to the registers in the debug context instead of accessing them | ||
| 417 | // directly... | ||
| 418 | |||
| 419 | const auto& framebuffer = Pica::g_state.regs.framebuffer.framebuffer; | ||
| 420 | |||
| 421 | surface_address = framebuffer.GetColorBufferPhysicalAddress(); | ||
| 422 | surface_width = framebuffer.GetWidth(); | ||
| 423 | surface_height = framebuffer.GetHeight(); | ||
| 424 | |||
| 425 | switch (framebuffer.color_format) { | ||
| 426 | case Pica::FramebufferRegs::ColorFormat::RGBA8: | ||
| 427 | surface_format = Format::RGBA8; | ||
| 428 | break; | ||
| 429 | |||
| 430 | case Pica::FramebufferRegs::ColorFormat::RGB8: | ||
| 431 | surface_format = Format::RGB8; | ||
| 432 | break; | ||
| 433 | |||
| 434 | case Pica::FramebufferRegs::ColorFormat::RGB5A1: | ||
| 435 | surface_format = Format::RGB5A1; | ||
| 436 | break; | ||
| 437 | |||
| 438 | case Pica::FramebufferRegs::ColorFormat::RGB565: | ||
| 439 | surface_format = Format::RGB565; | ||
| 440 | break; | ||
| 441 | |||
| 442 | case Pica::FramebufferRegs::ColorFormat::RGBA4: | ||
| 443 | surface_format = Format::RGBA4; | ||
| 444 | break; | ||
| 445 | |||
| 446 | default: | ||
| 447 | surface_format = Format::Unknown; | ||
| 448 | break; | ||
| 449 | } | ||
| 450 | |||
| 451 | break; | ||
| 452 | } | ||
| 453 | |||
| 454 | case Source::DepthBuffer: { | ||
| 455 | const auto& framebuffer = Pica::g_state.regs.framebuffer.framebuffer; | ||
| 456 | |||
| 457 | surface_address = framebuffer.GetDepthBufferPhysicalAddress(); | ||
| 458 | surface_width = framebuffer.GetWidth(); | ||
| 459 | surface_height = framebuffer.GetHeight(); | ||
| 460 | |||
| 461 | switch (framebuffer.depth_format) { | ||
| 462 | case Pica::FramebufferRegs::DepthFormat::D16: | ||
| 463 | surface_format = Format::D16; | ||
| 464 | break; | ||
| 465 | |||
| 466 | case Pica::FramebufferRegs::DepthFormat::D24: | ||
| 467 | surface_format = Format::D24; | ||
| 468 | break; | ||
| 469 | |||
| 470 | case Pica::FramebufferRegs::DepthFormat::D24S8: | ||
| 471 | surface_format = Format::D24X8; | ||
| 472 | break; | ||
| 473 | |||
| 474 | default: | ||
| 475 | surface_format = Format::Unknown; | ||
| 476 | break; | ||
| 477 | } | ||
| 478 | |||
| 479 | break; | ||
| 480 | } | ||
| 481 | |||
| 482 | case Source::StencilBuffer: { | ||
| 483 | const auto& framebuffer = Pica::g_state.regs.framebuffer.framebuffer; | ||
| 484 | |||
| 485 | surface_address = framebuffer.GetDepthBufferPhysicalAddress(); | ||
| 486 | surface_width = framebuffer.GetWidth(); | ||
| 487 | surface_height = framebuffer.GetHeight(); | ||
| 488 | |||
| 489 | switch (framebuffer.depth_format) { | ||
| 490 | case Pica::FramebufferRegs::DepthFormat::D24S8: | ||
| 491 | surface_format = Format::X24S8; | ||
| 492 | break; | ||
| 493 | |||
| 494 | default: | ||
| 495 | surface_format = Format::Unknown; | ||
| 496 | break; | ||
| 497 | } | ||
| 498 | |||
| 499 | break; | ||
| 500 | } | ||
| 501 | |||
| 502 | case Source::Texture0: | ||
| 503 | case Source::Texture1: | ||
| 504 | case Source::Texture2: { | ||
| 505 | unsigned texture_index; | ||
| 506 | if (surface_source == Source::Texture0) | ||
| 507 | texture_index = 0; | ||
| 508 | else if (surface_source == Source::Texture1) | ||
| 509 | texture_index = 1; | ||
| 510 | else if (surface_source == Source::Texture2) | ||
| 511 | texture_index = 2; | ||
| 512 | else { | ||
| 513 | qDebug() << "Unknown texture source " << static_cast<int>(surface_source); | ||
| 514 | break; | ||
| 515 | } | ||
| 516 | |||
| 517 | const auto texture = Pica::g_state.regs.texturing.GetTextures()[texture_index]; | ||
| 518 | auto info = Pica::Texture::TextureInfo::FromPicaRegister(texture.config, texture.format); | ||
| 519 | |||
| 520 | surface_address = info.physical_address; | ||
| 521 | surface_width = info.width; | ||
| 522 | surface_height = info.height; | ||
| 523 | surface_format = static_cast<Format>(info.format); | ||
| 524 | |||
| 525 | if (surface_format > Format::MaxTextureFormat) { | ||
| 526 | qDebug() << "Unknown texture format " << static_cast<int>(info.format); | ||
| 527 | } | ||
| 528 | break; | ||
| 529 | } | ||
| 530 | |||
| 531 | case Source::Custom: { | ||
| 532 | // Keep user-specified values | ||
| 533 | break; | ||
| 534 | } | ||
| 535 | |||
| 536 | default: | ||
| 537 | qDebug() << "Unknown surface source " << static_cast<int>(surface_source); | ||
| 538 | break; | ||
| 539 | } | ||
| 540 | |||
| 541 | surface_address_control->SetValue(surface_address); | ||
| 542 | surface_width_control->setValue(surface_width); | ||
| 543 | surface_height_control->setValue(surface_height); | ||
| 544 | surface_format_control->setCurrentIndex(static_cast<int>(surface_format)); | ||
| 545 | |||
| 546 | // TODO: Implement a good way to visualize alpha components! | ||
| 547 | |||
| 548 | QImage decoded_image(surface_width, surface_height, QImage::Format_ARGB32); | ||
| 549 | u8* buffer = Memory::GetPhysicalPointer(surface_address); | ||
| 550 | |||
| 551 | if (buffer == nullptr) { | ||
| 552 | surface_picture_label->hide(); | ||
| 553 | surface_info_label->setText(tr("(invalid surface address)")); | ||
| 554 | surface_info_label->setAlignment(Qt::AlignCenter); | ||
| 555 | surface_picker_x_control->setEnabled(false); | ||
| 556 | surface_picker_y_control->setEnabled(false); | ||
| 557 | save_surface->setEnabled(false); | ||
| 558 | return; | ||
| 559 | } | ||
| 560 | |||
| 561 | if (surface_format == Format::Unknown) { | ||
| 562 | surface_picture_label->hide(); | ||
| 563 | surface_info_label->setText(tr("(unknown surface format)")); | ||
| 564 | surface_info_label->setAlignment(Qt::AlignCenter); | ||
| 565 | surface_picker_x_control->setEnabled(false); | ||
| 566 | surface_picker_y_control->setEnabled(false); | ||
| 567 | save_surface->setEnabled(false); | ||
| 568 | return; | ||
| 569 | } | ||
| 570 | |||
| 571 | surface_picture_label->show(); | ||
| 572 | |||
| 573 | if (surface_format <= Format::MaxTextureFormat) { | ||
| 574 | // Generate a virtual texture | ||
| 575 | Pica::Texture::TextureInfo info; | ||
| 576 | info.physical_address = surface_address; | ||
| 577 | info.width = surface_width; | ||
| 578 | info.height = surface_height; | ||
| 579 | info.format = static_cast<Pica::TexturingRegs::TextureFormat>(surface_format); | ||
| 580 | info.SetDefaultStride(); | ||
| 581 | |||
| 582 | for (unsigned int y = 0; y < surface_height; ++y) { | ||
| 583 | for (unsigned int x = 0; x < surface_width; ++x) { | ||
| 584 | Math::Vec4<u8> color = Pica::Texture::LookupTexture(buffer, x, y, info, true); | ||
| 585 | decoded_image.setPixel(x, y, qRgba(color.r(), color.g(), color.b(), color.a())); | ||
| 586 | } | ||
| 587 | } | ||
| 588 | } else { | ||
| 589 | // We handle depth formats here because DebugUtils only supports TextureFormats | ||
| 590 | |||
| 591 | // TODO(yuriks): Convert to newer tile-based addressing | ||
| 592 | unsigned nibbles_per_pixel = GraphicsSurfaceWidget::NibblesPerPixel(surface_format); | ||
| 593 | unsigned stride = nibbles_per_pixel * surface_width / 2; | ||
| 594 | |||
| 595 | ASSERT_MSG(nibbles_per_pixel >= 2, | ||
| 596 | "Depth decoder only supports formats with at least one byte per pixel"); | ||
| 597 | unsigned bytes_per_pixel = nibbles_per_pixel / 2; | ||
| 598 | |||
| 599 | for (unsigned int y = 0; y < surface_height; ++y) { | ||
| 600 | for (unsigned int x = 0; x < surface_width; ++x) { | ||
| 601 | const u32 coarse_y = y & ~7; | ||
| 602 | u32 offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * stride; | ||
| 603 | const u8* pixel = buffer + offset; | ||
| 604 | Math::Vec4<u8> color = {0, 0, 0, 0}; | ||
| 605 | |||
| 606 | switch (surface_format) { | ||
| 607 | case Format::D16: { | ||
| 608 | u32 data = Color::DecodeD16(pixel); | ||
| 609 | color.r() = data & 0xFF; | ||
| 610 | color.g() = (data >> 8) & 0xFF; | ||
| 611 | break; | ||
| 612 | } | ||
| 613 | case Format::D24: { | ||
| 614 | u32 data = Color::DecodeD24(pixel); | ||
| 615 | color.r() = data & 0xFF; | ||
| 616 | color.g() = (data >> 8) & 0xFF; | ||
| 617 | color.b() = (data >> 16) & 0xFF; | ||
| 618 | break; | ||
| 619 | } | ||
| 620 | case Format::D24X8: { | ||
| 621 | Math::Vec2<u32> data = Color::DecodeD24S8(pixel); | ||
| 622 | color.r() = data.x & 0xFF; | ||
| 623 | color.g() = (data.x >> 8) & 0xFF; | ||
| 624 | color.b() = (data.x >> 16) & 0xFF; | ||
| 625 | break; | ||
| 626 | } | ||
| 627 | case Format::X24S8: { | ||
| 628 | Math::Vec2<u32> data = Color::DecodeD24S8(pixel); | ||
| 629 | color.r() = color.g() = color.b() = data.y; | ||
| 630 | break; | ||
| 631 | } | ||
| 632 | default: | ||
| 633 | qDebug() << "Unknown surface format " << static_cast<int>(surface_format); | ||
| 634 | break; | ||
| 635 | } | ||
| 636 | |||
| 637 | decoded_image.setPixel(x, y, qRgba(color.r(), color.g(), color.b(), 255)); | ||
| 638 | } | ||
| 639 | } | ||
| 640 | } | ||
| 641 | |||
| 642 | pixmap = QPixmap::fromImage(decoded_image); | ||
| 643 | surface_picture_label->setPixmap(pixmap); | ||
| 644 | surface_picture_label->resize(pixmap.size()); | ||
| 645 | |||
| 646 | // Update the info with pixel data | ||
| 647 | surface_picker_x_control->setEnabled(true); | ||
| 648 | surface_picker_y_control->setEnabled(true); | ||
| 649 | Pick(surface_picker_x, surface_picker_y); | ||
| 650 | |||
| 651 | // Enable saving the converted pixmap to file | ||
| 652 | save_surface->setEnabled(true); | ||
| 653 | } | ||
| 654 | |||
| 655 | void GraphicsSurfaceWidget::SaveSurface() { | ||
| 656 | QString png_filter = tr("Portable Network Graphic (*.png)"); | ||
| 657 | QString bin_filter = tr("Binary data (*.bin)"); | ||
| 658 | |||
| 659 | QString selectedFilter; | ||
| 660 | QString filename = QFileDialog::getSaveFileName( | ||
| 661 | this, tr("Save Surface"), | ||
| 662 | QString("texture-0x%1.png").arg(QString::number(surface_address, 16)), | ||
| 663 | QString("%1;;%2").arg(png_filter, bin_filter), &selectedFilter); | ||
| 664 | |||
| 665 | if (filename.isEmpty()) { | ||
| 666 | // If the user canceled the dialog, don't save anything. | ||
| 667 | return; | ||
| 668 | } | ||
| 669 | |||
| 670 | if (selectedFilter == png_filter) { | ||
| 671 | const QPixmap* pixmap = surface_picture_label->pixmap(); | ||
| 672 | ASSERT_MSG(pixmap != nullptr, "No pixmap set"); | ||
| 673 | |||
| 674 | QFile file(filename); | ||
| 675 | file.open(QIODevice::WriteOnly); | ||
| 676 | if (pixmap) | ||
| 677 | pixmap->save(&file, "PNG"); | ||
| 678 | } else if (selectedFilter == bin_filter) { | ||
| 679 | const u8* buffer = Memory::GetPhysicalPointer(surface_address); | ||
| 680 | ASSERT_MSG(buffer != nullptr, "Memory not accessible"); | ||
| 681 | |||
| 682 | QFile file(filename); | ||
| 683 | file.open(QIODevice::WriteOnly); | ||
| 684 | int size = surface_width * surface_height * NibblesPerPixel(surface_format) / 2; | ||
| 685 | QByteArray data(reinterpret_cast<const char*>(buffer), size); | ||
| 686 | file.write(data); | ||
| 687 | } else { | ||
| 688 | UNREACHABLE_MSG("Unhandled filter selected"); | ||
| 689 | } | ||
| 690 | } | ||
| 691 | |||
| 692 | unsigned int GraphicsSurfaceWidget::NibblesPerPixel(GraphicsSurfaceWidget::Format format) { | ||
| 693 | if (format <= Format::MaxTextureFormat) { | ||
| 694 | return Pica::TexturingRegs::NibblesPerPixel( | ||
| 695 | static_cast<Pica::TexturingRegs::TextureFormat>(format)); | ||
| 696 | } | ||
| 697 | |||
| 698 | switch (format) { | ||
| 699 | case Format::D24X8: | ||
| 700 | case Format::X24S8: | ||
| 701 | return 4 * 2; | ||
| 702 | case Format::D24: | ||
| 703 | return 3 * 2; | ||
| 704 | case Format::D16: | ||
| 705 | return 2 * 2; | ||
| 706 | default: | ||
| 707 | UNREACHABLE_MSG("GraphicsSurfaceWidget::BytesPerPixel: this should not be reached as this " | ||
| 708 | "function should be given a format which is in " | ||
| 709 | "GraphicsSurfaceWidget::Format. Instead got %i", | ||
| 710 | static_cast<int>(format)); | ||
| 711 | return 0; | ||
| 712 | } | ||
| 713 | } | ||
diff --git a/src/citra_qt/debugger/graphics/graphics_surface.h b/src/citra_qt/debugger/graphics/graphics_surface.h deleted file mode 100644 index 28f5650a7..000000000 --- a/src/citra_qt/debugger/graphics/graphics_surface.h +++ /dev/null | |||
| @@ -1,118 +0,0 @@ | |||
| 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 <QLabel> | ||
| 8 | #include <QPushButton> | ||
| 9 | #include "citra_qt/debugger/graphics/graphics_breakpoint_observer.h" | ||
| 10 | |||
| 11 | class QComboBox; | ||
| 12 | class QSpinBox; | ||
| 13 | class CSpinBox; | ||
| 14 | |||
| 15 | class GraphicsSurfaceWidget; | ||
| 16 | |||
| 17 | class SurfacePicture : public QLabel { | ||
| 18 | Q_OBJECT | ||
| 19 | |||
| 20 | public: | ||
| 21 | explicit SurfacePicture(QWidget* parent = nullptr, | ||
| 22 | GraphicsSurfaceWidget* surface_widget = nullptr); | ||
| 23 | ~SurfacePicture(); | ||
| 24 | |||
| 25 | protected slots: | ||
| 26 | virtual void mouseMoveEvent(QMouseEvent* event); | ||
| 27 | virtual void mousePressEvent(QMouseEvent* event); | ||
| 28 | |||
| 29 | private: | ||
| 30 | GraphicsSurfaceWidget* surface_widget; | ||
| 31 | }; | ||
| 32 | |||
| 33 | class GraphicsSurfaceWidget : public BreakPointObserverDock { | ||
| 34 | Q_OBJECT | ||
| 35 | |||
| 36 | using Event = Pica::DebugContext::Event; | ||
| 37 | |||
| 38 | enum class Source { | ||
| 39 | ColorBuffer = 0, | ||
| 40 | DepthBuffer = 1, | ||
| 41 | StencilBuffer = 2, | ||
| 42 | Texture0 = 3, | ||
| 43 | Texture1 = 4, | ||
| 44 | Texture2 = 5, | ||
| 45 | Custom = 6, | ||
| 46 | }; | ||
| 47 | |||
| 48 | enum class Format { | ||
| 49 | // These must match the TextureFormat type! | ||
| 50 | RGBA8 = 0, | ||
| 51 | RGB8 = 1, | ||
| 52 | RGB5A1 = 2, | ||
| 53 | RGB565 = 3, | ||
| 54 | RGBA4 = 4, | ||
| 55 | IA8 = 5, | ||
| 56 | RG8 = 6, ///< @note Also called HILO8 in 3DBrew. | ||
| 57 | I8 = 7, | ||
| 58 | A8 = 8, | ||
| 59 | IA4 = 9, | ||
| 60 | I4 = 10, | ||
| 61 | A4 = 11, | ||
| 62 | ETC1 = 12, // compressed | ||
| 63 | ETC1A4 = 13, | ||
| 64 | MaxTextureFormat = 13, | ||
| 65 | D16 = 14, | ||
| 66 | D24 = 15, | ||
| 67 | D24X8 = 16, | ||
| 68 | X24S8 = 17, | ||
| 69 | Unknown = 18, | ||
| 70 | }; | ||
| 71 | |||
| 72 | static unsigned int NibblesPerPixel(Format format); | ||
| 73 | |||
| 74 | public: | ||
| 75 | explicit GraphicsSurfaceWidget(std::shared_ptr<Pica::DebugContext> debug_context, | ||
| 76 | QWidget* parent = nullptr); | ||
| 77 | void Pick(int x, int y); | ||
| 78 | |||
| 79 | public slots: | ||
| 80 | void OnSurfaceSourceChanged(int new_value); | ||
| 81 | void OnSurfaceAddressChanged(qint64 new_value); | ||
| 82 | void OnSurfaceWidthChanged(int new_value); | ||
| 83 | void OnSurfaceHeightChanged(int new_value); | ||
| 84 | void OnSurfaceFormatChanged(int new_value); | ||
| 85 | void OnSurfacePickerXChanged(int new_value); | ||
| 86 | void OnSurfacePickerYChanged(int new_value); | ||
| 87 | void OnUpdate(); | ||
| 88 | |||
| 89 | private slots: | ||
| 90 | void OnBreakPointHit(Pica::DebugContext::Event event, void* data) override; | ||
| 91 | void OnResumed() override; | ||
| 92 | |||
| 93 | void SaveSurface(); | ||
| 94 | |||
| 95 | signals: | ||
| 96 | void Update(); | ||
| 97 | |||
| 98 | private: | ||
| 99 | QComboBox* surface_source_list; | ||
| 100 | CSpinBox* surface_address_control; | ||
| 101 | QSpinBox* surface_width_control; | ||
| 102 | QSpinBox* surface_height_control; | ||
| 103 | QComboBox* surface_format_control; | ||
| 104 | |||
| 105 | SurfacePicture* surface_picture_label; | ||
| 106 | QSpinBox* surface_picker_x_control; | ||
| 107 | QSpinBox* surface_picker_y_control; | ||
| 108 | QLabel* surface_info_label; | ||
| 109 | QPushButton* save_surface; | ||
| 110 | |||
| 111 | Source surface_source; | ||
| 112 | unsigned surface_address; | ||
| 113 | unsigned surface_width; | ||
| 114 | unsigned surface_height; | ||
| 115 | Format surface_format; | ||
| 116 | int surface_picker_x = 0; | ||
| 117 | int surface_picker_y = 0; | ||
| 118 | }; | ||
diff --git a/src/citra_qt/debugger/graphics/graphics_tracing.cpp b/src/citra_qt/debugger/graphics/graphics_tracing.cpp deleted file mode 100644 index 40d5bed51..000000000 --- a/src/citra_qt/debugger/graphics/graphics_tracing.cpp +++ /dev/null | |||
| @@ -1,177 +0,0 @@ | |||
| 1 | // Copyright 2015 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <algorithm> | ||
| 6 | #include <array> | ||
| 7 | #include <iterator> | ||
| 8 | #include <memory> | ||
| 9 | #include <QBoxLayout> | ||
| 10 | #include <QComboBox> | ||
| 11 | #include <QFileDialog> | ||
| 12 | #include <QMessageBox> | ||
| 13 | #include <QPushButton> | ||
| 14 | #include <boost/range/algorithm/copy.hpp> | ||
| 15 | #include "citra_qt/debugger/graphics/graphics_tracing.h" | ||
| 16 | #include "common/common_types.h" | ||
| 17 | #include "core/hw/gpu.h" | ||
| 18 | #include "core/hw/lcd.h" | ||
| 19 | #include "core/tracer/recorder.h" | ||
| 20 | #include "nihstro/float24.h" | ||
| 21 | #include "video_core/pica_state.h" | ||
| 22 | |||
| 23 | GraphicsTracingWidget::GraphicsTracingWidget(std::shared_ptr<Pica::DebugContext> debug_context, | ||
| 24 | QWidget* parent) | ||
| 25 | : BreakPointObserverDock(debug_context, tr("CiTrace Recorder"), parent) { | ||
| 26 | |||
| 27 | setObjectName("CiTracing"); | ||
| 28 | |||
| 29 | QPushButton* start_recording = new QPushButton(tr("Start Recording")); | ||
| 30 | QPushButton* stop_recording = | ||
| 31 | new QPushButton(QIcon::fromTheme("document-save"), tr("Stop and Save")); | ||
| 32 | QPushButton* abort_recording = new QPushButton(tr("Abort Recording")); | ||
| 33 | |||
| 34 | connect(this, SIGNAL(SetStartTracingButtonEnabled(bool)), start_recording, | ||
| 35 | SLOT(setVisible(bool))); | ||
| 36 | connect(this, SIGNAL(SetStopTracingButtonEnabled(bool)), stop_recording, | ||
| 37 | SLOT(setVisible(bool))); | ||
| 38 | connect(this, SIGNAL(SetAbortTracingButtonEnabled(bool)), abort_recording, | ||
| 39 | SLOT(setVisible(bool))); | ||
| 40 | connect(start_recording, SIGNAL(clicked()), this, SLOT(StartRecording())); | ||
| 41 | connect(stop_recording, SIGNAL(clicked()), this, SLOT(StopRecording())); | ||
| 42 | connect(abort_recording, SIGNAL(clicked()), this, SLOT(AbortRecording())); | ||
| 43 | |||
| 44 | stop_recording->setVisible(false); | ||
| 45 | abort_recording->setVisible(false); | ||
| 46 | |||
| 47 | auto main_widget = new QWidget; | ||
| 48 | auto main_layout = new QVBoxLayout; | ||
| 49 | { | ||
| 50 | auto sub_layout = new QHBoxLayout; | ||
| 51 | sub_layout->addWidget(start_recording); | ||
| 52 | sub_layout->addWidget(stop_recording); | ||
| 53 | sub_layout->addWidget(abort_recording); | ||
| 54 | main_layout->addLayout(sub_layout); | ||
| 55 | } | ||
| 56 | main_widget->setLayout(main_layout); | ||
| 57 | setWidget(main_widget); | ||
| 58 | } | ||
| 59 | |||
| 60 | void GraphicsTracingWidget::StartRecording() { | ||
| 61 | auto context = context_weak.lock(); | ||
| 62 | if (!context) | ||
| 63 | return; | ||
| 64 | |||
| 65 | auto shader_binary = Pica::g_state.vs.program_code; | ||
| 66 | auto swizzle_data = Pica::g_state.vs.swizzle_data; | ||
| 67 | |||
| 68 | // Encode floating point numbers to 24-bit values | ||
| 69 | // TODO: Drop this explicit conversion once we store float24 values bit-correctly internally. | ||
| 70 | std::array<u32, 4 * 16> default_attributes; | ||
| 71 | for (unsigned i = 0; i < 16; ++i) { | ||
| 72 | for (unsigned comp = 0; comp < 3; ++comp) { | ||
| 73 | default_attributes[4 * i + comp] = nihstro::to_float24( | ||
| 74 | Pica::g_state.input_default_attributes.attr[i][comp].ToFloat32()); | ||
| 75 | } | ||
| 76 | } | ||
| 77 | |||
| 78 | std::array<u32, 4 * 96> vs_float_uniforms; | ||
| 79 | for (unsigned i = 0; i < 96; ++i) | ||
| 80 | for (unsigned comp = 0; comp < 3; ++comp) | ||
| 81 | vs_float_uniforms[4 * i + comp] = | ||
| 82 | nihstro::to_float24(Pica::g_state.vs.uniforms.f[i][comp].ToFloat32()); | ||
| 83 | |||
| 84 | CiTrace::Recorder::InitialState state; | ||
| 85 | std::copy_n((u32*)&GPU::g_regs, sizeof(GPU::g_regs) / sizeof(u32), | ||
| 86 | std::back_inserter(state.gpu_registers)); | ||
| 87 | std::copy_n((u32*)&LCD::g_regs, sizeof(LCD::g_regs) / sizeof(u32), | ||
| 88 | std::back_inserter(state.lcd_registers)); | ||
| 89 | std::copy_n((u32*)&Pica::g_state.regs, sizeof(Pica::g_state.regs) / sizeof(u32), | ||
| 90 | std::back_inserter(state.pica_registers)); | ||
| 91 | boost::copy(default_attributes, std::back_inserter(state.default_attributes)); | ||
| 92 | boost::copy(shader_binary, std::back_inserter(state.vs_program_binary)); | ||
| 93 | boost::copy(swizzle_data, std::back_inserter(state.vs_swizzle_data)); | ||
| 94 | boost::copy(vs_float_uniforms, std::back_inserter(state.vs_float_uniforms)); | ||
| 95 | // boost::copy(TODO: Not implemented, std::back_inserter(state.gs_program_binary)); | ||
| 96 | // boost::copy(TODO: Not implemented, std::back_inserter(state.gs_swizzle_data)); | ||
| 97 | // boost::copy(TODO: Not implemented, std::back_inserter(state.gs_float_uniforms)); | ||
| 98 | |||
| 99 | auto recorder = new CiTrace::Recorder(state); | ||
| 100 | context->recorder = std::shared_ptr<CiTrace::Recorder>(recorder); | ||
| 101 | |||
| 102 | emit SetStartTracingButtonEnabled(false); | ||
| 103 | emit SetStopTracingButtonEnabled(true); | ||
| 104 | emit SetAbortTracingButtonEnabled(true); | ||
| 105 | } | ||
| 106 | |||
| 107 | void GraphicsTracingWidget::StopRecording() { | ||
| 108 | auto context = context_weak.lock(); | ||
| 109 | if (!context) | ||
| 110 | return; | ||
| 111 | |||
| 112 | QString filename = QFileDialog::getSaveFileName(this, tr("Save CiTrace"), "citrace.ctf", | ||
| 113 | tr("CiTrace File (*.ctf)")); | ||
| 114 | |||
| 115 | if (filename.isEmpty()) { | ||
| 116 | // If the user canceled the dialog, keep recording | ||
| 117 | return; | ||
| 118 | } | ||
| 119 | |||
| 120 | context->recorder->Finish(filename.toStdString()); | ||
| 121 | context->recorder = nullptr; | ||
| 122 | |||
| 123 | emit SetStopTracingButtonEnabled(false); | ||
| 124 | emit SetAbortTracingButtonEnabled(false); | ||
| 125 | emit SetStartTracingButtonEnabled(true); | ||
| 126 | } | ||
| 127 | |||
| 128 | void GraphicsTracingWidget::AbortRecording() { | ||
| 129 | auto context = context_weak.lock(); | ||
| 130 | if (!context) | ||
| 131 | return; | ||
| 132 | |||
| 133 | context->recorder = nullptr; | ||
| 134 | |||
| 135 | emit SetStopTracingButtonEnabled(false); | ||
| 136 | emit SetAbortTracingButtonEnabled(false); | ||
| 137 | emit SetStartTracingButtonEnabled(true); | ||
| 138 | } | ||
| 139 | |||
| 140 | void GraphicsTracingWidget::OnBreakPointHit(Pica::DebugContext::Event event, void* data) { | ||
| 141 | widget()->setEnabled(true); | ||
| 142 | } | ||
| 143 | |||
| 144 | void GraphicsTracingWidget::OnResumed() { | ||
| 145 | widget()->setEnabled(false); | ||
| 146 | } | ||
| 147 | |||
| 148 | void GraphicsTracingWidget::OnEmulationStarting(EmuThread* emu_thread) { | ||
| 149 | // Disable tracing starting/stopping until a GPU breakpoint is reached | ||
| 150 | widget()->setEnabled(false); | ||
| 151 | } | ||
| 152 | |||
| 153 | void GraphicsTracingWidget::OnEmulationStopping() { | ||
| 154 | // TODO: Is it safe to access the context here? | ||
| 155 | |||
| 156 | auto context = context_weak.lock(); | ||
| 157 | if (!context) | ||
| 158 | return; | ||
| 159 | |||
| 160 | if (context->recorder) { | ||
| 161 | auto reply = | ||
| 162 | QMessageBox::question(this, tr("CiTracing still active"), | ||
| 163 | tr("A CiTrace is still being recorded. Do you want to save it? " | ||
| 164 | "If not, all recorded data will be discarded."), | ||
| 165 | QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); | ||
| 166 | |||
| 167 | if (reply == QMessageBox::Yes) { | ||
| 168 | StopRecording(); | ||
| 169 | } else { | ||
| 170 | AbortRecording(); | ||
| 171 | } | ||
| 172 | } | ||
| 173 | |||
| 174 | // If the widget was disabled before, enable it now to allow starting | ||
| 175 | // tracing before starting the next emulation session | ||
| 176 | widget()->setEnabled(true); | ||
| 177 | } | ||
diff --git a/src/citra_qt/debugger/graphics/graphics_tracing.h b/src/citra_qt/debugger/graphics/graphics_tracing.h deleted file mode 100644 index eb1292c29..000000000 --- a/src/citra_qt/debugger/graphics/graphics_tracing.h +++ /dev/null | |||
| @@ -1,33 +0,0 @@ | |||
| 1 | // Copyright 2015 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 "citra_qt/debugger/graphics/graphics_breakpoint_observer.h" | ||
| 8 | |||
| 9 | class EmuThread; | ||
| 10 | |||
| 11 | class GraphicsTracingWidget : public BreakPointObserverDock { | ||
| 12 | Q_OBJECT | ||
| 13 | |||
| 14 | public: | ||
| 15 | explicit GraphicsTracingWidget(std::shared_ptr<Pica::DebugContext> debug_context, | ||
| 16 | QWidget* parent = nullptr); | ||
| 17 | |||
| 18 | void OnEmulationStarting(EmuThread* emu_thread); | ||
| 19 | void OnEmulationStopping(); | ||
| 20 | |||
| 21 | private slots: | ||
| 22 | void StartRecording(); | ||
| 23 | void StopRecording(); | ||
| 24 | void AbortRecording(); | ||
| 25 | |||
| 26 | void OnBreakPointHit(Pica::DebugContext::Event event, void* data) override; | ||
| 27 | void OnResumed() override; | ||
| 28 | |||
| 29 | signals: | ||
| 30 | void SetStartTracingButtonEnabled(bool enable); | ||
| 31 | void SetStopTracingButtonEnabled(bool enable); | ||
| 32 | void SetAbortTracingButtonEnabled(bool enable); | ||
| 33 | }; | ||
diff --git a/src/citra_qt/debugger/graphics/graphics_vertex_shader.cpp b/src/citra_qt/debugger/graphics/graphics_vertex_shader.cpp deleted file mode 100644 index 7f4ec0c52..000000000 --- a/src/citra_qt/debugger/graphics/graphics_vertex_shader.cpp +++ /dev/null | |||
| @@ -1,622 +0,0 @@ | |||
| 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 <iomanip> | ||
| 6 | #include <sstream> | ||
| 7 | #include <QBoxLayout> | ||
| 8 | #include <QFileDialog> | ||
| 9 | #include <QFormLayout> | ||
| 10 | #include <QGroupBox> | ||
| 11 | #include <QLabel> | ||
| 12 | #include <QLineEdit> | ||
| 13 | #include <QPushButton> | ||
| 14 | #include <QSignalMapper> | ||
| 15 | #include <QSpinBox> | ||
| 16 | #include <QTreeView> | ||
| 17 | #include "citra_qt/debugger/graphics/graphics_vertex_shader.h" | ||
| 18 | #include "citra_qt/util/util.h" | ||
| 19 | #include "video_core/pica_state.h" | ||
| 20 | #include "video_core/shader/debug_data.h" | ||
| 21 | #include "video_core/shader/shader.h" | ||
| 22 | #include "video_core/shader/shader_interpreter.h" | ||
| 23 | |||
| 24 | using nihstro::OpCode; | ||
| 25 | using nihstro::Instruction; | ||
| 26 | using nihstro::SourceRegister; | ||
| 27 | using nihstro::SwizzlePattern; | ||
| 28 | |||
| 29 | GraphicsVertexShaderModel::GraphicsVertexShaderModel(GraphicsVertexShaderWidget* parent) | ||
| 30 | : QAbstractTableModel(parent), par(parent) {} | ||
| 31 | |||
| 32 | int GraphicsVertexShaderModel::columnCount(const QModelIndex& parent) const { | ||
| 33 | return 3; | ||
| 34 | } | ||
| 35 | |||
| 36 | int GraphicsVertexShaderModel::rowCount(const QModelIndex& parent) const { | ||
| 37 | return static_cast<int>(par->info.code.size()); | ||
| 38 | } | ||
| 39 | |||
| 40 | QVariant GraphicsVertexShaderModel::headerData(int section, Qt::Orientation orientation, | ||
| 41 | int role) const { | ||
| 42 | switch (role) { | ||
| 43 | case Qt::DisplayRole: { | ||
| 44 | if (section == 0) { | ||
| 45 | return tr("Offset"); | ||
| 46 | } else if (section == 1) { | ||
| 47 | return tr("Raw"); | ||
| 48 | } else if (section == 2) { | ||
| 49 | return tr("Disassembly"); | ||
| 50 | } | ||
| 51 | |||
| 52 | break; | ||
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 56 | return QVariant(); | ||
| 57 | } | ||
| 58 | |||
| 59 | static std::string SelectorToString(u32 selector) { | ||
| 60 | std::string ret; | ||
| 61 | for (int i = 0; i < 4; ++i) { | ||
| 62 | int component = (selector >> ((3 - i) * 2)) & 3; | ||
| 63 | ret += "xyzw"[component]; | ||
| 64 | } | ||
| 65 | return ret; | ||
| 66 | } | ||
| 67 | |||
| 68 | // e.g. "-c92[a0.x].xyzw" | ||
| 69 | static void print_input(std::ostringstream& output, const SourceRegister& input, bool negate, | ||
| 70 | const std::string& swizzle_mask, bool align = true, | ||
| 71 | const std::string& address_register_name = std::string()) { | ||
| 72 | if (align) | ||
| 73 | output << std::setw(4) << std::right; | ||
| 74 | output << ((negate ? "-" : "") + input.GetName()); | ||
| 75 | |||
| 76 | if (!address_register_name.empty()) | ||
| 77 | output << '[' << address_register_name << ']'; | ||
| 78 | output << '.' << swizzle_mask; | ||
| 79 | }; | ||
| 80 | |||
| 81 | QVariant GraphicsVertexShaderModel::data(const QModelIndex& index, int role) const { | ||
| 82 | switch (role) { | ||
| 83 | case Qt::DisplayRole: { | ||
| 84 | switch (index.column()) { | ||
| 85 | case 0: | ||
| 86 | if (par->info.HasLabel(index.row())) | ||
| 87 | return QString::fromStdString(par->info.GetLabel(index.row())); | ||
| 88 | |||
| 89 | return QString("%1").arg(4 * index.row(), 4, 16, QLatin1Char('0')); | ||
| 90 | |||
| 91 | case 1: | ||
| 92 | return QString("%1").arg(par->info.code[index.row()].hex, 8, 16, QLatin1Char('0')); | ||
| 93 | |||
| 94 | case 2: { | ||
| 95 | std::ostringstream output; | ||
| 96 | output.flags(std::ios::uppercase); | ||
| 97 | |||
| 98 | // To make the code aligning columns of assembly easier to keep track of, this function | ||
| 99 | // keeps track of the start of the start of the previous column, allowing alignment | ||
| 100 | // based on desired field widths. | ||
| 101 | int current_column = 0; | ||
| 102 | auto AlignToColumn = [&](int col_width) { | ||
| 103 | // Prints spaces to the output to pad previous column to size and advances the | ||
| 104 | // column marker. | ||
| 105 | current_column += col_width; | ||
| 106 | int to_add = std::max(1, current_column - (int)output.tellp()); | ||
| 107 | for (int i = 0; i < to_add; ++i) { | ||
| 108 | output << ' '; | ||
| 109 | } | ||
| 110 | }; | ||
| 111 | |||
| 112 | const Instruction instr = par->info.code[index.row()]; | ||
| 113 | const OpCode opcode = instr.opcode; | ||
| 114 | const OpCode::Info opcode_info = opcode.GetInfo(); | ||
| 115 | const u32 operand_desc_id = opcode_info.type == OpCode::Type::MultiplyAdd | ||
| 116 | ? instr.mad.operand_desc_id.Value() | ||
| 117 | : instr.common.operand_desc_id.Value(); | ||
| 118 | const SwizzlePattern swizzle = par->info.swizzle_info[operand_desc_id].pattern; | ||
| 119 | |||
| 120 | // longest known instruction name: "setemit " | ||
| 121 | int kOpcodeColumnWidth = 8; | ||
| 122 | // "rXX.xyzw " | ||
| 123 | int kOutputColumnWidth = 10; | ||
| 124 | // "-rXX.xyzw ", no attempt is made to align indexed inputs | ||
| 125 | int kInputOperandColumnWidth = 11; | ||
| 126 | |||
| 127 | output << opcode_info.name; | ||
| 128 | |||
| 129 | switch (opcode_info.type) { | ||
| 130 | case OpCode::Type::Trivial: | ||
| 131 | // Nothing to do here | ||
| 132 | break; | ||
| 133 | |||
| 134 | case OpCode::Type::Arithmetic: | ||
| 135 | case OpCode::Type::MultiplyAdd: { | ||
| 136 | // Use custom code for special instructions | ||
| 137 | switch (opcode.EffectiveOpCode()) { | ||
| 138 | case OpCode::Id::CMP: { | ||
| 139 | AlignToColumn(kOpcodeColumnWidth); | ||
| 140 | |||
| 141 | // NOTE: CMP always writes both cc components, so we do not consider the dest | ||
| 142 | // mask here. | ||
| 143 | output << " cc.xy"; | ||
| 144 | AlignToColumn(kOutputColumnWidth); | ||
| 145 | |||
| 146 | SourceRegister src1 = instr.common.GetSrc1(false); | ||
| 147 | SourceRegister src2 = instr.common.GetSrc2(false); | ||
| 148 | |||
| 149 | output << ' '; | ||
| 150 | print_input(output, src1, swizzle.negate_src1, | ||
| 151 | swizzle.SelectorToString(false).substr(0, 1), false, | ||
| 152 | instr.common.AddressRegisterName()); | ||
| 153 | output << ' ' << instr.common.compare_op.ToString(instr.common.compare_op.x) | ||
| 154 | << ' '; | ||
| 155 | print_input(output, src2, swizzle.negate_src2, | ||
| 156 | swizzle.SelectorToString(true).substr(0, 1), false); | ||
| 157 | |||
| 158 | output << ", "; | ||
| 159 | |||
| 160 | print_input(output, src1, swizzle.negate_src1, | ||
| 161 | swizzle.SelectorToString(false).substr(1, 1), false, | ||
| 162 | instr.common.AddressRegisterName()); | ||
| 163 | output << ' ' << instr.common.compare_op.ToString(instr.common.compare_op.y) | ||
| 164 | << ' '; | ||
| 165 | print_input(output, src2, swizzle.negate_src2, | ||
| 166 | swizzle.SelectorToString(true).substr(1, 1), false); | ||
| 167 | |||
| 168 | break; | ||
| 169 | } | ||
| 170 | |||
| 171 | case OpCode::Id::MAD: | ||
| 172 | case OpCode::Id::MADI: { | ||
| 173 | AlignToColumn(kOpcodeColumnWidth); | ||
| 174 | |||
| 175 | bool src_is_inverted = 0 != (opcode_info.subtype & OpCode::Info::SrcInversed); | ||
| 176 | SourceRegister src1 = instr.mad.GetSrc1(src_is_inverted); | ||
| 177 | SourceRegister src2 = instr.mad.GetSrc2(src_is_inverted); | ||
| 178 | SourceRegister src3 = instr.mad.GetSrc3(src_is_inverted); | ||
| 179 | |||
| 180 | output << std::setw(3) << std::right << instr.mad.dest.Value().GetName() << '.' | ||
| 181 | << swizzle.DestMaskToString(); | ||
| 182 | AlignToColumn(kOutputColumnWidth); | ||
| 183 | print_input(output, src1, swizzle.negate_src1, | ||
| 184 | SelectorToString(swizzle.src1_selector)); | ||
| 185 | AlignToColumn(kInputOperandColumnWidth); | ||
| 186 | print_input(output, src2, swizzle.negate_src2, | ||
| 187 | SelectorToString(swizzle.src2_selector), true, | ||
| 188 | src_is_inverted ? "" : instr.mad.AddressRegisterName()); | ||
| 189 | AlignToColumn(kInputOperandColumnWidth); | ||
| 190 | print_input(output, src3, swizzle.negate_src3, | ||
| 191 | SelectorToString(swizzle.src3_selector), true, | ||
| 192 | src_is_inverted ? instr.mad.AddressRegisterName() : ""); | ||
| 193 | AlignToColumn(kInputOperandColumnWidth); | ||
| 194 | break; | ||
| 195 | } | ||
| 196 | |||
| 197 | default: { | ||
| 198 | AlignToColumn(kOpcodeColumnWidth); | ||
| 199 | |||
| 200 | bool src_is_inverted = 0 != (opcode_info.subtype & OpCode::Info::SrcInversed); | ||
| 201 | |||
| 202 | if (opcode_info.subtype & OpCode::Info::Dest) { | ||
| 203 | // e.g. "r12.xy__" | ||
| 204 | output << std::setw(3) << std::right << instr.common.dest.Value().GetName() | ||
| 205 | << '.' << swizzle.DestMaskToString(); | ||
| 206 | } else if (opcode_info.subtype == OpCode::Info::MOVA) { | ||
| 207 | output << " a0." << swizzle.DestMaskToString(); | ||
| 208 | } | ||
| 209 | AlignToColumn(kOutputColumnWidth); | ||
| 210 | |||
| 211 | if (opcode_info.subtype & OpCode::Info::Src1) { | ||
| 212 | SourceRegister src1 = instr.common.GetSrc1(src_is_inverted); | ||
| 213 | print_input(output, src1, swizzle.negate_src1, | ||
| 214 | swizzle.SelectorToString(false), true, | ||
| 215 | src_is_inverted ? "" : instr.common.AddressRegisterName()); | ||
| 216 | AlignToColumn(kInputOperandColumnWidth); | ||
| 217 | } | ||
| 218 | |||
| 219 | if (opcode_info.subtype & OpCode::Info::Src2) { | ||
| 220 | SourceRegister src2 = instr.common.GetSrc2(src_is_inverted); | ||
| 221 | print_input(output, src2, swizzle.negate_src2, | ||
| 222 | swizzle.SelectorToString(true), true, | ||
| 223 | src_is_inverted ? instr.common.AddressRegisterName() : ""); | ||
| 224 | AlignToColumn(kInputOperandColumnWidth); | ||
| 225 | } | ||
| 226 | break; | ||
| 227 | } | ||
| 228 | } | ||
| 229 | |||
| 230 | break; | ||
| 231 | } | ||
| 232 | |||
| 233 | case OpCode::Type::Conditional: | ||
| 234 | case OpCode::Type::UniformFlowControl: { | ||
| 235 | output << ' '; | ||
| 236 | |||
| 237 | switch (opcode.EffectiveOpCode()) { | ||
| 238 | case OpCode::Id::LOOP: | ||
| 239 | output << 'i' << instr.flow_control.int_uniform_id << " (end on 0x" | ||
| 240 | << std::setw(4) << std::right << std::setfill('0') << std::hex | ||
| 241 | << (4 * instr.flow_control.dest_offset) << ")"; | ||
| 242 | break; | ||
| 243 | |||
| 244 | default: | ||
| 245 | if (opcode_info.subtype & OpCode::Info::HasCondition) { | ||
| 246 | output << '('; | ||
| 247 | |||
| 248 | if (instr.flow_control.op != instr.flow_control.JustY) { | ||
| 249 | if (!instr.flow_control.refx) | ||
| 250 | output << '!'; | ||
| 251 | output << "cc.x"; | ||
| 252 | } | ||
| 253 | |||
| 254 | if (instr.flow_control.op == instr.flow_control.Or) { | ||
| 255 | output << " || "; | ||
| 256 | } else if (instr.flow_control.op == instr.flow_control.And) { | ||
| 257 | output << " && "; | ||
| 258 | } | ||
| 259 | |||
| 260 | if (instr.flow_control.op != instr.flow_control.JustX) { | ||
| 261 | if (!instr.flow_control.refy) | ||
| 262 | output << '!'; | ||
| 263 | output << "cc.y"; | ||
| 264 | } | ||
| 265 | |||
| 266 | output << ") "; | ||
| 267 | } else if (opcode_info.subtype & OpCode::Info::HasUniformIndex) { | ||
| 268 | if (opcode.EffectiveOpCode() == OpCode::Id::JMPU && | ||
| 269 | (instr.flow_control.num_instructions & 1) == 1) { | ||
| 270 | output << '!'; | ||
| 271 | } | ||
| 272 | output << 'b' << instr.flow_control.bool_uniform_id << ' '; | ||
| 273 | } | ||
| 274 | |||
| 275 | if (opcode_info.subtype & OpCode::Info::HasAlternative) { | ||
| 276 | output << "else jump to 0x" << std::setw(4) << std::right | ||
| 277 | << std::setfill('0') << std::hex | ||
| 278 | << (4 * instr.flow_control.dest_offset); | ||
| 279 | } else if (opcode_info.subtype & OpCode::Info::HasExplicitDest) { | ||
| 280 | output << "jump to 0x" << std::setw(4) << std::right << std::setfill('0') | ||
| 281 | << std::hex << (4 * instr.flow_control.dest_offset); | ||
| 282 | } else { | ||
| 283 | // TODO: Handle other cases | ||
| 284 | output << "(unknown destination)"; | ||
| 285 | } | ||
| 286 | |||
| 287 | if (opcode_info.subtype & OpCode::Info::HasFinishPoint) { | ||
| 288 | output << " (return on 0x" << std::setw(4) << std::right | ||
| 289 | << std::setfill('0') << std::hex | ||
| 290 | << (4 * instr.flow_control.dest_offset + | ||
| 291 | 4 * instr.flow_control.num_instructions) | ||
| 292 | << ')'; | ||
| 293 | } | ||
| 294 | |||
| 295 | break; | ||
| 296 | } | ||
| 297 | break; | ||
| 298 | } | ||
| 299 | |||
| 300 | default: | ||
| 301 | output << " (unknown instruction format)"; | ||
| 302 | break; | ||
| 303 | } | ||
| 304 | |||
| 305 | return QString::fromLatin1(output.str().c_str()); | ||
| 306 | } | ||
| 307 | |||
| 308 | default: | ||
| 309 | break; | ||
| 310 | } | ||
| 311 | } | ||
| 312 | |||
| 313 | case Qt::FontRole: | ||
| 314 | return GetMonospaceFont(); | ||
| 315 | |||
| 316 | case Qt::BackgroundRole: { | ||
| 317 | // Highlight current instruction | ||
| 318 | int current_record_index = par->cycle_index->value(); | ||
| 319 | if (current_record_index < static_cast<int>(par->debug_data.records.size())) { | ||
| 320 | const auto& current_record = par->debug_data.records[current_record_index]; | ||
| 321 | if (index.row() == static_cast<int>(current_record.instruction_offset)) { | ||
| 322 | return QColor(255, 255, 63); | ||
| 323 | } | ||
| 324 | } | ||
| 325 | |||
| 326 | // Use a grey background for instructions which have no debug data associated to them | ||
| 327 | for (const auto& record : par->debug_data.records) | ||
| 328 | if (index.row() == static_cast<int>(record.instruction_offset)) | ||
| 329 | return QVariant(); | ||
| 330 | |||
| 331 | return QBrush(QColor(192, 192, 192)); | ||
| 332 | } | ||
| 333 | |||
| 334 | // TODO: Draw arrows for each "reachable" instruction to visualize control flow | ||
| 335 | |||
| 336 | default: | ||
| 337 | break; | ||
| 338 | } | ||
| 339 | |||
| 340 | return QVariant(); | ||
| 341 | } | ||
| 342 | |||
| 343 | void GraphicsVertexShaderWidget::DumpShader() { | ||
| 344 | QString filename = QFileDialog::getSaveFileName( | ||
| 345 | this, tr("Save Shader Dump"), "shader_dump.shbin", tr("Shader Binary (*.shbin)")); | ||
| 346 | |||
| 347 | if (filename.isEmpty()) { | ||
| 348 | // If the user canceled the dialog, don't dump anything. | ||
| 349 | return; | ||
| 350 | } | ||
| 351 | |||
| 352 | auto& setup = Pica::g_state.vs; | ||
| 353 | auto& config = Pica::g_state.regs.vs; | ||
| 354 | |||
| 355 | Pica::DebugUtils::DumpShader(filename.toStdString(), config, setup, | ||
| 356 | Pica::g_state.regs.rasterizer.vs_output_attributes); | ||
| 357 | } | ||
| 358 | |||
| 359 | GraphicsVertexShaderWidget::GraphicsVertexShaderWidget( | ||
| 360 | std::shared_ptr<Pica::DebugContext> debug_context, QWidget* parent) | ||
| 361 | : BreakPointObserverDock(debug_context, "Pica Vertex Shader", parent) { | ||
| 362 | setObjectName("PicaVertexShader"); | ||
| 363 | |||
| 364 | // Clear input vertex data so that it contains valid float values in case a debug shader | ||
| 365 | // execution happens before the first Vertex Loaded breakpoint. | ||
| 366 | // TODO: This makes a crash in the interpreter much less likely, but not impossible. The | ||
| 367 | // interpreter should guard against out-of-bounds accesses to ensure crashes in it aren't | ||
| 368 | // possible. | ||
| 369 | std::memset(&input_vertex, 0, sizeof(input_vertex)); | ||
| 370 | |||
| 371 | auto input_data_mapper = new QSignalMapper(this); | ||
| 372 | |||
| 373 | // TODO: Support inputting data in hexadecimal raw format | ||
| 374 | for (unsigned i = 0; i < ARRAY_SIZE(input_data); ++i) { | ||
| 375 | input_data[i] = new QLineEdit; | ||
| 376 | input_data[i]->setValidator(new QDoubleValidator(input_data[i])); | ||
| 377 | } | ||
| 378 | |||
| 379 | breakpoint_warning = | ||
| 380 | new QLabel(tr("(data only available at vertex shader invocation breakpoints)")); | ||
| 381 | |||
| 382 | // TODO: Add some button for jumping to the shader entry point | ||
| 383 | |||
| 384 | model = new GraphicsVertexShaderModel(this); | ||
| 385 | binary_list = new QTreeView; | ||
| 386 | binary_list->setModel(model); | ||
| 387 | binary_list->setRootIsDecorated(false); | ||
| 388 | binary_list->setAlternatingRowColors(true); | ||
| 389 | |||
| 390 | auto dump_shader = new QPushButton(QIcon::fromTheme("document-save"), tr("Dump")); | ||
| 391 | |||
| 392 | instruction_description = new QLabel; | ||
| 393 | |||
| 394 | cycle_index = new QSpinBox; | ||
| 395 | |||
| 396 | connect(dump_shader, SIGNAL(clicked()), this, SLOT(DumpShader())); | ||
| 397 | |||
| 398 | connect(cycle_index, SIGNAL(valueChanged(int)), this, SLOT(OnCycleIndexChanged(int))); | ||
| 399 | |||
| 400 | for (unsigned i = 0; i < ARRAY_SIZE(input_data); ++i) { | ||
| 401 | connect(input_data[i], SIGNAL(textEdited(const QString&)), input_data_mapper, SLOT(map())); | ||
| 402 | input_data_mapper->setMapping(input_data[i], i); | ||
| 403 | } | ||
| 404 | connect(input_data_mapper, SIGNAL(mapped(int)), this, SLOT(OnInputAttributeChanged(int))); | ||
| 405 | |||
| 406 | auto main_widget = new QWidget; | ||
| 407 | auto main_layout = new QVBoxLayout; | ||
| 408 | { | ||
| 409 | auto input_data_group = new QGroupBox(tr("Input Data")); | ||
| 410 | |||
| 411 | // For each vertex attribute, add a QHBoxLayout consisting of: | ||
| 412 | // - A QLabel denoting the source attribute index | ||
| 413 | // - Four QLineEdits for showing and manipulating attribute data | ||
| 414 | // - A QLabel denoting the shader input attribute index | ||
| 415 | auto sub_layout = new QVBoxLayout; | ||
| 416 | for (unsigned i = 0; i < 16; ++i) { | ||
| 417 | // Create an HBoxLayout to store the widgets used to specify a particular attribute | ||
| 418 | // and store it in a QWidget to allow for easy hiding and unhiding. | ||
| 419 | auto row_layout = new QHBoxLayout; | ||
| 420 | // Remove unnecessary padding between rows | ||
| 421 | row_layout->setContentsMargins(0, 0, 0, 0); | ||
| 422 | |||
| 423 | row_layout->addWidget(new QLabel(tr("Attribute %1").arg(i, 2))); | ||
| 424 | for (unsigned comp = 0; comp < 4; ++comp) | ||
| 425 | row_layout->addWidget(input_data[4 * i + comp]); | ||
| 426 | |||
| 427 | row_layout->addWidget(input_data_mapping[i] = new QLabel); | ||
| 428 | |||
| 429 | input_data_container[i] = new QWidget; | ||
| 430 | input_data_container[i]->setLayout(row_layout); | ||
| 431 | input_data_container[i]->hide(); | ||
| 432 | |||
| 433 | sub_layout->addWidget(input_data_container[i]); | ||
| 434 | } | ||
| 435 | |||
| 436 | sub_layout->addWidget(breakpoint_warning); | ||
| 437 | breakpoint_warning->hide(); | ||
| 438 | |||
| 439 | input_data_group->setLayout(sub_layout); | ||
| 440 | main_layout->addWidget(input_data_group); | ||
| 441 | } | ||
| 442 | |||
| 443 | // Make program listing expand to fill available space in the dialog | ||
| 444 | binary_list->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); | ||
| 445 | main_layout->addWidget(binary_list); | ||
| 446 | |||
| 447 | main_layout->addWidget(dump_shader); | ||
| 448 | { | ||
| 449 | auto sub_layout = new QFormLayout; | ||
| 450 | sub_layout->addRow(tr("Cycle Index:"), cycle_index); | ||
| 451 | |||
| 452 | main_layout->addLayout(sub_layout); | ||
| 453 | } | ||
| 454 | |||
| 455 | // Set a minimum height so that the size of this label doesn't cause the rest of the bottom | ||
| 456 | // part of the UI to keep jumping up and down when cycling through instructions. | ||
| 457 | instruction_description->setMinimumHeight(instruction_description->fontMetrics().lineSpacing() * | ||
| 458 | 6); | ||
| 459 | instruction_description->setAlignment(Qt::AlignLeft | Qt::AlignTop); | ||
| 460 | main_layout->addWidget(instruction_description); | ||
| 461 | |||
| 462 | main_widget->setLayout(main_layout); | ||
| 463 | setWidget(main_widget); | ||
| 464 | |||
| 465 | widget()->setEnabled(false); | ||
| 466 | } | ||
| 467 | |||
| 468 | void GraphicsVertexShaderWidget::OnBreakPointHit(Pica::DebugContext::Event event, void* data) { | ||
| 469 | if (event == Pica::DebugContext::Event::VertexShaderInvocation) { | ||
| 470 | Reload(true, data); | ||
| 471 | } else { | ||
| 472 | // No vertex data is retrievable => invalidate currently stored vertex data | ||
| 473 | Reload(true, nullptr); | ||
| 474 | } | ||
| 475 | widget()->setEnabled(true); | ||
| 476 | } | ||
| 477 | |||
| 478 | void GraphicsVertexShaderWidget::Reload(bool replace_vertex_data, void* vertex_data) { | ||
| 479 | model->beginResetModel(); | ||
| 480 | |||
| 481 | if (replace_vertex_data) { | ||
| 482 | if (vertex_data) { | ||
| 483 | memcpy(&input_vertex, vertex_data, sizeof(input_vertex)); | ||
| 484 | for (unsigned attr = 0; attr < 16; ++attr) { | ||
| 485 | for (unsigned comp = 0; comp < 4; ++comp) { | ||
| 486 | input_data[4 * attr + comp]->setText( | ||
| 487 | QString("%1").arg(input_vertex.attr[attr][comp].ToFloat32())); | ||
| 488 | } | ||
| 489 | } | ||
| 490 | breakpoint_warning->hide(); | ||
| 491 | } else { | ||
| 492 | for (unsigned attr = 0; attr < 16; ++attr) { | ||
| 493 | for (unsigned comp = 0; comp < 4; ++comp) { | ||
| 494 | input_data[4 * attr + comp]->setText(QString("???")); | ||
| 495 | } | ||
| 496 | } | ||
| 497 | breakpoint_warning->show(); | ||
| 498 | } | ||
| 499 | } | ||
| 500 | |||
| 501 | // Reload shader code | ||
| 502 | info.Clear(); | ||
| 503 | |||
| 504 | auto& shader_setup = Pica::g_state.vs; | ||
| 505 | auto& shader_config = Pica::g_state.regs.vs; | ||
| 506 | for (auto instr : shader_setup.program_code) | ||
| 507 | info.code.push_back({instr}); | ||
| 508 | int num_attributes = shader_config.max_input_attribute_index + 1; | ||
| 509 | |||
| 510 | for (auto pattern : shader_setup.swizzle_data) | ||
| 511 | info.swizzle_info.push_back({pattern}); | ||
| 512 | |||
| 513 | u32 entry_point = Pica::g_state.regs.vs.main_offset; | ||
| 514 | info.labels.insert({entry_point, "main"}); | ||
| 515 | |||
| 516 | // Generate debug information | ||
| 517 | Pica::Shader::InterpreterEngine shader_engine; | ||
| 518 | shader_engine.SetupBatch(shader_setup, entry_point); | ||
| 519 | debug_data = shader_engine.ProduceDebugInfo(shader_setup, input_vertex, shader_config); | ||
| 520 | |||
| 521 | // Reload widget state | ||
| 522 | for (int attr = 0; attr < num_attributes; ++attr) { | ||
| 523 | unsigned source_attr = shader_config.GetRegisterForAttribute(attr); | ||
| 524 | input_data_mapping[attr]->setText(QString("-> v%1").arg(source_attr)); | ||
| 525 | input_data_container[attr]->setVisible(true); | ||
| 526 | } | ||
| 527 | // Only show input attributes which are used as input to the shader | ||
| 528 | for (unsigned int attr = num_attributes; attr < 16; ++attr) { | ||
| 529 | input_data_container[attr]->setVisible(false); | ||
| 530 | } | ||
| 531 | |||
| 532 | // Initialize debug info text for current cycle count | ||
| 533 | cycle_index->setMaximum(static_cast<int>(debug_data.records.size() - 1)); | ||
| 534 | OnCycleIndexChanged(cycle_index->value()); | ||
| 535 | |||
| 536 | model->endResetModel(); | ||
| 537 | } | ||
| 538 | |||
| 539 | void GraphicsVertexShaderWidget::OnResumed() { | ||
| 540 | widget()->setEnabled(false); | ||
| 541 | } | ||
| 542 | |||
| 543 | void GraphicsVertexShaderWidget::OnInputAttributeChanged(int index) { | ||
| 544 | float value = input_data[index]->text().toFloat(); | ||
| 545 | input_vertex.attr[index / 4][index % 4] = Pica::float24::FromFloat32(value); | ||
| 546 | // Re-execute shader with updated value | ||
| 547 | Reload(); | ||
| 548 | } | ||
| 549 | |||
| 550 | void GraphicsVertexShaderWidget::OnCycleIndexChanged(int index) { | ||
| 551 | QString text; | ||
| 552 | |||
| 553 | auto& record = debug_data.records[index]; | ||
| 554 | if (record.mask & Pica::Shader::DebugDataRecord::SRC1) | ||
| 555 | text += tr("SRC1: %1, %2, %3, %4\n") | ||
| 556 | .arg(record.src1.x.ToFloat32()) | ||
| 557 | .arg(record.src1.y.ToFloat32()) | ||
| 558 | .arg(record.src1.z.ToFloat32()) | ||
| 559 | .arg(record.src1.w.ToFloat32()); | ||
| 560 | if (record.mask & Pica::Shader::DebugDataRecord::SRC2) | ||
| 561 | text += tr("SRC2: %1, %2, %3, %4\n") | ||
| 562 | .arg(record.src2.x.ToFloat32()) | ||
| 563 | .arg(record.src2.y.ToFloat32()) | ||
| 564 | .arg(record.src2.z.ToFloat32()) | ||
| 565 | .arg(record.src2.w.ToFloat32()); | ||
| 566 | if (record.mask & Pica::Shader::DebugDataRecord::SRC3) | ||
| 567 | text += tr("SRC3: %1, %2, %3, %4\n") | ||
| 568 | .arg(record.src3.x.ToFloat32()) | ||
| 569 | .arg(record.src3.y.ToFloat32()) | ||
| 570 | .arg(record.src3.z.ToFloat32()) | ||
| 571 | .arg(record.src3.w.ToFloat32()); | ||
| 572 | if (record.mask & Pica::Shader::DebugDataRecord::DEST_IN) | ||
| 573 | text += tr("DEST_IN: %1, %2, %3, %4\n") | ||
| 574 | .arg(record.dest_in.x.ToFloat32()) | ||
| 575 | .arg(record.dest_in.y.ToFloat32()) | ||
| 576 | .arg(record.dest_in.z.ToFloat32()) | ||
| 577 | .arg(record.dest_in.w.ToFloat32()); | ||
| 578 | if (record.mask & Pica::Shader::DebugDataRecord::DEST_OUT) | ||
| 579 | text += tr("DEST_OUT: %1, %2, %3, %4\n") | ||
| 580 | .arg(record.dest_out.x.ToFloat32()) | ||
| 581 | .arg(record.dest_out.y.ToFloat32()) | ||
| 582 | .arg(record.dest_out.z.ToFloat32()) | ||
| 583 | .arg(record.dest_out.w.ToFloat32()); | ||
| 584 | |||
| 585 | if (record.mask & Pica::Shader::DebugDataRecord::ADDR_REG_OUT) | ||
| 586 | text += tr("Address Registers: %1, %2\n") | ||
| 587 | .arg(record.address_registers[0]) | ||
| 588 | .arg(record.address_registers[1]); | ||
| 589 | if (record.mask & Pica::Shader::DebugDataRecord::CMP_RESULT) | ||
| 590 | text += tr("Compare Result: %1, %2\n") | ||
| 591 | .arg(record.conditional_code[0] ? "true" : "false") | ||
| 592 | .arg(record.conditional_code[1] ? "true" : "false"); | ||
| 593 | |||
| 594 | if (record.mask & Pica::Shader::DebugDataRecord::COND_BOOL_IN) | ||
| 595 | text += tr("Static Condition: %1\n").arg(record.cond_bool ? "true" : "false"); | ||
| 596 | if (record.mask & Pica::Shader::DebugDataRecord::COND_CMP_IN) | ||
| 597 | text += tr("Dynamic Conditions: %1, %2\n") | ||
| 598 | .arg(record.cond_cmp[0] ? "true" : "false") | ||
| 599 | .arg(record.cond_cmp[1] ? "true" : "false"); | ||
| 600 | if (record.mask & Pica::Shader::DebugDataRecord::LOOP_INT_IN) | ||
| 601 | text += tr("Loop Parameters: %1 (repeats), %2 (initializer), %3 (increment), %4\n") | ||
| 602 | .arg(record.loop_int.x) | ||
| 603 | .arg(record.loop_int.y) | ||
| 604 | .arg(record.loop_int.z) | ||
| 605 | .arg(record.loop_int.w); | ||
| 606 | |||
| 607 | text += | ||
| 608 | tr("Instruction offset: 0x%1").arg(4 * record.instruction_offset, 4, 16, QLatin1Char('0')); | ||
| 609 | if (record.mask & Pica::Shader::DebugDataRecord::NEXT_INSTR) { | ||
| 610 | text += tr(" -> 0x%2").arg(4 * record.next_instruction, 4, 16, QLatin1Char('0')); | ||
| 611 | } else { | ||
| 612 | text += tr(" (last instruction)"); | ||
| 613 | } | ||
| 614 | |||
| 615 | instruction_description->setText(text); | ||
| 616 | |||
| 617 | // Emit model update notification and scroll to current instruction | ||
| 618 | QModelIndex instr_index = model->index(record.instruction_offset, 0); | ||
| 619 | emit model->dataChanged(instr_index, | ||
| 620 | model->index(record.instruction_offset, model->columnCount())); | ||
| 621 | binary_list->scrollTo(instr_index, QAbstractItemView::EnsureVisible); | ||
| 622 | } | ||
diff --git a/src/citra_qt/debugger/graphics/graphics_vertex_shader.h b/src/citra_qt/debugger/graphics/graphics_vertex_shader.h deleted file mode 100644 index c249a2ff8..000000000 --- a/src/citra_qt/debugger/graphics/graphics_vertex_shader.h +++ /dev/null | |||
| @@ -1,88 +0,0 @@ | |||
| 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 <QAbstractTableModel> | ||
| 8 | #include <QTreeView> | ||
| 9 | #include "citra_qt/debugger/graphics/graphics_breakpoint_observer.h" | ||
| 10 | #include "nihstro/parser_shbin.h" | ||
| 11 | #include "video_core/shader/debug_data.h" | ||
| 12 | #include "video_core/shader/shader.h" | ||
| 13 | |||
| 14 | class QLabel; | ||
| 15 | class QSpinBox; | ||
| 16 | |||
| 17 | class GraphicsVertexShaderWidget; | ||
| 18 | |||
| 19 | class GraphicsVertexShaderModel : public QAbstractTableModel { | ||
| 20 | Q_OBJECT | ||
| 21 | |||
| 22 | public: | ||
| 23 | explicit GraphicsVertexShaderModel(GraphicsVertexShaderWidget* parent); | ||
| 24 | |||
| 25 | int columnCount(const QModelIndex& parent = QModelIndex()) const override; | ||
| 26 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; | ||
| 27 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; | ||
| 28 | QVariant headerData(int section, Qt::Orientation orientation, | ||
| 29 | int role = Qt::DisplayRole) const override; | ||
| 30 | |||
| 31 | private: | ||
| 32 | GraphicsVertexShaderWidget* par; | ||
| 33 | |||
| 34 | friend class GraphicsVertexShaderWidget; | ||
| 35 | }; | ||
| 36 | |||
| 37 | class GraphicsVertexShaderWidget : public BreakPointObserverDock { | ||
| 38 | Q_OBJECT | ||
| 39 | |||
| 40 | using Event = Pica::DebugContext::Event; | ||
| 41 | |||
| 42 | public: | ||
| 43 | GraphicsVertexShaderWidget(std::shared_ptr<Pica::DebugContext> debug_context, | ||
| 44 | QWidget* parent = nullptr); | ||
| 45 | |||
| 46 | private slots: | ||
| 47 | void OnBreakPointHit(Pica::DebugContext::Event event, void* data) override; | ||
| 48 | void OnResumed() override; | ||
| 49 | |||
| 50 | void OnInputAttributeChanged(int index); | ||
| 51 | |||
| 52 | void OnCycleIndexChanged(int index); | ||
| 53 | |||
| 54 | void DumpShader(); | ||
| 55 | |||
| 56 | /** | ||
| 57 | * Reload widget based on the current PICA200 state | ||
| 58 | * @param replace_vertex_data If true, invalidate all current vertex data | ||
| 59 | * @param vertex_data New vertex data to use, as passed to OnBreakPointHit. May be nullptr to | ||
| 60 | * specify that no valid vertex data can be retrieved currently. Only used if | ||
| 61 | * replace_vertex_data is true. | ||
| 62 | */ | ||
| 63 | void Reload(bool replace_vertex_data = false, void* vertex_data = nullptr); | ||
| 64 | |||
| 65 | private: | ||
| 66 | QLabel* instruction_description; | ||
| 67 | QTreeView* binary_list; | ||
| 68 | GraphicsVertexShaderModel* model; | ||
| 69 | |||
| 70 | /// TODO: Move these into a single struct | ||
| 71 | std::array<QLineEdit*, 4 * 16> | ||
| 72 | input_data; // A text box for each of the 4 components of up to 16 vertex attributes | ||
| 73 | std::array<QWidget*, 16> | ||
| 74 | input_data_container; // QWidget containing the QLayout containing each vertex attribute | ||
| 75 | std::array<QLabel*, 16> input_data_mapping; // A QLabel denoting the shader input attribute | ||
| 76 | // which the vertex attribute maps to | ||
| 77 | |||
| 78 | // Text to be shown when input vertex data is not retrievable | ||
| 79 | QLabel* breakpoint_warning; | ||
| 80 | |||
| 81 | QSpinBox* cycle_index; | ||
| 82 | |||
| 83 | nihstro::ShaderInfo info; | ||
| 84 | Pica::Shader::DebugData<true> debug_data; | ||
| 85 | Pica::Shader::AttributeBuffer input_vertex; | ||
| 86 | |||
| 87 | friend class GraphicsVertexShaderModel; | ||
| 88 | }; | ||
diff --git a/src/citra_qt/debugger/profiler.cpp b/src/citra_qt/debugger/profiler.cpp deleted file mode 100644 index f060bbe08..000000000 --- a/src/citra_qt/debugger/profiler.cpp +++ /dev/null | |||
| @@ -1,224 +0,0 @@ | |||
| 1 | // Copyright 2015 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <QAction> | ||
| 6 | #include <QLayout> | ||
| 7 | #include <QMouseEvent> | ||
| 8 | #include <QPainter> | ||
| 9 | #include <QString> | ||
| 10 | #include "citra_qt/debugger/profiler.h" | ||
| 11 | #include "citra_qt/util/util.h" | ||
| 12 | #include "common/common_types.h" | ||
| 13 | #include "common/microprofile.h" | ||
| 14 | |||
| 15 | // Include the implementation of the UI in this file. This isn't in microprofile.cpp because the | ||
| 16 | // non-Qt frontends don't need it (and don't implement the UI drawing hooks either). | ||
| 17 | #if MICROPROFILE_ENABLED | ||
| 18 | #define MICROPROFILEUI_IMPL 1 | ||
| 19 | #include "common/microprofileui.h" | ||
| 20 | |||
| 21 | class MicroProfileWidget : public QWidget { | ||
| 22 | public: | ||
| 23 | MicroProfileWidget(QWidget* parent = nullptr); | ||
| 24 | |||
| 25 | protected: | ||
| 26 | void paintEvent(QPaintEvent* ev) override; | ||
| 27 | void showEvent(QShowEvent* ev) override; | ||
| 28 | void hideEvent(QHideEvent* ev) override; | ||
| 29 | |||
| 30 | void mouseMoveEvent(QMouseEvent* ev) override; | ||
| 31 | void mousePressEvent(QMouseEvent* ev) override; | ||
| 32 | void mouseReleaseEvent(QMouseEvent* ev) override; | ||
| 33 | void wheelEvent(QWheelEvent* ev) override; | ||
| 34 | |||
| 35 | void keyPressEvent(QKeyEvent* ev) override; | ||
| 36 | void keyReleaseEvent(QKeyEvent* ev) override; | ||
| 37 | |||
| 38 | private: | ||
| 39 | /// This timer is used to redraw the widget's contents continuously. To save resources, it only | ||
| 40 | /// runs while the widget is visible. | ||
| 41 | QTimer update_timer; | ||
| 42 | /// Scale the coordinate system appropriately when dpi != 96. | ||
| 43 | qreal x_scale = 1.0, y_scale = 1.0; | ||
| 44 | }; | ||
| 45 | |||
| 46 | #endif | ||
| 47 | |||
| 48 | MicroProfileDialog::MicroProfileDialog(QWidget* parent) : QWidget(parent, Qt::Dialog) { | ||
| 49 | setObjectName("MicroProfile"); | ||
| 50 | setWindowTitle(tr("MicroProfile")); | ||
| 51 | resize(1000, 600); | ||
| 52 | // Remove the "?" button from the titlebar and enable the maximize button | ||
| 53 | setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint | Qt::WindowMaximizeButtonHint); | ||
| 54 | |||
| 55 | #if MICROPROFILE_ENABLED | ||
| 56 | |||
| 57 | MicroProfileWidget* widget = new MicroProfileWidget(this); | ||
| 58 | |||
| 59 | QLayout* layout = new QVBoxLayout(this); | ||
| 60 | layout->setContentsMargins(0, 0, 0, 0); | ||
| 61 | layout->addWidget(widget); | ||
| 62 | setLayout(layout); | ||
| 63 | |||
| 64 | // Configure focus so that widget is focusable and the dialog automatically forwards focus to | ||
| 65 | // it. | ||
| 66 | setFocusProxy(widget); | ||
| 67 | widget->setFocusPolicy(Qt::StrongFocus); | ||
| 68 | widget->setFocus(); | ||
| 69 | #endif | ||
| 70 | } | ||
| 71 | |||
| 72 | QAction* MicroProfileDialog::toggleViewAction() { | ||
| 73 | if (toggle_view_action == nullptr) { | ||
| 74 | toggle_view_action = new QAction(windowTitle(), this); | ||
| 75 | toggle_view_action->setCheckable(true); | ||
| 76 | toggle_view_action->setChecked(isVisible()); | ||
| 77 | connect(toggle_view_action, SIGNAL(toggled(bool)), SLOT(setVisible(bool))); | ||
| 78 | } | ||
| 79 | |||
| 80 | return toggle_view_action; | ||
| 81 | } | ||
| 82 | |||
| 83 | void MicroProfileDialog::showEvent(QShowEvent* ev) { | ||
| 84 | if (toggle_view_action) { | ||
| 85 | toggle_view_action->setChecked(isVisible()); | ||
| 86 | } | ||
| 87 | QWidget::showEvent(ev); | ||
| 88 | } | ||
| 89 | |||
| 90 | void MicroProfileDialog::hideEvent(QHideEvent* ev) { | ||
| 91 | if (toggle_view_action) { | ||
| 92 | toggle_view_action->setChecked(isVisible()); | ||
| 93 | } | ||
| 94 | QWidget::hideEvent(ev); | ||
| 95 | } | ||
| 96 | |||
| 97 | #if MICROPROFILE_ENABLED | ||
| 98 | |||
| 99 | /// There's no way to pass a user pointer to MicroProfile, so this variable is used to make the | ||
| 100 | /// QPainter available inside the drawing callbacks. | ||
| 101 | static QPainter* mp_painter = nullptr; | ||
| 102 | |||
| 103 | MicroProfileWidget::MicroProfileWidget(QWidget* parent) : QWidget(parent) { | ||
| 104 | // Send mouse motion events even when not dragging. | ||
| 105 | setMouseTracking(true); | ||
| 106 | |||
| 107 | MicroProfileSetDisplayMode(1); // Timers screen | ||
| 108 | MicroProfileInitUI(); | ||
| 109 | |||
| 110 | connect(&update_timer, SIGNAL(timeout()), SLOT(update())); | ||
| 111 | } | ||
| 112 | |||
| 113 | void MicroProfileWidget::paintEvent(QPaintEvent* ev) { | ||
| 114 | QPainter painter(this); | ||
| 115 | |||
| 116 | // The units used by Microprofile for drawing are based in pixels on a 96 dpi display. | ||
| 117 | x_scale = qreal(painter.device()->logicalDpiX()) / 96.0; | ||
| 118 | y_scale = qreal(painter.device()->logicalDpiY()) / 96.0; | ||
| 119 | painter.scale(x_scale, y_scale); | ||
| 120 | |||
| 121 | painter.setBackground(Qt::black); | ||
| 122 | painter.eraseRect(rect()); | ||
| 123 | |||
| 124 | QFont font = GetMonospaceFont(); | ||
| 125 | font.setPixelSize(MICROPROFILE_TEXT_HEIGHT); | ||
| 126 | painter.setFont(font); | ||
| 127 | |||
| 128 | mp_painter = &painter; | ||
| 129 | MicroProfileDraw(rect().width() / x_scale, rect().height() / y_scale); | ||
| 130 | mp_painter = nullptr; | ||
| 131 | } | ||
| 132 | |||
| 133 | void MicroProfileWidget::showEvent(QShowEvent* ev) { | ||
| 134 | update_timer.start(15); // ~60 Hz | ||
| 135 | QWidget::showEvent(ev); | ||
| 136 | } | ||
| 137 | |||
| 138 | void MicroProfileWidget::hideEvent(QHideEvent* ev) { | ||
| 139 | update_timer.stop(); | ||
| 140 | QWidget::hideEvent(ev); | ||
| 141 | } | ||
| 142 | |||
| 143 | void MicroProfileWidget::mouseMoveEvent(QMouseEvent* ev) { | ||
| 144 | MicroProfileMousePosition(ev->x() / x_scale, ev->y() / y_scale, 0); | ||
| 145 | ev->accept(); | ||
| 146 | } | ||
| 147 | |||
| 148 | void MicroProfileWidget::mousePressEvent(QMouseEvent* ev) { | ||
| 149 | MicroProfileMousePosition(ev->x() / x_scale, ev->y() / y_scale, 0); | ||
| 150 | MicroProfileMouseButton(ev->buttons() & Qt::LeftButton, ev->buttons() & Qt::RightButton); | ||
| 151 | ev->accept(); | ||
| 152 | } | ||
| 153 | |||
| 154 | void MicroProfileWidget::mouseReleaseEvent(QMouseEvent* ev) { | ||
| 155 | MicroProfileMousePosition(ev->x() / x_scale, ev->y() / y_scale, 0); | ||
| 156 | MicroProfileMouseButton(ev->buttons() & Qt::LeftButton, ev->buttons() & Qt::RightButton); | ||
| 157 | ev->accept(); | ||
| 158 | } | ||
| 159 | |||
| 160 | void MicroProfileWidget::wheelEvent(QWheelEvent* ev) { | ||
| 161 | MicroProfileMousePosition(ev->x() / x_scale, ev->y() / y_scale, ev->delta() / 120); | ||
| 162 | ev->accept(); | ||
| 163 | } | ||
| 164 | |||
| 165 | void MicroProfileWidget::keyPressEvent(QKeyEvent* ev) { | ||
| 166 | if (ev->key() == Qt::Key_Control) { | ||
| 167 | // Inform MicroProfile that the user is holding Ctrl. | ||
| 168 | MicroProfileModKey(1); | ||
| 169 | } | ||
| 170 | QWidget::keyPressEvent(ev); | ||
| 171 | } | ||
| 172 | |||
| 173 | void MicroProfileWidget::keyReleaseEvent(QKeyEvent* ev) { | ||
| 174 | if (ev->key() == Qt::Key_Control) { | ||
| 175 | MicroProfileModKey(0); | ||
| 176 | } | ||
| 177 | QWidget::keyReleaseEvent(ev); | ||
| 178 | } | ||
| 179 | |||
| 180 | // These functions are called by MicroProfileDraw to draw the interface elements on the screen. | ||
| 181 | |||
| 182 | void MicroProfileDrawText(int x, int y, u32 hex_color, const char* text, u32 text_length) { | ||
| 183 | // hex_color does not include an alpha, so it must be assumed to be 255 | ||
| 184 | mp_painter->setPen(QColor::fromRgb(hex_color)); | ||
| 185 | |||
| 186 | // It's impossible to draw a string using a monospaced font with a fixed width per cell in a | ||
| 187 | // way that's reliable across different platforms and fonts as far as I (yuriks) can tell, so | ||
| 188 | // draw each character individually in order to precisely control the text advance. | ||
| 189 | for (u32 i = 0; i < text_length; ++i) { | ||
| 190 | // Position the text baseline 1 pixel above the bottom of the text cell, this gives nice | ||
| 191 | // vertical alignment of text for a wide range of tested fonts. | ||
| 192 | mp_painter->drawText(x, y + MICROPROFILE_TEXT_HEIGHT - 2, QChar(text[i])); | ||
| 193 | x += MICROPROFILE_TEXT_WIDTH + 1; | ||
| 194 | } | ||
| 195 | } | ||
| 196 | |||
| 197 | void MicroProfileDrawBox(int left, int top, int right, int bottom, u32 hex_color, | ||
| 198 | MicroProfileBoxType type) { | ||
| 199 | QColor color = QColor::fromRgba(hex_color); | ||
| 200 | QBrush brush = color; | ||
| 201 | if (type == MicroProfileBoxTypeBar) { | ||
| 202 | QLinearGradient gradient(left, top, left, bottom); | ||
| 203 | gradient.setColorAt(0.f, color.lighter(125)); | ||
| 204 | gradient.setColorAt(1.f, color.darker(125)); | ||
| 205 | brush = gradient; | ||
| 206 | } | ||
| 207 | mp_painter->fillRect(left, top, right - left, bottom - top, brush); | ||
| 208 | } | ||
| 209 | |||
| 210 | void MicroProfileDrawLine2D(u32 vertices_length, float* vertices, u32 hex_color) { | ||
| 211 | // Temporary vector used to convert between the float array and QPointF. Marked static to reuse | ||
| 212 | // the allocation across calls. | ||
| 213 | static std::vector<QPointF> point_buf; | ||
| 214 | |||
| 215 | for (u32 i = 0; i < vertices_length; ++i) { | ||
| 216 | point_buf.emplace_back(vertices[i * 2 + 0], vertices[i * 2 + 1]); | ||
| 217 | } | ||
| 218 | |||
| 219 | // hex_color does not include an alpha, so it must be assumed to be 255 | ||
| 220 | mp_painter->setPen(QColor::fromRgb(hex_color)); | ||
| 221 | mp_painter->drawPolyline(point_buf.data(), vertices_length); | ||
| 222 | point_buf.clear(); | ||
| 223 | } | ||
| 224 | #endif | ||
diff --git a/src/citra_qt/debugger/profiler.h b/src/citra_qt/debugger/profiler.h deleted file mode 100644 index eae1e9e3c..000000000 --- a/src/citra_qt/debugger/profiler.h +++ /dev/null | |||
| @@ -1,27 +0,0 @@ | |||
| 1 | // Copyright 2015 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 <QAbstractItemModel> | ||
| 8 | #include <QDockWidget> | ||
| 9 | #include <QTimer> | ||
| 10 | #include "common/microprofile.h" | ||
| 11 | |||
| 12 | class MicroProfileDialog : public QWidget { | ||
| 13 | Q_OBJECT | ||
| 14 | |||
| 15 | public: | ||
| 16 | explicit MicroProfileDialog(QWidget* parent = nullptr); | ||
| 17 | |||
| 18 | /// Returns a QAction that can be used to toggle visibility of this dialog. | ||
| 19 | QAction* toggleViewAction(); | ||
| 20 | |||
| 21 | protected: | ||
| 22 | void showEvent(QShowEvent* ev) override; | ||
| 23 | void hideEvent(QHideEvent* ev) override; | ||
| 24 | |||
| 25 | private: | ||
| 26 | QAction* toggle_view_action = nullptr; | ||
| 27 | }; | ||
diff --git a/src/citra_qt/debugger/registers.cpp b/src/citra_qt/debugger/registers.cpp deleted file mode 100644 index f9345c9f6..000000000 --- a/src/citra_qt/debugger/registers.cpp +++ /dev/null | |||
| @@ -1,190 +0,0 @@ | |||
| 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 <QTreeWidgetItem> | ||
| 6 | #include "citra_qt/debugger/registers.h" | ||
| 7 | #include "citra_qt/util/util.h" | ||
| 8 | #include "core/arm/arm_interface.h" | ||
| 9 | #include "core/core.h" | ||
| 10 | |||
| 11 | RegistersWidget::RegistersWidget(QWidget* parent) : QDockWidget(parent) { | ||
| 12 | cpu_regs_ui.setupUi(this); | ||
| 13 | |||
| 14 | tree = cpu_regs_ui.treeWidget; | ||
| 15 | tree->addTopLevelItem(core_registers = new QTreeWidgetItem(QStringList(tr("Registers")))); | ||
| 16 | tree->addTopLevelItem(vfp_registers = new QTreeWidgetItem(QStringList(tr("VFP Registers")))); | ||
| 17 | tree->addTopLevelItem(vfp_system_registers = | ||
| 18 | new QTreeWidgetItem(QStringList(tr("VFP System Registers")))); | ||
| 19 | tree->addTopLevelItem(cpsr = new QTreeWidgetItem(QStringList("CPSR"))); | ||
| 20 | |||
| 21 | for (int i = 0; i < 16; ++i) { | ||
| 22 | QTreeWidgetItem* child = new QTreeWidgetItem(QStringList(QString("R[%1]").arg(i))); | ||
| 23 | core_registers->addChild(child); | ||
| 24 | } | ||
| 25 | |||
| 26 | for (int i = 0; i < 32; ++i) { | ||
| 27 | QTreeWidgetItem* child = new QTreeWidgetItem(QStringList(QString("S[%1]").arg(i))); | ||
| 28 | vfp_registers->addChild(child); | ||
| 29 | } | ||
| 30 | |||
| 31 | QFont font = GetMonospaceFont(); | ||
| 32 | |||
| 33 | CreateCPSRChildren(); | ||
| 34 | CreateVFPSystemRegisterChildren(); | ||
| 35 | |||
| 36 | // Set Registers to display in monospace font | ||
| 37 | for (int i = 0; i < core_registers->childCount(); ++i) | ||
| 38 | core_registers->child(i)->setFont(1, font); | ||
| 39 | |||
| 40 | for (int i = 0; i < vfp_registers->childCount(); ++i) | ||
| 41 | vfp_registers->child(i)->setFont(1, font); | ||
| 42 | |||
| 43 | for (int i = 0; i < vfp_system_registers->childCount(); ++i) { | ||
| 44 | vfp_system_registers->child(i)->setFont(1, font); | ||
| 45 | for (int x = 0; x < vfp_system_registers->child(i)->childCount(); ++x) { | ||
| 46 | vfp_system_registers->child(i)->child(x)->setFont(1, font); | ||
| 47 | } | ||
| 48 | } | ||
| 49 | // Set CSPR to display in monospace font | ||
| 50 | cpsr->setFont(1, font); | ||
| 51 | for (int i = 0; i < cpsr->childCount(); ++i) { | ||
| 52 | cpsr->child(i)->setFont(1, font); | ||
| 53 | for (int x = 0; x < cpsr->child(i)->childCount(); ++x) { | ||
| 54 | cpsr->child(i)->child(x)->setFont(1, font); | ||
| 55 | } | ||
| 56 | } | ||
| 57 | setEnabled(false); | ||
| 58 | } | ||
| 59 | |||
| 60 | void RegistersWidget::OnDebugModeEntered() { | ||
| 61 | if (!Core::System::GetInstance().IsPoweredOn()) | ||
| 62 | return; | ||
| 63 | |||
| 64 | for (int i = 0; i < core_registers->childCount(); ++i) | ||
| 65 | core_registers->child(i)->setText( | ||
| 66 | 1, QString("0x%1").arg(Core::CPU().GetReg(i), 8, 16, QLatin1Char('0'))); | ||
| 67 | |||
| 68 | UpdateCPSRValues(); | ||
| 69 | } | ||
| 70 | |||
| 71 | void RegistersWidget::OnDebugModeLeft() {} | ||
| 72 | |||
| 73 | void RegistersWidget::OnEmulationStarting(EmuThread* emu_thread) { | ||
| 74 | setEnabled(true); | ||
| 75 | } | ||
| 76 | |||
| 77 | void RegistersWidget::OnEmulationStopping() { | ||
| 78 | // Reset widget text | ||
| 79 | for (int i = 0; i < core_registers->childCount(); ++i) | ||
| 80 | core_registers->child(i)->setText(1, QString("")); | ||
| 81 | |||
| 82 | for (int i = 0; i < vfp_registers->childCount(); ++i) | ||
| 83 | vfp_registers->child(i)->setText(1, QString("")); | ||
| 84 | |||
| 85 | for (int i = 0; i < cpsr->childCount(); ++i) | ||
| 86 | cpsr->child(i)->setText(1, QString("")); | ||
| 87 | |||
| 88 | cpsr->setText(1, QString("")); | ||
| 89 | |||
| 90 | // FPSCR | ||
| 91 | for (int i = 0; i < vfp_system_registers->child(0)->childCount(); ++i) | ||
| 92 | vfp_system_registers->child(0)->child(i)->setText(1, QString("")); | ||
| 93 | |||
| 94 | // FPEXC | ||
| 95 | for (int i = 0; i < vfp_system_registers->child(1)->childCount(); ++i) | ||
| 96 | vfp_system_registers->child(1)->child(i)->setText(1, QString("")); | ||
| 97 | |||
| 98 | vfp_system_registers->child(0)->setText(1, QString("")); | ||
| 99 | vfp_system_registers->child(1)->setText(1, QString("")); | ||
| 100 | vfp_system_registers->child(2)->setText(1, QString("")); | ||
| 101 | vfp_system_registers->child(3)->setText(1, QString("")); | ||
| 102 | |||
| 103 | setEnabled(false); | ||
| 104 | } | ||
| 105 | |||
| 106 | void RegistersWidget::CreateCPSRChildren() { | ||
| 107 | cpsr->addChild(new QTreeWidgetItem(QStringList("M"))); | ||
| 108 | cpsr->addChild(new QTreeWidgetItem(QStringList("T"))); | ||
| 109 | cpsr->addChild(new QTreeWidgetItem(QStringList("F"))); | ||
| 110 | cpsr->addChild(new QTreeWidgetItem(QStringList("I"))); | ||
| 111 | cpsr->addChild(new QTreeWidgetItem(QStringList("A"))); | ||
| 112 | cpsr->addChild(new QTreeWidgetItem(QStringList("E"))); | ||
| 113 | cpsr->addChild(new QTreeWidgetItem(QStringList("IT"))); | ||
| 114 | cpsr->addChild(new QTreeWidgetItem(QStringList("GE"))); | ||
| 115 | cpsr->addChild(new QTreeWidgetItem(QStringList("DNM"))); | ||
| 116 | cpsr->addChild(new QTreeWidgetItem(QStringList("J"))); | ||
| 117 | cpsr->addChild(new QTreeWidgetItem(QStringList("Q"))); | ||
| 118 | cpsr->addChild(new QTreeWidgetItem(QStringList("V"))); | ||
| 119 | cpsr->addChild(new QTreeWidgetItem(QStringList("C"))); | ||
| 120 | cpsr->addChild(new QTreeWidgetItem(QStringList("Z"))); | ||
| 121 | cpsr->addChild(new QTreeWidgetItem(QStringList("N"))); | ||
| 122 | } | ||
| 123 | |||
| 124 | void RegistersWidget::UpdateCPSRValues() { | ||
| 125 | const u32 cpsr_val = Core::CPU().GetCPSR(); | ||
| 126 | |||
| 127 | cpsr->setText(1, QString("0x%1").arg(cpsr_val, 8, 16, QLatin1Char('0'))); | ||
| 128 | cpsr->child(0)->setText( | ||
| 129 | 1, QString("b%1").arg(cpsr_val & 0x1F, 5, 2, QLatin1Char('0'))); // M - Mode | ||
| 130 | cpsr->child(1)->setText(1, QString::number((cpsr_val >> 5) & 1)); // T - State | ||
| 131 | cpsr->child(2)->setText(1, QString::number((cpsr_val >> 6) & 1)); // F - FIQ disable | ||
| 132 | cpsr->child(3)->setText(1, QString::number((cpsr_val >> 7) & 1)); // I - IRQ disable | ||
| 133 | cpsr->child(4)->setText(1, QString::number((cpsr_val >> 8) & 1)); // A - Imprecise abort | ||
| 134 | cpsr->child(5)->setText(1, QString::number((cpsr_val >> 9) & 1)); // E - Data endianness | ||
| 135 | cpsr->child(6)->setText(1, | ||
| 136 | QString::number((cpsr_val >> 10) & 0x3F)); // IT - If-Then state (DNM) | ||
| 137 | cpsr->child(7)->setText(1, | ||
| 138 | QString::number((cpsr_val >> 16) & 0xF)); // GE - Greater-than-or-Equal | ||
| 139 | cpsr->child(8)->setText(1, QString::number((cpsr_val >> 20) & 0xF)); // DNM - Do not modify | ||
| 140 | cpsr->child(9)->setText(1, QString::number((cpsr_val >> 24) & 1)); // J - Jazelle | ||
| 141 | cpsr->child(10)->setText(1, QString::number((cpsr_val >> 27) & 1)); // Q - Saturation | ||
| 142 | cpsr->child(11)->setText(1, QString::number((cpsr_val >> 28) & 1)); // V - Overflow | ||
| 143 | cpsr->child(12)->setText(1, QString::number((cpsr_val >> 29) & 1)); // C - Carry/Borrow/Extend | ||
| 144 | cpsr->child(13)->setText(1, QString::number((cpsr_val >> 30) & 1)); // Z - Zero | ||
| 145 | cpsr->child(14)->setText(1, QString::number((cpsr_val >> 31) & 1)); // N - Negative/Less than | ||
| 146 | } | ||
| 147 | |||
| 148 | void RegistersWidget::CreateVFPSystemRegisterChildren() { | ||
| 149 | QTreeWidgetItem* const fpscr = new QTreeWidgetItem(QStringList("FPSCR")); | ||
| 150 | fpscr->addChild(new QTreeWidgetItem(QStringList("IOC"))); | ||
| 151 | fpscr->addChild(new QTreeWidgetItem(QStringList("DZC"))); | ||
| 152 | fpscr->addChild(new QTreeWidgetItem(QStringList("OFC"))); | ||
| 153 | fpscr->addChild(new QTreeWidgetItem(QStringList("UFC"))); | ||
| 154 | fpscr->addChild(new QTreeWidgetItem(QStringList("IXC"))); | ||
| 155 | fpscr->addChild(new QTreeWidgetItem(QStringList("IDC"))); | ||
| 156 | fpscr->addChild(new QTreeWidgetItem(QStringList("IOE"))); | ||
| 157 | fpscr->addChild(new QTreeWidgetItem(QStringList("DZE"))); | ||
| 158 | fpscr->addChild(new QTreeWidgetItem(QStringList("OFE"))); | ||
| 159 | fpscr->addChild(new QTreeWidgetItem(QStringList("UFE"))); | ||
| 160 | fpscr->addChild(new QTreeWidgetItem(QStringList("IXE"))); | ||
| 161 | fpscr->addChild(new QTreeWidgetItem(QStringList("IDE"))); | ||
| 162 | fpscr->addChild(new QTreeWidgetItem(QStringList(tr("Vector Length")))); | ||
| 163 | fpscr->addChild(new QTreeWidgetItem(QStringList(tr("Vector Stride")))); | ||
| 164 | fpscr->addChild(new QTreeWidgetItem(QStringList(tr("Rounding Mode")))); | ||
| 165 | fpscr->addChild(new QTreeWidgetItem(QStringList("FZ"))); | ||
| 166 | fpscr->addChild(new QTreeWidgetItem(QStringList("DN"))); | ||
| 167 | fpscr->addChild(new QTreeWidgetItem(QStringList("V"))); | ||
| 168 | fpscr->addChild(new QTreeWidgetItem(QStringList("C"))); | ||
| 169 | fpscr->addChild(new QTreeWidgetItem(QStringList("Z"))); | ||
| 170 | fpscr->addChild(new QTreeWidgetItem(QStringList("N"))); | ||
| 171 | |||
| 172 | QTreeWidgetItem* const fpexc = new QTreeWidgetItem(QStringList("FPEXC")); | ||
| 173 | fpexc->addChild(new QTreeWidgetItem(QStringList("IOC"))); | ||
| 174 | fpexc->addChild(new QTreeWidgetItem(QStringList("OFC"))); | ||
| 175 | fpexc->addChild(new QTreeWidgetItem(QStringList("UFC"))); | ||
| 176 | fpexc->addChild(new QTreeWidgetItem(QStringList("INV"))); | ||
| 177 | fpexc->addChild(new QTreeWidgetItem(QStringList(tr("Vector Iteration Count")))); | ||
| 178 | fpexc->addChild(new QTreeWidgetItem(QStringList("FP2V"))); | ||
| 179 | fpexc->addChild(new QTreeWidgetItem(QStringList("EN"))); | ||
| 180 | fpexc->addChild(new QTreeWidgetItem(QStringList("EX"))); | ||
| 181 | |||
| 182 | vfp_system_registers->addChild(fpscr); | ||
| 183 | vfp_system_registers->addChild(fpexc); | ||
| 184 | vfp_system_registers->addChild(new QTreeWidgetItem(QStringList("FPINST"))); | ||
| 185 | vfp_system_registers->addChild(new QTreeWidgetItem(QStringList("FPINST2"))); | ||
| 186 | } | ||
| 187 | |||
| 188 | void RegistersWidget::UpdateVFPSystemRegisterValues() { | ||
| 189 | UNIMPLEMENTED(); | ||
| 190 | } | ||
diff --git a/src/citra_qt/debugger/registers.h b/src/citra_qt/debugger/registers.h deleted file mode 100644 index 55bda5b59..000000000 --- a/src/citra_qt/debugger/registers.h +++ /dev/null | |||
| @@ -1,42 +0,0 @@ | |||
| 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 | #include "ui_registers.h" | ||
| 9 | |||
| 10 | class QTreeWidget; | ||
| 11 | class QTreeWidgetItem; | ||
| 12 | class EmuThread; | ||
| 13 | |||
| 14 | class RegistersWidget : public QDockWidget { | ||
| 15 | Q_OBJECT | ||
| 16 | |||
| 17 | public: | ||
| 18 | explicit RegistersWidget(QWidget* parent = nullptr); | ||
| 19 | |||
| 20 | public slots: | ||
| 21 | void OnDebugModeEntered(); | ||
| 22 | void OnDebugModeLeft(); | ||
| 23 | |||
| 24 | void OnEmulationStarting(EmuThread* emu_thread); | ||
| 25 | void OnEmulationStopping(); | ||
| 26 | |||
| 27 | private: | ||
| 28 | void CreateCPSRChildren(); | ||
| 29 | void UpdateCPSRValues(); | ||
| 30 | |||
| 31 | void CreateVFPSystemRegisterChildren(); | ||
| 32 | void UpdateVFPSystemRegisterValues(); | ||
| 33 | |||
| 34 | Ui::ARMRegisters cpu_regs_ui; | ||
| 35 | |||
| 36 | QTreeWidget* tree; | ||
| 37 | |||
| 38 | QTreeWidgetItem* core_registers; | ||
| 39 | QTreeWidgetItem* vfp_registers; | ||
| 40 | QTreeWidgetItem* vfp_system_registers; | ||
| 41 | QTreeWidgetItem* cpsr; | ||
| 42 | }; | ||
diff --git a/src/citra_qt/debugger/registers.ui b/src/citra_qt/debugger/registers.ui deleted file mode 100644 index c81ae03f9..000000000 --- a/src/citra_qt/debugger/registers.ui +++ /dev/null | |||
| @@ -1,40 +0,0 @@ | |||
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <ui version="4.0"> | ||
| 3 | <class>ARMRegisters</class> | ||
| 4 | <widget class="QDockWidget" name="ARMRegisters"> | ||
| 5 | <property name="geometry"> | ||
| 6 | <rect> | ||
| 7 | <x>0</x> | ||
| 8 | <y>0</y> | ||
| 9 | <width>400</width> | ||
| 10 | <height>300</height> | ||
| 11 | </rect> | ||
| 12 | </property> | ||
| 13 | <property name="windowTitle"> | ||
| 14 | <string>ARM Registers</string> | ||
| 15 | </property> | ||
| 16 | <widget class="QWidget" name="dockWidgetContents"> | ||
| 17 | <layout class="QVBoxLayout" name="verticalLayout"> | ||
| 18 | <item> | ||
| 19 | <widget class="QTreeWidget" name="treeWidget"> | ||
| 20 | <property name="alternatingRowColors"> | ||
| 21 | <bool>true</bool> | ||
| 22 | </property> | ||
| 23 | <column> | ||
| 24 | <property name="text"> | ||
| 25 | <string>Register</string> | ||
| 26 | </property> | ||
| 27 | </column> | ||
| 28 | <column> | ||
| 29 | <property name="text"> | ||
| 30 | <string>Value</string> | ||
| 31 | </property> | ||
| 32 | </column> | ||
| 33 | </widget> | ||
| 34 | </item> | ||
| 35 | </layout> | ||
| 36 | </widget> | ||
| 37 | </widget> | ||
| 38 | <resources/> | ||
| 39 | <connections/> | ||
| 40 | </ui> | ||
diff --git a/src/citra_qt/debugger/wait_tree.cpp b/src/citra_qt/debugger/wait_tree.cpp deleted file mode 100644 index eefbcb9f1..000000000 --- a/src/citra_qt/debugger/wait_tree.cpp +++ /dev/null | |||
| @@ -1,417 +0,0 @@ | |||
| 1 | // Copyright 2016 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "citra_qt/debugger/wait_tree.h" | ||
| 6 | #include "citra_qt/util/util.h" | ||
| 7 | |||
| 8 | #include "core/hle/kernel/condition_variable.h" | ||
| 9 | #include "core/hle/kernel/event.h" | ||
| 10 | #include "core/hle/kernel/mutex.h" | ||
| 11 | #include "core/hle/kernel/thread.h" | ||
| 12 | #include "core/hle/kernel/timer.h" | ||
| 13 | #include "core/hle/kernel/wait_object.h" | ||
| 14 | |||
| 15 | WaitTreeItem::~WaitTreeItem() {} | ||
| 16 | |||
| 17 | QColor WaitTreeItem::GetColor() const { | ||
| 18 | return QColor(Qt::GlobalColor::black); | ||
| 19 | } | ||
| 20 | |||
| 21 | std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeItem::GetChildren() const { | ||
| 22 | return {}; | ||
| 23 | } | ||
| 24 | |||
| 25 | void WaitTreeItem::Expand() { | ||
| 26 | if (IsExpandable() && !expanded) { | ||
| 27 | children = GetChildren(); | ||
| 28 | for (std::size_t i = 0; i < children.size(); ++i) { | ||
| 29 | children[i]->parent = this; | ||
| 30 | children[i]->row = i; | ||
| 31 | } | ||
| 32 | expanded = true; | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | WaitTreeItem* WaitTreeItem::Parent() const { | ||
| 37 | return parent; | ||
| 38 | } | ||
| 39 | |||
| 40 | const std::vector<std::unique_ptr<WaitTreeItem>>& WaitTreeItem::Children() const { | ||
| 41 | return children; | ||
| 42 | } | ||
| 43 | |||
| 44 | bool WaitTreeItem::IsExpandable() const { | ||
| 45 | return false; | ||
| 46 | } | ||
| 47 | |||
| 48 | std::size_t WaitTreeItem::Row() const { | ||
| 49 | return row; | ||
| 50 | } | ||
| 51 | |||
| 52 | std::vector<std::unique_ptr<WaitTreeThread>> WaitTreeItem::MakeThreadItemList() { | ||
| 53 | const auto& threads = Kernel::GetThreadList(); | ||
| 54 | std::vector<std::unique_ptr<WaitTreeThread>> item_list; | ||
| 55 | item_list.reserve(threads.size()); | ||
| 56 | for (std::size_t i = 0; i < threads.size(); ++i) { | ||
| 57 | item_list.push_back(std::make_unique<WaitTreeThread>(*threads[i])); | ||
| 58 | item_list.back()->row = i; | ||
| 59 | } | ||
| 60 | return item_list; | ||
| 61 | } | ||
| 62 | |||
| 63 | WaitTreeText::WaitTreeText(const QString& t) : text(t) {} | ||
| 64 | |||
| 65 | QString WaitTreeText::GetText() const { | ||
| 66 | return text; | ||
| 67 | } | ||
| 68 | |||
| 69 | WaitTreeWaitObject::WaitTreeWaitObject(const Kernel::WaitObject& o) : object(o) {} | ||
| 70 | |||
| 71 | bool WaitTreeExpandableItem::IsExpandable() const { | ||
| 72 | return true; | ||
| 73 | } | ||
| 74 | |||
| 75 | QString WaitTreeWaitObject::GetText() const { | ||
| 76 | return tr("[%1]%2 %3") | ||
| 77 | .arg(object.GetObjectId()) | ||
| 78 | .arg(QString::fromStdString(object.GetTypeName()), | ||
| 79 | QString::fromStdString(object.GetName())); | ||
| 80 | } | ||
| 81 | |||
| 82 | std::unique_ptr<WaitTreeWaitObject> WaitTreeWaitObject::make(const Kernel::WaitObject& object) { | ||
| 83 | switch (object.GetHandleType()) { | ||
| 84 | case Kernel::HandleType::Event: | ||
| 85 | return std::make_unique<WaitTreeEvent>(static_cast<const Kernel::Event&>(object)); | ||
| 86 | case Kernel::HandleType::Mutex: | ||
| 87 | return std::make_unique<WaitTreeMutex>(static_cast<const Kernel::Mutex&>(object)); | ||
| 88 | case Kernel::HandleType::ConditionVariable: | ||
| 89 | return std::make_unique<WaitTreeConditionVariable>( | ||
| 90 | static_cast<const Kernel::ConditionVariable&>(object)); | ||
| 91 | case Kernel::HandleType::Timer: | ||
| 92 | return std::make_unique<WaitTreeTimer>(static_cast<const Kernel::Timer&>(object)); | ||
| 93 | case Kernel::HandleType::Thread: | ||
| 94 | return std::make_unique<WaitTreeThread>(static_cast<const Kernel::Thread&>(object)); | ||
| 95 | default: | ||
| 96 | return std::make_unique<WaitTreeWaitObject>(object); | ||
| 97 | } | ||
| 98 | } | ||
| 99 | |||
| 100 | std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeWaitObject::GetChildren() const { | ||
| 101 | std::vector<std::unique_ptr<WaitTreeItem>> list; | ||
| 102 | |||
| 103 | const auto& threads = object.GetWaitingThreads(); | ||
| 104 | if (threads.empty()) { | ||
| 105 | list.push_back(std::make_unique<WaitTreeText>(tr("waited by no thread"))); | ||
| 106 | } else { | ||
| 107 | list.push_back(std::make_unique<WaitTreeThreadList>(threads)); | ||
| 108 | } | ||
| 109 | return list; | ||
| 110 | } | ||
| 111 | |||
| 112 | QString WaitTreeWaitObject::GetResetTypeQString(Kernel::ResetType reset_type) { | ||
| 113 | switch (reset_type) { | ||
| 114 | case Kernel::ResetType::OneShot: | ||
| 115 | return tr("one shot"); | ||
| 116 | case Kernel::ResetType::Sticky: | ||
| 117 | return tr("sticky"); | ||
| 118 | case Kernel::ResetType::Pulse: | ||
| 119 | return tr("pulse"); | ||
| 120 | } | ||
| 121 | } | ||
| 122 | |||
| 123 | WaitTreeObjectList::WaitTreeObjectList( | ||
| 124 | const std::vector<Kernel::SharedPtr<Kernel::WaitObject>>& list, bool w_all) | ||
| 125 | : object_list(list), wait_all(w_all) {} | ||
| 126 | |||
| 127 | QString WaitTreeObjectList::GetText() const { | ||
| 128 | if (wait_all) | ||
| 129 | return tr("waiting for all objects"); | ||
| 130 | return tr("waiting for one of the following objects"); | ||
| 131 | } | ||
| 132 | |||
| 133 | std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeObjectList::GetChildren() const { | ||
| 134 | std::vector<std::unique_ptr<WaitTreeItem>> list(object_list.size()); | ||
| 135 | std::transform(object_list.begin(), object_list.end(), list.begin(), | ||
| 136 | [](const auto& t) { return WaitTreeWaitObject::make(*t); }); | ||
| 137 | return list; | ||
| 138 | } | ||
| 139 | |||
| 140 | WaitTreeThread::WaitTreeThread(const Kernel::Thread& thread) : WaitTreeWaitObject(thread) {} | ||
| 141 | |||
| 142 | QString WaitTreeThread::GetText() const { | ||
| 143 | const auto& thread = static_cast<const Kernel::Thread&>(object); | ||
| 144 | QString status; | ||
| 145 | switch (thread.status) { | ||
| 146 | case THREADSTATUS_RUNNING: | ||
| 147 | status = tr("running"); | ||
| 148 | break; | ||
| 149 | case THREADSTATUS_READY: | ||
| 150 | status = tr("ready"); | ||
| 151 | break; | ||
| 152 | case THREADSTATUS_WAIT_ARB: | ||
| 153 | status = tr("waiting for address 0x%1").arg(thread.wait_address, 8, 16, QLatin1Char('0')); | ||
| 154 | break; | ||
| 155 | case THREADSTATUS_WAIT_SLEEP: | ||
| 156 | status = tr("sleeping"); | ||
| 157 | break; | ||
| 158 | case THREADSTATUS_WAIT_SYNCH_ALL: | ||
| 159 | case THREADSTATUS_WAIT_SYNCH_ANY: | ||
| 160 | status = tr("waiting for objects"); | ||
| 161 | break; | ||
| 162 | case THREADSTATUS_DORMANT: | ||
| 163 | status = tr("dormant"); | ||
| 164 | break; | ||
| 165 | case THREADSTATUS_DEAD: | ||
| 166 | status = tr("dead"); | ||
| 167 | break; | ||
| 168 | } | ||
| 169 | QString pc_info = tr(" PC = 0x%1 LR = 0x%2") | ||
| 170 | .arg(thread.context.pc, 8, 16, QLatin1Char('0')) | ||
| 171 | .arg(thread.context.cpu_registers[31], 8, 16, QLatin1Char('0')); | ||
| 172 | return WaitTreeWaitObject::GetText() + pc_info + " (" + status + ") "; | ||
| 173 | } | ||
| 174 | |||
| 175 | QColor WaitTreeThread::GetColor() const { | ||
| 176 | const auto& thread = static_cast<const Kernel::Thread&>(object); | ||
| 177 | switch (thread.status) { | ||
| 178 | case THREADSTATUS_RUNNING: | ||
| 179 | return QColor(Qt::GlobalColor::darkGreen); | ||
| 180 | case THREADSTATUS_READY: | ||
| 181 | return QColor(Qt::GlobalColor::darkBlue); | ||
| 182 | case THREADSTATUS_WAIT_ARB: | ||
| 183 | return QColor(Qt::GlobalColor::darkRed); | ||
| 184 | case THREADSTATUS_WAIT_SLEEP: | ||
| 185 | return QColor(Qt::GlobalColor::darkYellow); | ||
| 186 | case THREADSTATUS_WAIT_SYNCH_ALL: | ||
| 187 | case THREADSTATUS_WAIT_SYNCH_ANY: | ||
| 188 | return QColor(Qt::GlobalColor::red); | ||
| 189 | case THREADSTATUS_DORMANT: | ||
| 190 | return QColor(Qt::GlobalColor::darkCyan); | ||
| 191 | case THREADSTATUS_DEAD: | ||
| 192 | return QColor(Qt::GlobalColor::gray); | ||
| 193 | default: | ||
| 194 | return WaitTreeItem::GetColor(); | ||
| 195 | } | ||
| 196 | } | ||
| 197 | |||
| 198 | std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeThread::GetChildren() const { | ||
| 199 | std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeWaitObject::GetChildren()); | ||
| 200 | |||
| 201 | const auto& thread = static_cast<const Kernel::Thread&>(object); | ||
| 202 | |||
| 203 | QString processor; | ||
| 204 | switch (thread.processor_id) { | ||
| 205 | case ThreadProcessorId::THREADPROCESSORID_DEFAULT: | ||
| 206 | processor = tr("default"); | ||
| 207 | break; | ||
| 208 | case ThreadProcessorId::THREADPROCESSORID_0: | ||
| 209 | case ThreadProcessorId::THREADPROCESSORID_1: | ||
| 210 | case ThreadProcessorId::THREADPROCESSORID_2: | ||
| 211 | case ThreadProcessorId::THREADPROCESSORID_3: | ||
| 212 | processor = tr("core %1").arg(thread.processor_id); | ||
| 213 | break; | ||
| 214 | default: | ||
| 215 | processor = tr("Unknown processor %1").arg(thread.processor_id); | ||
| 216 | break; | ||
| 217 | } | ||
| 218 | |||
| 219 | list.push_back(std::make_unique<WaitTreeText>(tr("processor = %1").arg(processor))); | ||
| 220 | list.push_back(std::make_unique<WaitTreeText>(tr("thread id = %1").arg(thread.GetThreadId()))); | ||
| 221 | list.push_back(std::make_unique<WaitTreeText>(tr("priority = %1(current) / %2(normal)") | ||
| 222 | .arg(thread.current_priority) | ||
| 223 | .arg(thread.nominal_priority))); | ||
| 224 | list.push_back(std::make_unique<WaitTreeText>( | ||
| 225 | tr("last running ticks = %1").arg(thread.last_running_ticks))); | ||
| 226 | |||
| 227 | if (thread.held_mutexes.empty()) { | ||
| 228 | list.push_back(std::make_unique<WaitTreeText>(tr("not holding mutex"))); | ||
| 229 | } else { | ||
| 230 | list.push_back(std::make_unique<WaitTreeMutexList>(thread.held_mutexes)); | ||
| 231 | } | ||
| 232 | if (thread.status == THREADSTATUS_WAIT_SYNCH_ANY || | ||
| 233 | thread.status == THREADSTATUS_WAIT_SYNCH_ALL) { | ||
| 234 | list.push_back(std::make_unique<WaitTreeObjectList>(thread.wait_objects, | ||
| 235 | thread.IsSleepingOnWaitAll())); | ||
| 236 | } | ||
| 237 | |||
| 238 | return list; | ||
| 239 | } | ||
| 240 | |||
| 241 | WaitTreeEvent::WaitTreeEvent(const Kernel::Event& object) : WaitTreeWaitObject(object) {} | ||
| 242 | |||
| 243 | std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeEvent::GetChildren() const { | ||
| 244 | std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeWaitObject::GetChildren()); | ||
| 245 | |||
| 246 | list.push_back(std::make_unique<WaitTreeText>( | ||
| 247 | tr("reset type = %1") | ||
| 248 | .arg(GetResetTypeQString(static_cast<const Kernel::Event&>(object).reset_type)))); | ||
| 249 | return list; | ||
| 250 | } | ||
| 251 | |||
| 252 | WaitTreeMutex::WaitTreeMutex(const Kernel::Mutex& object) : WaitTreeWaitObject(object) {} | ||
| 253 | |||
| 254 | std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeMutex::GetChildren() const { | ||
| 255 | std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeWaitObject::GetChildren()); | ||
| 256 | |||
| 257 | const auto& mutex = static_cast<const Kernel::Mutex&>(object); | ||
| 258 | if (mutex.GetHasWaiters()) { | ||
| 259 | list.push_back(std::make_unique<WaitTreeText>(tr("locked by thread:"))); | ||
| 260 | list.push_back(std::make_unique<WaitTreeThread>(*mutex.GetHoldingThread())); | ||
| 261 | } else { | ||
| 262 | list.push_back(std::make_unique<WaitTreeText>(tr("free"))); | ||
| 263 | } | ||
| 264 | return list; | ||
| 265 | } | ||
| 266 | |||
| 267 | WaitTreeConditionVariable::WaitTreeConditionVariable(const Kernel::ConditionVariable& object) | ||
| 268 | : WaitTreeWaitObject(object) {} | ||
| 269 | |||
| 270 | std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeConditionVariable::GetChildren() const { | ||
| 271 | std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeWaitObject::GetChildren()); | ||
| 272 | |||
| 273 | const auto& condition_variable = static_cast<const Kernel::ConditionVariable&>(object); | ||
| 274 | list.push_back(std::make_unique<WaitTreeText>( | ||
| 275 | tr("available count = %1").arg(condition_variable.GetAvailableCount()))); | ||
| 276 | return list; | ||
| 277 | } | ||
| 278 | |||
| 279 | WaitTreeTimer::WaitTreeTimer(const Kernel::Timer& object) : WaitTreeWaitObject(object) {} | ||
| 280 | |||
| 281 | std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeTimer::GetChildren() const { | ||
| 282 | std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeWaitObject::GetChildren()); | ||
| 283 | |||
| 284 | const auto& timer = static_cast<const Kernel::Timer&>(object); | ||
| 285 | |||
| 286 | list.push_back(std::make_unique<WaitTreeText>( | ||
| 287 | tr("reset type = %1").arg(GetResetTypeQString(timer.reset_type)))); | ||
| 288 | list.push_back( | ||
| 289 | std::make_unique<WaitTreeText>(tr("initial delay = %1").arg(timer.initial_delay))); | ||
| 290 | list.push_back( | ||
| 291 | std::make_unique<WaitTreeText>(tr("interval delay = %1").arg(timer.interval_delay))); | ||
| 292 | return list; | ||
| 293 | } | ||
| 294 | |||
| 295 | WaitTreeMutexList::WaitTreeMutexList( | ||
| 296 | const boost::container::flat_set<Kernel::SharedPtr<Kernel::Mutex>>& list) | ||
| 297 | : mutex_list(list) {} | ||
| 298 | |||
| 299 | QString WaitTreeMutexList::GetText() const { | ||
| 300 | return tr("holding mutexes"); | ||
| 301 | } | ||
| 302 | |||
| 303 | std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeMutexList::GetChildren() const { | ||
| 304 | std::vector<std::unique_ptr<WaitTreeItem>> list(mutex_list.size()); | ||
| 305 | std::transform(mutex_list.begin(), mutex_list.end(), list.begin(), | ||
| 306 | [](const auto& t) { return std::make_unique<WaitTreeMutex>(*t); }); | ||
| 307 | return list; | ||
| 308 | } | ||
| 309 | |||
| 310 | WaitTreeThreadList::WaitTreeThreadList(const std::vector<Kernel::SharedPtr<Kernel::Thread>>& list) | ||
| 311 | : thread_list(list) {} | ||
| 312 | |||
| 313 | QString WaitTreeThreadList::GetText() const { | ||
| 314 | return tr("waited by thread"); | ||
| 315 | } | ||
| 316 | |||
| 317 | std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeThreadList::GetChildren() const { | ||
| 318 | std::vector<std::unique_ptr<WaitTreeItem>> list(thread_list.size()); | ||
| 319 | std::transform(thread_list.begin(), thread_list.end(), list.begin(), | ||
| 320 | [](const auto& t) { return std::make_unique<WaitTreeThread>(*t); }); | ||
| 321 | return list; | ||
| 322 | } | ||
| 323 | |||
| 324 | WaitTreeModel::WaitTreeModel(QObject* parent) : QAbstractItemModel(parent) {} | ||
| 325 | |||
| 326 | QModelIndex WaitTreeModel::index(int row, int column, const QModelIndex& parent) const { | ||
| 327 | if (!hasIndex(row, column, parent)) | ||
| 328 | return {}; | ||
| 329 | |||
| 330 | if (parent.isValid()) { | ||
| 331 | WaitTreeItem* parent_item = static_cast<WaitTreeItem*>(parent.internalPointer()); | ||
| 332 | parent_item->Expand(); | ||
| 333 | return createIndex(row, column, parent_item->Children()[row].get()); | ||
| 334 | } | ||
| 335 | |||
| 336 | return createIndex(row, column, thread_items[row].get()); | ||
| 337 | } | ||
| 338 | |||
| 339 | QModelIndex WaitTreeModel::parent(const QModelIndex& index) const { | ||
| 340 | if (!index.isValid()) | ||
| 341 | return {}; | ||
| 342 | |||
| 343 | WaitTreeItem* parent_item = static_cast<WaitTreeItem*>(index.internalPointer())->Parent(); | ||
| 344 | if (!parent_item) { | ||
| 345 | return QModelIndex(); | ||
| 346 | } | ||
| 347 | return createIndex(static_cast<int>(parent_item->Row()), 0, parent_item); | ||
| 348 | } | ||
| 349 | |||
| 350 | int WaitTreeModel::rowCount(const QModelIndex& parent) const { | ||
| 351 | if (!parent.isValid()) | ||
| 352 | return static_cast<int>(thread_items.size()); | ||
| 353 | |||
| 354 | WaitTreeItem* parent_item = static_cast<WaitTreeItem*>(parent.internalPointer()); | ||
| 355 | parent_item->Expand(); | ||
| 356 | return static_cast<int>(parent_item->Children().size()); | ||
| 357 | } | ||
| 358 | |||
| 359 | int WaitTreeModel::columnCount(const QModelIndex&) const { | ||
| 360 | return 1; | ||
| 361 | } | ||
| 362 | |||
| 363 | QVariant WaitTreeModel::data(const QModelIndex& index, int role) const { | ||
| 364 | if (!index.isValid()) | ||
| 365 | return {}; | ||
| 366 | |||
| 367 | switch (role) { | ||
| 368 | case Qt::DisplayRole: | ||
| 369 | return static_cast<WaitTreeItem*>(index.internalPointer())->GetText(); | ||
| 370 | case Qt::ForegroundRole: | ||
| 371 | return static_cast<WaitTreeItem*>(index.internalPointer())->GetColor(); | ||
| 372 | default: | ||
| 373 | return {}; | ||
| 374 | } | ||
| 375 | } | ||
| 376 | |||
| 377 | void WaitTreeModel::ClearItems() { | ||
| 378 | thread_items.clear(); | ||
| 379 | } | ||
| 380 | |||
| 381 | void WaitTreeModel::InitItems() { | ||
| 382 | thread_items = WaitTreeItem::MakeThreadItemList(); | ||
| 383 | } | ||
| 384 | |||
| 385 | WaitTreeWidget::WaitTreeWidget(QWidget* parent) : QDockWidget(tr("Wait Tree"), parent) { | ||
| 386 | setObjectName("WaitTreeWidget"); | ||
| 387 | view = new QTreeView(this); | ||
| 388 | view->setHeaderHidden(true); | ||
| 389 | setWidget(view); | ||
| 390 | setEnabled(false); | ||
| 391 | } | ||
| 392 | |||
| 393 | void WaitTreeWidget::OnDebugModeEntered() { | ||
| 394 | if (!Core::System::GetInstance().IsPoweredOn()) | ||
| 395 | return; | ||
| 396 | model->InitItems(); | ||
| 397 | view->setModel(model); | ||
| 398 | setEnabled(true); | ||
| 399 | } | ||
| 400 | |||
| 401 | void WaitTreeWidget::OnDebugModeLeft() { | ||
| 402 | setEnabled(false); | ||
| 403 | view->setModel(nullptr); | ||
| 404 | model->ClearItems(); | ||
| 405 | } | ||
| 406 | |||
| 407 | void WaitTreeWidget::OnEmulationStarting(EmuThread* emu_thread) { | ||
| 408 | model = new WaitTreeModel(this); | ||
| 409 | view->setModel(model); | ||
| 410 | setEnabled(false); | ||
| 411 | } | ||
| 412 | |||
| 413 | void WaitTreeWidget::OnEmulationStopping() { | ||
| 414 | view->setModel(nullptr); | ||
| 415 | delete model; | ||
| 416 | setEnabled(false); | ||
| 417 | } | ||
diff --git a/src/citra_qt/debugger/wait_tree.h b/src/citra_qt/debugger/wait_tree.h deleted file mode 100644 index 4034e909b..000000000 --- a/src/citra_qt/debugger/wait_tree.h +++ /dev/null | |||
| @@ -1,187 +0,0 @@ | |||
| 1 | // Copyright 2016 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 <QAbstractItemModel> | ||
| 8 | #include <QDockWidget> | ||
| 9 | #include <QTreeView> | ||
| 10 | #include <boost/container/flat_set.hpp> | ||
| 11 | #include "core/core.h" | ||
| 12 | #include "core/hle/kernel/kernel.h" | ||
| 13 | |||
| 14 | class EmuThread; | ||
| 15 | |||
| 16 | namespace Kernel { | ||
| 17 | class WaitObject; | ||
| 18 | class Event; | ||
| 19 | class Mutex; | ||
| 20 | class ConditionVariable; | ||
| 21 | class Thread; | ||
| 22 | class Timer; | ||
| 23 | } | ||
| 24 | |||
| 25 | class WaitTreeThread; | ||
| 26 | |||
| 27 | class WaitTreeItem : public QObject { | ||
| 28 | Q_OBJECT | ||
| 29 | public: | ||
| 30 | virtual bool IsExpandable() const; | ||
| 31 | virtual std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const; | ||
| 32 | virtual QString GetText() const = 0; | ||
| 33 | virtual QColor GetColor() const; | ||
| 34 | virtual ~WaitTreeItem(); | ||
| 35 | void Expand(); | ||
| 36 | WaitTreeItem* Parent() const; | ||
| 37 | const std::vector<std::unique_ptr<WaitTreeItem>>& Children() const; | ||
| 38 | std::size_t Row() const; | ||
| 39 | static std::vector<std::unique_ptr<WaitTreeThread>> MakeThreadItemList(); | ||
| 40 | |||
| 41 | private: | ||
| 42 | std::size_t row; | ||
| 43 | bool expanded = false; | ||
| 44 | WaitTreeItem* parent = nullptr; | ||
| 45 | std::vector<std::unique_ptr<WaitTreeItem>> children; | ||
| 46 | }; | ||
| 47 | |||
| 48 | class WaitTreeText : public WaitTreeItem { | ||
| 49 | Q_OBJECT | ||
| 50 | public: | ||
| 51 | explicit WaitTreeText(const QString& text); | ||
| 52 | QString GetText() const override; | ||
| 53 | |||
| 54 | private: | ||
| 55 | QString text; | ||
| 56 | }; | ||
| 57 | |||
| 58 | class WaitTreeExpandableItem : public WaitTreeItem { | ||
| 59 | Q_OBJECT | ||
| 60 | public: | ||
| 61 | bool IsExpandable() const override; | ||
| 62 | }; | ||
| 63 | |||
| 64 | class WaitTreeWaitObject : public WaitTreeExpandableItem { | ||
| 65 | Q_OBJECT | ||
| 66 | public: | ||
| 67 | explicit WaitTreeWaitObject(const Kernel::WaitObject& object); | ||
| 68 | static std::unique_ptr<WaitTreeWaitObject> make(const Kernel::WaitObject& object); | ||
| 69 | QString GetText() const override; | ||
| 70 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; | ||
| 71 | |||
| 72 | protected: | ||
| 73 | const Kernel::WaitObject& object; | ||
| 74 | |||
| 75 | static QString GetResetTypeQString(Kernel::ResetType reset_type); | ||
| 76 | }; | ||
| 77 | |||
| 78 | class WaitTreeObjectList : public WaitTreeExpandableItem { | ||
| 79 | Q_OBJECT | ||
| 80 | public: | ||
| 81 | WaitTreeObjectList(const std::vector<Kernel::SharedPtr<Kernel::WaitObject>>& list, | ||
| 82 | bool wait_all); | ||
| 83 | QString GetText() const override; | ||
| 84 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; | ||
| 85 | |||
| 86 | private: | ||
| 87 | const std::vector<Kernel::SharedPtr<Kernel::WaitObject>>& object_list; | ||
| 88 | bool wait_all; | ||
| 89 | }; | ||
| 90 | |||
| 91 | class WaitTreeThread : public WaitTreeWaitObject { | ||
| 92 | Q_OBJECT | ||
| 93 | public: | ||
| 94 | explicit WaitTreeThread(const Kernel::Thread& thread); | ||
| 95 | QString GetText() const override; | ||
| 96 | QColor GetColor() const override; | ||
| 97 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; | ||
| 98 | }; | ||
| 99 | |||
| 100 | class WaitTreeEvent : public WaitTreeWaitObject { | ||
| 101 | Q_OBJECT | ||
| 102 | public: | ||
| 103 | explicit WaitTreeEvent(const Kernel::Event& object); | ||
| 104 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; | ||
| 105 | }; | ||
| 106 | |||
| 107 | class WaitTreeMutex : public WaitTreeWaitObject { | ||
| 108 | Q_OBJECT | ||
| 109 | public: | ||
| 110 | explicit WaitTreeMutex(const Kernel::Mutex& object); | ||
| 111 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; | ||
| 112 | }; | ||
| 113 | |||
| 114 | class WaitTreeConditionVariable : public WaitTreeWaitObject { | ||
| 115 | Q_OBJECT | ||
| 116 | public: | ||
| 117 | explicit WaitTreeConditionVariable(const Kernel::ConditionVariable& object); | ||
| 118 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; | ||
| 119 | }; | ||
| 120 | |||
| 121 | class WaitTreeTimer : public WaitTreeWaitObject { | ||
| 122 | Q_OBJECT | ||
| 123 | public: | ||
| 124 | explicit WaitTreeTimer(const Kernel::Timer& object); | ||
| 125 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; | ||
| 126 | }; | ||
| 127 | |||
| 128 | class WaitTreeMutexList : public WaitTreeExpandableItem { | ||
| 129 | Q_OBJECT | ||
| 130 | public: | ||
| 131 | explicit WaitTreeMutexList( | ||
| 132 | const boost::container::flat_set<Kernel::SharedPtr<Kernel::Mutex>>& list); | ||
| 133 | |||
| 134 | QString GetText() const override; | ||
| 135 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; | ||
| 136 | |||
| 137 | private: | ||
| 138 | const boost::container::flat_set<Kernel::SharedPtr<Kernel::Mutex>>& mutex_list; | ||
| 139 | }; | ||
| 140 | |||
| 141 | class WaitTreeThreadList : public WaitTreeExpandableItem { | ||
| 142 | Q_OBJECT | ||
| 143 | public: | ||
| 144 | explicit WaitTreeThreadList(const std::vector<Kernel::SharedPtr<Kernel::Thread>>& list); | ||
| 145 | QString GetText() const override; | ||
| 146 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; | ||
| 147 | |||
| 148 | private: | ||
| 149 | const std::vector<Kernel::SharedPtr<Kernel::Thread>>& thread_list; | ||
| 150 | }; | ||
| 151 | |||
| 152 | class WaitTreeModel : public QAbstractItemModel { | ||
| 153 | Q_OBJECT | ||
| 154 | |||
| 155 | public: | ||
| 156 | explicit WaitTreeModel(QObject* parent = nullptr); | ||
| 157 | |||
| 158 | QVariant data(const QModelIndex& index, int role) const override; | ||
| 159 | QModelIndex index(int row, int column, const QModelIndex& parent) const override; | ||
| 160 | QModelIndex parent(const QModelIndex& index) const override; | ||
| 161 | int rowCount(const QModelIndex& parent) const override; | ||
| 162 | int columnCount(const QModelIndex& parent) const override; | ||
| 163 | |||
| 164 | void ClearItems(); | ||
| 165 | void InitItems(); | ||
| 166 | |||
| 167 | private: | ||
| 168 | std::vector<std::unique_ptr<WaitTreeThread>> thread_items; | ||
| 169 | }; | ||
| 170 | |||
| 171 | class WaitTreeWidget : public QDockWidget { | ||
| 172 | Q_OBJECT | ||
| 173 | |||
| 174 | public: | ||
| 175 | explicit WaitTreeWidget(QWidget* parent = nullptr); | ||
| 176 | |||
| 177 | public slots: | ||
| 178 | void OnDebugModeEntered(); | ||
| 179 | void OnDebugModeLeft(); | ||
| 180 | |||
| 181 | void OnEmulationStarting(EmuThread* emu_thread); | ||
| 182 | void OnEmulationStopping(); | ||
| 183 | |||
| 184 | private: | ||
| 185 | QTreeView* view; | ||
| 186 | WaitTreeModel* model; | ||
| 187 | }; | ||