diff options
| author | 2014-08-17 12:17:32 +0200 | |
|---|---|---|
| committer | 2014-08-25 22:03:18 +0200 | |
| commit | 34fa0b6d9cd9e4027198ce11562da6c03375cd70 (patch) | |
| tree | b6515008dbef56469057171762cf308d394ec670 /src/video_core/debug_utils | |
| parent | Pica/Rasterizer: Add initial implementation of texture combiners. (diff) | |
| download | yuzu-34fa0b6d9cd9e4027198ce11562da6c03375cd70.tar.gz yuzu-34fa0b6d9cd9e4027198ce11562da6c03375cd70.tar.xz yuzu-34fa0b6d9cd9e4027198ce11562da6c03375cd70.zip | |
Pica/DebugUtils: Add convenient tev setup printer.
Diffstat (limited to 'src/video_core/debug_utils')
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.cpp | 97 | ||||
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.h | 2 |
2 files changed, 99 insertions, 0 deletions
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index 753de41e8..619c0fbe5 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp | |||
| @@ -446,6 +446,103 @@ finalise: | |||
| 446 | #endif | 446 | #endif |
| 447 | } | 447 | } |
| 448 | 448 | ||
| 449 | void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig,6>& stages) | ||
| 450 | { | ||
| 451 | using Source = Pica::Regs::TevStageConfig::Source; | ||
| 452 | using ColorModifier = Pica::Regs::TevStageConfig::ColorModifier; | ||
| 453 | using AlphaModifier = Pica::Regs::TevStageConfig::AlphaModifier; | ||
| 454 | using Operation = Pica::Regs::TevStageConfig::Operation; | ||
| 455 | |||
| 456 | std::string stage_info = "Tev setup:\n"; | ||
| 457 | for (int index = 0; index < stages.size(); ++index) { | ||
| 458 | const auto& tev_stage = stages[index]; | ||
| 459 | |||
| 460 | const std::map<Source, std::string> source_map = { | ||
| 461 | { Source::PrimaryColor, "PrimaryColor" }, | ||
| 462 | { Source::Texture0, "Texture0" }, | ||
| 463 | { Source::Constant, "Constant" }, | ||
| 464 | { Source::Previous, "Previous" }, | ||
| 465 | }; | ||
| 466 | |||
| 467 | const std::map<ColorModifier, std::string> color_modifier_map = { | ||
| 468 | { ColorModifier::SourceColor, { "%source.rgb" } } | ||
| 469 | }; | ||
| 470 | const std::map<AlphaModifier, std::string> alpha_modifier_map = { | ||
| 471 | { AlphaModifier::SourceAlpha, "%source.a" } | ||
| 472 | }; | ||
| 473 | |||
| 474 | std::map<Operation, std::string> combiner_map = { | ||
| 475 | { Operation::Replace, "%source1" }, | ||
| 476 | { Operation::Modulate, "(%source1 * %source2) / 255" }, | ||
| 477 | }; | ||
| 478 | |||
| 479 | auto ReplacePattern = | ||
| 480 | [](const std::string& input, const std::string& pattern, const std::string& replacement) -> std::string { | ||
| 481 | size_t start = input.find(pattern); | ||
| 482 | if (start == std::string::npos) | ||
| 483 | return input; | ||
| 484 | |||
| 485 | std::string ret = input; | ||
| 486 | ret.replace(start, pattern.length(), replacement); | ||
| 487 | return ret; | ||
| 488 | }; | ||
| 489 | auto GetColorSourceStr = | ||
| 490 | [&source_map,&color_modifier_map,&ReplacePattern](const Source& src, const ColorModifier& modifier) { | ||
| 491 | auto src_it = source_map.find(src); | ||
| 492 | std::string src_str = "Unknown"; | ||
| 493 | if (src_it != source_map.end()) | ||
| 494 | src_str = src_it->second; | ||
| 495 | |||
| 496 | auto modifier_it = color_modifier_map.find(modifier); | ||
| 497 | std::string modifier_str = "%source.????"; | ||
| 498 | if (modifier_it != color_modifier_map.end()) | ||
| 499 | modifier_str = modifier_it->second; | ||
| 500 | |||
| 501 | return ReplacePattern(modifier_str, "%source", src_str); | ||
| 502 | }; | ||
| 503 | auto GetColorCombinerStr = | ||
| 504 | [&](const Regs::TevStageConfig& tev_stage) { | ||
| 505 | auto op_it = combiner_map.find(tev_stage.color_op); | ||
| 506 | std::string op_str = "Unknown op (%source1, %source2, %source3)"; | ||
| 507 | if (op_it != combiner_map.end()) | ||
| 508 | op_str = op_it->second; | ||
| 509 | |||
| 510 | op_str = ReplacePattern(op_str, "%source1", GetColorSourceStr(tev_stage.color_source1, tev_stage.color_modifier1)); | ||
| 511 | op_str = ReplacePattern(op_str, "%source2", GetColorSourceStr(tev_stage.color_source2, tev_stage.color_modifier2)); | ||
| 512 | return ReplacePattern(op_str, "%source3", GetColorSourceStr(tev_stage.color_source3, tev_stage.color_modifier3)); | ||
| 513 | }; | ||
| 514 | auto GetAlphaSourceStr = | ||
| 515 | [&source_map,&alpha_modifier_map,&ReplacePattern](const Source& src, const AlphaModifier& modifier) { | ||
| 516 | auto src_it = source_map.find(src); | ||
| 517 | std::string src_str = "Unknown"; | ||
| 518 | if (src_it != source_map.end()) | ||
| 519 | src_str = src_it->second; | ||
| 520 | |||
| 521 | auto modifier_it = alpha_modifier_map.find(modifier); | ||
| 522 | std::string modifier_str = "%source.????"; | ||
| 523 | if (modifier_it != alpha_modifier_map.end()) | ||
| 524 | modifier_str = modifier_it->second; | ||
| 525 | |||
| 526 | return ReplacePattern(modifier_str, "%source", src_str); | ||
| 527 | }; | ||
| 528 | auto GetAlphaCombinerStr = | ||
| 529 | [&](const Regs::TevStageConfig& tev_stage) { | ||
| 530 | auto op_it = combiner_map.find(tev_stage.alpha_op); | ||
| 531 | std::string op_str = "Unknown op (%source1, %source2, %source3)"; | ||
| 532 | if (op_it != combiner_map.end()) | ||
| 533 | op_str = op_it->second; | ||
| 534 | |||
| 535 | op_str = ReplacePattern(op_str, "%source1", GetAlphaSourceStr(tev_stage.alpha_source1, tev_stage.alpha_modifier1)); | ||
| 536 | op_str = ReplacePattern(op_str, "%source2", GetAlphaSourceStr(tev_stage.alpha_source2, tev_stage.alpha_modifier2)); | ||
| 537 | return ReplacePattern(op_str, "%source3", GetAlphaSourceStr(tev_stage.alpha_source3, tev_stage.alpha_modifier3)); | ||
| 538 | }; | ||
| 539 | |||
| 540 | stage_info += "Stage " + std::to_string(index) + ": " + GetColorCombinerStr(tev_stage) + " " + GetAlphaCombinerStr(tev_stage) + "\n"; | ||
| 541 | } | ||
| 542 | |||
| 543 | DEBUG_LOG(GPU, "%s", stage_info.c_str()); | ||
| 544 | } | ||
| 545 | |||
| 449 | } // namespace | 546 | } // namespace |
| 450 | 547 | ||
| 451 | } // namespace | 548 | } // namespace |
diff --git a/src/video_core/debug_utils/debug_utils.h b/src/video_core/debug_utils/debug_utils.h index 49b19b28a..53c33c96e 100644 --- a/src/video_core/debug_utils/debug_utils.h +++ b/src/video_core/debug_utils/debug_utils.h | |||
| @@ -61,6 +61,8 @@ std::unique_ptr<PicaTrace> FinishPicaTracing(); | |||
| 61 | 61 | ||
| 62 | void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data); | 62 | void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data); |
| 63 | 63 | ||
| 64 | void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig,6>& stages); | ||
| 65 | |||
| 64 | } // namespace | 66 | } // namespace |
| 65 | 67 | ||
| 66 | } // namespace | 68 | } // namespace |