2014-05-17 21:38:10 +01:00
|
|
|
// Copyright 2014 Citra Emulator Project
|
2014-12-17 05:38:14 +00:00
|
|
|
// Licensed under GPLv2 or any later version
|
2014-05-17 21:38:10 +01:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2016-09-20 16:21:23 +01:00
|
|
|
#include <QListView>
|
2016-09-21 07:52:38 +01:00
|
|
|
#include "citra_qt/debugger/graphics.h"
|
2015-08-19 21:00:56 +01:00
|
|
|
#include "citra_qt/util/util.h"
|
|
|
|
|
2014-05-17 21:38:10 +01:00
|
|
|
extern GraphicsDebugger g_debugger;
|
|
|
|
|
2016-09-18 01:38:01 +01:00
|
|
|
GPUCommandStreamItemModel::GPUCommandStreamItemModel(QObject* parent)
|
|
|
|
: QAbstractListModel(parent), command_count(0) {
|
2014-05-17 21:38:10 +01:00
|
|
|
connect(this, SIGNAL(GXCommandFinished(int)), this, SLOT(OnGXCommandFinishedInternal(int)));
|
|
|
|
}
|
|
|
|
|
2016-09-18 01:38:01 +01:00
|
|
|
int GPUCommandStreamItemModel::rowCount(const QModelIndex& parent) const {
|
2014-05-17 21:38:10 +01:00
|
|
|
return command_count;
|
|
|
|
}
|
|
|
|
|
2016-09-18 01:38:01 +01:00
|
|
|
QVariant GPUCommandStreamItemModel::data(const QModelIndex& index, int role) const {
|
2014-05-17 21:38:10 +01:00
|
|
|
if (!index.isValid())
|
|
|
|
return QVariant();
|
|
|
|
|
|
|
|
int command_index = index.row();
|
2016-12-10 12:51:50 +00:00
|
|
|
const Service::GSP::Command& command = GetDebugger()->ReadGXCommandHistory(command_index);
|
2016-09-18 01:38:01 +01:00
|
|
|
if (role == Qt::DisplayRole) {
|
2016-12-10 12:51:50 +00:00
|
|
|
std::map<Service::GSP::CommandId, const char*> command_names = {
|
|
|
|
{Service::GSP::CommandId::REQUEST_DMA, "REQUEST_DMA"},
|
|
|
|
{Service::GSP::CommandId::SUBMIT_GPU_CMDLIST, "SUBMIT_GPU_CMDLIST"},
|
|
|
|
{Service::GSP::CommandId::SET_MEMORY_FILL, "SET_MEMORY_FILL"},
|
|
|
|
{Service::GSP::CommandId::SET_DISPLAY_TRANSFER, "SET_DISPLAY_TRANSFER"},
|
|
|
|
{Service::GSP::CommandId::SET_TEXTURE_COPY, "SET_TEXTURE_COPY"},
|
|
|
|
{Service::GSP::CommandId::CACHE_FLUSH, "CACHE_FLUSH"},
|
2014-07-22 11:41:16 +01:00
|
|
|
};
|
|
|
|
const u32* command_data = reinterpret_cast<const u32*>(&command);
|
2016-09-18 01:38:01 +01:00
|
|
|
QString str = QString("%1 %2 %3 %4 %5 %6 %7 %8 %9")
|
|
|
|
.arg(command_names[command.id])
|
|
|
|
.arg(command_data[0], 8, 16, QLatin1Char('0'))
|
|
|
|
.arg(command_data[1], 8, 16, QLatin1Char('0'))
|
|
|
|
.arg(command_data[2], 8, 16, QLatin1Char('0'))
|
|
|
|
.arg(command_data[3], 8, 16, QLatin1Char('0'))
|
|
|
|
.arg(command_data[4], 8, 16, QLatin1Char('0'))
|
|
|
|
.arg(command_data[5], 8, 16, QLatin1Char('0'))
|
|
|
|
.arg(command_data[6], 8, 16, QLatin1Char('0'))
|
|
|
|
.arg(command_data[7], 8, 16, QLatin1Char('0'));
|
2014-05-17 21:38:10 +01:00
|
|
|
return QVariant(str);
|
2016-09-18 01:38:01 +01:00
|
|
|
} else {
|
2014-05-17 21:38:10 +01:00
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-18 01:38:01 +01:00
|
|
|
void GPUCommandStreamItemModel::GXCommandProcessed(int total_command_count) {
|
2014-05-17 21:38:10 +01:00
|
|
|
emit GXCommandFinished(total_command_count);
|
|
|
|
}
|
|
|
|
|
2016-09-18 01:38:01 +01:00
|
|
|
void GPUCommandStreamItemModel::OnGXCommandFinishedInternal(int total_command_count) {
|
2014-05-17 21:38:10 +01:00
|
|
|
if (total_command_count == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int prev_command_count = command_count;
|
|
|
|
command_count = total_command_count;
|
2016-09-18 01:38:01 +01:00
|
|
|
emit dataChanged(index(prev_command_count, 0), index(total_command_count - 1, 0));
|
2014-05-17 21:38:10 +01:00
|
|
|
}
|
|
|
|
|
2016-09-18 01:38:01 +01:00
|
|
|
GPUCommandStreamWidget::GPUCommandStreamWidget(QWidget* parent)
|
|
|
|
: QDockWidget(tr("Graphics Debugger"), parent) {
|
2015-01-01 13:49:35 +00:00
|
|
|
setObjectName("GraphicsDebugger");
|
2014-05-17 21:38:10 +01:00
|
|
|
|
|
|
|
GPUCommandStreamItemModel* command_model = new GPUCommandStreamItemModel(this);
|
|
|
|
g_debugger.RegisterObserver(command_model);
|
|
|
|
|
|
|
|
QListView* command_list = new QListView;
|
|
|
|
command_list->setModel(command_model);
|
2015-08-19 21:00:56 +01:00
|
|
|
command_list->setFont(GetMonospaceFont());
|
2014-05-17 21:38:10 +01:00
|
|
|
|
|
|
|
setWidget(command_list);
|
|
|
|
}
|