mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-11-23 06:05:46 +01:00
Refactor Tev stage dumper
This commit is contained in:
parent
324c21c922
commit
d77279a415
@ -696,17 +696,18 @@ finalise:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig,6>& stages)
|
static std::string ReplacePattern(const std::string& input, const std::string& pattern, const std::string& replacement) {
|
||||||
{
|
size_t start = input.find(pattern);
|
||||||
|
if (start == std::string::npos)
|
||||||
|
return input;
|
||||||
|
|
||||||
|
std::string ret = input;
|
||||||
|
ret.replace(start, pattern.length(), replacement);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string GetTevStageConfigSourceString(const Pica::Regs::TevStageConfig::Source& source) {
|
||||||
using Source = Pica::Regs::TevStageConfig::Source;
|
using Source = Pica::Regs::TevStageConfig::Source;
|
||||||
using ColorModifier = Pica::Regs::TevStageConfig::ColorModifier;
|
|
||||||
using AlphaModifier = Pica::Regs::TevStageConfig::AlphaModifier;
|
|
||||||
using Operation = Pica::Regs::TevStageConfig::Operation;
|
|
||||||
|
|
||||||
std::string stage_info = "Tev setup:\n";
|
|
||||||
for (size_t index = 0; index < stages.size(); ++index) {
|
|
||||||
const auto& tev_stage = stages[index];
|
|
||||||
|
|
||||||
static const std::map<Source, std::string> source_map = {
|
static const std::map<Source, std::string> source_map = {
|
||||||
{ Source::PrimaryColor, "PrimaryColor" },
|
{ Source::PrimaryColor, "PrimaryColor" },
|
||||||
{ Source::PrimaryFragmentColor, "PrimaryFragmentColor" },
|
{ Source::PrimaryFragmentColor, "PrimaryFragmentColor" },
|
||||||
@ -720,6 +721,15 @@ void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig,6>& stages)
|
|||||||
{ Source::Previous, "Previous" },
|
{ Source::Previous, "Previous" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const auto src_it = source_map.find(source);
|
||||||
|
if (src_it == source_map.end())
|
||||||
|
return "Unknown";
|
||||||
|
|
||||||
|
return src_it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string GetTevStageConfigColorSourceString(const Pica::Regs::TevStageConfig::Source& source, const Pica::Regs::TevStageConfig::ColorModifier modifier) {
|
||||||
|
using ColorModifier = Pica::Regs::TevStageConfig::ColorModifier;
|
||||||
static const std::map<ColorModifier, std::string> color_modifier_map = {
|
static const std::map<ColorModifier, std::string> color_modifier_map = {
|
||||||
{ ColorModifier::SourceColor, "%source.rgb" },
|
{ ColorModifier::SourceColor, "%source.rgb" },
|
||||||
{ ColorModifier::OneMinusSourceColor, "(1.0 - %source.rgb)" },
|
{ ColorModifier::OneMinusSourceColor, "(1.0 - %source.rgb)" },
|
||||||
@ -733,6 +743,17 @@ void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig,6>& stages)
|
|||||||
{ ColorModifier::OneMinusSourceBlue, "(1.0 - %source.bbb)" },
|
{ ColorModifier::OneMinusSourceBlue, "(1.0 - %source.bbb)" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto src_str = GetTevStageConfigSourceString(source);
|
||||||
|
auto modifier_it = color_modifier_map.find(modifier);
|
||||||
|
std::string modifier_str = "%source.????";
|
||||||
|
if (modifier_it != color_modifier_map.end())
|
||||||
|
modifier_str = modifier_it->second;
|
||||||
|
|
||||||
|
return ReplacePattern(modifier_str, "%source", src_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string GetTevStageConfigAlphaSourceString(const Pica::Regs::TevStageConfig::Source& source, const Pica::Regs::TevStageConfig::AlphaModifier modifier) {
|
||||||
|
using AlphaModifier = Pica::Regs::TevStageConfig::AlphaModifier;
|
||||||
static const std::map<AlphaModifier, std::string> alpha_modifier_map = {
|
static const std::map<AlphaModifier, std::string> alpha_modifier_map = {
|
||||||
{ AlphaModifier::SourceAlpha, "%source.a" },
|
{ AlphaModifier::SourceAlpha, "%source.a" },
|
||||||
{ AlphaModifier::OneMinusSourceAlpha, "(1.0 - %source.a)" },
|
{ AlphaModifier::OneMinusSourceAlpha, "(1.0 - %source.a)" },
|
||||||
@ -744,6 +765,17 @@ void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig,6>& stages)
|
|||||||
{ AlphaModifier::OneMinusSourceBlue, "(1.0 - %source.b)" },
|
{ AlphaModifier::OneMinusSourceBlue, "(1.0 - %source.b)" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto src_str = GetTevStageConfigSourceString(source);
|
||||||
|
auto modifier_it = alpha_modifier_map.find(modifier);
|
||||||
|
std::string modifier_str = "%source.????";
|
||||||
|
if (modifier_it != alpha_modifier_map.end())
|
||||||
|
modifier_str = modifier_it->second;
|
||||||
|
|
||||||
|
return ReplacePattern(modifier_str, "%source", src_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string GetTevStageConfigOperationString(const Pica::Regs::TevStageConfig::Operation& operation) {
|
||||||
|
using Operation = Pica::Regs::TevStageConfig::Operation;
|
||||||
static const std::map<Operation, std::string> combiner_map = {
|
static const std::map<Operation, std::string> combiner_map = {
|
||||||
{ Operation::Replace, "%source1" },
|
{ Operation::Replace, "%source1" },
|
||||||
{ Operation::Modulate, "(%source1 * %source2)" },
|
{ Operation::Modulate, "(%source1 * %source2)" },
|
||||||
@ -756,70 +788,33 @@ void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig,6>& stages)
|
|||||||
{ Operation::AddThenMultiply, "((%source1 + %source2) * %source3)" },
|
{ Operation::AddThenMultiply, "((%source1 + %source2) * %source3)" },
|
||||||
};
|
};
|
||||||
|
|
||||||
static auto ReplacePattern =
|
const auto op_it = combiner_map.find(operation);
|
||||||
[](const std::string& input, const std::string& pattern, const std::string& replacement) -> std::string {
|
if (op_it == combiner_map.end())
|
||||||
size_t start = input.find(pattern);
|
return "Unknown op (%source1, %source2, %source3)";
|
||||||
if (start == std::string::npos)
|
|
||||||
return input;
|
|
||||||
|
|
||||||
std::string ret = input;
|
return op_it->second;
|
||||||
ret.replace(start, pattern.length(), replacement);
|
}
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
static auto GetColorSourceStr =
|
|
||||||
[](const Source& src, const ColorModifier& modifier) {
|
|
||||||
auto src_it = source_map.find(src);
|
|
||||||
std::string src_str = "Unknown";
|
|
||||||
if (src_it != source_map.end())
|
|
||||||
src_str = src_it->second;
|
|
||||||
|
|
||||||
auto modifier_it = color_modifier_map.find(modifier);
|
std::string GetTevStageConfigColorCombinerString(const Pica::Regs::TevStageConfig& tev_stage) {
|
||||||
std::string modifier_str = "%source.????";
|
auto op_str = GetTevStageConfigOperationString(tev_stage.color_op);
|
||||||
if (modifier_it != color_modifier_map.end())
|
op_str = ReplacePattern(op_str, "%source1", GetTevStageConfigColorSourceString(tev_stage.color_source1, tev_stage.color_modifier1));
|
||||||
modifier_str = modifier_it->second;
|
op_str = ReplacePattern(op_str, "%source2", GetTevStageConfigColorSourceString(tev_stage.color_source2, tev_stage.color_modifier2));
|
||||||
|
return ReplacePattern(op_str, "%source3", GetTevStageConfigColorSourceString(tev_stage.color_source3, tev_stage.color_modifier3));
|
||||||
|
}
|
||||||
|
|
||||||
return ReplacePattern(modifier_str, "%source", src_str);
|
std::string GetTevStageConfigAlphaCombinerString(const Pica::Regs::TevStageConfig& tev_stage) {
|
||||||
};
|
auto op_str = GetTevStageConfigOperationString(tev_stage.alpha_op);
|
||||||
static auto GetColorCombinerStr =
|
op_str = ReplacePattern(op_str, "%source1", GetTevStageConfigAlphaSourceString(tev_stage.alpha_source1, tev_stage.alpha_modifier1));
|
||||||
[](const Regs::TevStageConfig& tev_stage) {
|
op_str = ReplacePattern(op_str, "%source2", GetTevStageConfigAlphaSourceString(tev_stage.alpha_source2, tev_stage.alpha_modifier2));
|
||||||
auto op_it = combiner_map.find(tev_stage.color_op);
|
return ReplacePattern(op_str, "%source3", GetTevStageConfigAlphaSourceString(tev_stage.alpha_source3, tev_stage.alpha_modifier3));
|
||||||
std::string op_str = "Unknown op (%source1, %source2, %source3)";
|
}
|
||||||
if (op_it != combiner_map.end())
|
|
||||||
op_str = op_it->second;
|
|
||||||
|
|
||||||
op_str = ReplacePattern(op_str, "%source1", GetColorSourceStr(tev_stage.color_source1, tev_stage.color_modifier1));
|
void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig, 6>& stages) {
|
||||||
op_str = ReplacePattern(op_str, "%source2", GetColorSourceStr(tev_stage.color_source2, tev_stage.color_modifier2));
|
std::string stage_info = "Tev setup:\n";
|
||||||
return ReplacePattern(op_str, "%source3", GetColorSourceStr(tev_stage.color_source3, tev_stage.color_modifier3));
|
for (size_t index = 0; index < stages.size(); ++index) {
|
||||||
};
|
const auto& tev_stage = stages[index];
|
||||||
static auto GetAlphaSourceStr =
|
stage_info += "Stage " + std::to_string(index) + ": " + GetTevStageConfigColorCombinerString(tev_stage) + " " + GetTevStageConfigAlphaCombinerString(tev_stage) + "\n";
|
||||||
[](const Source& src, const AlphaModifier& modifier) {
|
|
||||||
auto src_it = source_map.find(src);
|
|
||||||
std::string src_str = "Unknown";
|
|
||||||
if (src_it != source_map.end())
|
|
||||||
src_str = src_it->second;
|
|
||||||
|
|
||||||
auto modifier_it = alpha_modifier_map.find(modifier);
|
|
||||||
std::string modifier_str = "%source.????";
|
|
||||||
if (modifier_it != alpha_modifier_map.end())
|
|
||||||
modifier_str = modifier_it->second;
|
|
||||||
|
|
||||||
return ReplacePattern(modifier_str, "%source", src_str);
|
|
||||||
};
|
|
||||||
static auto GetAlphaCombinerStr =
|
|
||||||
[](const Regs::TevStageConfig& tev_stage) {
|
|
||||||
auto op_it = combiner_map.find(tev_stage.alpha_op);
|
|
||||||
std::string op_str = "Unknown op (%source1, %source2, %source3)";
|
|
||||||
if (op_it != combiner_map.end())
|
|
||||||
op_str = op_it->second;
|
|
||||||
|
|
||||||
op_str = ReplacePattern(op_str, "%source1", GetAlphaSourceStr(tev_stage.alpha_source1, tev_stage.alpha_modifier1));
|
|
||||||
op_str = ReplacePattern(op_str, "%source2", GetAlphaSourceStr(tev_stage.alpha_source2, tev_stage.alpha_modifier2));
|
|
||||||
return ReplacePattern(op_str, "%source3", GetAlphaSourceStr(tev_stage.alpha_source3, tev_stage.alpha_modifier3));
|
|
||||||
};
|
|
||||||
|
|
||||||
stage_info += "Stage " + std::to_string(index) + ": " + GetColorCombinerStr(tev_stage) + " " + GetAlphaCombinerStr(tev_stage) + "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_TRACE(HW_GPU, "%s", stage_info.c_str());
|
LOG_TRACE(HW_GPU, "%s", stage_info.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,7 +224,11 @@ const Math::Vec4<u8> LookupTexture(const u8* source, int s, int t, const Texture
|
|||||||
|
|
||||||
void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data);
|
void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data);
|
||||||
|
|
||||||
void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig,6>& stages);
|
std::string GetTevStageConfigColorCombinerString(const Pica::Regs::TevStageConfig& tev_stage);
|
||||||
|
std::string GetTevStageConfigAlphaCombinerString(const Pica::Regs::TevStageConfig& tev_stage);
|
||||||
|
|
||||||
|
/// Dumps the Tev stage config to log at trace level
|
||||||
|
void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig, 6>& stages);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used in the vertex loader to merge access records. TODO: Investigate if actually useful.
|
* Used in the vertex loader to merge access records. TODO: Investigate if actually useful.
|
||||||
|
Loading…
Reference in New Issue
Block a user