diff options
| author | 2014-05-17 22:38:10 +0200 | |
|---|---|---|
| committer | 2014-06-12 06:10:49 -0400 | |
| commit | 87e98ff97be94edf8d4c50a9cf232a008213a928 (patch) | |
| tree | 147076e1bf12fc83817600b405206d3f722ab215 /src/citra_qt/debugger/graphics.cpp | |
| parent | Add initial graphics debugger interface. (diff) | |
| download | yuzu-87e98ff97be94edf8d4c50a9cf232a008213a928.tar.gz yuzu-87e98ff97be94edf8d4c50a9cf232a008213a928.tar.xz yuzu-87e98ff97be94edf8d4c50a9cf232a008213a928.zip | |
citra-qt: Add GX command history viewer.
Diffstat (limited to 'src/citra_qt/debugger/graphics.cpp')
| -rw-r--r-- | src/citra_qt/debugger/graphics.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/citra_qt/debugger/graphics.cpp b/src/citra_qt/debugger/graphics.cpp new file mode 100644 index 000000000..9aaade8f9 --- /dev/null +++ b/src/citra_qt/debugger/graphics.cpp | |||
| @@ -0,0 +1,83 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "graphics.hxx" | ||
| 6 | #include <QListView> | ||
| 7 | #include <QVBoxLayout> | ||
| 8 | #include <QDebug> | ||
| 9 | |||
| 10 | extern GraphicsDebugger g_debugger; | ||
| 11 | |||
| 12 | GPUCommandStreamItemModel::GPUCommandStreamItemModel(QObject* parent) : QAbstractListModel(parent), command_count(0) | ||
| 13 | { | ||
| 14 | connect(this, SIGNAL(GXCommandFinished(int)), this, SLOT(OnGXCommandFinishedInternal(int))); | ||
| 15 | } | ||
| 16 | |||
| 17 | int GPUCommandStreamItemModel::rowCount(const QModelIndex& parent) const | ||
| 18 | { | ||
| 19 | return command_count; | ||
| 20 | } | ||
| 21 | |||
| 22 | QVariant GPUCommandStreamItemModel::data(const QModelIndex& index, int role) const | ||
| 23 | { | ||
| 24 | if (!index.isValid()) | ||
| 25 | return QVariant(); | ||
| 26 | |||
| 27 | int command_index = index.row(); | ||
| 28 | const GSP_GPU::GXCommand& command = GetDebugger()->ReadGXCommandHistory(command_index); | ||
| 29 | if (role == Qt::DisplayRole) | ||
| 30 | { | ||
| 31 | std::map<GSP_GPU::GXCommandId, const char*> command_names; | ||
| 32 | command_names[GSP_GPU::GXCommandId::REQUEST_DMA] = "REQUEST_DMA"; | ||
| 33 | command_names[GSP_GPU::GXCommandId::SET_COMMAND_LIST_FIRST] = "SET_COMMAND_LIST_FIRST"; | ||
| 34 | command_names[GSP_GPU::GXCommandId::SET_MEMORY_FILL] = "SET_MEMORY_FILL"; | ||
| 35 | command_names[GSP_GPU::GXCommandId::SET_DISPLAY_TRANSFER] = "SET_DISPLAY_TRANSFER"; | ||
| 36 | command_names[GSP_GPU::GXCommandId::SET_TEXTURE_COPY] = "SET_TEXTURE_COPY"; | ||
| 37 | command_names[GSP_GPU::GXCommandId::SET_COMMAND_LIST_LAST] = "SET_COMMAND_LIST_LAST"; | ||
| 38 | QString str = QString("%1 %2 %3 %4 %5 %6 %7 %8 %9").arg(command_names[static_cast<GSP_GPU::GXCommandId>(command.id)]) | ||
| 39 | .arg(command.data[0], 8, 16, QLatin1Char('0')) | ||
| 40 | .arg(command.data[1], 8, 16, QLatin1Char('0')) | ||
| 41 | .arg(command.data[2], 8, 16, QLatin1Char('0')) | ||
| 42 | .arg(command.data[3], 8, 16, QLatin1Char('0')) | ||
| 43 | .arg(command.data[4], 8, 16, QLatin1Char('0')) | ||
| 44 | .arg(command.data[5], 8, 16, QLatin1Char('0')) | ||
| 45 | .arg(command.data[6], 8, 16, QLatin1Char('0')) | ||
| 46 | .arg(command.data[7], 8, 16, QLatin1Char('0')); | ||
| 47 | return QVariant(str); | ||
| 48 | } | ||
| 49 | else | ||
| 50 | { | ||
| 51 | return QVariant(); | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
| 55 | void GPUCommandStreamItemModel::GXCommandProcessed(int total_command_count) | ||
| 56 | { | ||
| 57 | emit GXCommandFinished(total_command_count); | ||
| 58 | } | ||
| 59 | |||
| 60 | void GPUCommandStreamItemModel::OnGXCommandFinishedInternal(int total_command_count) | ||
| 61 | { | ||
| 62 | if (total_command_count == 0) | ||
| 63 | return; | ||
| 64 | |||
| 65 | int prev_command_count = command_count; | ||
| 66 | command_count = total_command_count; | ||
| 67 | emit dataChanged(index(prev_command_count,0), index(total_command_count-1,0)); | ||
| 68 | } | ||
| 69 | |||
| 70 | |||
| 71 | GPUCommandStreamWidget::GPUCommandStreamWidget(QWidget* parent) : QDockWidget(tr("Graphics Debugger"), parent) | ||
| 72 | { | ||
| 73 | // TODO: set objectName! | ||
| 74 | |||
| 75 | GPUCommandStreamItemModel* command_model = new GPUCommandStreamItemModel(this); | ||
| 76 | g_debugger.RegisterObserver(command_model); | ||
| 77 | |||
| 78 | QListView* command_list = new QListView; | ||
| 79 | command_list->setModel(command_model); | ||
| 80 | command_list->setFont(QFont("monospace")); | ||
| 81 | |||
| 82 | setWidget(command_list); | ||
| 83 | } | ||