2014-05-18 21:22:22 +05:30
|
|
|
// Copyright 2014 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2014-08-14 22:51:55 +05:30
|
|
|
#include <QListView>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QVBoxLayout>
|
2014-05-18 23:29:36 +05:30
|
|
|
#include <QTreeView>
|
2014-05-18 21:22:22 +05:30
|
|
|
|
2014-08-14 22:51:55 +05:30
|
|
|
#include "graphics_cmdlists.hxx"
|
2014-05-18 23:29:36 +05:30
|
|
|
|
2014-08-14 22:51:55 +05:30
|
|
|
GPUCommandListModel::GPUCommandListModel(QObject* parent) : QAbstractListModel(parent)
|
2014-05-18 23:29:36 +05:30
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-18 21:22:22 +05:30
|
|
|
int GPUCommandListModel::rowCount(const QModelIndex& parent) const
|
|
|
|
{
|
2014-08-14 22:51:55 +05:30
|
|
|
return pica_trace.writes.size();
|
2014-05-18 23:29:36 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
int GPUCommandListModel::columnCount(const QModelIndex& parent) const
|
|
|
|
{
|
2014-05-19 00:48:38 +05:30
|
|
|
return 2;
|
2014-05-18 21:22:22 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
QVariant GPUCommandListModel::data(const QModelIndex& index, int role) const
|
|
|
|
{
|
|
|
|
if (!index.isValid())
|
|
|
|
return QVariant();
|
|
|
|
|
2014-08-14 22:51:55 +05:30
|
|
|
const auto& writes = pica_trace.writes;
|
|
|
|
const Pica::CommandProcessor::CommandHeader cmd{writes[index.row()].Id()};
|
|
|
|
const u32 val{writes[index.row()].Value()};
|
|
|
|
|
|
|
|
if (role == Qt::DisplayRole) {
|
|
|
|
QString content;
|
|
|
|
if (index.column() == 0) {
|
|
|
|
content = QString::fromLatin1(Pica::Regs::GetCommandName(cmd.cmd_id).c_str());
|
|
|
|
content.append(" ");
|
|
|
|
} else if (index.column() == 1) {
|
|
|
|
content.append(QString("%1 ").arg(cmd.hex, 8, 16, QLatin1Char('0')));
|
|
|
|
content.append(QString("%1 ").arg(val, 8, 16, QLatin1Char('0')));
|
2014-05-18 21:22:22 +05:30
|
|
|
}
|
2014-08-14 22:51:55 +05:30
|
|
|
|
|
|
|
return QVariant(content);
|
2014-05-18 21:22:22 +05:30
|
|
|
}
|
2014-05-18 23:29:36 +05:30
|
|
|
|
2014-05-18 21:22:22 +05:30
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
|
2014-10-26 16:10:12 +05:30
|
|
|
QVariant GPUCommandListModel::headerData(int section, Qt::Orientation orientation, int role) const
|
|
|
|
{
|
|
|
|
switch(role) {
|
|
|
|
case Qt::DisplayRole:
|
|
|
|
{
|
|
|
|
if (section == 0) {
|
|
|
|
return tr("Command Name");
|
|
|
|
} else if (section == 1) {
|
|
|
|
return tr("Data");
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
|
2014-08-14 22:51:55 +05:30
|
|
|
void GPUCommandListModel::OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace& trace)
|
2014-05-18 21:22:22 +05:30
|
|
|
{
|
2014-08-14 22:51:55 +05:30
|
|
|
beginResetModel();
|
|
|
|
|
|
|
|
pica_trace = trace;
|
|
|
|
|
|
|
|
endResetModel();
|
2014-05-18 21:22:22 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-14 22:51:55 +05:30
|
|
|
GPUCommandListWidget::GPUCommandListWidget(QWidget* parent) : QDockWidget(tr("Pica Command List"), parent)
|
2014-05-18 21:22:22 +05:30
|
|
|
{
|
2014-08-14 22:51:55 +05:30
|
|
|
GPUCommandListModel* model = new GPUCommandListModel(this);
|
2014-05-18 21:22:22 +05:30
|
|
|
|
2014-08-14 22:51:55 +05:30
|
|
|
QWidget* main_widget = new QWidget;
|
2014-05-18 23:29:36 +05:30
|
|
|
|
2014-08-14 22:51:55 +05:30
|
|
|
QTreeView* list_widget = new QTreeView;
|
|
|
|
list_widget->setModel(model);
|
|
|
|
list_widget->setFont(QFont("monospace"));
|
|
|
|
list_widget->setRootIsDecorated(false);
|
2014-05-18 23:29:36 +05:30
|
|
|
|
2014-10-26 16:10:12 +05:30
|
|
|
toggle_tracing = new QPushButton(tr("Start Tracing"));
|
2014-05-18 23:29:36 +05:30
|
|
|
|
2014-08-14 22:51:55 +05:30
|
|
|
connect(toggle_tracing, SIGNAL(clicked()), this, SLOT(OnToggleTracing()));
|
|
|
|
connect(this, SIGNAL(TracingFinished(const Pica::DebugUtils::PicaTrace&)),
|
|
|
|
model, SLOT(OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace&)));
|
2014-05-18 21:22:22 +05:30
|
|
|
|
2014-08-14 22:51:55 +05:30
|
|
|
QVBoxLayout* main_layout = new QVBoxLayout;
|
|
|
|
main_layout->addWidget(list_widget);
|
|
|
|
main_layout->addWidget(toggle_tracing);
|
|
|
|
main_widget->setLayout(main_layout);
|
|
|
|
|
|
|
|
setWidget(main_widget);
|
2014-05-18 21:22:22 +05:30
|
|
|
}
|
|
|
|
|
2014-08-14 22:51:55 +05:30
|
|
|
void GPUCommandListWidget::OnToggleTracing()
|
2014-05-18 21:22:22 +05:30
|
|
|
{
|
2014-08-14 22:51:55 +05:30
|
|
|
if (!Pica::DebugUtils::IsPicaTracing()) {
|
|
|
|
Pica::DebugUtils::StartPicaTracing();
|
2014-10-26 16:10:12 +05:30
|
|
|
toggle_tracing->setText(tr("Stop Tracing"));
|
2014-08-14 22:51:55 +05:30
|
|
|
} else {
|
|
|
|
pica_trace = Pica::DebugUtils::FinishPicaTracing();
|
|
|
|
emit TracingFinished(*pica_trace);
|
2014-10-26 16:10:12 +05:30
|
|
|
toggle_tracing->setText(tr("Start Tracing"));
|
2014-08-14 22:51:55 +05:30
|
|
|
}
|
2014-05-18 21:22:22 +05:30
|
|
|
}
|