diff options
| author | JMC47 <JMC4789@gmail.com> | 2022-02-11 06:26:35 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-11 06:26:35 -0500 |
| commit | 30a9777c5afa1e8cb32d4cf919ce30d240372efb (patch) | |
| tree | 23d06cd0b5d33fa9c962e5907c7e1ed1d2519b5f /Source/Core/VideoCommon/PixelShaderGen.cpp | |
| parent | a6f9dd5a83e5eca872d294524ef624dfde5237ee (diff) | |
| parent | 444f6fd0cb84a673329cf33eacf8907bf96b5951 (diff) | |
Merge pull request #10394 from Pokechu22/alpha-1-blend
Revert TEV alpha lerp change and special-case alpha=1 in blending
Diffstat (limited to 'Source/Core/VideoCommon/PixelShaderGen.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/PixelShaderGen.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index 673c97ec9b..ddb03f8e96 100644 --- a/Source/Core/VideoCommon/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/PixelShaderGen.cpp @@ -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); @@ -1234,6 +1234,18 @@ ShaderCode GeneratePixelShaderCode(APIType api_type, const ShaderHostConfig& hos use_dual_source || use_shader_blend); } + // This situation is important for Mario Kart Wii's menus (they will render incorrectly if the + // alpha test for the FMV in the background fails, since they depend on depth for drawing a yellow + // border) and Fortune Street's gameplay (where a rectangle with an alpha value of 1 is drawn over + // the center of the screen several times, but those rectangles shouldn't be visible). + // Blending seems to result in no changes to the output with an alpha of 1, even if the input + // color is white. + // TODO: Investigate this further: we might be handling blending incorrectly in general (though + // there might not be any good way of changing blending behavior) + out.Write("\t// Hardware testing indicates that an alpha of 1 can pass an alpha test,\n" + "\t// but doesn't do anything in blending\n" + "\tif (prev.a == 1) prev.a = 0;\n"); + if (uid_data->zfreeze) { out.SetConstantsUsed(C_ZSLOPE, C_ZSLOPE); @@ -1677,7 +1689,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 +1722,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 +1754,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 +1792,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]); } |
