mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Use the same logic for lerp bias for color and alpha
It doesn't make sense for alpha to add the bias ONLY when dividing by 2, while color doesn't apply the bias for divide by 2 only; hardware testing indicates that alpha should have the bias.
This fixes the menus in Mario Kart Wii (https://bugs.dolphin-emu.org/issues/11909) but reintroduces the white rectangle in Fortune Street.
This reverts commit 5aaa5141ed
(and several other matching changes elsewhere).
This commit is contained in:
@ -852,7 +852,7 @@ uint WrapCoord(int coord, uint wrap, int size) {{
|
||||
static void WriteStage(ShaderCode& out, const pixel_shader_uid_data* uid_data, int n,
|
||||
APIType api_type, bool stereo);
|
||||
static void WriteTevRegular(ShaderCode& out, std::string_view components, TevBias bias, TevOp op,
|
||||
bool clamp, TevScale scale, bool alpha);
|
||||
bool clamp, TevScale scale);
|
||||
static void WriteAlphaTest(ShaderCode& out, const pixel_shader_uid_data* uid_data, APIType api_type,
|
||||
bool per_pixel_depth, bool use_dual_source);
|
||||
static void WriteFog(ShaderCode& out, const pixel_shader_uid_data* uid_data);
|
||||
@ -1677,7 +1677,7 @@ static void WriteStage(ShaderCode& out, const pixel_shader_uid_data* uid_data, i
|
||||
out.Write("\t{} = clamp(", tev_c_output_table[cc.dest]);
|
||||
if (cc.bias != TevBias::Compare)
|
||||
{
|
||||
WriteTevRegular(out, "rgb", cc.bias, cc.op, cc.clamp, cc.scale, false);
|
||||
WriteTevRegular(out, "rgb", cc.bias, cc.op, cc.clamp, cc.scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1710,7 +1710,7 @@ static void WriteStage(ShaderCode& out, const pixel_shader_uid_data* uid_data, i
|
||||
out.Write("\t{} = clamp(", tev_a_output_table[ac.dest]);
|
||||
if (ac.bias != TevBias::Compare)
|
||||
{
|
||||
WriteTevRegular(out, "a", ac.bias, ac.op, ac.clamp, ac.scale, true);
|
||||
WriteTevRegular(out, "a", ac.bias, ac.op, ac.clamp, ac.scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1742,7 +1742,7 @@ static void WriteStage(ShaderCode& out, const pixel_shader_uid_data* uid_data, i
|
||||
}
|
||||
|
||||
static void WriteTevRegular(ShaderCode& out, std::string_view components, TevBias bias, TevOp op,
|
||||
bool clamp, TevScale scale, bool alpha)
|
||||
bool clamp, TevScale scale)
|
||||
{
|
||||
static constexpr Common::EnumMap<const char*, TevScale::Divide2> tev_scale_table_left{
|
||||
"", // Scale1
|
||||
@ -1780,12 +1780,14 @@ static void WriteTevRegular(ShaderCode& out, std::string_view components, TevBia
|
||||
// - c is scaled from 0..255 to 0..256, which allows dividing the result by 256 instead of 255
|
||||
// - if scale is bigger than one, it is moved inside the lerp calculation for increased accuracy
|
||||
// - a rounding bias is added before dividing by 256
|
||||
// TODO: Is the rounding bias still added when the scale is divide by 2? Currently we do not
|
||||
// apply it.
|
||||
out.Write("(((tevin_d.{}{}){})", components, tev_bias_table[bias], tev_scale_table_left[scale]);
|
||||
out.Write(" {} ", tev_op_table[op]);
|
||||
out.Write("(((((tevin_a.{0}<<8) + "
|
||||
"(tevin_b.{0}-tevin_a.{0})*(tevin_c.{0}+(tevin_c.{0}>>7))){1}){2})>>8)",
|
||||
components, tev_scale_table_left[scale],
|
||||
((scale == TevScale::Divide2) == alpha) ? tev_lerp_bias[op] : "");
|
||||
(scale != TevScale::Divide2) ? tev_lerp_bias[op] : "");
|
||||
out.Write("){}", tev_scale_table_right[scale]);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user