Search bar for GPU Commands

This commit is contained in:
GASTER 2016-10-08 21:33:21 -05:00
parent cc7f1155a8
commit 8aa28825db
3 changed files with 263 additions and 209 deletions

View File

@ -13,6 +13,7 @@
#include <QSpinBox> #include <QSpinBox>
#include <QTreeView> #include <QTreeView>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QLineEdit>
#include "citra_qt/debugger/graphics_cmdlists.h" #include "citra_qt/debugger/graphics_cmdlists.h"
#include "citra_qt/util/spinbox.h" #include "citra_qt/util/spinbox.h"
#include "citra_qt/util/util.h" #include "citra_qt/util/util.h"
@ -20,6 +21,8 @@
#include "video_core/debug_utils/debug_utils.h" #include "video_core/debug_utils/debug_utils.h"
#include "video_core/pica.h" #include "video_core/pica.h"
#include "video_core/pica_state.h" #include "video_core/pica_state.h"
#include <iostream>
using namespace std;
QImage LoadTexture(u8* src, const Pica::DebugUtils::TextureInfo& info) { QImage LoadTexture(u8* src, const Pica::DebugUtils::TextureInfo& info) {
QImage decoded_image(info.width, info.height, QImage::Format_ARGB32); QImage decoded_image(info.width, info.height, QImage::Format_ARGB32);
@ -51,7 +54,7 @@ public:
GPUCommandListModel::GPUCommandListModel(QObject* parent) : QAbstractListModel(parent) {} GPUCommandListModel::GPUCommandListModel(QObject* parent) : QAbstractListModel(parent) {}
int GPUCommandListModel::rowCount(const QModelIndex& parent) const { int GPUCommandListModel::rowCount(const QModelIndex& parent) const {
return static_cast<int>(pica_trace.writes.size()); return static_cast<int>((pica_trace.isSearchCorrected ? pica_trace.search_corrected_writes : pica_trace.writes).size());
} }
int GPUCommandListModel::columnCount(const QModelIndex& parent) const { int GPUCommandListModel::columnCount(const QModelIndex& parent) const {
@ -62,7 +65,7 @@ QVariant GPUCommandListModel::data(const QModelIndex& index, int role) const {
if (!index.isValid()) if (!index.isValid())
return QVariant(); return QVariant();
const auto& write = pica_trace.writes[index.row()]; const auto& write = (pica_trace.isSearchCorrected ? pica_trace.search_corrected_writes[index.row()] : pica_trace.writes[index.row()]);
if (role == Qt::DisplayRole) { if (role == Qt::DisplayRole) {
QString content; QString content;
@ -112,6 +115,16 @@ void GPUCommandListModel::OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace&
endResetModel(); endResetModel();
} }
void GPUCommandListModel::UpdatePicaTrace(const QString& str) {
pica_trace.CorrectSearchWrites(str.toStdString());
cout << "Updated writes";
beginResetModel();
endResetModel();
}
#define COMMAND_IN_RANGE(cmd_id, reg_name) \ #define COMMAND_IN_RANGE(cmd_id, reg_name) \
(cmd_id >= PICA_REG_INDEX(reg_name) && \ (cmd_id >= PICA_REG_INDEX(reg_name) && \
cmd_id < PICA_REG_INDEX(reg_name) + sizeof(decltype(Pica::g_state.regs.reg_name)) / 4) cmd_id < PICA_REG_INDEX(reg_name) + sizeof(decltype(Pica::g_state.regs.reg_name)) / 4)
@ -218,6 +231,13 @@ GPUCommandListWidget::GPUCommandListWidget(QWidget* parent)
sub_layout->addWidget(copy_all); sub_layout->addWidget(copy_all);
main_layout->addLayout(sub_layout); main_layout->addLayout(sub_layout);
} }
search_bar = new QLineEdit();
search_bar->setPlaceholderText("Search Bar");
main_layout->addWidget(search_bar);
connect(search_bar, SIGNAL(textChanged(const QString &)), model, SLOT(UpdatePicaTrace(const QString &)));
main_widget->setLayout(main_layout); main_widget->setLayout(main_layout);
setWidget(main_widget); setWidget(main_widget);

View File

@ -30,6 +30,7 @@ public:
public slots: public slots:
void OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace& trace); void OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace& trace);
void UpdatePicaTrace(const QString &);
private: private:
Pica::DebugUtils::PicaTrace pica_trace; Pica::DebugUtils::PicaTrace pica_trace;
@ -41,10 +42,11 @@ class GPUCommandListWidget : public QDockWidget {
public: public:
GPUCommandListWidget(QWidget* parent = nullptr); GPUCommandListWidget(QWidget* parent = nullptr);
QLineEdit* search_bar;
public slots: public slots:
void OnToggleTracing(); void OnToggleTracing();
void OnCommandDoubleClicked(const QModelIndex&); void OnCommandDoubleClicked(const QModelIndex&);
void SetCommandInfo(const QModelIndex&); void SetCommandInfo(const QModelIndex&);
void CopyAllToClipboard(); void CopyAllToClipboard();

View File

@ -194,6 +194,38 @@ struct PicaTrace {
u32 value; u32 value;
}; };
std::vector<Write> writes; std::vector<Write> writes;
std::vector<Write> search_corrected_writes;
bool isSearchCorrected = false;
void CorrectSearchWrites(std::string search_string) {
search_corrected_writes.clear();
if (search_string.size() == 0)
isSearchCorrected = false;
else isSearchCorrected = true;
for (int i = 0; i < writes.size(); i++) {
bool isValid = true;
std::string cmdName = Pica::Regs::GetCommandName(writes[i].cmd_id);
if (cmdName.size() < search_string.size())
continue;
for (int j = 0; j < search_string.size(); j++) {
if (cmdName.at(j) != search_string.at(j)) {
isValid = false;
break;
}
}
if (!isValid)
continue;
search_corrected_writes.push_back(writes[i]);
}
}
}; };
void StartPicaTracing(); void StartPicaTracing();