diff options
| author | 2015-05-27 16:20:46 +0200 | |
|---|---|---|
| committer | 2015-08-16 13:22:00 +0200 | |
| commit | 4cb302c8aeb86bdb7c7bd6f9e5d716e140868075 (patch) | |
| tree | 3aebbc2a55c68a48cbf72bcf7652485c1ac9b745 /src | |
| parent | citra-qt: Print the correct swizzle mask for SRC2 in the shader disassembler. (diff) | |
| download | yuzu-4cb302c8aeb86bdb7c7bd6f9e5d716e140868075.tar.gz yuzu-4cb302c8aeb86bdb7c7bd6f9e5d716e140868075.tar.xz yuzu-4cb302c8aeb86bdb7c7bd6f9e5d716e140868075.zip | |
citra-qt: Improve shader debugger.
Now supports dumping the current shader and recognizes a larger number of output semantics.
Diffstat (limited to 'src')
| -rw-r--r-- | src/citra_qt/debugger/graphics_vertex_shader.cpp | 21 | ||||
| -rw-r--r-- | src/citra_qt/debugger/graphics_vertex_shader.h | 2 | ||||
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.cpp | 23 | ||||
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.h | 1 | ||||
| -rw-r--r-- | src/video_core/pica.h | 11 | ||||
| -rw-r--r-- | src/video_core/shader/shader.cpp | 6 |
6 files changed, 48 insertions, 16 deletions
diff --git a/src/citra_qt/debugger/graphics_vertex_shader.cpp b/src/citra_qt/debugger/graphics_vertex_shader.cpp index b7882741d..92d3a8323 100644 --- a/src/citra_qt/debugger/graphics_vertex_shader.cpp +++ b/src/citra_qt/debugger/graphics_vertex_shader.cpp | |||
| @@ -6,6 +6,8 @@ | |||
| 6 | #include <sstream> | 6 | #include <sstream> |
| 7 | 7 | ||
| 8 | #include <QBoxLayout> | 8 | #include <QBoxLayout> |
| 9 | #include <QLabel> | ||
| 10 | #include <QPushButton> | ||
| 9 | #include <QTreeView> | 11 | #include <QTreeView> |
| 10 | 12 | ||
| 11 | #include "video_core/shader/shader_interpreter.h" | 13 | #include "video_core/shader/shader_interpreter.h" |
| @@ -253,18 +255,27 @@ void GraphicsVertexShaderModel::OnUpdate() | |||
| 253 | 255 | ||
| 254 | info.Clear(); | 256 | info.Clear(); |
| 255 | 257 | ||
| 256 | for (auto instr : Pica::g_state.vs.program_code) | 258 | auto& shader_setup = Pica::g_state.vs; |
| 259 | for (auto instr : shader_setup.program_code) | ||
| 257 | info.code.push_back({instr}); | 260 | info.code.push_back({instr}); |
| 258 | 261 | ||
| 259 | for (auto pattern : Pica::g_state.vs.swizzle_data) | 262 | for (auto pattern : shader_setup.swizzle_data) |
| 260 | info.swizzle_info.push_back({pattern}); | 263 | info.swizzle_info.push_back({pattern}); |
| 261 | 264 | ||
| 262 | info.labels.insert({ Pica::g_state.regs.vs.main_offset, "main" }); | 265 | u32 entry_point = Pica::g_state.regs.vs.main_offset; |
| 266 | info.labels.insert({ entry_point, "main" }); | ||
| 263 | 267 | ||
| 264 | endResetModel(); | 268 | endResetModel(); |
| 265 | } | 269 | } |
| 266 | 270 | ||
| 271 | void GraphicsVertexShaderModel::DumpShader() { | ||
| 272 | auto& setup = Pica::g_state.vs; | ||
| 273 | auto& config = Pica::g_state.regs.vs; | ||
| 267 | 274 | ||
| 275 | Pica::DebugUtils::DumpShader(setup.program_code.data(), setup.program_code.size(), | ||
| 276 | setup.swizzle_data.data(), setup.swizzle_data.size(), | ||
| 277 | config.main_offset, Pica::g_state.regs.vs_output_attributes); | ||
| 278 | } | ||
| 268 | GraphicsVertexShaderWidget::GraphicsVertexShaderWidget(std::shared_ptr< Pica::DebugContext > debug_context, | 279 | GraphicsVertexShaderWidget::GraphicsVertexShaderWidget(std::shared_ptr< Pica::DebugContext > debug_context, |
| 269 | QWidget* parent) | 280 | QWidget* parent) |
| 270 | : BreakPointObserverDock(debug_context, "Pica Vertex Shader", parent) { | 281 | : BreakPointObserverDock(debug_context, "Pica Vertex Shader", parent) { |
| @@ -276,6 +287,9 @@ GraphicsVertexShaderWidget::GraphicsVertexShaderWidget(std::shared_ptr< Pica::De | |||
| 276 | binary_list->setRootIsDecorated(false); | 287 | binary_list->setRootIsDecorated(false); |
| 277 | binary_list->setAlternatingRowColors(true); | 288 | binary_list->setAlternatingRowColors(true); |
| 278 | 289 | ||
| 290 | auto dump_shader = new QPushButton(tr("Dump")); | ||
| 291 | |||
| 292 | connect(dump_shader, SIGNAL(clicked()), binary_model, SLOT(DumpShader())); | ||
| 279 | connect(this, SIGNAL(Update()), binary_model, SLOT(OnUpdate())); | 293 | connect(this, SIGNAL(Update()), binary_model, SLOT(OnUpdate())); |
| 280 | 294 | ||
| 281 | auto main_widget = new QWidget; | 295 | auto main_widget = new QWidget; |
| @@ -285,6 +299,7 @@ GraphicsVertexShaderWidget::GraphicsVertexShaderWidget(std::shared_ptr< Pica::De | |||
| 285 | sub_layout->addWidget(binary_list); | 299 | sub_layout->addWidget(binary_list); |
| 286 | main_layout->addLayout(sub_layout); | 300 | main_layout->addLayout(sub_layout); |
| 287 | } | 301 | } |
| 302 | main_layout->addWidget(dump_shader); | ||
| 288 | main_widget->setLayout(main_layout); | 303 | main_widget->setLayout(main_layout); |
| 289 | setWidget(main_widget); | 304 | setWidget(main_widget); |
| 290 | } | 305 | } |
diff --git a/src/citra_qt/debugger/graphics_vertex_shader.h b/src/citra_qt/debugger/graphics_vertex_shader.h index 38339dc05..5dc9e3703 100644 --- a/src/citra_qt/debugger/graphics_vertex_shader.h +++ b/src/citra_qt/debugger/graphics_vertex_shader.h | |||
| @@ -26,6 +26,8 @@ public: | |||
| 26 | public slots: | 26 | public slots: |
| 27 | void OnUpdate(); | 27 | void OnUpdate(); |
| 28 | 28 | ||
| 29 | void DumpShader(); | ||
| 30 | |||
| 29 | private: | 31 | private: |
| 30 | nihstro::ShaderInfo info; | 32 | nihstro::ShaderInfo info; |
| 31 | }; | 33 | }; |
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index 572b4fd62..7cb7a6ef4 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp | |||
| @@ -131,11 +131,14 @@ void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data | |||
| 131 | // into shbin format (separate type and component mask). | 131 | // into shbin format (separate type and component mask). |
| 132 | union OutputRegisterInfo { | 132 | union OutputRegisterInfo { |
| 133 | enum Type : u64 { | 133 | enum Type : u64 { |
| 134 | POSITION = 0, | 134 | POSITION = 0, |
| 135 | COLOR = 2, | 135 | QUATERNION = 1, |
| 136 | TEXCOORD0 = 3, | 136 | COLOR = 2, |
| 137 | TEXCOORD1 = 5, | 137 | TEXCOORD0 = 3, |
| 138 | TEXCOORD2 = 6, | 138 | TEXCOORD1 = 5, |
| 139 | TEXCOORD2 = 6, | ||
| 140 | |||
| 141 | VIEW = 8, | ||
| 139 | }; | 142 | }; |
| 140 | 143 | ||
| 141 | BitField< 0, 64, u64> hex; | 144 | BitField< 0, 64, u64> hex; |
| @@ -157,6 +160,10 @@ void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data | |||
| 157 | { OutputAttributes::POSITION_Y, { OutputRegisterInfo::POSITION, 2} }, | 160 | { OutputAttributes::POSITION_Y, { OutputRegisterInfo::POSITION, 2} }, |
| 158 | { OutputAttributes::POSITION_Z, { OutputRegisterInfo::POSITION, 4} }, | 161 | { OutputAttributes::POSITION_Z, { OutputRegisterInfo::POSITION, 4} }, |
| 159 | { OutputAttributes::POSITION_W, { OutputRegisterInfo::POSITION, 8} }, | 162 | { OutputAttributes::POSITION_W, { OutputRegisterInfo::POSITION, 8} }, |
| 163 | { OutputAttributes::QUATERNION_X, { OutputRegisterInfo::QUATERNION, 1} }, | ||
| 164 | { OutputAttributes::QUATERNION_Y, { OutputRegisterInfo::QUATERNION, 2} }, | ||
| 165 | { OutputAttributes::QUATERNION_Z, { OutputRegisterInfo::QUATERNION, 4} }, | ||
| 166 | { OutputAttributes::QUATERNION_W, { OutputRegisterInfo::QUATERNION, 8} }, | ||
| 160 | { OutputAttributes::COLOR_R, { OutputRegisterInfo::COLOR, 1} }, | 167 | { OutputAttributes::COLOR_R, { OutputRegisterInfo::COLOR, 1} }, |
| 161 | { OutputAttributes::COLOR_G, { OutputRegisterInfo::COLOR, 2} }, | 168 | { OutputAttributes::COLOR_G, { OutputRegisterInfo::COLOR, 2} }, |
| 162 | { OutputAttributes::COLOR_B, { OutputRegisterInfo::COLOR, 4} }, | 169 | { OutputAttributes::COLOR_B, { OutputRegisterInfo::COLOR, 4} }, |
| @@ -166,7 +173,10 @@ void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data | |||
| 166 | { OutputAttributes::TEXCOORD1_U, { OutputRegisterInfo::TEXCOORD1, 1} }, | 173 | { OutputAttributes::TEXCOORD1_U, { OutputRegisterInfo::TEXCOORD1, 1} }, |
| 167 | { OutputAttributes::TEXCOORD1_V, { OutputRegisterInfo::TEXCOORD1, 2} }, | 174 | { OutputAttributes::TEXCOORD1_V, { OutputRegisterInfo::TEXCOORD1, 2} }, |
| 168 | { OutputAttributes::TEXCOORD2_U, { OutputRegisterInfo::TEXCOORD2, 1} }, | 175 | { OutputAttributes::TEXCOORD2_U, { OutputRegisterInfo::TEXCOORD2, 1} }, |
| 169 | { OutputAttributes::TEXCOORD2_V, { OutputRegisterInfo::TEXCOORD2, 2} } | 176 | { OutputAttributes::TEXCOORD2_V, { OutputRegisterInfo::TEXCOORD2, 2} }, |
| 177 | { OutputAttributes::VIEW_X, { OutputRegisterInfo::VIEW, 1} }, | ||
| 178 | { OutputAttributes::VIEW_Y, { OutputRegisterInfo::VIEW, 2} }, | ||
| 179 | { OutputAttributes::VIEW_Z, { OutputRegisterInfo::VIEW, 4} } | ||
| 170 | }; | 180 | }; |
| 171 | 181 | ||
| 172 | for (const auto& semantic : std::vector<OutputAttributes::Semantic>{ | 182 | 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 | |||
| 239 | 249 | ||
| 240 | // TODO: Create a label table for "main" | 250 | // TODO: Create a label table for "main" |
| 241 | 251 | ||
| 252 | // TODO: Write uniforms as constants | ||
| 242 | 253 | ||
| 243 | // Write data to file | 254 | // Write data to file |
| 244 | static int dump_index = 0; | 255 | static int dump_index = 0; |
diff --git a/src/video_core/debug_utils/debug_utils.h b/src/video_core/debug_utils/debug_utils.h index 81eea30a9..4939e6c06 100644 --- a/src/video_core/debug_utils/debug_utils.h +++ b/src/video_core/debug_utils/debug_utils.h | |||
| @@ -158,7 +158,6 @@ extern std::shared_ptr<DebugContext> g_debug_context; // TODO: Get rid of this g | |||
| 158 | namespace DebugUtils { | 158 | namespace DebugUtils { |
| 159 | 159 | ||
| 160 | #define PICA_DUMP_GEOMETRY 0 | 160 | #define PICA_DUMP_GEOMETRY 0 |
| 161 | #define PICA_DUMP_SHADERS 0 | ||
| 162 | #define PICA_DUMP_TEXTURES 0 | 161 | #define PICA_DUMP_TEXTURES 0 |
| 163 | #define PICA_LOG_TEV 0 | 162 | #define PICA_LOG_TEV 0 |
| 164 | 163 | ||
diff --git a/src/video_core/pica.h b/src/video_core/pica.h index 6ce90f95a..36916f862 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h | |||
| @@ -80,6 +80,11 @@ struct Regs { | |||
| 80 | POSITION_Z = 2, | 80 | POSITION_Z = 2, |
| 81 | POSITION_W = 3, | 81 | POSITION_W = 3, |
| 82 | 82 | ||
| 83 | QUATERNION_X = 4, | ||
| 84 | QUATERNION_Y = 5, | ||
| 85 | QUATERNION_Z = 6, | ||
| 86 | QUATERNION_W = 7, | ||
| 87 | |||
| 83 | COLOR_R = 8, | 88 | COLOR_R = 8, |
| 84 | COLOR_G = 9, | 89 | COLOR_G = 9, |
| 85 | COLOR_B = 10, | 90 | COLOR_B = 10, |
| @@ -89,6 +94,12 @@ struct Regs { | |||
| 89 | TEXCOORD0_V = 13, | 94 | TEXCOORD0_V = 13, |
| 90 | TEXCOORD1_U = 14, | 95 | TEXCOORD1_U = 14, |
| 91 | TEXCOORD1_V = 15, | 96 | TEXCOORD1_V = 15, |
| 97 | |||
| 98 | // TODO: Not verified | ||
| 99 | VIEW_X = 18, | ||
| 100 | VIEW_Y = 19, | ||
| 101 | VIEW_Z = 20, | ||
| 102 | |||
| 92 | TEXCOORD2_U = 22, | 103 | TEXCOORD2_U = 22, |
| 93 | TEXCOORD2_V = 23, | 104 | TEXCOORD2_V = 23, |
| 94 | 105 | ||
diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp index 6a27a8015..2692b91e4 100644 --- a/src/video_core/shader/shader.cpp +++ b/src/video_core/shader/shader.cpp | |||
| @@ -96,12 +96,6 @@ OutputVertex Run(UnitState& state, const InputVertex& input, int num_attributes) | |||
| 96 | RunInterpreter(state); | 96 | RunInterpreter(state); |
| 97 | #endif // ARCHITECTURE_x86_64 | 97 | #endif // ARCHITECTURE_x86_64 |
| 98 | 98 | ||
| 99 | #if PICA_DUMP_SHADERS | ||
| 100 | DebugUtils::DumpShader(setup.program_code.data(), state.debug.max_offset, setup.swizzle_data.data(), | ||
| 101 | state.debug.max_opdesc_id, config.main_offset, | ||
| 102 | g_state.regs.vs_output_attributes); // TODO: Don't hardcode VS here | ||
| 103 | #endif | ||
| 104 | |||
| 105 | // Setup output data | 99 | // Setup output data |
| 106 | OutputVertex ret; | 100 | OutputVertex ret; |
| 107 | // TODO(neobrain): Under some circumstances, up to 16 attributes may be output. We need to | 101 | // TODO(neobrain): Under some circumstances, up to 16 attributes may be output. We need to |