mirror of
https://github.com/PabloMK7/citra
synced 2024-11-15 05:08:23 +00:00
citra-qt: Improve shader debugger.
Now supports dumping the current shader and recognizes a larger number of output semantics.
This commit is contained in:
parent
6a5d560c4f
commit
4cb302c8ae
6 changed files with 48 additions and 16 deletions
|
@ -6,6 +6,8 @@
|
|||
#include <sstream>
|
||||
|
||||
#include <QBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QTreeView>
|
||||
|
||||
#include "video_core/shader/shader_interpreter.h"
|
||||
|
@ -253,18 +255,27 @@ void GraphicsVertexShaderModel::OnUpdate()
|
|||
|
||||
info.Clear();
|
||||
|
||||
for (auto instr : Pica::g_state.vs.program_code)
|
||||
auto& shader_setup = Pica::g_state.vs;
|
||||
for (auto instr : shader_setup.program_code)
|
||||
info.code.push_back({instr});
|
||||
|
||||
for (auto pattern : Pica::g_state.vs.swizzle_data)
|
||||
for (auto pattern : shader_setup.swizzle_data)
|
||||
info.swizzle_info.push_back({pattern});
|
||||
|
||||
info.labels.insert({ Pica::g_state.regs.vs.main_offset, "main" });
|
||||
u32 entry_point = Pica::g_state.regs.vs.main_offset;
|
||||
info.labels.insert({ entry_point, "main" });
|
||||
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void GraphicsVertexShaderModel::DumpShader() {
|
||||
auto& setup = Pica::g_state.vs;
|
||||
auto& config = Pica::g_state.regs.vs;
|
||||
|
||||
Pica::DebugUtils::DumpShader(setup.program_code.data(), setup.program_code.size(),
|
||||
setup.swizzle_data.data(), setup.swizzle_data.size(),
|
||||
config.main_offset, Pica::g_state.regs.vs_output_attributes);
|
||||
}
|
||||
GraphicsVertexShaderWidget::GraphicsVertexShaderWidget(std::shared_ptr< Pica::DebugContext > debug_context,
|
||||
QWidget* parent)
|
||||
: BreakPointObserverDock(debug_context, "Pica Vertex Shader", parent) {
|
||||
|
@ -276,6 +287,9 @@ GraphicsVertexShaderWidget::GraphicsVertexShaderWidget(std::shared_ptr< Pica::De
|
|||
binary_list->setRootIsDecorated(false);
|
||||
binary_list->setAlternatingRowColors(true);
|
||||
|
||||
auto dump_shader = new QPushButton(tr("Dump"));
|
||||
|
||||
connect(dump_shader, SIGNAL(clicked()), binary_model, SLOT(DumpShader()));
|
||||
connect(this, SIGNAL(Update()), binary_model, SLOT(OnUpdate()));
|
||||
|
||||
auto main_widget = new QWidget;
|
||||
|
@ -285,6 +299,7 @@ GraphicsVertexShaderWidget::GraphicsVertexShaderWidget(std::shared_ptr< Pica::De
|
|||
sub_layout->addWidget(binary_list);
|
||||
main_layout->addLayout(sub_layout);
|
||||
}
|
||||
main_layout->addWidget(dump_shader);
|
||||
main_widget->setLayout(main_layout);
|
||||
setWidget(main_widget);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@ public:
|
|||
public slots:
|
||||
void OnUpdate();
|
||||
|
||||
void DumpShader();
|
||||
|
||||
private:
|
||||
nihstro::ShaderInfo info;
|
||||
};
|
||||
|
|
|
@ -131,11 +131,14 @@ void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data
|
|||
// into shbin format (separate type and component mask).
|
||||
union OutputRegisterInfo {
|
||||
enum Type : u64 {
|
||||
POSITION = 0,
|
||||
COLOR = 2,
|
||||
TEXCOORD0 = 3,
|
||||
TEXCOORD1 = 5,
|
||||
TEXCOORD2 = 6,
|
||||
POSITION = 0,
|
||||
QUATERNION = 1,
|
||||
COLOR = 2,
|
||||
TEXCOORD0 = 3,
|
||||
TEXCOORD1 = 5,
|
||||
TEXCOORD2 = 6,
|
||||
|
||||
VIEW = 8,
|
||||
};
|
||||
|
||||
BitField< 0, 64, u64> hex;
|
||||
|
@ -157,6 +160,10 @@ void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data
|
|||
{ OutputAttributes::POSITION_Y, { OutputRegisterInfo::POSITION, 2} },
|
||||
{ OutputAttributes::POSITION_Z, { OutputRegisterInfo::POSITION, 4} },
|
||||
{ OutputAttributes::POSITION_W, { OutputRegisterInfo::POSITION, 8} },
|
||||
{ OutputAttributes::QUATERNION_X, { OutputRegisterInfo::QUATERNION, 1} },
|
||||
{ OutputAttributes::QUATERNION_Y, { OutputRegisterInfo::QUATERNION, 2} },
|
||||
{ OutputAttributes::QUATERNION_Z, { OutputRegisterInfo::QUATERNION, 4} },
|
||||
{ OutputAttributes::QUATERNION_W, { OutputRegisterInfo::QUATERNION, 8} },
|
||||
{ OutputAttributes::COLOR_R, { OutputRegisterInfo::COLOR, 1} },
|
||||
{ OutputAttributes::COLOR_G, { OutputRegisterInfo::COLOR, 2} },
|
||||
{ OutputAttributes::COLOR_B, { OutputRegisterInfo::COLOR, 4} },
|
||||
|
@ -166,7 +173,10 @@ void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data
|
|||
{ OutputAttributes::TEXCOORD1_U, { OutputRegisterInfo::TEXCOORD1, 1} },
|
||||
{ OutputAttributes::TEXCOORD1_V, { OutputRegisterInfo::TEXCOORD1, 2} },
|
||||
{ OutputAttributes::TEXCOORD2_U, { OutputRegisterInfo::TEXCOORD2, 1} },
|
||||
{ OutputAttributes::TEXCOORD2_V, { OutputRegisterInfo::TEXCOORD2, 2} }
|
||||
{ OutputAttributes::TEXCOORD2_V, { OutputRegisterInfo::TEXCOORD2, 2} },
|
||||
{ OutputAttributes::VIEW_X, { OutputRegisterInfo::VIEW, 1} },
|
||||
{ OutputAttributes::VIEW_Y, { OutputRegisterInfo::VIEW, 2} },
|
||||
{ OutputAttributes::VIEW_Z, { OutputRegisterInfo::VIEW, 4} }
|
||||
};
|
||||
|
||||
for (const auto& semantic : std::vector<OutputAttributes::Semantic>{
|
||||
|
@ -239,6 +249,7 @@ void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data
|
|||
|
||||
// TODO: Create a label table for "main"
|
||||
|
||||
// TODO: Write uniforms as constants
|
||||
|
||||
// Write data to file
|
||||
static int dump_index = 0;
|
||||
|
|
|
@ -158,7 +158,6 @@ extern std::shared_ptr<DebugContext> g_debug_context; // TODO: Get rid of this g
|
|||
namespace DebugUtils {
|
||||
|
||||
#define PICA_DUMP_GEOMETRY 0
|
||||
#define PICA_DUMP_SHADERS 0
|
||||
#define PICA_DUMP_TEXTURES 0
|
||||
#define PICA_LOG_TEV 0
|
||||
|
||||
|
|
|
@ -80,6 +80,11 @@ struct Regs {
|
|||
POSITION_Z = 2,
|
||||
POSITION_W = 3,
|
||||
|
||||
QUATERNION_X = 4,
|
||||
QUATERNION_Y = 5,
|
||||
QUATERNION_Z = 6,
|
||||
QUATERNION_W = 7,
|
||||
|
||||
COLOR_R = 8,
|
||||
COLOR_G = 9,
|
||||
COLOR_B = 10,
|
||||
|
@ -89,6 +94,12 @@ struct Regs {
|
|||
TEXCOORD0_V = 13,
|
||||
TEXCOORD1_U = 14,
|
||||
TEXCOORD1_V = 15,
|
||||
|
||||
// TODO: Not verified
|
||||
VIEW_X = 18,
|
||||
VIEW_Y = 19,
|
||||
VIEW_Z = 20,
|
||||
|
||||
TEXCOORD2_U = 22,
|
||||
TEXCOORD2_V = 23,
|
||||
|
||||
|
|
|
@ -96,12 +96,6 @@ OutputVertex Run(UnitState& state, const InputVertex& input, int num_attributes)
|
|||
RunInterpreter(state);
|
||||
#endif // ARCHITECTURE_x86_64
|
||||
|
||||
#if PICA_DUMP_SHADERS
|
||||
DebugUtils::DumpShader(setup.program_code.data(), state.debug.max_offset, setup.swizzle_data.data(),
|
||||
state.debug.max_opdesc_id, config.main_offset,
|
||||
g_state.regs.vs_output_attributes); // TODO: Don't hardcode VS here
|
||||
#endif
|
||||
|
||||
// Setup output data
|
||||
OutputVertex ret;
|
||||
// TODO(neobrain): Under some circumstances, up to 16 attributes may be output. We need to
|
||||
|
|
Loading…
Reference in a new issue