citra-emu
/
citra
Archived
1
0
Fork 0

gl_shader_gen: Eliminate unnecessary std::string construction in AppendProcTexCombineAndMap()

We can make use of a std::string_view here, since only string literals
are used within the switch.
This commit is contained in:
Lioncash 2020-06-08 06:37:39 -04:00
parent edb5977fba
commit 9645c1e1b2
1 changed files with 28 additions and 37 deletions

View File

@ -1018,43 +1018,34 @@ void AppendProcTexClamp(std::string& out, std::string_view var, ProcTexClamp mod
void AppendProcTexCombineAndMap(std::string& out, ProcTexCombiner combiner,
std::string_view offset) {
std::string combined;
const auto combined = [combiner]() -> std::string_view {
switch (combiner) {
case ProcTexCombiner::U:
combined = "u";
break;
return "u";
case ProcTexCombiner::U2:
combined = "(u * u)";
break;
return "(u * u)";
case TexturingRegs::ProcTexCombiner::V:
combined = "v";
break;
return "v";
case TexturingRegs::ProcTexCombiner::V2:
combined = "(v * v)";
break;
return "(v * v)";
case TexturingRegs::ProcTexCombiner::Add:
combined = "((u + v) * 0.5)";
break;
return "((u + v) * 0.5)";
case TexturingRegs::ProcTexCombiner::Add2:
combined = "((u * u + v * v) * 0.5)";
break;
return "((u * u + v * v) * 0.5)";
case TexturingRegs::ProcTexCombiner::SqrtAdd2:
combined = "min(sqrt(u * u + v * v), 1.0)";
break;
return "min(sqrt(u * u + v * v), 1.0)";
case TexturingRegs::ProcTexCombiner::Min:
combined = "min(u, v)";
break;
return "min(u, v)";
case TexturingRegs::ProcTexCombiner::Max:
combined = "max(u, v)";
break;
return "max(u, v)";
case TexturingRegs::ProcTexCombiner::RMax:
combined = "min(((u + v) * 0.5 + sqrt(u * u + v * v)) * 0.5, 1.0)";
break;
return "min(((u + v) * 0.5 + sqrt(u * u + v * v)) * 0.5, 1.0)";
default:
LOG_CRITICAL(HW_GPU, "Unknown combiner {}", static_cast<u32>(combiner));
combined = "0.0";
break;
return "0.0";
}
}();
out += fmt::format("ProcTexLookupLUT({}, {})", offset, combined);
}