diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/citra_qt/configure_audio.cpp | 6 | ||||
| -rw-r--r-- | src/tests/CMakeLists.txt | 16 | ||||
| -rw-r--r-- | src/tests/tests.cpp | 9 | ||||
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.cpp | 199 | ||||
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.h | 6 |
6 files changed, 143 insertions, 94 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index de4fe716a..1e1245160 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt | |||
| @@ -5,6 +5,7 @@ add_subdirectory(common) | |||
| 5 | add_subdirectory(core) | 5 | add_subdirectory(core) |
| 6 | add_subdirectory(video_core) | 6 | add_subdirectory(video_core) |
| 7 | add_subdirectory(audio_core) | 7 | add_subdirectory(audio_core) |
| 8 | add_subdirectory(tests) | ||
| 8 | if (ENABLE_SDL2) | 9 | if (ENABLE_SDL2) |
| 9 | add_subdirectory(citra) | 10 | add_subdirectory(citra) |
| 10 | endif() | 11 | endif() |
diff --git a/src/citra_qt/configure_audio.cpp b/src/citra_qt/configure_audio.cpp index f3685e11a..cedfa2f2a 100644 --- a/src/citra_qt/configure_audio.cpp +++ b/src/citra_qt/configure_audio.cpp | |||
| @@ -28,14 +28,14 @@ ConfigureAudio::~ConfigureAudio() { | |||
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | void ConfigureAudio::setConfiguration() { | 30 | void ConfigureAudio::setConfiguration() { |
| 31 | int new_sink_index = 0; | ||
| 31 | for (int index = 0; index < ui->output_sink_combo_box->count(); index++) { | 32 | for (int index = 0; index < ui->output_sink_combo_box->count(); index++) { |
| 32 | if (ui->output_sink_combo_box->itemText(index).toStdString() == Settings::values.sink_id) { | 33 | if (ui->output_sink_combo_box->itemText(index).toStdString() == Settings::values.sink_id) { |
| 33 | ui->output_sink_combo_box->setCurrentIndex(index); | 34 | new_sink_index = index; |
| 34 | break; | 35 | break; |
| 35 | } | 36 | } |
| 36 | } | 37 | } |
| 37 | 38 | ui->output_sink_combo_box->setCurrentIndex(new_sink_index); | |
| 38 | ui->output_sink_combo_box->setCurrentIndex(0); | ||
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | void ConfigureAudio::applyConfiguration() { | 41 | void ConfigureAudio::applyConfiguration() { |
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt new file mode 100644 index 000000000..457c55571 --- /dev/null +++ b/src/tests/CMakeLists.txt | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | set(SRCS | ||
| 2 | tests.cpp | ||
| 3 | ) | ||
| 4 | |||
| 5 | set(HEADERS | ||
| 6 | ) | ||
| 7 | |||
| 8 | create_directory_groups(${SRCS} ${HEADERS}) | ||
| 9 | |||
| 10 | include_directories(../../externals/catch/single_include/) | ||
| 11 | |||
| 12 | add_executable(tests ${SRCS} ${HEADERS}) | ||
| 13 | target_link_libraries(tests core video_core audio_core common) | ||
| 14 | target_link_libraries(tests ${PLATFORM_LIBRARIES}) | ||
| 15 | |||
| 16 | add_test(NAME tests COMMAND $<TARGET_FILE:tests>) | ||
diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp new file mode 100644 index 000000000..73978676f --- /dev/null +++ b/src/tests/tests.cpp | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | // Copyright 2016 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #define CATCH_CONFIG_MAIN | ||
| 6 | #include <catch.hpp> | ||
| 7 | |||
| 8 | // Catch provides the main function since we've given it the | ||
| 9 | // CATCH_CONFIG_MAIN preprocessor directive. | ||
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index 2f645b441..871368323 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp | |||
| @@ -696,106 +696,125 @@ finalise: | |||
| 696 | #endif | 696 | #endif |
| 697 | } | 697 | } |
| 698 | 698 | ||
| 699 | void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig,6>& stages) | 699 | static std::string ReplacePattern(const std::string& input, const std::string& pattern, const std::string& replacement) { |
| 700 | { | 700 | size_t start = input.find(pattern); |
| 701 | if (start == std::string::npos) | ||
| 702 | return input; | ||
| 703 | |||
| 704 | std::string ret = input; | ||
| 705 | ret.replace(start, pattern.length(), replacement); | ||
| 706 | return ret; | ||
| 707 | } | ||
| 708 | |||
| 709 | static std::string GetTevStageConfigSourceString(const Pica::Regs::TevStageConfig::Source& source) { | ||
| 701 | using Source = Pica::Regs::TevStageConfig::Source; | 710 | using Source = Pica::Regs::TevStageConfig::Source; |
| 711 | static const std::map<Source, std::string> source_map = { | ||
| 712 | { Source::PrimaryColor, "PrimaryColor" }, | ||
| 713 | { Source::PrimaryFragmentColor, "PrimaryFragmentColor" }, | ||
| 714 | { Source::SecondaryFragmentColor, "SecondaryFragmentColor" }, | ||
| 715 | { Source::Texture0, "Texture0" }, | ||
| 716 | { Source::Texture1, "Texture1" }, | ||
| 717 | { Source::Texture2, "Texture2" }, | ||
| 718 | { Source::Texture3, "Texture3" }, | ||
| 719 | { Source::PreviousBuffer, "PreviousBuffer" }, | ||
| 720 | { Source::Constant, "Constant" }, | ||
| 721 | { Source::Previous, "Previous" }, | ||
| 722 | }; | ||
| 723 | |||
| 724 | const auto src_it = source_map.find(source); | ||
| 725 | if (src_it == source_map.end()) | ||
| 726 | return "Unknown"; | ||
| 727 | |||
| 728 | return src_it->second; | ||
| 729 | } | ||
| 730 | |||
| 731 | static std::string GetTevStageConfigColorSourceString(const Pica::Regs::TevStageConfig::Source& source, const Pica::Regs::TevStageConfig::ColorModifier modifier) { | ||
| 702 | using ColorModifier = Pica::Regs::TevStageConfig::ColorModifier; | 732 | using ColorModifier = Pica::Regs::TevStageConfig::ColorModifier; |
| 733 | static const std::map<ColorModifier, std::string> color_modifier_map = { | ||
| 734 | { ColorModifier::SourceColor, "%source.rgb" }, | ||
| 735 | { ColorModifier::OneMinusSourceColor, "(1.0 - %source.rgb)" }, | ||
| 736 | { ColorModifier::SourceAlpha, "%source.aaa" }, | ||
| 737 | { ColorModifier::OneMinusSourceAlpha, "(1.0 - %source.aaa)" }, | ||
| 738 | { ColorModifier::SourceRed, "%source.rrr" }, | ||
| 739 | { ColorModifier::OneMinusSourceRed, "(1.0 - %source.rrr)" }, | ||
| 740 | { ColorModifier::SourceGreen, "%source.ggg" }, | ||
| 741 | { ColorModifier::OneMinusSourceGreen, "(1.0 - %source.ggg)" }, | ||
| 742 | { ColorModifier::SourceBlue, "%source.bbb" }, | ||
| 743 | { ColorModifier::OneMinusSourceBlue, "(1.0 - %source.bbb)" }, | ||
| 744 | }; | ||
| 745 | |||
| 746 | auto src_str = GetTevStageConfigSourceString(source); | ||
| 747 | auto modifier_it = color_modifier_map.find(modifier); | ||
| 748 | std::string modifier_str = "%source.????"; | ||
| 749 | if (modifier_it != color_modifier_map.end()) | ||
| 750 | modifier_str = modifier_it->second; | ||
| 751 | |||
| 752 | return ReplacePattern(modifier_str, "%source", src_str); | ||
| 753 | } | ||
| 754 | |||
| 755 | static std::string GetTevStageConfigAlphaSourceString(const Pica::Regs::TevStageConfig::Source& source, const Pica::Regs::TevStageConfig::AlphaModifier modifier) { | ||
| 703 | using AlphaModifier = Pica::Regs::TevStageConfig::AlphaModifier; | 756 | using AlphaModifier = Pica::Regs::TevStageConfig::AlphaModifier; |
| 757 | static const std::map<AlphaModifier, std::string> alpha_modifier_map = { | ||
| 758 | { AlphaModifier::SourceAlpha, "%source.a" }, | ||
| 759 | { AlphaModifier::OneMinusSourceAlpha, "(1.0 - %source.a)" }, | ||
| 760 | { AlphaModifier::SourceRed, "%source.r" }, | ||
| 761 | { AlphaModifier::OneMinusSourceRed, "(1.0 - %source.r)" }, | ||
| 762 | { AlphaModifier::SourceGreen, "%source.g" }, | ||
| 763 | { AlphaModifier::OneMinusSourceGreen, "(1.0 - %source.g)" }, | ||
| 764 | { AlphaModifier::SourceBlue, "%source.b" }, | ||
| 765 | { AlphaModifier::OneMinusSourceBlue, "(1.0 - %source.b)" }, | ||
| 766 | }; | ||
| 767 | |||
| 768 | auto src_str = GetTevStageConfigSourceString(source); | ||
| 769 | auto modifier_it = alpha_modifier_map.find(modifier); | ||
| 770 | std::string modifier_str = "%source.????"; | ||
| 771 | if (modifier_it != alpha_modifier_map.end()) | ||
| 772 | modifier_str = modifier_it->second; | ||
| 773 | |||
| 774 | return ReplacePattern(modifier_str, "%source", src_str); | ||
| 775 | } | ||
| 776 | |||
| 777 | static std::string GetTevStageConfigOperationString(const Pica::Regs::TevStageConfig::Operation& operation) { | ||
| 704 | using Operation = Pica::Regs::TevStageConfig::Operation; | 778 | using Operation = Pica::Regs::TevStageConfig::Operation; |
| 779 | static const std::map<Operation, std::string> combiner_map = { | ||
| 780 | { Operation::Replace, "%source1" }, | ||
| 781 | { Operation::Modulate, "(%source1 * %source2)" }, | ||
| 782 | { Operation::Add, "(%source1 + %source2)" }, | ||
| 783 | { Operation::AddSigned, "(%source1 + %source2) - 0.5" }, | ||
| 784 | { Operation::Lerp, "lerp(%source1, %source2, %source3)" }, | ||
| 785 | { Operation::Subtract, "(%source1 - %source2)" }, | ||
| 786 | { Operation::Dot3_RGB, "dot(%source1, %source2)" }, | ||
| 787 | { Operation::MultiplyThenAdd, "((%source1 * %source2) + %source3)" }, | ||
| 788 | { Operation::AddThenMultiply, "((%source1 + %source2) * %source3)" }, | ||
| 789 | }; | ||
| 705 | 790 | ||
| 706 | std::string stage_info = "Tev setup:\n"; | 791 | const auto op_it = combiner_map.find(operation); |
| 707 | for (size_t index = 0; index < stages.size(); ++index) { | 792 | if (op_it == combiner_map.end()) |
| 708 | const auto& tev_stage = stages[index]; | 793 | return "Unknown op (%source1, %source2, %source3)"; |
| 709 | 794 | ||
| 710 | static const std::map<Source, std::string> source_map = { | 795 | return op_it->second; |
| 711 | { Source::PrimaryColor, "PrimaryColor" }, | 796 | } |
| 712 | { Source::Texture0, "Texture0" }, | ||
| 713 | { Source::Texture1, "Texture1" }, | ||
| 714 | { Source::Texture2, "Texture2" }, | ||
| 715 | { Source::Constant, "Constant" }, | ||
| 716 | { Source::Previous, "Previous" }, | ||
| 717 | }; | ||
| 718 | 797 | ||
| 719 | static const std::map<ColorModifier, std::string> color_modifier_map = { | 798 | std::string GetTevStageConfigColorCombinerString(const Pica::Regs::TevStageConfig& tev_stage) { |
| 720 | { ColorModifier::SourceColor, { "%source.rgb" } }, | 799 | auto op_str = GetTevStageConfigOperationString(tev_stage.color_op); |
| 721 | { ColorModifier::SourceAlpha, { "%source.aaa" } }, | 800 | op_str = ReplacePattern(op_str, "%source1", GetTevStageConfigColorSourceString(tev_stage.color_source1, tev_stage.color_modifier1)); |
| 722 | }; | 801 | op_str = ReplacePattern(op_str, "%source2", GetTevStageConfigColorSourceString(tev_stage.color_source2, tev_stage.color_modifier2)); |
| 723 | static const std::map<AlphaModifier, std::string> alpha_modifier_map = { | 802 | return ReplacePattern(op_str, "%source3", GetTevStageConfigColorSourceString(tev_stage.color_source3, tev_stage.color_modifier3)); |
| 724 | { AlphaModifier::SourceAlpha, "%source.a" }, | 803 | } |
| 725 | { AlphaModifier::OneMinusSourceAlpha, "(255 - %source.a)" }, | ||
| 726 | }; | ||
| 727 | 804 | ||
| 728 | static const std::map<Operation, std::string> combiner_map = { | 805 | std::string GetTevStageConfigAlphaCombinerString(const Pica::Regs::TevStageConfig& tev_stage) { |
| 729 | { Operation::Replace, "%source1" }, | 806 | auto op_str = GetTevStageConfigOperationString(tev_stage.alpha_op); |
| 730 | { Operation::Modulate, "(%source1 * %source2) / 255" }, | 807 | op_str = ReplacePattern(op_str, "%source1", GetTevStageConfigAlphaSourceString(tev_stage.alpha_source1, tev_stage.alpha_modifier1)); |
| 731 | { Operation::Add, "(%source1 + %source2)" }, | 808 | op_str = ReplacePattern(op_str, "%source2", GetTevStageConfigAlphaSourceString(tev_stage.alpha_source2, tev_stage.alpha_modifier2)); |
| 732 | { Operation::Lerp, "lerp(%source1, %source2, %source3)" }, | 809 | return ReplacePattern(op_str, "%source3", GetTevStageConfigAlphaSourceString(tev_stage.alpha_source3, tev_stage.alpha_modifier3)); |
| 733 | }; | 810 | } |
| 734 | 811 | ||
| 735 | static auto ReplacePattern = | 812 | void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig, 6>& stages) { |
| 736 | [](const std::string& input, const std::string& pattern, const std::string& replacement) -> std::string { | 813 | std::string stage_info = "Tev setup:\n"; |
| 737 | size_t start = input.find(pattern); | 814 | for (size_t index = 0; index < stages.size(); ++index) { |
| 738 | if (start == std::string::npos) | 815 | const auto& tev_stage = stages[index]; |
| 739 | return input; | 816 | stage_info += "Stage " + std::to_string(index) + ": " + GetTevStageConfigColorCombinerString(tev_stage) + " " + GetTevStageConfigAlphaCombinerString(tev_stage) + "\n"; |
| 740 | |||
| 741 | std::string ret = input; | ||
| 742 | ret.replace(start, pattern.length(), replacement); | ||
| 743 | return ret; | ||
| 744 | }; | ||
| 745 | static auto GetColorSourceStr = | ||
| 746 | [](const Source& src, const ColorModifier& modifier) { | ||
| 747 | auto src_it = source_map.find(src); | ||
| 748 | std::string src_str = "Unknown"; | ||
| 749 | if (src_it != source_map.end()) | ||
| 750 | src_str = src_it->second; | ||
| 751 | |||
| 752 | auto modifier_it = color_modifier_map.find(modifier); | ||
| 753 | std::string modifier_str = "%source.????"; | ||
| 754 | if (modifier_it != color_modifier_map.end()) | ||
| 755 | modifier_str = modifier_it->second; | ||
| 756 | |||
| 757 | return ReplacePattern(modifier_str, "%source", src_str); | ||
| 758 | }; | ||
| 759 | static auto GetColorCombinerStr = | ||
| 760 | [](const Regs::TevStageConfig& tev_stage) { | ||
| 761 | auto op_it = combiner_map.find(tev_stage.color_op); | ||
| 762 | std::string op_str = "Unknown op (%source1, %source2, %source3)"; | ||
| 763 | if (op_it != combiner_map.end()) | ||
| 764 | op_str = op_it->second; | ||
| 765 | |||
| 766 | op_str = ReplacePattern(op_str, "%source1", GetColorSourceStr(tev_stage.color_source1, tev_stage.color_modifier1)); | ||
| 767 | op_str = ReplacePattern(op_str, "%source2", GetColorSourceStr(tev_stage.color_source2, tev_stage.color_modifier2)); | ||
| 768 | return ReplacePattern(op_str, "%source3", GetColorSourceStr(tev_stage.color_source3, tev_stage.color_modifier3)); | ||
| 769 | }; | ||
| 770 | static auto GetAlphaSourceStr = | ||
| 771 | [](const Source& src, const AlphaModifier& modifier) { | ||
| 772 | auto src_it = source_map.find(src); | ||
| 773 | std::string src_str = "Unknown"; | ||
| 774 | if (src_it != source_map.end()) | ||
| 775 | src_str = src_it->second; | ||
| 776 | |||
| 777 | auto modifier_it = alpha_modifier_map.find(modifier); | ||
| 778 | std::string modifier_str = "%source.????"; | ||
| 779 | if (modifier_it != alpha_modifier_map.end()) | ||
| 780 | modifier_str = modifier_it->second; | ||
| 781 | |||
| 782 | return ReplacePattern(modifier_str, "%source", src_str); | ||
| 783 | }; | ||
| 784 | static auto GetAlphaCombinerStr = | ||
| 785 | [](const Regs::TevStageConfig& tev_stage) { | ||
| 786 | auto op_it = combiner_map.find(tev_stage.alpha_op); | ||
| 787 | std::string op_str = "Unknown op (%source1, %source2, %source3)"; | ||
| 788 | if (op_it != combiner_map.end()) | ||
| 789 | op_str = op_it->second; | ||
| 790 | |||
| 791 | op_str = ReplacePattern(op_str, "%source1", GetAlphaSourceStr(tev_stage.alpha_source1, tev_stage.alpha_modifier1)); | ||
| 792 | op_str = ReplacePattern(op_str, "%source2", GetAlphaSourceStr(tev_stage.alpha_source2, tev_stage.alpha_modifier2)); | ||
| 793 | return ReplacePattern(op_str, "%source3", GetAlphaSourceStr(tev_stage.alpha_source3, tev_stage.alpha_modifier3)); | ||
| 794 | }; | ||
| 795 | |||
| 796 | stage_info += "Stage " + std::to_string(index) + ": " + GetColorCombinerStr(tev_stage) + " " + GetAlphaCombinerStr(tev_stage) + "\n"; | ||
| 797 | } | 817 | } |
| 798 | |||
| 799 | LOG_TRACE(HW_GPU, "%s", stage_info.c_str()); | 818 | LOG_TRACE(HW_GPU, "%s", stage_info.c_str()); |
| 800 | } | 819 | } |
| 801 | 820 | ||
diff --git a/src/video_core/debug_utils/debug_utils.h b/src/video_core/debug_utils/debug_utils.h index f628292a4..92e9734ae 100644 --- a/src/video_core/debug_utils/debug_utils.h +++ b/src/video_core/debug_utils/debug_utils.h | |||
| @@ -224,7 +224,11 @@ const Math::Vec4<u8> LookupTexture(const u8* source, int s, int t, const Texture | |||
| 224 | 224 | ||
| 225 | void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data); | 225 | void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data); |
| 226 | 226 | ||
| 227 | void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig,6>& stages); | 227 | std::string GetTevStageConfigColorCombinerString(const Pica::Regs::TevStageConfig& tev_stage); |
| 228 | std::string GetTevStageConfigAlphaCombinerString(const Pica::Regs::TevStageConfig& tev_stage); | ||
| 229 | |||
| 230 | /// Dumps the Tev stage config to log at trace level | ||
| 231 | void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig, 6>& stages); | ||
| 228 | 232 | ||
| 229 | /** | 233 | /** |
| 230 | * Used in the vertex loader to merge access records. TODO: Investigate if actually useful. | 234 | * Used in the vertex loader to merge access records. TODO: Investigate if actually useful. |