diff options
| author | 2015-05-28 00:31:26 +0200 | |
|---|---|---|
| committer | 2015-08-16 13:22:01 +0200 | |
| commit | 2e3601f4156e73f22fa30d6b6cb42831ec1f713e (patch) | |
| tree | 62fbc98e323f230dcb2d16d0f2a0b0ded6b9e2d9 /src/video_core/debug_utils | |
| parent | citra-qt: Improve shader debugger. (diff) | |
| download | yuzu-2e3601f4156e73f22fa30d6b6cb42831ec1f713e.tar.gz yuzu-2e3601f4156e73f22fa30d6b6cb42831ec1f713e.tar.xz yuzu-2e3601f4156e73f22fa30d6b6cb42831ec1f713e.zip | |
Pica/DebugUtils: Include uniform information into shader dumps.
Diffstat (limited to 'src/video_core/debug_utils')
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.cpp | 59 | ||||
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.h | 3 |
2 files changed, 51 insertions, 11 deletions
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index 7cb7a6ef4..a79d90ef1 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include <png.h> | 14 | #include <png.h> |
| 15 | #endif | 15 | #endif |
| 16 | 16 | ||
| 17 | #include <nihstro/float24.h> | ||
| 17 | #include <nihstro/shader_binary.h> | 18 | #include <nihstro/shader_binary.h> |
| 18 | 19 | ||
| 19 | #include "common/assert.h" | 20 | #include "common/assert.h" |
| @@ -110,8 +111,7 @@ void GeometryDumper::Dump() { | |||
| 110 | } | 111 | } |
| 111 | 112 | ||
| 112 | 113 | ||
| 113 | void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data, u32 swizzle_size, | 114 | void DumpShader(const Regs::ShaderConfig& config, const State::ShaderSetup& setup, const Regs::VSOutputAttributes* output_attributes) |
| 114 | u32 main_offset, const Regs::VSOutputAttributes* output_attributes) | ||
| 115 | { | 115 | { |
| 116 | struct StuffToWrite { | 116 | struct StuffToWrite { |
| 117 | u8* pointer; | 117 | u8* pointer; |
| @@ -231,25 +231,66 @@ void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data | |||
| 231 | 231 | ||
| 232 | // TODO: Reduce the amount of binary code written to relevant portions | 232 | // TODO: Reduce the amount of binary code written to relevant portions |
| 233 | dvlp.binary_offset = write_offset - dvlp_offset; | 233 | dvlp.binary_offset = write_offset - dvlp_offset; |
| 234 | dvlp.binary_size_words = binary_size; | 234 | dvlp.binary_size_words = setup.program_code.size(); |
| 235 | QueueForWriting((u8*)binary_data, binary_size * sizeof(u32)); | 235 | QueueForWriting((u8*)setup.program_code.data(), setup.program_code.size() * sizeof(u32)); |
| 236 | 236 | ||
| 237 | dvlp.swizzle_info_offset = write_offset - dvlp_offset; | 237 | dvlp.swizzle_info_offset = write_offset - dvlp_offset; |
| 238 | dvlp.swizzle_info_num_entries = swizzle_size; | 238 | dvlp.swizzle_info_num_entries = setup.swizzle_data.size(); |
| 239 | u32 dummy = 0; | 239 | u32 dummy = 0; |
| 240 | for (unsigned int i = 0; i < swizzle_size; ++i) { | 240 | for (unsigned int i = 0; i < setup.swizzle_data.size(); ++i) { |
| 241 | QueueForWriting((u8*)&swizzle_data[i], sizeof(swizzle_data[i])); | 241 | QueueForWriting((u8*)&setup.swizzle_data[i], sizeof(setup.swizzle_data[i])); |
| 242 | QueueForWriting((u8*)&dummy, sizeof(dummy)); | 242 | QueueForWriting((u8*)&dummy, sizeof(dummy)); |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | dvle.main_offset_words = main_offset; | 245 | dvle.main_offset_words = config.main_offset; |
| 246 | dvle.output_register_table_offset = write_offset - dvlb.dvle_offset; | 246 | dvle.output_register_table_offset = write_offset - dvlb.dvle_offset; |
| 247 | dvle.output_register_table_size = static_cast<u32>(output_info_table.size()); | 247 | dvle.output_register_table_size = static_cast<u32>(output_info_table.size()); |
| 248 | QueueForWriting((u8*)output_info_table.data(), static_cast<u32>(output_info_table.size() * sizeof(OutputRegisterInfo))); | 248 | QueueForWriting((u8*)output_info_table.data(), static_cast<u32>(output_info_table.size() * sizeof(OutputRegisterInfo))); |
| 249 | 249 | ||
| 250 | // TODO: Create a label table for "main" | 250 | // TODO: Create a label table for "main" |
| 251 | 251 | ||
| 252 | // TODO: Write uniforms as constants | 252 | std::vector<nihstro::ConstantInfo> constant_table; |
| 253 | for (unsigned i = 0; i < setup.uniforms.b.size(); ++i) { | ||
| 254 | nihstro::ConstantInfo constant; | ||
| 255 | memset(&constant, 0, sizeof(constant)); | ||
| 256 | constant.type = nihstro::ConstantInfo::Bool; | ||
| 257 | constant.regid = i; | ||
| 258 | constant.b = setup.uniforms.b[i]; | ||
| 259 | constant_table.emplace_back(constant); | ||
| 260 | } | ||
| 261 | for (unsigned i = 0; i < setup.uniforms.i.size(); ++i) { | ||
| 262 | nihstro::ConstantInfo constant; | ||
| 263 | memset(&constant, 0, sizeof(constant)); | ||
| 264 | constant.type = nihstro::ConstantInfo::Int; | ||
| 265 | constant.regid = i; | ||
| 266 | constant.i.x = setup.uniforms.i[i].x; | ||
| 267 | constant.i.y = setup.uniforms.i[i].y; | ||
| 268 | constant.i.z = setup.uniforms.i[i].z; | ||
| 269 | constant.i.w = setup.uniforms.i[i].w; | ||
| 270 | constant_table.emplace_back(constant); | ||
| 271 | } | ||
| 272 | for (unsigned i = 0; i < sizeof(setup.uniforms.f) / sizeof(setup.uniforms.f[0]); ++i) { | ||
| 273 | nihstro::ConstantInfo constant; | ||
| 274 | memset(&constant, 0, sizeof(constant)); | ||
| 275 | constant.type = nihstro::ConstantInfo::Float; | ||
| 276 | constant.regid = i; | ||
| 277 | constant.f.x = nihstro::to_float24(setup.uniforms.f[i].x.ToFloat32()); | ||
| 278 | constant.f.y = nihstro::to_float24(setup.uniforms.f[i].y.ToFloat32()); | ||
| 279 | constant.f.z = nihstro::to_float24(setup.uniforms.f[i].z.ToFloat32()); | ||
| 280 | constant.f.w = nihstro::to_float24(setup.uniforms.f[i].w.ToFloat32()); | ||
| 281 | |||
| 282 | // Store constant if it's different from zero.. | ||
| 283 | if (setup.uniforms.f[i].x.ToFloat32() != 0.0 || | ||
| 284 | setup.uniforms.f[i].y.ToFloat32() != 0.0 || | ||
| 285 | setup.uniforms.f[i].z.ToFloat32() != 0.0 || | ||
| 286 | setup.uniforms.f[i].w.ToFloat32() != 0.0) | ||
| 287 | constant_table.emplace_back(constant); | ||
| 288 | } | ||
| 289 | dvle.constant_table_offset = write_offset - dvlb.dvle_offset; | ||
| 290 | dvle.constant_table_size = constant_table.size(); | ||
| 291 | for (const auto& constant : constant_table) { | ||
| 292 | QueueForWriting((uint8_t*)&constant, sizeof(constant)); | ||
| 293 | } | ||
| 253 | 294 | ||
| 254 | // Write data to file | 295 | // Write data to file |
| 255 | static int dump_index = 0; | 296 | 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 4939e6c06..1450e5bf3 100644 --- a/src/video_core/debug_utils/debug_utils.h +++ b/src/video_core/debug_utils/debug_utils.h | |||
| @@ -181,8 +181,7 @@ private: | |||
| 181 | std::vector<Face> faces; | 181 | std::vector<Face> faces; |
| 182 | }; | 182 | }; |
| 183 | 183 | ||
| 184 | void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data, u32 swizzle_size, | 184 | void DumpShader(const Regs::ShaderConfig& config, const State::ShaderSetup& setup, const Regs::VSOutputAttributes* output_attributes); |
| 185 | u32 main_offset, const Regs::VSOutputAttributes* output_attributes); | ||
| 186 | 185 | ||
| 187 | 186 | ||
| 188 | // Utility class to log Pica commands. | 187 | // Utility class to log Pica commands. |