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 <QTreeView>
#include <QVBoxLayout>
#include <QLineEdit>
#include "citra_qt/debugger/graphics_cmdlists.h"
#include "citra_qt/util/spinbox.h"
#include "citra_qt/util/util.h"
@ -20,6 +21,8 @@
#include "video_core/debug_utils/debug_utils.h"
#include "video_core/pica.h"
#include "video_core/pica_state.h"
#include <iostream>
using namespace std;
QImage LoadTexture(u8* src, const Pica::DebugUtils::TextureInfo& info) {
QImage decoded_image(info.width, info.height, QImage::Format_ARGB32);
@ -51,7 +54,7 @@ public:
GPUCommandListModel::GPUCommandListModel(QObject* parent) : QAbstractListModel(parent) {}
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 {
@ -62,7 +65,7 @@ QVariant GPUCommandListModel::data(const QModelIndex& index, int role) const {
if (!index.isValid())
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) {
QString content;
@ -112,6 +115,16 @@ void GPUCommandListModel::OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace&
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) \
(cmd_id >= PICA_REG_INDEX(reg_name) && \
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);
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);
setWidget(main_widget);

View File

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

View File

@ -20,17 +20,17 @@
#include "video_core/pica.h"
namespace CiTrace {
class Recorder;
class Recorder;
}
namespace Pica {
namespace Shader {
struct ShaderSetup;
}
namespace Shader {
struct ShaderSetup;
}
class DebugContext {
public:
class DebugContext {
public:
enum class Event {
FirstEvent = 0,
@ -158,7 +158,7 @@ public:
std::shared_ptr<CiTrace::Recorder> recorder = nullptr;
private:
private:
/**
* Private default constructor to make sure people always construct this through Construct()
* instead.
@ -173,35 +173,67 @@ private:
/// List of registered observers
std::list<BreakPointObserver*> breakpoint_observers;
};
};
extern std::shared_ptr<DebugContext> g_debug_context; // TODO: Get rid of this global
extern std::shared_ptr<DebugContext> g_debug_context; // TODO: Get rid of this global
namespace DebugUtils {
namespace DebugUtils {
#define PICA_DUMP_TEXTURES 0
#define PICA_LOG_TEV 0
void DumpShader(const std::string& filename, const Regs::ShaderConfig& config,
void DumpShader(const std::string& filename, const Regs::ShaderConfig& config,
const Shader::ShaderSetup& setup,
const Regs::VSOutputAttributes* output_attributes);
// Utility class to log Pica commands.
struct PicaTrace {
// Utility class to log Pica commands.
struct PicaTrace {
struct Write {
u16 cmd_id;
u16 mask;
u32 value;
};
std::vector<Write> writes;
};
std::vector<Write> search_corrected_writes;
bool isSearchCorrected = false;
void CorrectSearchWrites(std::string search_string) {
void StartPicaTracing();
bool IsPicaTracing();
void OnPicaRegWrite(PicaTrace::Write write);
std::unique_ptr<PicaTrace> FinishPicaTracing();
search_corrected_writes.clear();
struct TextureInfo {
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();
bool IsPicaTracing();
void OnPicaRegWrite(PicaTrace::Write write);
std::unique_ptr<PicaTrace> FinishPicaTracing();
struct TextureInfo {
PAddr physical_address;
int width;
int height;
@ -210,9 +242,9 @@ struct TextureInfo {
static TextureInfo FromPicaRegister(const Pica::Regs::TextureConfig& config,
const Pica::Regs::TextureFormat& format);
};
};
/**
/**
* Lookup texel located at the given coordinates and return an RGBA vector of its color.
* @param source Source pointer to read data from
* @param s,t Texture coordinates to read from
@ -223,21 +255,21 @@ struct TextureInfo {
* channel.
* @todo Eventually we should get rid of the disable_alpha parameter.
*/
const Math::Vec4<u8> LookupTexture(const u8* source, int s, int t, const TextureInfo& info,
const Math::Vec4<u8> LookupTexture(const u8* source, int s, int t, const TextureInfo& info,
bool disable_alpha = false);
void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data);
void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data);
std::string GetTevStageConfigColorCombinerString(const Pica::Regs::TevStageConfig& tev_stage);
std::string GetTevStageConfigAlphaCombinerString(const Pica::Regs::TevStageConfig& tev_stage);
std::string GetTevStageConfigColorCombinerString(const Pica::Regs::TevStageConfig& tev_stage);
std::string GetTevStageConfigAlphaCombinerString(const Pica::Regs::TevStageConfig& tev_stage);
/// Dumps the Tev stage config to log at trace level
void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig, 6>& stages);
/// Dumps the Tev stage config to log at trace level
void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig, 6>& stages);
/**
/**
* Used in the vertex loader to merge access records. TODO: Investigate if actually useful.
*/
class MemoryAccessTracker {
class MemoryAccessTracker {
/// Combine overlapping and close ranges
void SimplifyRanges() {
for (auto it = ranges.begin(); it != ranges.end(); ++it) {
@ -251,7 +283,7 @@ class MemoryAccessTracker {
}
}
public:
public:
/// Record a particular memory access in the list
void AddAccess(u32 paddr, u32 size) {
// Create new range or extend existing one
@ -263,8 +295,8 @@ public:
/// Map of accessed ranges (mapping start address to range size)
std::map<u32, u32> ranges;
};
} // namespace
};
} // namespace
} // namespace