mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-25 20:40:15 +00:00
Search bar for GPU Commands
This commit is contained in:
parent
cc7f1155a8
commit
8aa28825db
@ -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);
|
||||||
|
@ -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();
|
||||||
|
@ -20,17 +20,17 @@
|
|||||||
#include "video_core/pica.h"
|
#include "video_core/pica.h"
|
||||||
|
|
||||||
namespace CiTrace {
|
namespace CiTrace {
|
||||||
class Recorder;
|
class Recorder;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Pica {
|
namespace Pica {
|
||||||
|
|
||||||
namespace Shader {
|
namespace Shader {
|
||||||
struct ShaderSetup;
|
struct ShaderSetup;
|
||||||
}
|
}
|
||||||
|
|
||||||
class DebugContext {
|
class DebugContext {
|
||||||
public:
|
public:
|
||||||
enum class Event {
|
enum class Event {
|
||||||
FirstEvent = 0,
|
FirstEvent = 0,
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ public:
|
|||||||
|
|
||||||
std::shared_ptr<CiTrace::Recorder> recorder = nullptr;
|
std::shared_ptr<CiTrace::Recorder> recorder = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Private default constructor to make sure people always construct this through Construct()
|
* Private default constructor to make sure people always construct this through Construct()
|
||||||
* instead.
|
* instead.
|
||||||
@ -173,35 +173,67 @@ private:
|
|||||||
|
|
||||||
/// List of registered observers
|
/// List of registered observers
|
||||||
std::list<BreakPointObserver*> breakpoint_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_DUMP_TEXTURES 0
|
||||||
#define PICA_LOG_TEV 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 Shader::ShaderSetup& setup,
|
||||||
const Regs::VSOutputAttributes* output_attributes);
|
const Regs::VSOutputAttributes* output_attributes);
|
||||||
|
|
||||||
// Utility class to log Pica commands.
|
// Utility class to log Pica commands.
|
||||||
struct PicaTrace {
|
struct PicaTrace {
|
||||||
struct Write {
|
struct Write {
|
||||||
u16 cmd_id;
|
u16 cmd_id;
|
||||||
u16 mask;
|
u16 mask;
|
||||||
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) {
|
||||||
|
|
||||||
void StartPicaTracing();
|
search_corrected_writes.clear();
|
||||||
bool IsPicaTracing();
|
|
||||||
void OnPicaRegWrite(PicaTrace::Write write);
|
|
||||||
std::unique_ptr<PicaTrace> FinishPicaTracing();
|
|
||||||
|
|
||||||
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;
|
PAddr physical_address;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
@ -210,9 +242,9 @@ struct TextureInfo {
|
|||||||
|
|
||||||
static TextureInfo FromPicaRegister(const Pica::Regs::TextureConfig& config,
|
static TextureInfo FromPicaRegister(const Pica::Regs::TextureConfig& config,
|
||||||
const Pica::Regs::TextureFormat& format);
|
const Pica::Regs::TextureFormat& format);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lookup texel located at the given coordinates and return an RGBA vector of its color.
|
* Lookup texel located at the given coordinates and return an RGBA vector of its color.
|
||||||
* @param source Source pointer to read data from
|
* @param source Source pointer to read data from
|
||||||
* @param s,t Texture coordinates to read from
|
* @param s,t Texture coordinates to read from
|
||||||
@ -223,21 +255,21 @@ struct TextureInfo {
|
|||||||
* channel.
|
* channel.
|
||||||
* @todo Eventually we should get rid of the disable_alpha parameter.
|
* @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);
|
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 GetTevStageConfigColorCombinerString(const Pica::Regs::TevStageConfig& tev_stage);
|
||||||
std::string GetTevStageConfigAlphaCombinerString(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
|
/// Dumps the Tev stage config to log at trace level
|
||||||
void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig, 6>& stages);
|
void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig, 6>& stages);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used in the vertex loader to merge access records. TODO: Investigate if actually useful.
|
* Used in the vertex loader to merge access records. TODO: Investigate if actually useful.
|
||||||
*/
|
*/
|
||||||
class MemoryAccessTracker {
|
class MemoryAccessTracker {
|
||||||
/// Combine overlapping and close ranges
|
/// Combine overlapping and close ranges
|
||||||
void SimplifyRanges() {
|
void SimplifyRanges() {
|
||||||
for (auto it = ranges.begin(); it != ranges.end(); ++it) {
|
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
|
/// Record a particular memory access in the list
|
||||||
void AddAccess(u32 paddr, u32 size) {
|
void AddAccess(u32 paddr, u32 size) {
|
||||||
// Create new range or extend existing one
|
// Create new range or extend existing one
|
||||||
@ -263,8 +295,8 @@ public:
|
|||||||
|
|
||||||
/// Map of accessed ranges (mapping start address to range size)
|
/// Map of accessed ranges (mapping start address to range size)
|
||||||
std::map<u32, u32> ranges;
|
std::map<u32, u32> ranges;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
Loading…
Reference in New Issue
Block a user