rasterizer: implement combiner operation 7 (Dot3_RGBA)

This commit is contained in:
wwylele 2017-04-19 23:48:10 +03:00
parent 6a72bd62b5
commit b624a95205
4 changed files with 38 additions and 19 deletions

View file

@ -403,13 +403,22 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve
};
auto color_output = ColorCombine(tev_stage.color_op, color_result);
// alpha combiner
std::array<u8, 3> alpha_result = {{
GetAlphaModifier(tev_stage.alpha_modifier1, GetSource(tev_stage.alpha_source1)),
GetAlphaModifier(tev_stage.alpha_modifier2, GetSource(tev_stage.alpha_source2)),
GetAlphaModifier(tev_stage.alpha_modifier3, GetSource(tev_stage.alpha_source3)),
}};
auto alpha_output = AlphaCombine(tev_stage.alpha_op, alpha_result);
u8 alpha_output;
if (tev_stage.color_op == TexturingRegs::TevStageConfig::Operation::Dot3_RGBA) {
// result of Dot3_RGBA operation is also placed to the alpha component
alpha_output = color_output.x;
} else {
// alpha combiner
std::array<u8, 3> alpha_result = {{
GetAlphaModifier(tev_stage.alpha_modifier1,
GetSource(tev_stage.alpha_source1)),
GetAlphaModifier(tev_stage.alpha_modifier2,
GetSource(tev_stage.alpha_source2)),
GetAlphaModifier(tev_stage.alpha_modifier3,
GetSource(tev_stage.alpha_source3)),
}};
alpha_output = AlphaCombine(tev_stage.alpha_op, alpha_result);
}
combiner_output[0] =
std::min((unsigned)255, color_output.r() * tev_stage.GetColorMultiplier());

View file

@ -169,7 +169,8 @@ Math::Vec3<u8> ColorCombine(TevStageConfig::Operation op, const Math::Vec3<u8> i
result = (result * input[2].Cast<int>()) / 255;
return result.Cast<u8>();
}
case Operation::Dot3_RGB: {
case Operation::Dot3_RGB:
case Operation::Dot3_RGBA: {
// Not fully accurate. Worst case scenario seems to yield a +/-3 error. Some HW results
// indicate that the per-component computation can't have a higher precision than 1/256,
// while dot3_rgb((0x80,g0,b0), (0x7F,g1,b1)) and dot3_rgb((0x80,g0,b0), (0x80,g1,b1)) give