summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/UberShaderPixel.cpp
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2022-02-11 06:26:35 -0500
committerGitHub <noreply@github.com>2022-02-11 06:26:35 -0500
commit30a9777c5afa1e8cb32d4cf919ce30d240372efb (patch)
tree23d06cd0b5d33fa9c962e5907c7e1ed1d2519b5f /Source/Core/VideoCommon/UberShaderPixel.cpp
parenta6f9dd5a83e5eca872d294524ef624dfde5237ee (diff)
parent444f6fd0cb84a673329cf33eacf8907bf96b5951 (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/UberShaderPixel.cpp')
-rw-r--r--Source/Core/VideoCommon/UberShaderPixel.cpp35
1 files changed, 20 insertions, 15 deletions
diff --git a/Source/Core/VideoCommon/UberShaderPixel.cpp b/Source/Core/VideoCommon/UberShaderPixel.cpp
index ebf4afa55f..fa6ad7bc75 100644
--- a/Source/Core/VideoCommon/UberShaderPixel.cpp
+++ b/Source/Core/VideoCommon/UberShaderPixel.cpp
@@ -334,8 +334,8 @@ ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
const auto WriteTevLerp = [&out](std::string_view components) {
out.Write(
"// TEV's Linear Interpolate, plus bias, add/subtract and scale\n"
- "int{0} tevLerp{0}(int{0} A, int{0} B, int{0} C, int{0} D, uint bias, bool op, bool alpha, "
- "uint shift) {{\n"
+ "int{0} tevLerp{0}(int{0} A, int{0} B, int{0} C, int{0} D, uint bias, bool op, "
+ "uint scale) {{\n"
" // Scale C from 0..255 to 0..256\n"
" C += C >> 7;\n"
"\n"
@@ -344,12 +344,14 @@ ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
" else if (bias == 2u) D -= 128;\n"
"\n"
" int{0} lerp = (A << 8) + (B - A)*C;\n"
- " if (shift != 3u) {{\n"
- " lerp = lerp << shift;\n"
- " D = D << shift;\n"
+ " if (scale != 3u) {{\n"
+ " lerp = lerp << scale;\n"
+ " D = D << scale;\n"
" }}\n"
"\n"
- " if ((shift == 3u) == alpha)\n"
+ " // TODO: Is this rounding bias still added when the scale is divide by 2? Currently we "
+ "do not apply it.\n"
+ " if (scale != 3u)\n"
" lerp = lerp + (op ? 127 : 128);\n"
"\n"
" int{0} result = lerp >> 8;\n"
@@ -360,9 +362,9 @@ ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
" else // Add\n"
" result = D + result;\n"
"\n"
- " // Most of the Shift was moved inside the lerp for improved precision\n"
+ " // Most of the Scale was moved inside the lerp for improved precision\n"
" // But we still do the divide by 2 here\n"
- " if (shift == 3u)\n"
+ " if (scale == 3u)\n"
" result = result >> 1;\n"
" return result;\n"
"}}\n\n",
@@ -810,13 +812,13 @@ ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
BitfieldExtract<&TevStageCombiner::ColorCombiner::op>("ss.cc"));
out.Write(" bool color_clamp = bool({});\n",
BitfieldExtract<&TevStageCombiner::ColorCombiner::clamp>("ss.cc"));
- out.Write(" uint color_shift = {};\n",
+ out.Write(" uint color_scale = {};\n",
BitfieldExtract<&TevStageCombiner::ColorCombiner::scale>("ss.cc"));
out.Write(" uint color_dest = {};\n",
BitfieldExtract<&TevStageCombiner::ColorCombiner::dest>("ss.cc"));
out.Write(
- " uint color_compare_op = color_shift << 1 | uint(color_op);\n"
+ " uint color_compare_op = color_scale << 1 | uint(color_op);\n"
"\n"
" int3 color_A = selectColorInput(s, ss, {0}colors_0, {0}colors_1, color_a) & "
"int3(255, 255, 255);\n"
@@ -831,8 +833,8 @@ ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
out.Write(
" int3 color;\n"
" if (color_bias != 3u) {{ // Normal mode\n"
- " color = tevLerp3(color_A, color_B, color_C, color_D, color_bias, color_op, false, "
- "color_shift);\n"
+ " color = tevLerp3(color_A, color_B, color_C, color_D, color_bias, color_op, "
+ "color_scale);\n"
" }} else {{ // Compare mode\n"
" // op 6 and 7 do a select per color channel\n"
" if (color_compare_op == 6u) {{\n"
@@ -880,13 +882,13 @@ ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
BitfieldExtract<&TevStageCombiner::AlphaCombiner::op>("ss.ac"));
out.Write(" bool alpha_clamp = bool({});\n",
BitfieldExtract<&TevStageCombiner::AlphaCombiner::clamp>("ss.ac"));
- out.Write(" uint alpha_shift = {};\n",
+ out.Write(" uint alpha_scale = {};\n",
BitfieldExtract<&TevStageCombiner::AlphaCombiner::scale>("ss.ac"));
out.Write(" uint alpha_dest = {};\n",
BitfieldExtract<&TevStageCombiner::AlphaCombiner::dest>("ss.ac"));
out.Write(
- " uint alpha_compare_op = alpha_shift << 1 | uint(alpha_op);\n"
+ " uint alpha_compare_op = alpha_scale << 1 | uint(alpha_op);\n"
"\n"
" int alpha_A;\n"
" int alpha_B;\n"
@@ -904,7 +906,7 @@ ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
" int alpha;\n"
" if (alpha_bias != 3u) {{ // Normal mode\n"
" alpha = tevLerp(alpha_A, alpha_B, alpha_C, alpha_D, alpha_bias, alpha_op, "
- "true, alpha_shift);\n"
+ "alpha_scale);\n"
" }} else {{ // Compare mode\n"
" if (alpha_compare_op == 6u) {{\n"
" // TevCompareMode::A8, TevComparison::GT\n"
@@ -1030,6 +1032,9 @@ ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
" }}\n"
"\n");
+ out.Write(" // Hardware testing indicates that an alpha of 1 can pass an alpha test,\n"
+ " // but doesn't do anything in blending\n"
+ " if (TevResult.a == 1) TevResult.a = 0;\n");
// =========
// Dithering
// =========